Skip to content

Instantly share code, notes, and snippets.

@plmok61
Created December 8, 2023 19:44
Show Gist options
  • Save plmok61/46fc91891666f0a9c10551684a524107 to your computer and use it in GitHub Desktop.
Save plmok61/46fc91891666f0a9c10551684a524107 to your computer and use it in GitHub Desktop.
JS Bundle
This file has been truncated, but you can view the full file.
/******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ({
/***/ "./src/App.js":
/*!********************!*\
!*** ./src/App.js ***!
\********************/
/***/ ((module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _vladmandic_human__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @vladmandic/human */ "./node_modules/@vladmandic/human/dist/human.esm.js");
/* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./config */ "./src/config.js");
/* harmony import */ var _setVideoSource__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./setVideoSource */ "./src/setVideoSource.js");
/* harmony import */ var _App_css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./App.css */ "./src/App.css");
/* harmony import */ var react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! react/jsx-dev-runtime */ "./node_modules/react/jsx-dev-runtime.js");
/* provided dependency */ var __react_refresh_utils__ = __webpack_require__(/*! ./node_modules/@pmmmwh/react-refresh-webpack-plugin/lib/runtime/RefreshUtils.js */ "./node_modules/@pmmmwh/react-refresh-webpack-plugin/lib/runtime/RefreshUtils.js");
__webpack_require__.$Refresh$.runtime = __webpack_require__(/*! ./node_modules/react-refresh/runtime.js */ "./node_modules/react-refresh/runtime.js");
var _jsxFileName = "/Users/philipmok/Desktop/test-human/src/App.js",
_s = __webpack_require__.$Refresh$.signature();
function App() {
_s();
const videoRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null);
const [videoElReady, setVideoElReady] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false);
const [human, setHuman] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(null);
const [loading, setLoading] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(true);
const [faces, setFaces] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)([]);
const [faceDetected, setFaceDetected] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false);
const [face, setFace] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(null);
const [progress, setProgress] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(0);
const [status, setStatus] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)('complete');
const [error, setError] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(null);
const [averageAge, setAverageAge] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(null);
const [recursiveDetect, setRecursiveDetect] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false);
const [detectOnceFace, setDetectOnceFace] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false);
const handleLoadedMetadata = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(() => {
setVideoElReady(true);
}, [setVideoElReady]);
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
if (human) {
return;
}
const init = async () => {
const h = new _vladmandic_human__WEBPACK_IMPORTED_MODULE_5__["default"](_config__WEBPACK_IMPORTED_MODULE_1__["default"]);
console.log('load start');
await h.load();
console.log('warmup start');
await h.warmup();
console.log('done initializing');
setHuman(h);
};
init();
}, [human]);
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
if (!videoElReady || !human) {
return;
}
const videoEl = videoRef.current;
if (videoEl === null) {
return;
}
if (recursiveDetect) {
const recursive = async () => {
console.log('Starting recursive detect');
setStatus('in progress');
let count = 0;
let facesArray = [];
setError(null);
setFaces([]);
setFace(null);
setFaceDetected(false);
const detect = async () => {
count += 1;
if (count >= 100) {
setFaces(facesArray);
setStatus('complete');
return;
}
try {
const res = await human.detect(videoEl);
if (res !== null && res !== void 0 && res.error) {
console.error(res.error);
setFaceDetected(false);
setTimeout(detect, 25);
setError(res.error);
return;
}
console.log('face response', res);
if (!res.face.length || res.face[0].faceScore < 1) {
console.warn('No face detected');
setFaceDetected(false);
setTimeout(detect, 25);
return;
}
const face = res.face[0];
if (face) {
setFaceDetected(true);
facesArray.push(face);
setFace(face);
setProgress(count);
setTimeout(detect, 25);
}
} catch (error) {
console.error(error);
setFaceDetected(false);
}
};
detect();
};
recursive();
}
}, [videoElReady, human, videoRef, recursiveDetect]);
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
const awaitSetVideoSource = async () => {
if (!videoRef.current) {
return;
}
await (0,_setVideoSource__WEBPACK_IMPORTED_MODULE_2__["default"])(videoRef.current, 'user', err => {
if (err.name === 'NotAllowedError') {
console.warn('Camera permission denied.', {
error: err.message
});
return;
}
console.error('Error setting video source', err);
});
setLoading(false);
};
awaitSetVideoSource();
}, []);
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
if (!faces.length) {
return;
}
const averageAge = faces.reduce((acc, face) => {
if (!face.age) {
return acc;
}
return acc + face.age;
}, 0) / faces.length;
setAverageAge(averageAge);
}, [faces]);
const detectOnce = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(async () => {
if (!videoRef.current) return;
if (!human) return;
setRecursiveDetect(false);
const videoEl = videoRef.current;
const res = await human.detect(videoEl);
console.log('response', res);
if (!res.face.length || res.face[0].faceScore < 1) {
console.warn('No face detected');
return setDetectOnceFace(false);
}
setDetectOnceFace(true);
}, [human]);
return /*#__PURE__*/(0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_4__.jsxDEV)("div", {
className: "App",
children: [/*#__PURE__*/(0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_4__.jsxDEV)("div", {
style: {
width: '50%'
},
children: /*#__PURE__*/(0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_4__.jsxDEV)("video", {
ref: videoRef,
"data-testid": "age-prediction-video",
style: {
transform: 'rotateY(180deg)',
objectFit: 'cover',
width: '100%',
height: '100%'
},
onLoadedMetadata: handleLoadedMetadata,
playsInline: true,
autoPlay: true,
muted: true
}, void 0, false, {
fileName: _jsxFileName,
lineNumber: 156,
columnNumber: 9
}, this)
}, void 0, false, {
fileName: _jsxFileName,
lineNumber: 155,
columnNumber: 7
}, this), loading && /*#__PURE__*/(0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_4__.jsxDEV)("p", {
children: "Setting video source"
}, void 0, false, {
fileName: _jsxFileName,
lineNumber: 171,
columnNumber: 19
}, this), /*#__PURE__*/(0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_4__.jsxDEV)("p", {
children: "Javascript"
}, void 0, false, {
fileName: _jsxFileName,
lineNumber: 172,
columnNumber: 7
}, this), human ? /*#__PURE__*/(0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_4__.jsxDEV)(react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_4__.Fragment, {
children: [/*#__PURE__*/(0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_4__.jsxDEV)("div", {
style: {
border: '1px solid black',
padding: '1rem',
margin: '1rem'
},
children: [/*#__PURE__*/(0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_4__.jsxDEV)("button", {
onClick: () => setRecursiveDetect(prev => !prev),
disabled: status === 'in progress',
children: `Recursive Detect ${recursiveDetect ? 'On' : 'Off'}`
}, void 0, false, {
fileName: _jsxFileName,
lineNumber: 183,
columnNumber: 13
}, this), /*#__PURE__*/(0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_4__.jsxDEV)("div", {
children: [/*#__PURE__*/(0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_4__.jsxDEV)("p", {
children: ["Face Detected: ", faceDetected ? 'Yes' : 'No']
}, void 0, true, {
fileName: _jsxFileName,
lineNumber: 191,
columnNumber: 15
}, this), /*#__PURE__*/(0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_4__.jsxDEV)("p", {
children: ["Faces: ", progress, " / 100"]
}, void 0, true, {
fileName: _jsxFileName,
lineNumber: 192,
columnNumber: 15
}, this), /*#__PURE__*/(0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_4__.jsxDEV)("p", {
children: ["Error: ", error ? error.message : 'none']
}, void 0, true, {
fileName: _jsxFileName,
lineNumber: 193,
columnNumber: 15
}, this), face && /*#__PURE__*/(0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_4__.jsxDEV)(react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_4__.Fragment, {
children: [/*#__PURE__*/(0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_4__.jsxDEV)("h3", {
children: "Most Recent Face"
}, void 0, false, {
fileName: _jsxFileName,
lineNumber: 196,
columnNumber: 19
}, this), /*#__PURE__*/(0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_4__.jsxDEV)("p", {
children: ["Age: ", face.age || 'null']
}, void 0, true, {
fileName: _jsxFileName,
lineNumber: 197,
columnNumber: 19
}, this), /*#__PURE__*/(0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_4__.jsxDEV)("p", {
children: ["Live Score: ", face.live || 'null']
}, void 0, true, {
fileName: _jsxFileName,
lineNumber: 198,
columnNumber: 19
}, this), /*#__PURE__*/(0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_4__.jsxDEV)("p", {
children: ["Real Score: ", face.real || 'null']
}, void 0, true, {
fileName: _jsxFileName,
lineNumber: 199,
columnNumber: 19
}, this)]
}, void 0, true), averageAge && /*#__PURE__*/(0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_4__.jsxDEV)("p", {
children: ["Average Age: ", averageAge]
}, void 0, true, {
fileName: _jsxFileName,
lineNumber: 203,
columnNumber: 17
}, this)]
}, void 0, true, {
fileName: _jsxFileName,
lineNumber: 190,
columnNumber: 13
}, this)]
}, void 0, true, {
fileName: _jsxFileName,
lineNumber: 176,
columnNumber: 11
}, this), /*#__PURE__*/(0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_4__.jsxDEV)("div", {
style: {
border: '1px solid black',
padding: '1rem',
margin: '1rem'
},
children: [/*#__PURE__*/(0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_4__.jsxDEV)("button", {
onClick: detectOnce,
children: "Detect Once"
}, void 0, false, {
fileName: _jsxFileName,
lineNumber: 215,
columnNumber: 13
}, this), /*#__PURE__*/(0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_4__.jsxDEV)("p", {
children: ["Face Detected: ", detectOnceFace ? 'Yes' : 'No']
}, void 0, true, {
fileName: _jsxFileName,
lineNumber: 220,
columnNumber: 13
}, this)]
}, void 0, true, {
fileName: _jsxFileName,
lineNumber: 208,
columnNumber: 11
}, this), /*#__PURE__*/(0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_4__.jsxDEV)("button", {
onClick: () => setHuman(null),
children: "Re-init"
}, void 0, false, {
fileName: _jsxFileName,
lineNumber: 223,
columnNumber: 11
}, this)]
}, void 0, true) : /*#__PURE__*/(0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_4__.jsxDEV)("p", {
children: "Initializing..."
}, void 0, false, {
fileName: _jsxFileName,
lineNumber: 229,
columnNumber: 12
}, this)]
}, void 0, true, {
fileName: _jsxFileName,
lineNumber: 154,
columnNumber: 5
}, this);
}
_s(App, "10rxijvImZlPjjQhHkwdj/tJS8c=");
_c = App;
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (App);
var _c;
__webpack_require__.$Refresh$.register(_c, "App");
const $ReactRefreshModuleId$ = __webpack_require__.$Refresh$.moduleId;
const $ReactRefreshCurrentExports$ = __react_refresh_utils__.getModuleExports(
$ReactRefreshModuleId$
);
function $ReactRefreshModuleRuntime$(exports) {
if (true) {
let errorOverlay;
if (true) {
errorOverlay = false;
}
let testMode;
if (typeof __react_refresh_test__ !== 'undefined') {
testMode = __react_refresh_test__;
}
return __react_refresh_utils__.executeRuntime(
exports,
$ReactRefreshModuleId$,
module.hot,
errorOverlay,
testMode
);
}
}
if (typeof Promise !== 'undefined' && $ReactRefreshCurrentExports$ instanceof Promise) {
$ReactRefreshCurrentExports$.then($ReactRefreshModuleRuntime$);
} else {
$ReactRefreshModuleRuntime$($ReactRefreshCurrentExports$);
}
/***/ }),
/***/ "./src/config.js":
/*!***********************!*\
!*** ./src/config.js ***!
\***********************/
/***/ ((module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* provided dependency */ var __react_refresh_utils__ = __webpack_require__(/*! ./node_modules/@pmmmwh/react-refresh-webpack-plugin/lib/runtime/RefreshUtils.js */ "./node_modules/@pmmmwh/react-refresh-webpack-plugin/lib/runtime/RefreshUtils.js");
__webpack_require__.$Refresh$.runtime = __webpack_require__(/*! ./node_modules/react-refresh/runtime.js */ "./node_modules/react-refresh/runtime.js");
const humanConfig = {
gesture: {
enabled: false
},
hand: {
enabled: false
},
body: {
enabled: false
},
segmentation: {
enabled: false
},
face: {
antispoof: {
enabled: true
},
liveness: {
enabled: true
},
iris: {
enabled: true
},
emotion: {
enabled: true
},
mesh: {
enabled: true
},
detector: {
rotation: true
}
}
};
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (humanConfig);
const $ReactRefreshModuleId$ = __webpack_require__.$Refresh$.moduleId;
const $ReactRefreshCurrentExports$ = __react_refresh_utils__.getModuleExports(
$ReactRefreshModuleId$
);
function $ReactRefreshModuleRuntime$(exports) {
if (true) {
let errorOverlay;
if (true) {
errorOverlay = false;
}
let testMode;
if (typeof __react_refresh_test__ !== 'undefined') {
testMode = __react_refresh_test__;
}
return __react_refresh_utils__.executeRuntime(
exports,
$ReactRefreshModuleId$,
module.hot,
errorOverlay,
testMode
);
}
}
if (typeof Promise !== 'undefined' && $ReactRefreshCurrentExports$ instanceof Promise) {
$ReactRefreshCurrentExports$.then($ReactRefreshModuleRuntime$);
} else {
$ReactRefreshModuleRuntime$($ReactRefreshCurrentExports$);
}
/***/ }),
/***/ "./src/index.js":
/*!**********************!*\
!*** ./src/index.js ***!
\**********************/
/***/ ((module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var react_dom_client__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-dom/client */ "./node_modules/react-dom/client.js");
/* harmony import */ var _index_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./index.css */ "./src/index.css");
/* harmony import */ var _App__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./App */ "./src/App.js");
/* harmony import */ var _reportWebVitals__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./reportWebVitals */ "./src/reportWebVitals.js");
/* harmony import */ var react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! react/jsx-dev-runtime */ "./node_modules/react/jsx-dev-runtime.js");
/* provided dependency */ var __react_refresh_utils__ = __webpack_require__(/*! ./node_modules/@pmmmwh/react-refresh-webpack-plugin/lib/runtime/RefreshUtils.js */ "./node_modules/@pmmmwh/react-refresh-webpack-plugin/lib/runtime/RefreshUtils.js");
__webpack_require__.$Refresh$.runtime = __webpack_require__(/*! ./node_modules/react-refresh/runtime.js */ "./node_modules/react-refresh/runtime.js");
var _jsxFileName = "/Users/philipmok/Desktop/test-human/src/index.js";
const root = react_dom_client__WEBPACK_IMPORTED_MODULE_1__.createRoot(document.getElementById('root'));
root.render( /*#__PURE__*/(0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxDEV)(_App__WEBPACK_IMPORTED_MODULE_3__["default"], {}, void 0, false, {
fileName: _jsxFileName,
lineNumber: 9,
columnNumber: 3
}, undefined));
// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
(0,_reportWebVitals__WEBPACK_IMPORTED_MODULE_4__["default"])();
const $ReactRefreshModuleId$ = __webpack_require__.$Refresh$.moduleId;
const $ReactRefreshCurrentExports$ = __react_refresh_utils__.getModuleExports(
$ReactRefreshModuleId$
);
function $ReactRefreshModuleRuntime$(exports) {
if (true) {
let errorOverlay;
if (true) {
errorOverlay = false;
}
let testMode;
if (typeof __react_refresh_test__ !== 'undefined') {
testMode = __react_refresh_test__;
}
return __react_refresh_utils__.executeRuntime(
exports,
$ReactRefreshModuleId$,
module.hot,
errorOverlay,
testMode
);
}
}
if (typeof Promise !== 'undefined' && $ReactRefreshCurrentExports$ instanceof Promise) {
$ReactRefreshCurrentExports$.then($ReactRefreshModuleRuntime$);
} else {
$ReactRefreshModuleRuntime$($ReactRefreshCurrentExports$);
}
/***/ }),
/***/ "./src/reportWebVitals.js":
/*!********************************!*\
!*** ./src/reportWebVitals.js ***!
\********************************/
/***/ ((module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* provided dependency */ var __react_refresh_utils__ = __webpack_require__(/*! ./node_modules/@pmmmwh/react-refresh-webpack-plugin/lib/runtime/RefreshUtils.js */ "./node_modules/@pmmmwh/react-refresh-webpack-plugin/lib/runtime/RefreshUtils.js");
__webpack_require__.$Refresh$.runtime = __webpack_require__(/*! ./node_modules/react-refresh/runtime.js */ "./node_modules/react-refresh/runtime.js");
const reportWebVitals = onPerfEntry => {
if (onPerfEntry && onPerfEntry instanceof Function) {
__webpack_require__.e(/*! import() */ "node_modules_web-vitals_dist_web-vitals_js").then(__webpack_require__.bind(__webpack_require__, /*! web-vitals */ "./node_modules/web-vitals/dist/web-vitals.js")).then(({
getCLS,
getFID,
getFCP,
getLCP,
getTTFB
}) => {
getCLS(onPerfEntry);
getFID(onPerfEntry);
getFCP(onPerfEntry);
getLCP(onPerfEntry);
getTTFB(onPerfEntry);
});
}
};
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (reportWebVitals);
const $ReactRefreshModuleId$ = __webpack_require__.$Refresh$.moduleId;
const $ReactRefreshCurrentExports$ = __react_refresh_utils__.getModuleExports(
$ReactRefreshModuleId$
);
function $ReactRefreshModuleRuntime$(exports) {
if (true) {
let errorOverlay;
if (true) {
errorOverlay = false;
}
let testMode;
if (typeof __react_refresh_test__ !== 'undefined') {
testMode = __react_refresh_test__;
}
return __react_refresh_utils__.executeRuntime(
exports,
$ReactRefreshModuleId$,
module.hot,
errorOverlay,
testMode
);
}
}
if (typeof Promise !== 'undefined' && $ReactRefreshCurrentExports$ instanceof Promise) {
$ReactRefreshCurrentExports$.then($ReactRefreshModuleRuntime$);
} else {
$ReactRefreshModuleRuntime$($ReactRefreshCurrentExports$);
}
/***/ }),
/***/ "./src/setVideoSource.js":
/*!*******************************!*\
!*** ./src/setVideoSource.js ***!
\*******************************/
/***/ ((module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* provided dependency */ var __react_refresh_utils__ = __webpack_require__(/*! ./node_modules/@pmmmwh/react-refresh-webpack-plugin/lib/runtime/RefreshUtils.js */ "./node_modules/@pmmmwh/react-refresh-webpack-plugin/lib/runtime/RefreshUtils.js");
__webpack_require__.$Refresh$.runtime = __webpack_require__(/*! ./node_modules/react-refresh/runtime.js */ "./node_modules/react-refresh/runtime.js");
async function setVideoSource(videoEl, facingMode, handleError) {
try {
var _navigator$mediaDevic;
if (videoEl === null) {
return null;
}
const stream = await ((_navigator$mediaDevic = navigator.mediaDevices) === null || _navigator$mediaDevic === void 0 ? void 0 : _navigator$mediaDevic.getUserMedia({
video: {
facingMode
}
}));
videoEl.srcObject = stream;
const tracks = stream === null || stream === void 0 ? void 0 : stream.getTracks();
if (tracks.length === 0) {
return null;
}
/**
* getCapabilities is not supported in Firefox
*/
if (tracks[0].getCapabilities === undefined) {
return 'unknown';
}
const capabilities = tracks[0].getCapabilities();
console.log(capabilities);
const f = (capabilities === null || capabilities === void 0 ? void 0 : capabilities.facingMode) || [];
if (f.length) {
return f[0];
}
return null;
} catch (err) {
handleError();
return null;
}
}
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (setVideoSource);
const $ReactRefreshModuleId$ = __webpack_require__.$Refresh$.moduleId;
const $ReactRefreshCurrentExports$ = __react_refresh_utils__.getModuleExports(
$ReactRefreshModuleId$
);
function $ReactRefreshModuleRuntime$(exports) {
if (true) {
let errorOverlay;
if (true) {
errorOverlay = false;
}
let testMode;
if (typeof __react_refresh_test__ !== 'undefined') {
testMode = __react_refresh_test__;
}
return __react_refresh_utils__.executeRuntime(
exports,
$ReactRefreshModuleId$,
module.hot,
errorOverlay,
testMode
);
}
}
if (typeof Promise !== 'undefined' && $ReactRefreshCurrentExports$ instanceof Promise) {
$ReactRefreshCurrentExports$.then($ReactRefreshModuleRuntime$);
} else {
$ReactRefreshModuleRuntime$($ReactRefreshCurrentExports$);
}
/***/ }),
/***/ "./node_modules/@pmmmwh/react-refresh-webpack-plugin/lib/runtime/RefreshUtils.js":
/*!***************************************************************************************!*\
!*** ./node_modules/@pmmmwh/react-refresh-webpack-plugin/lib/runtime/RefreshUtils.js ***!
\***************************************************************************************/
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/* global __webpack_require__ */
var Refresh = __webpack_require__(/*! react-refresh/runtime */ "./node_modules/react-refresh/runtime.js");
/**
* Extracts exports from a webpack module object.
* @param {string} moduleId A Webpack module ID.
* @returns {*} An exports object from the module.
*/
function getModuleExports(moduleId) {
if (typeof moduleId === 'undefined') {
// `moduleId` is unavailable, which indicates that this module is not in the cache,
// which means we won't be able to capture any exports,
// and thus they cannot be refreshed safely.
// These are likely runtime or dynamically generated modules.
return {};
}
var maybeModule = __webpack_require__.c[moduleId];
if (typeof maybeModule === 'undefined') {
// `moduleId` is available but the module in cache is unavailable,
// which indicates the module is somehow corrupted (e.g. broken Webpacak `module` globals).
// We will warn the user (as this is likely a mistake) and assume they cannot be refreshed.
console.warn('[React Refresh] Failed to get exports for module: ' + moduleId + '.');
return {};
}
var exportsOrPromise = maybeModule.exports;
if (typeof Promise !== 'undefined' && exportsOrPromise instanceof Promise) {
return exportsOrPromise.then(function (exports) {
return exports;
});
}
return exportsOrPromise;
}
/**
* Calculates the signature of a React refresh boundary.
* If this signature changes, it's unsafe to accept the boundary.
*
* This implementation is based on the one in [Metro](https://github.com/facebook/metro/blob/907d6af22ac6ebe58572be418e9253a90665ecbd/packages/metro/src/lib/polyfills/require.js#L795-L816).
* @param {*} moduleExports A Webpack module exports object.
* @returns {string[]} A React refresh boundary signature array.
*/
function getReactRefreshBoundarySignature(moduleExports) {
var signature = [];
signature.push(Refresh.getFamilyByType(moduleExports));
if (moduleExports == null || typeof moduleExports !== 'object') {
// Exit if we can't iterate over exports.
return signature;
}
for (var key in moduleExports) {
if (key === '__esModule') {
continue;
}
signature.push(key);
signature.push(Refresh.getFamilyByType(moduleExports[key]));
}
return signature;
}
/**
* Creates a data object to be retained across refreshes.
* This object should not transtively reference previous exports,
* which can form infinite chain of objects across refreshes, which can pressure RAM.
*
* @param {*} moduleExports A Webpack module exports object.
* @returns {*} A React refresh boundary signature array.
*/
function getWebpackHotData(moduleExports) {
return {
signature: getReactRefreshBoundarySignature(moduleExports),
isReactRefreshBoundary: isReactRefreshBoundary(moduleExports)
};
}
/**
* Creates a helper that performs a delayed React refresh.
* @returns {function(function(): void): void} A debounced React refresh function.
*/
function createDebounceUpdate() {
/**
* A cached setTimeout handler.
* @type {number | undefined}
*/
var refreshTimeout;
/**
* Performs react refresh on a delay and clears the error overlay.
* @param {function(): void} callback
* @returns {void}
*/
function enqueueUpdate(callback) {
if (typeof refreshTimeout === 'undefined') {
refreshTimeout = setTimeout(function () {
refreshTimeout = undefined;
Refresh.performReactRefresh();
callback();
}, 30);
}
}
return enqueueUpdate;
}
/**
* Checks if all exports are likely a React component.
*
* This implementation is based on the one in [Metro](https://github.com/facebook/metro/blob/febdba2383113c88296c61e28e4ef6a7f4939fda/packages/metro/src/lib/polyfills/require.js#L748-L774).
* @param {*} moduleExports A Webpack module exports object.
* @returns {boolean} Whether the exports are React component like.
*/
function isReactRefreshBoundary(moduleExports) {
if (Refresh.isLikelyComponentType(moduleExports)) {
return true;
}
if (moduleExports === undefined || moduleExports === null || typeof moduleExports !== 'object') {
// Exit if we can't iterate over exports.
return false;
}
var hasExports = false;
var areAllExportsComponents = true;
for (var key in moduleExports) {
hasExports = true;
// This is the ES Module indicator flag
if (key === '__esModule') {
continue;
}
// We can (and have to) safely execute getters here,
// as Webpack manually assigns harmony exports to getters,
// without any side-effects attached.
// Ref: https://github.com/webpack/webpack/blob/b93048643fe74de2a6931755911da1212df55897/lib/MainTemplate.js#L281
var exportValue = moduleExports[key];
if (!Refresh.isLikelyComponentType(exportValue)) {
areAllExportsComponents = false;
}
}
return hasExports && areAllExportsComponents;
}
/**
* Checks if exports are likely a React component and registers them.
*
* This implementation is based on the one in [Metro](https://github.com/facebook/metro/blob/febdba2383113c88296c61e28e4ef6a7f4939fda/packages/metro/src/lib/polyfills/require.js#L818-L835).
* @param {*} moduleExports A Webpack module exports object.
* @param {string} moduleId A Webpack module ID.
* @returns {void}
*/
function registerExportsForReactRefresh(moduleExports, moduleId) {
if (Refresh.isLikelyComponentType(moduleExports)) {
// Register module.exports if it is likely a component
Refresh.register(moduleExports, moduleId + ' %exports%');
}
if (moduleExports === undefined || moduleExports === null || typeof moduleExports !== 'object') {
// Exit if we can't iterate over the exports.
return;
}
for (var key in moduleExports) {
// Skip registering the ES Module indicator
if (key === '__esModule') {
continue;
}
var exportValue = moduleExports[key];
if (Refresh.isLikelyComponentType(exportValue)) {
var typeID = moduleId + ' %exports% ' + key;
Refresh.register(exportValue, typeID);
}
}
}
/**
* Compares previous and next module objects to check for mutated boundaries.
*
* This implementation is based on the one in [Metro](https://github.com/facebook/metro/blob/907d6af22ac6ebe58572be418e9253a90665ecbd/packages/metro/src/lib/polyfills/require.js#L776-L792).
* @param {*} prevSignature The signature of the current Webpack module exports object.
* @param {*} nextSignature The signature of the next Webpack module exports object.
* @returns {boolean} Whether the React refresh boundary should be invalidated.
*/
function shouldInvalidateReactRefreshBoundary(prevSignature, nextSignature) {
if (prevSignature.length !== nextSignature.length) {
return true;
}
for (var i = 0; i < nextSignature.length; i += 1) {
if (prevSignature[i] !== nextSignature[i]) {
return true;
}
}
return false;
}
var enqueueUpdate = createDebounceUpdate();
function executeRuntime(moduleExports, moduleId, webpackHot, refreshOverlay, isTest) {
registerExportsForReactRefresh(moduleExports, moduleId);
if (webpackHot) {
var isHotUpdate = !!webpackHot.data;
var prevData;
if (isHotUpdate) {
prevData = webpackHot.data.prevData;
}
if (isReactRefreshBoundary(moduleExports)) {
webpackHot.dispose(
/**
* A callback to performs a full refresh if React has unrecoverable errors,
* and also caches the to-be-disposed module.
* @param {*} data A hot module data object from Webpack HMR.
* @returns {void}
*/
function hotDisposeCallback(data) {
// We have to mutate the data object to get data registered and cached
data.prevData = getWebpackHotData(moduleExports);
});
webpackHot.accept(
/**
* An error handler to allow self-recovering behaviours.
* @param {Error} error An error occurred during evaluation of a module.
* @returns {void}
*/
function hotErrorHandler(error) {
if (typeof refreshOverlay !== 'undefined' && refreshOverlay) {
refreshOverlay.handleRuntimeError(error);
}
if (typeof isTest !== 'undefined' && isTest) {
if (window.onHotAcceptError) {
window.onHotAcceptError(error.message);
}
}
__webpack_require__.c[moduleId].hot.accept(hotErrorHandler);
});
if (isHotUpdate) {
if (prevData && prevData.isReactRefreshBoundary && shouldInvalidateReactRefreshBoundary(prevData.signature, getReactRefreshBoundarySignature(moduleExports))) {
webpackHot.invalidate();
} else {
enqueueUpdate(
/**
* A function to dismiss the error overlay after performing React refresh.
* @returns {void}
*/
function updateCallback() {
if (typeof refreshOverlay !== 'undefined' && refreshOverlay) {
refreshOverlay.clearRuntimeErrors();
}
});
}
}
} else {
if (isHotUpdate && typeof prevData !== 'undefined') {
webpackHot.invalidate();
}
}
}
}
module.exports = Object.freeze({
enqueueUpdate: enqueueUpdate,
executeRuntime: executeRuntime,
getModuleExports: getModuleExports,
isReactRefreshBoundary: isReactRefreshBoundary,
registerExportsForReactRefresh: registerExportsForReactRefresh
});
/***/ }),
/***/ "./node_modules/@vladmandic/human/dist/human.esm.js":
/*!**********************************************************!*\
!*** ./node_modules/@vladmandic/human/dist/human.esm.js ***!
\**********************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
var __filename = "/index.js";
var __dirname = "/";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ Env: () => (/* binding */ Env),
/* harmony export */ Human: () => (/* binding */ Human),
/* harmony export */ "default": () => (/* binding */ Human),
/* harmony export */ defaults: () => (/* binding */ config),
/* harmony export */ draw: () => (/* binding */ draw_exports),
/* harmony export */ empty: () => (/* binding */ empty),
/* harmony export */ env: () => (/* binding */ env),
/* harmony export */ match: () => (/* binding */ match_exports),
/* harmony export */ models: () => (/* binding */ models_exports2)
/* harmony export */ });
/*
Human
homepage: <https://github.com/vladmandic/human>
author: <https://github.com/vladmandic>'
*/
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 __export = (target, all2) => {
for (var name in all2) __defProp(target, name, {
get: all2[name],
enumerable: true
});
};
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, {
Abs: () => Gs,
Acos: () => zo,
Acosh: () => Vo,
AdadeltaOptimizer: () => Yu,
AdagradOptimizer: () => Qu,
AdamOptimizer: () => Zu,
AdamaxOptimizer: () => Ju,
Add: () => no,
AddN: () => Wo,
All: () => Uo,
Any: () => Go,
ArgMax: () => Hs,
ArgMin: () => Ks,
Asin: () => Ho,
Asinh: () => Ko,
Atan: () => qo,
Atan2: () => Xo,
Atanh: () => jo,
AvgPool: () => Yo,
AvgPool3D: () => qs,
AvgPool3DGrad: () => Ni,
AvgPoolGrad: () => Gp,
BackendWasm: () => am,
BatchMatMul: () => Qo,
BatchToSpaceND: () => js,
Bincount: () => Zo,
BitwiseAnd: () => ml,
BroadcastArgs: () => Xs,
BroadcastTo: () => Kpe,
Cast: () => ho,
Ceil: () => Jo,
ClipByValue: () => go,
Complex: () => Ti,
ComplexAbs: () => _i,
Concat: () => Ys,
Conv2D: () => en,
Conv2DBackpropFilter: () => $i,
Conv2DBackpropInput: () => tn,
Conv3D: () => rn,
Conv3DBackpropFilterV2: () => za,
Conv3DBackpropInputV2: () => on,
Cos: () => nn,
Cosh: () => sn,
CropAndResize: () => pn,
Cumprod: () => an,
Cumsum: () => un,
DataStorage: () => Lo,
DenseBincount: () => Qs,
DepthToSpace: () => cn,
DepthwiseConv2dNative: () => ln,
DepthwiseConv2dNativeBackpropFilter: () => Ei,
DepthwiseConv2dNativeBackpropInput: () => Ri,
Diag: () => Zs,
Dilation2D: () => mn,
Dilation2DBackpropFilter: () => Ai,
Dilation2DBackpropInput: () => Di,
ENV: () => WC,
Einsum: () => Fi,
Elu: () => fn,
EluGrad: () => Va,
Environment: () => cl,
Equal: () => hn,
Erf: () => Wa,
Exp: () => gn,
ExpandDims: () => Js,
Expm1: () => xn,
FFT: () => Pi,
Fill: () => ea,
FlipLeftRight: () => yn,
Floor: () => bn,
FloorDiv: () => Cn,
FromPixels: () => $u,
FusedBatchNorm: () => wn,
FusedConv2D: () => Co,
FusedDepthwiseConv2D: () => wo,
GPGPUContext: () => xp,
GatherNd: () => Sn,
GatherV2: () => ta,
GraphModel: () => Ol,
Greater: () => In,
GreaterEqual: () => vn,
IFFT: () => Oi,
Identity: () => xo,
Imag: () => Mi,
IsFinite: () => kn,
IsInf: () => Nn,
IsNan: () => Tn,
KernelBackend: () => ro,
LRN: () => Mn,
LRNGrad: () => Ua,
LeakyRelu: () => _n,
Less: () => $n,
LessEqual: () => En,
LinSpace: () => Rn,
Log: () => Dn,
Log1p: () => An,
LogSoftmax: () => qpe,
LogicalAnd: () => Fn,
LogicalNot: () => Pn,
LogicalOr: () => On,
LogicalXor: () => m0,
LowerBound: () => jpe,
MathBackendCPU: () => lu,
MathBackendWebGL: () => hu,
MatrixBandPart: () => Xpe,
Max: () => Ln,
MaxPool: () => zn,
MaxPool3D: () => ra,
MaxPool3DGrad: () => Li,
MaxPoolGrad: () => Hp,
MaxPoolWithArgmax: () => Bi,
Maximum: () => Bn,
Mean: () => Vn,
Min: () => Wn,
Minimum: () => Un,
MirrorPad: () => Gn,
Mod: () => Ga,
MomentumOptimizer: () => ep,
Multinomial: () => Hn,
Multiply: () => Kn,
Neg: () => oa,
NonMaxSuppressionV3: () => jn,
NonMaxSuppressionV4: () => Ha,
NonMaxSuppressionV5: () => Xn,
NotEqual: () => qn,
OP_SCOPE_SUFFIX: () => pw,
OneHot: () => Yn,
OnesLike: () => na,
Optimizer: () => kr,
OptimizerConstructors: () => Dl,
Pack: () => sa,
PadV2: () => Qn,
Pool: () => Ype,
Pow: () => Zn,
Prelu: () => Jn,
Prod: () => es,
RMSPropOptimizer: () => tp,
RaggedGather: () => Kp,
RaggedRange: () => qp,
RaggedTensorToTensor: () => jp,
Range: () => aa,
Rank: () => JC,
Real: () => zi,
RealDiv: () => dn,
Reciprocal: () => ts,
Reduction: () => Et,
Relu: () => rs,
Relu6: () => ss,
Reshape: () => ia,
ResizeBilinear: () => ns,
ResizeBilinearGrad: () => qa,
ResizeNearestNeighbor: () => os,
ResizeNearestNeighborGrad: () => Ka,
Reverse: () => as,
RotateWithOffset: () => _s,
Round: () => is,
Rsqrt: () => us,
SGDOptimizer: () => ii,
ScatterNd: () => ps,
SearchSorted: () => ls,
Select: () => ua,
Selu: () => ms,
Sigmoid: () => hs,
Sign: () => fs,
Sin: () => ds,
Sinh: () => ja,
Slice: () => pa,
Softmax: () => bs,
Softplus: () => gs,
SpaceToBatchND: () => ca,
SparseFillEmptyRows: () => Vi,
SparseReshape: () => Xa,
SparseSegmentMean: () => Wi,
SparseSegmentSum: () => Ui,
SparseToDense: () => Cs,
SplitV: () => la,
Sqrt: () => xs,
Square: () => Gi,
SquaredDifference: () => ws,
StaticRegexReplace: () => _u,
Step: () => yo,
StridedSlice: () => Ss,
StringNGrams: () => ma,
StringSplit: () => Hi,
StringToHashBucketFast: () => Ki,
Sub: () => Is,
Sum: () => ys,
Tan: () => vs,
Tanh: () => ks,
Tensor: () => pt,
TensorBuffer: () => tt,
TensorScatterUpdate: () => cs,
Tile: () => so,
TopK: () => Ns,
Transform: () => Ts,
Transpose: () => ao,
Unique: () => qi,
Unpack: () => da,
UnsortedSegmentSum: () => ji,
UpperBound: () => Qpe,
Variable: () => Qa,
WebGPUBackend: () => Cu,
ZerosLike: () => fa,
_FusedMatMul: () => bo,
abs: () => Zt,
acos: () => ik,
acosh: () => uk,
add: () => be,
addN: () => pk,
all: () => ck,
any: () => lk,
argMax: () => mk,
argMin: () => dk,
asin: () => fk,
asinh: () => hk,
atan: () => gk,
atan2: () => xk,
atanh: () => yk,
avgPool: () => cd,
avgPool3d: () => wk,
backend: () => Tme,
backend_util: () => C,
basicLSTMCell: () => Sk,
batchNorm: () => tu,
batchNorm2d: () => vk,
batchNorm3d: () => kk,
batchNorm4d: () => Nk,
batchToSpaceND: () => ld,
bincount: () => md,
bitwiseAnd: () => Tk,
booleanMaskAsync: () => qq,
broadcastArgs: () => _k,
broadcastTo: () => ru,
broadcast_util: () => Sr,
browser: () => MN,
buffer: () => me,
cast: () => Ye,
ceil: () => $k,
clipByValue: () => Ek,
clone: () => Vr,
complex: () => $r,
concat: () => yt,
concat1d: () => Rk,
concat2d: () => Dk,
concat3d: () => Ak,
concat4d: () => Fk,
conv1d: () => Pk,
conv2d: () => ou,
conv2dTranspose: () => Ok,
conv3d: () => Mk,
conv3dTranspose: () => Bk,
copyRegisteredKernels: () => sce,
cos: () => zk,
cosh: () => Vk,
cosineWindow: () => _l,
cumprod: () => Wk,
cumsum: () => Uk,
customGrad: () => Ir,
denseBincount: () => Gk,
deprecationWarn: () => bw,
depthToSpace: () => Hk,
depthwiseConv2d: () => ac,
deregisterOp: () => KX,
device_util: () => Zi,
diag: () => Kk,
dilation2d: () => qk,
disableDeprecationWarnings: () => gme,
dispose: () => Ot,
disposeVariables: () => xme,
div: () => Ke,
divNoNan: () => Xk,
dot: () => Yk,
dropout: () => s6,
einsum: () => Qk,
elu: () => gd,
enableDebugMode: () => hme,
enableProdMode: () => fme,
enclosingPowerOfTwo: () => Pw,
engine: () => ur,
ensureShape: () => Zk,
env: () => P,
equal: () => hd,
erf: () => Jk,
euclideanNorm: () => r2,
exp: () => ko,
expandDims: () => oi,
expm1: () => o2,
eye: () => xd,
fft: () => pc,
fill: () => Sa,
findBackend: () => kme,
findBackendFactory: () => Nme,
floor: () => yd,
floorDiv: () => pd,
forceHalfFloat: () => hD,
fused: () => Ow,
gather: () => bd,
gatherND: () => o6,
gather_util: () => of,
getBackend: () => Ime,
getGradient: () => HC,
getKernel: () => fl,
getKernelsForBackend: () => Km,
getThreadsCount: () => ese,
gpgpu_util: () => qI,
grad: () => YH,
grads: () => QH,
greater: () => Bu,
greaterEqual: () => Cd,
ifft: () => Hu,
imag: () => su,
image: () => uj,
inTopKAsync: () => i6,
io: () => pi,
irfft: () => Wd,
isFinite: () => n2,
isInf: () => s2,
isNaN: () => a2,
keep: () => Er,
kernel_impls: () => Wt,
leakyRelu: () => wd,
less: () => kl,
lessEqual: () => ic,
linalg: () => pj,
linspace: () => i2,
loadGraphModel: () => W5,
loadGraphModelSync: () => U5,
localResponseNormalization: () => u2,
log: () => ni,
log1p: () => Sd,
logSigmoid: () => p2,
logSoftmax: () => c2,
logSumExp: () => kd,
logicalAnd: () => zu,
logicalNot: () => Nd,
logicalOr: () => Td,
logicalXor: () => l2,
losses: () => cj,
lowerBound: () => m2,
matMul: () => Qe,
math: () => PN,
max: () => Ia,
maxPool: () => $d,
maxPool3d: () => d2,
maxPoolWithArgmax: () => f2,
maximum: () => Ed,
mean: () => Vu,
memory: () => yme,
meshgrid: () => h2,
min: () => vl,
minimum: () => Wu,
mirrorPad: () => g2,
mod: () => x2,
moments: () => y2,
movingAverage: () => Yq,
mul: () => se,
multiRNNCell: () => b2,
multinomial: () => C2,
neg: () => pr,
nextFrame: () => Kw,
norm: () => Lu,
notEqual: () => Rd,
oneHot: () => Tl,
ones: () => va,
onesLike: () => w2,
op: () => N,
outerProduct: () => S2,
pad: () => ka,
pad1d: () => I2,
pad2d: () => v2,
pad3d: () => k2,
pad4d: () => N2,
pool: () => T2,
pow: () => ri,
prelu: () => Ad,
print: () => ud,
prod: () => _2,
profile: () => bme,
raggedGather: () => $2,
raggedRange: () => E2,
raggedTensorToTensor: () => R2,
rand: () => D2,
randomGamma: () => J2,
randomNormal: () => Bd,
randomStandardNormal: () => e1,
randomUniform: () => uc,
randomUniformInt: () => t1,
range: () => au,
ready: () => Sme,
real: () => si,
reciprocal: () => r1,
registerBackend: () => eu,
registerGradient: () => rce,
registerKernel: () => Ya,
registerOp: () => HX,
relu: () => iu,
relu6: () => zd,
removeBackend: () => vme,
reshape: () => W,
reverse: () => uo,
reverse1d: () => o1,
reverse2d: () => n1,
reverse3d: () => s1,
reverse4d: () => a1,
rfft: () => cc,
round: () => Vd,
rsqrt: () => i1,
scalar: () => ke,
scatterND: () => Zq,
scatter_util: () => pu,
searchSorted: () => Nl,
selu: () => u1,
separableConv2d: () => p1,
serialization: () => vN,
setBackend: () => wme,
setPlatform: () => _me,
setThreadsCount: () => Jne,
setWasmPath: () => Qne,
setWasmPaths: () => Zne,
setWebGLContext: () => iI,
setdiff1dAsync: () => c1,
shared: () => Sc,
sigmoid: () => wa,
sign: () => l1,
signal: () => ij,
sin: () => m1,
sinh: () => d1,
slice: () => qe,
slice1d: () => f1,
slice2d: () => h1,
slice3d: () => g1,
slice4d: () => x1,
slice_util: () => ct,
softmax: () => y1,
softplus: () => vd,
spaceToBatchND: () => Dd,
sparse: () => lj,
sparseToDense: () => t6,
spectral: () => aj,
split: () => ai,
sqrt: () => Rr,
square: () => Jt,
squaredDifference: () => Ud,
squeeze: () => lc,
stack: () => vr,
step: () => Gd,
stridedSlice: () => b1,
string: () => mj,
sub: () => Te,
sum: () => ot,
sumOutType: () => Za,
tan: () => C1,
tanh: () => Il,
tensor: () => ir,
tensor1d: () => xr,
tensor2d: () => uu,
tensor3d: () => Hd,
tensor4d: () => w1,
tensor5d: () => S1,
tensor6d: () => I1,
tensorScatterUpdate: () => k1,
tensor_util: () => M0,
test_util: () => Z2,
tidy: () => De,
tile: () => nu,
time: () => Cme,
topk: () => N1,
train: () => CUe,
transpose: () => dc,
truncatedNormal: () => T1,
unique: () => _1,
unregisterGradient: () => nce,
unregisterKernel: () => oce,
unsortedSegmentSum: () => $1,
unstack: () => po,
upcastType: () => dt,
upperBound: () => E1,
util: () => y,
valueAndGrad: () => ZH,
valueAndGrads: () => JH,
variable: () => R1,
variableGrads: () => vw,
version: () => zpe,
version_converter: () => H5,
version_core: () => Vj,
version_cpu: () => I8,
version_wasm: () => tse,
version_webgl: () => xZ,
webgl: () => cst,
webgl_util: () => _c,
webgpu_util: () => Fv,
where: () => io,
whereAsync: () => qd,
zeros: () => Wr,
zerosLike: () => Ht
});
var BU = Object.create;
var PC = Object.defineProperty;
var zU = Object.getOwnPropertyDescriptor;
var VU = Object.getOwnPropertyNames;
var WU = Object.getPrototypeOf;
var UU = Object.prototype.hasOwnProperty;
var qt = (r, e) => () => (e || r((e = {
exports: {}
}).exports, e), e.exports);
var He = (r, e) => {
for (var t10 in e) PC(r, t10, {
get: e[t10],
enumerable: true
});
};
var GU = (r, e, t10, o) => {
if (e && typeof e == "object" || typeof e == "function") for (let n of VU(e)) !UU.call(r, n) && n !== t10 && PC(r, n, {
get: () => e[n],
enumerable: !(o = zU(e, n)) || o.enumerable
});
return r;
};
var Bp = (r, e, t10) => (t10 = r != null ? BU(WU(r)) : {}, GU(e || !r || !r.__esModule ? PC(t10, "default", {
value: r,
enumerable: true
}) : t10, r));
var v0 = qt((uce, I0) => {
I0.exports = vt;
var So = null;
try {
So = 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 vt(r, e, t10) {
this.low = r | 0, this.high = e | 0, this.unsigned = !!t10;
}
vt.prototype.__isLong__;
Object.defineProperty(vt.prototype, "__isLong__", {
value: true
});
function zr(r) {
return (r && r.__isLong__) === true;
}
vt.isLong = zr;
var f0 = {},
h0 = {};
function Ru(r, e) {
var t10, o, n;
return e ? (r >>>= 0, (n = 0 <= r && r < 256) && (o = h0[r], o) ? o : (t10 = kt(r, (r | 0) < 0 ? -1 : 0, true), n && (h0[r] = t10), t10)) : (r |= 0, (n = -128 <= r && r < 128) && (o = f0[r], o) ? o : (t10 = kt(r, r < 0 ? -1 : 0, false), n && (f0[r] = t10), t10));
}
vt.fromInt = Ru;
function Io(r, e) {
if (isNaN(r)) return e ? Eu : vo;
if (e) {
if (r < 0) return Eu;
if (r >= b0) return S0;
} else {
if (r <= -x0) return Br;
if (r + 1 >= x0) return w0;
}
return r < 0 ? Io(-r, e).neg() : kt(r % Qp | 0, r / Qp | 0, e);
}
vt.fromNumber = Io;
function kt(r, e, t10) {
return new vt(r, e, t10);
}
vt.fromBits = kt;
var jm = Math.pow;
function jC(r, e, t10) {
if (r.length === 0) throw Error("empty string");
if (r === "NaN" || r === "Infinity" || r === "+Infinity" || r === "-Infinity") return vo;
if (typeof e == "number" ? (t10 = e, e = false) : e = !!e, t10 = t10 || 10, t10 < 2 || 36 < t10) throw RangeError("radix");
var o;
if ((o = r.indexOf("-")) > 0) throw Error("interior hyphen");
if (o === 0) return jC(r.substring(1), e, t10).neg();
for (var n = Io(jm(t10, 8)), s = vo, a = 0; a < r.length; a += 8) {
var i = Math.min(8, r.length - a),
p = parseInt(r.substring(a, a + i), t10);
if (i < 8) {
var u = Io(jm(t10, i));
s = s.mul(u).add(Io(p));
} else s = s.mul(n), s = s.add(Io(p));
}
return s.unsigned = e, s;
}
vt.fromString = jC;
function $s(r, e) {
return typeof r == "number" ? Io(r, e) : typeof r == "string" ? jC(r, e) : kt(r.low, r.high, typeof e == "boolean" ? e : r.unsigned);
}
vt.fromValue = $s;
var g0 = 1 << 16,
dG = 1 << 24,
Qp = g0 * g0,
b0 = Qp * Qp,
x0 = b0 / 2,
y0 = Ru(dG),
vo = Ru(0);
vt.ZERO = vo;
var Eu = Ru(0, true);
vt.UZERO = Eu;
var Yp = Ru(1);
vt.ONE = Yp;
var C0 = Ru(1, true);
vt.UONE = C0;
var qC = Ru(-1);
vt.NEG_ONE = qC;
var w0 = kt(-1, 2147483647, false);
vt.MAX_VALUE = w0;
var S0 = kt(-1, -1, true);
vt.MAX_UNSIGNED_VALUE = S0;
var Br = kt(0, -2147483648, false);
vt.MIN_VALUE = Br;
var de = vt.prototype;
de.toInt = function () {
return this.unsigned ? this.low >>> 0 : this.low;
};
de.toNumber = function () {
return this.unsigned ? (this.high >>> 0) * Qp + (this.low >>> 0) : this.high * Qp + (this.low >>> 0);
};
de.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(Br)) {
var t10 = Io(e),
o = this.div(t10),
n = o.mul(t10).sub(this);
return o.toString(e) + n.toInt().toString(e);
} else return "-" + this.neg().toString(e);
for (var s = Io(jm(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;
for (; c.length < 6;) c = "0" + c;
i = "" + c + i;
}
};
de.getHighBits = function () {
return this.high;
};
de.getHighBitsUnsigned = function () {
return this.high >>> 0;
};
de.getLowBits = function () {
return this.low;
};
de.getLowBitsUnsigned = function () {
return this.low >>> 0;
};
de.getNumBitsAbs = function () {
if (this.isNegative()) return this.eq(Br) ? 64 : this.neg().getNumBitsAbs();
for (var e = this.high != 0 ? this.high : this.low, t10 = 31; t10 > 0 && !(e & 1 << t10); t10--);
return this.high != 0 ? t10 + 33 : t10 + 1;
};
de.isZero = function () {
return this.high === 0 && this.low === 0;
};
de.eqz = de.isZero;
de.isNegative = function () {
return !this.unsigned && this.high < 0;
};
de.isPositive = function () {
return this.unsigned || this.high >= 0;
};
de.isOdd = function () {
return (this.low & 1) === 1;
};
de.isEven = function () {
return (this.low & 1) === 0;
};
de.equals = function (e) {
return zr(e) || (e = $s(e)), this.unsigned !== e.unsigned && this.high >>> 31 === 1 && e.high >>> 31 === 1 ? false : this.high === e.high && this.low === e.low;
};
de.eq = de.equals;
de.notEquals = function (e) {
return !this.eq(e);
};
de.neq = de.notEquals;
de.ne = de.notEquals;
de.lessThan = function (e) {
return this.comp(e) < 0;
};
de.lt = de.lessThan;
de.lessThanOrEqual = function (e) {
return this.comp(e) <= 0;
};
de.lte = de.lessThanOrEqual;
de.le = de.lessThanOrEqual;
de.greaterThan = function (e) {
return this.comp(e) > 0;
};
de.gt = de.greaterThan;
de.greaterThanOrEqual = function (e) {
return this.comp(e) >= 0;
};
de.gte = de.greaterThanOrEqual;
de.ge = de.greaterThanOrEqual;
de.compare = function (e) {
if (zr(e) || (e = $s(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;
};
de.comp = de.compare;
de.negate = function () {
return !this.unsigned && this.eq(Br) ? Br : this.not().add(Yp);
};
de.neg = de.negate;
de.add = function (e) {
zr(e) || (e = $s(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,
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 += t10 + a, c &= 65535, kt(m << 16 | d, c << 16 | l, this.unsigned);
};
de.subtract = function (e) {
return zr(e) || (e = $s(e)), this.add(e.neg());
};
de.sub = de.subtract;
de.multiply = function (e) {
if (this.isZero()) return vo;
if (zr(e) || (e = $s(e)), So) {
var t10 = So.mul(this.low, this.high, e.low, e.high);
return kt(t10, So.get_high(), this.unsigned);
}
if (e.isZero()) return vo;
if (this.eq(Br)) return e.isOdd() ? Br : vo;
if (e.eq(Br)) return this.isOdd() ? Br : vo;
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(y0) && e.lt(y0)) return Io(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, kt(d << 16 | f, l << 16 | m, this.unsigned);
};
de.mul = de.multiply;
de.divide = function (e) {
if (zr(e) || (e = $s(e)), e.isZero()) throw Error("division by zero");
if (So) {
if (!this.unsigned && this.high === -2147483648 && e.low === -1 && e.high === -1) return this;
var t10 = (this.unsigned ? So.div_u : So.div_s)(this.low, this.high, e.low, e.high);
return kt(t10, So.get_high(), this.unsigned);
}
if (this.isZero()) return this.unsigned ? Eu : vo;
var o, n, s;
if (this.unsigned) {
if (e.unsigned || (e = e.toUnsigned()), e.gt(this)) return Eu;
if (e.gt(this.shru(1))) return C0;
s = Eu;
} else {
if (this.eq(Br)) {
if (e.eq(Yp) || e.eq(qC)) return Br;
if (e.eq(Br)) return Yp;
var a = this.shr(1);
return o = a.div(e).shl(1), o.eq(vo) ? e.isNegative() ? Yp : qC : (n = this.sub(e.mul(o)), s = o.add(n.div(e)), s);
} else if (e.eq(Br)) return this.unsigned ? Eu : vo;
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 = vo;
}
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 : jm(2, i - 48), u = Io(o), c = u.mul(e); c.isNegative() || c.gt(n);) o -= p, u = Io(o, this.unsigned), c = u.mul(e);
u.isZero() && (u = Yp), s = s.add(u), n = n.sub(c);
}
return s;
};
de.div = de.divide;
de.modulo = function (e) {
if (zr(e) || (e = $s(e)), So) {
var t10 = (this.unsigned ? So.rem_u : So.rem_s)(this.low, this.high, e.low, e.high);
return kt(t10, So.get_high(), this.unsigned);
}
return this.sub(this.div(e).mul(e));
};
de.mod = de.modulo;
de.rem = de.modulo;
de.not = function () {
return kt(~this.low, ~this.high, this.unsigned);
};
de.and = function (e) {
return zr(e) || (e = $s(e)), kt(this.low & e.low, this.high & e.high, this.unsigned);
};
de.or = function (e) {
return zr(e) || (e = $s(e)), kt(this.low | e.low, this.high | e.high, this.unsigned);
};
de.xor = function (e) {
return zr(e) || (e = $s(e)), kt(this.low ^ e.low, this.high ^ e.high, this.unsigned);
};
de.shiftLeft = function (e) {
return zr(e) && (e = e.toInt()), (e &= 63) === 0 ? this : e < 32 ? kt(this.low << e, this.high << e | this.low >>> 32 - e, this.unsigned) : kt(0, this.low << e - 32, this.unsigned);
};
de.shl = de.shiftLeft;
de.shiftRight = function (e) {
return zr(e) && (e = e.toInt()), (e &= 63) === 0 ? this : e < 32 ? kt(this.low >>> e | this.high << 32 - e, this.high >> e, this.unsigned) : kt(this.high >> e - 32, this.high >= 0 ? 0 : -1, this.unsigned);
};
de.shr = de.shiftRight;
de.shiftRightUnsigned = function (e) {
if (zr(e) && (e = e.toInt()), e &= 63, e === 0) return this;
var t10 = this.high;
if (e < 32) {
var o = this.low;
return kt(o >>> e | t10 << 32 - e, t10 >>> e, this.unsigned);
} else return e === 32 ? kt(t10, 0, this.unsigned) : kt(t10 >>> e - 32, 0, this.unsigned);
};
de.shru = de.shiftRightUnsigned;
de.shr_u = de.shiftRightUnsigned;
de.toSigned = function () {
return this.unsigned ? kt(this.low, this.high, false) : this;
};
de.toUnsigned = function () {
return this.unsigned ? this : kt(this.low, this.high, true);
};
de.toBytes = function (e) {
return e ? this.toBytesLE() : this.toBytesBE();
};
de.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];
};
de.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];
};
vt.fromBytes = function (e, t10, o) {
return o ? vt.fromBytesLE(e, t10) : vt.fromBytesBE(e, t10);
};
vt.fromBytesLE = function (e, t10) {
return new vt(e[0] | e[1] << 8 | e[2] << 16 | e[3] << 24, e[4] | e[5] << 8 | e[6] << 16 | e[7] << 24, t10);
};
vt.fromBytesBE = function (e, t10) {
return new vt(e[4] << 24 | e[5] << 16 | e[6] << 8 | e[7], e[0] << 24 | e[1] << 16 | e[2] << 8 | e[3], t10);
};
});
var sk = qt(() => {});
var ak = qt(() => {});
var F2 = qt((A2, kw) => {
(function (r, e, t10) {
function o(i) {
var p = this,
u = a();
p.next = function () {
var c = 2091639 * p.s0 + p.c * 23283064365386963e-26;
return p.s0 = p.s1, p.s1 = p.s2, p.s2 = c - (p.c = c | 0);
}, p.c = 1, p.s0 = u(" "), p.s1 = u(" "), p.s2 = u(" "), p.s0 -= u(i), p.s0 < 0 && (p.s0 += 1), p.s1 -= u(i), p.s1 < 0 && (p.s1 += 1), p.s2 -= u(i), p.s2 < 0 && (p.s2 += 1), u = null;
}
function n(i, p) {
return p.c = i.c, p.s0 = i.s0, p.s1 = i.s1, p.s2 = i.s2, p;
}
function s(i, p) {
var u = new o(i),
c = p && p.state,
l = u.next;
return l.int32 = function () {
return u.next() * 4294967296 | 0;
}, l.double = function () {
return l() + (l() * 2097152 | 0) * 11102230246251565e-32;
}, l.quick = l, c && (typeof c == "object" && n(c, u), l.state = function () {
return n(u, {});
}), l;
}
function a() {
var i = 4022871197,
p = function (u) {
u = String(u);
for (var c = 0; c < u.length; c++) {
i += u.charCodeAt(c);
var l = 0.02519603282416938 * i;
i = l >>> 0, l -= i, l *= i, i = l >>> 0, l -= i, i += l * 4294967296;
}
return (i >>> 0) * 23283064365386963e-26;
};
return p;
}
e && e.exports ? e.exports = s : t10 && t10.amd ? t10(function () {
return s;
}) : this.alea = s;
})(A2, typeof kw == "object" && kw, typeof define == "function" && define);
});
var O2 = qt((P2, Nw) => {
(function (r, e, t10) {
function o(a) {
var i = this,
p = "";
i.x = 0, i.y = 0, i.z = 0, i.w = 0, i.next = function () {
var c = i.x ^ i.x << 11;
return i.x = i.y, i.y = i.z, i.z = i.w, i.w ^= i.w >>> 19 ^ c ^ c >>> 8;
}, a === (a | 0) ? i.x = a : p += a;
for (var u = 0; u < p.length + 64; u++) i.x ^= p.charCodeAt(u) | 0, i.next();
}
function n(a, i) {
return i.x = a.x, i.y = a.y, i.z = a.z, i.w = a.w, i;
}
function s(a, i) {
var p = new o(a),
u = i && i.state,
c = function () {
return (p.next() >>> 0) / 4294967296;
};
return c.double = function () {
do 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 () {
return s;
}) : this.xor128 = s;
})(P2, typeof Nw == "object" && Nw, typeof define == "function" && define);
});
var L2 = qt((M2, Tw) => {
(function (r, e, t10) {
function o(a) {
var i = this,
p = "";
i.next = function () {
var c = i.x ^ i.x >>> 2;
return i.x = i.y, i.y = i.z, i.z = i.w, i.w = i.v, (i.d = i.d + 362437 | 0) + (i.v = i.v ^ i.v << 4 ^ (c ^ c << 1)) | 0;
}, i.x = 0, i.y = 0, i.z = 0, i.w = 0, i.v = 0, a === (a | 0) ? i.x = a : p += a;
for (var u = 0; u < p.length + 64; u++) i.x ^= p.charCodeAt(u) | 0, u == p.length && (i.d = i.x << 10 ^ i.x >>> 4), i.next();
}
function n(a, i) {
return i.x = a.x, i.y = a.y, i.z = a.z, i.w = a.w, i.v = a.v, i.d = a.d, i;
}
function s(a, i) {
var p = new o(a),
u = i && i.state,
c = function () {
return (p.next() >>> 0) / 4294967296;
};
return c.double = function () {
do 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 () {
return s;
}) : this.xorwow = s;
})(M2, typeof Tw == "object" && Tw, typeof define == "function" && define);
});
var z2 = qt((B2, _w) => {
(function (r, e, t10) {
function o(a) {
var i = this;
i.next = function () {
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,
d = [];
if (c === (c | 0)) m = d[0] = c;else for (c = "" + c, l = 0; l < c.length; ++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 = d[7] = -1 : m = d[l], u.x = d, u.i = 0, l = 256; l > 0; --l) u.next();
}
p(i, a);
}
function n(a, i) {
return i.x = a.x.slice(), i.i = a.i, i;
}
function s(a, i) {
a == null && (a = + /* @__PURE__ */new Date());
var p = new o(a),
u = i && i.state,
c = function () {
return (p.next() >>> 0) / 4294967296;
};
return c.double = function () {
do 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 () {
return s;
}) : this.xorshift7 = s;
})(B2, typeof _w == "object" && _w, typeof define == "function" && define);
});
var W2 = qt((V2, $w) => {
(function (r, e, t10) {
function o(a) {
var i = this;
i.next = function () {
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,
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);
}
function n(a, i) {
return i.i = a.i, i.w = a.w, i.X = a.X.slice(), i;
}
function s(a, i) {
a == null && (a = + /* @__PURE__ */new Date());
var p = new o(a),
u = i && i.state,
c = function () {
return (p.next() >>> 0) / 4294967296;
};
return c.double = function () {
do 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 () {
return s;
}) : this.xor4096 = s;
})(V2, typeof $w == "object" && $w, typeof define == "function" && define);
});
var G2 = qt((U2, Ew) => {
(function (r, e, t10) {
function o(a) {
var i = this,
p = "";
i.next = function () {
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();
}
function n(a, i) {
return i.a = a.a, i.b = a.b, i.c = a.c, i.d = a.d, i;
}
function s(a, i) {
var p = new o(a),
u = i && i.state,
c = function () {
return (p.next() >>> 0) / 4294967296;
};
return c.double = function () {
do 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 () {
return s;
}) : this.tychei = s;
})(U2, typeof Ew == "object" && Ew, typeof define == "function" && define);
});
var H2 = qt(() => {});
var q2 = qt((K2, Fd) => {
(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;
function m(w, S, k) {
var _ = [];
S = S == true ? {
entropy: true
} : S || {};
var E = g(h(S.entropy ? [w, b(e)] : w == null ? x() : w, 3), _),
R = new d(_),
D = function () {
for (var F = R.g(n), O = i, M = 0; F < p;) F = (F + M) * o, O *= o, M = R.g(1);
for (; F >= u;) F /= 2, O /= 2, M >>>= 1;
return (F + M) / O;
};
return D.int32 = function () {
return R.g(4) | 0;
}, D.quick = function () {
return R.g(4) / 4294967296;
}, D.double = D, g(b(R.S), e), (S.pass || k || function (F, O, M, L) {
return L && (L.S && f(L, R), F.state = function () {
return f(R, {});
}), M ? (t10[a] = F, O) : F;
})(D, E, "global" in S ? S.global : this == t10, S.state);
}
function d(w) {
var S,
k = w.length,
_ = this,
E = 0,
R = _.i = _.j = 0,
D = _.S = [];
for (k || (w = [k++]); E < o;) D[E] = E++;
for (E = 0; E < o; E++) D[E] = D[R = c & R + w[E % k] + (S = D[E])], D[R] = S;
(_.g = function (F) {
for (var O, M = 0, L = _.i, B = _.j, z = _.S; F--;) O = z[L = c & L + 1], M = M * o + z[c & (z[L] = z[B = c & B + O]) + (z[B] = O)];
return _.i = L, _.j = B, M;
})(o);
}
function f(w, S) {
return S.i = w.i, S.j = w.j, S.S = w.S.slice(), S;
}
function h(w, S) {
var k = [],
_ = typeof w,
E;
if (S && _ == "object") for (E in w) try {
k.push(h(w[E], S - 1));
} catch (R) {}
return k.length ? k : _ == "string" ? w : w + "\0";
}
function g(w, S) {
for (var k = w + "", _, E = 0; E < k.length;) S[c & E] = c & (_ ^= S[c & E] * 19) + k.charCodeAt(E++);
return b(S);
}
function x() {
try {
var w;
return l && (w = l.randomBytes) ? w = w(o) : (w = new Uint8Array(o), (r.crypto || r.msCrypto).getRandomValues(w)), b(w);
} catch (_) {
var S = r.navigator,
k = S && S.plugins;
return [+ /* @__PURE__ */new Date(), r, k, r.screen, b(e)];
}
}
function b(w) {
return String.fromCharCode.apply(0, w);
}
if (g(t10.random(), e), typeof Fd == "object" && Fd.exports) {
Fd.exports = m;
try {
l = H2();
} catch (w) {}
} else typeof define == "function" && __webpack_require__.amdO ? define(function () {
return m;
}) : t10["seed" + a] = m;
})(typeof self != "undefined" ? self : K2, [], Math);
});
var Rw = qt((Jke, j2) => {
var VK = F2(),
WK = O2(),
UK = L2(),
GK = z2(),
HK = W2(),
KK = G2(),
Uu = q2();
Uu.alea = VK;
Uu.xor128 = WK;
Uu.xorwow = UK;
Uu.xorshift7 = GK;
Uu.xor4096 = HK;
Uu.tychei = KK;
j2.exports = Uu;
});
var Sv = qt(() => {});
var Iv = qt(() => {});
var ZL = qt(() => {});
var JL = qt(() => {});
var eB = qt(() => {});
var tB = qt((Bg, kv) => {
var vv = (() => {
var r = typeof document != "undefined" && document.currentScript ? document.currentScript.src : void 0;
return true && (r = r || __filename), function (e) {
e = e || {};
function t10() {
return oe.buffer != We && Tt(oe.buffer), mt;
}
function o() {
return oe.buffer != We && Tt(oe.buffer), it;
}
function n() {
return oe.buffer != We && Tt(oe.buffer), ht;
}
function s() {
return oe.buffer != We && Tt(oe.buffer), Or;
}
function a() {
return oe.buffer != We && Tt(oe.buffer), Mt;
}
function i() {
return oe.buffer != We && Tt(oe.buffer), Qr;
}
function p() {
return oe.buffer != We && Tt(oe.buffer), or;
}
var u = typeof e != "undefined" ? e : {},
c,
l;
u.ready = new Promise(function (A, V) {
c = A, l = V;
});
var m;
typeof process != "undefined" && process.listeners && (m = {
uncaughtException: process.listeners("uncaughtException"),
unhandledRejection: process.listeners("unhandledRejection")
});
var d = Object.assign({}, u),
f = [],
h = "./this.program",
g = (A, V) => {
throw V;
},
x = typeof window == "object",
b = typeof importScripts == "function",
w = typeof process == "object" && typeof process.versions == "object" && typeof process.versions.node == "string",
S = u.ENVIRONMENT_IS_PTHREAD || false,
k = "";
function _(A) {
return u.locateFile ? u.locateFile(A, k) : k + A;
}
var E, R, D, F;
function O(A) {
if (A instanceof Iu) return;
j("exiting due to exception: " + A);
}
if (w) {
var M = Sv(),
L = Iv();
b ? k = L.dirname(k) + "/" : k = __dirname + "/", E = (V, ue) => (V = Ap(V) ? new URL(V) : L.normalize(V), M.readFileSync(V, ue ? void 0 : "utf8")), D = V => {
var ue = E(V, true);
return ue.buffer || (ue = new Uint8Array(ue)), ue;
}, R = (V, ue, Ee) => {
V = Ap(V) ? new URL(V) : L.normalize(V), M.readFile(V, function (Be, Le) {
Be ? Ee(Be) : ue(Le.buffer);
});
}, process.argv.length > 1 && (h = process.argv[1].replace(/\\/g, "/")), f = process.argv.slice(2), process.on("uncaughtException", function (V) {
if (!(V instanceof Iu)) throw V;
}), process.on("unhandledRejection", function (V) {
throw V;
}), g = (V, ue) => {
if (Mo()) throw process.exitCode = V, ue;
O(ue), process.exit(V);
}, u.inspect = function () {
return "[Emscripten Module object]";
};
let A;
try {
A = ZL();
} catch (V) {
throw console.error('The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?'), V;
}
__webpack_require__.g.Worker = A.Worker;
} else (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 = "", w || (E = A => {
var V = new XMLHttpRequest();
return V.open("GET", A, false), V.send(null), V.responseText;
}, b && (D = A => {
var V = new XMLHttpRequest();
return V.open("GET", A, false), V.responseType = "arraybuffer", V.send(null), new Uint8Array(V.response);
}), R = (A, V, ue) => {
var Ee = new XMLHttpRequest();
Ee.open("GET", A, true), Ee.responseType = "arraybuffer", Ee.onload = () => {
if (Ee.status == 200 || Ee.status == 0 && Ee.response) {
V(Ee.response);
return;
}
ue();
}, Ee.onerror = ue, Ee.send(null);
}), F = A => document.title = A);
w && typeof performance == "undefined" && (__webpack_require__.g.performance = JL().performance);
var B = console.log.bind(console),
z = console.warn.bind(console);
w && (B = A => M.writeSync(1, A + `
`), z = A => M.writeSync(2, A + `
`));
var U = u.print || B,
j = u.printErr || z;
Object.assign(u, d), d = null, u.arguments && (f = u.arguments), u.thisProgram && (h = u.thisProgram), u.quit && (g = u.quit);
var H = 4,
X = Atomics.load,
J = Atomics.store,
re = Atomics.compareExchange,
ne;
u.wasmBinary && (ne = u.wasmBinary);
var ee = u.noExitRuntime || true;
typeof WebAssembly != "object" && Su("no native wasm support detected");
var oe,
ie,
le = false,
ye;
function _e(A, V) {
A || Su(V);
}
var ve = typeof TextDecoder != "undefined" ? new TextDecoder("utf8") : void 0;
function Fe(A, V, ue) {
V >>>= 0;
for (var Ee = V + ue, Be = V; A[Be] && !(Be >= Ee);) ++Be;
if (Be - V > 16 && A.buffer && ve) return ve.decode(A.buffer instanceof SharedArrayBuffer ? A.slice(V, Be) : A.subarray(V, Be));
for (var Le = ""; V < Be;) {
var he = A[V++];
if (!(he & 128)) {
Le += String.fromCharCode(he);
continue;
}
var Ne = A[V++] & 63;
if ((he & 224) == 192) {
Le += String.fromCharCode((he & 31) << 6 | Ne);
continue;
}
var Ft = A[V++] & 63;
if ((he & 240) == 224 ? he = (he & 15) << 12 | Ne << 6 | Ft : he = (he & 7) << 18 | Ne << 12 | Ft << 6 | A[V++] & 63, he < 65536) Le += String.fromCharCode(he);else {
var to = he - 65536;
Le += String.fromCharCode(55296 | to >> 10, 56320 | to & 1023);
}
}
return Le;
}
function Pe(A, V) {
return A >>>= 0, A ? Fe(o(), A, V) : "";
}
function st(A, V, ue, Ee) {
if (ue >>>= 0, !(Ee > 0)) return 0;
for (var Be = ue, Le = ue + Ee - 1, he = 0; he < A.length; ++he) {
var Ne = A.charCodeAt(he);
if (Ne >= 55296 && Ne <= 57343) {
var Ft = A.charCodeAt(++he);
Ne = 65536 + ((Ne & 1023) << 10) | Ft & 1023;
}
if (Ne <= 127) {
if (ue >= Le) break;
V[ue++ >>> 0] = Ne;
} else if (Ne <= 2047) {
if (ue + 1 >= Le) break;
V[ue++ >>> 0] = 192 | Ne >> 6, V[ue++ >>> 0] = 128 | Ne & 63;
} else if (Ne <= 65535) {
if (ue + 2 >= Le) break;
V[ue++ >>> 0] = 224 | Ne >> 12, V[ue++ >>> 0] = 128 | Ne >> 6 & 63, V[ue++ >>> 0] = 128 | Ne & 63;
} else {
if (ue + 3 >= Le) break;
V[ue++ >>> 0] = 240 | Ne >> 18, V[ue++ >>> 0] = 128 | Ne >> 12 & 63, V[ue++ >>> 0] = 128 | Ne >> 6 & 63, V[ue++ >>> 0] = 128 | Ne & 63;
}
}
return V[ue >>> 0] = 0, ue - Be;
}
function lt(A, V, ue) {
return st(A, o(), V, ue);
}
var We, mt, it, ht, gt, Or, Mt, Qr, or;
S && (We = u.buffer);
function Tt(A) {
We = A, u.HEAP8 = mt = new Int8Array(A), u.HEAP16 = ht = new Int16Array(A), u.HEAP32 = Or = new Int32Array(A), u.HEAPU8 = it = new Uint8Array(A), u.HEAPU16 = gt = new Uint16Array(A), u.HEAPU32 = Mt = new Uint32Array(A), u.HEAPF32 = Qr = new Float32Array(A), u.HEAPF64 = or = new Float64Array(A);
}
var nr = u.INITIAL_MEMORY || 16777216;
if (S) oe = u.wasmMemory, We = u.buffer;else if (u.wasmMemory) oe = u.wasmMemory;else if (oe = new WebAssembly.Memory({
initial: nr / 65536,
maximum: 65536,
shared: true
}), !(oe.buffer instanceof SharedArrayBuffer)) throw j("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"), w && j("(on node you may need: --experimental-wasm-threads --experimental-wasm-bulk-memory and/or recent version)"), Error("bad memory");
oe && (We = oe.buffer), nr = We.byteLength, Tt(We);
var sr,
Zr = [],
Jr = [],
fr = [],
Fa = false;
function Mo() {
return ee;
}
function Vs() {
if (u.preRun) for (typeof u.preRun == "function" && (u.preRun = [u.preRun]); u.preRun.length;) el(u.preRun.shift());
ol(Zr);
}
function Xt() {
Fa = true, !S && ol(Jr);
}
function Pa() {
if (!S) {
if (u.postRun) for (typeof u.postRun == "function" && (u.postRun = [u.postRun]); u.postRun.length;) jv(u.postRun.shift());
ol(fr);
}
}
function el(A) {
Zr.unshift(A);
}
function tl(A) {
Jr.unshift(A);
}
function jv(A) {
fr.unshift(A);
}
var wi = 0,
Dp = null,
Oa = null;
function ly(A) {
wi++, u.monitorRunDependencies && u.monitorRunDependencies(wi);
}
function xm(A) {
if (wi--, u.monitorRunDependencies && u.monitorRunDependencies(wi), wi == 0 && (Dp !== null && (clearInterval(Dp), Dp = null), Oa)) {
var V = Oa;
Oa = null, V();
}
}
function Su(A) {
u.onAbort && u.onAbort(A), A = "Aborted(" + A + ")", j(A), le = true, ye = 1, A += ". Build with -sASSERTIONS for more info.";
var V = new WebAssembly.RuntimeError(A);
throw l(V), V;
}
var my = "data:application/octet-stream;base64,";
function ym(A) {
return A.startsWith(my);
}
function Ap(A) {
return A.startsWith("file://");
}
var hr;
hr = "tfjs-backend-wasm-threaded-simd.wasm", ym(hr) || (hr = _(hr));
function bm(A) {
try {
if (A == hr && ne) return new Uint8Array(ne);
if (D) return D(A);
throw "both async and sync fetching of the wasm failed";
} catch (V) {
Su(V);
}
}
function dy() {
if (!ne && (x || b)) {
if (typeof fetch == "function" && !Ap(hr)) return fetch(hr, {
credentials: "same-origin"
}).then(function (A) {
if (!A.ok) throw "failed to load wasm binary file at '" + hr + "'";
return A.arrayBuffer();
}).catch(function () {
return bm(hr);
});
if (R) return new Promise(function (A, V) {
R(hr, function (ue) {
A(new Uint8Array(ue));
}, V);
});
}
return Promise.resolve().then(function () {
return bm(hr);
});
}
function fy() {
var A = {
env: Dm,
wasi_snapshot_preview1: Dm
};
function V(he, Ne) {
var Ft = he.exports;
if (u.asm = Ft, Iy(u.asm._emscripten_tls_init), sr = u.asm.__indirect_function_table, tl(u.asm.__wasm_call_ctors), ie = Ne, !S) {
var to = Me.unusedWorkers.length;
Me.unusedWorkers.forEach(function (La) {
Me.loadWasmModuleToWorker(La, function () {
--to || xm("wasm-instantiate");
});
});
}
}
S || ly("wasm-instantiate");
function ue(he) {
V(he.instance, he.module);
}
function Ee(he) {
return dy().then(function (Ne) {
return WebAssembly.instantiate(Ne, A);
}).then(function (Ne) {
return Ne;
}).then(he, function (Ne) {
j("failed to asynchronously prepare wasm: " + Ne), Su(Ne);
});
}
function Be() {
return !ne && typeof WebAssembly.instantiateStreaming == "function" && !ym(hr) && !Ap(hr) && !w && typeof fetch == "function" ? fetch(hr, {
credentials: "same-origin"
}).then(function (he) {
var Ne = WebAssembly.instantiateStreaming(he, A);
return Ne.then(ue, function (Ft) {
return j("wasm streaming compile failed: " + Ft), j("falling back to ArrayBuffer instantiation"), Ee(ue);
});
}) : Ee(ue);
}
if (u.instantiateWasm) try {
var Le = u.instantiateWasm(A, V);
return Le;
} catch (he) {
j("Module.instantiateWasm callback failed with error: " + he), l(he);
}
return Be().catch(l), {};
}
var Xv,
Yv,
Cm = {};
function Iu(A) {
this.name = "ExitStatus", this.message = "Program terminated with exit(" + A + ")", this.status = A;
}
function hy(A) {
var V = Me.pthreads[A];
delete Me.pthreads[A], V.terminate(), DC(A), Me.runningWorkers.splice(Me.runningWorkers.indexOf(V), 1), V.pthread_ptr = 0;
}
function gy(A) {
var V = Me.pthreads[A];
V.postMessage({
cmd: "cancel"
});
}
function rl(A) {
var V = Me.pthreads[A];
_e(V), Me.returnWorkerToPool(V);
}
function xy(A) {
var V = Me.getNewWorker();
if (!V) return 6;
Me.runningWorkers.push(V), Me.pthreads[A.pthread_ptr] = V, V.pthread_ptr = A.pthread_ptr;
var ue = {
cmd: "run",
start_routine: A.startRoutine,
arg: A.arg,
pthread_ptr: A.pthread_ptr
};
return V.runPthread = () => {
w && V.ref(), V.postMessage(ue, A.transferList), delete V.runPthread;
}, V.loaded && V.runPthread(), 0;
}
var wm = {
varargs: void 0,
get: function () {
wm.varargs += 4;
var A = s()[wm.varargs - 4 >>> 2];
return A;
},
getStr: function (A) {
var V = Pe(A);
return V;
}
};
function Sm(A) {
if (S) return Si(1, 1, A);
ye = A, Mo() || (Me.terminateAllThreads(), u.onExit && u.onExit(A), le = true), g(A, new Iu(A));
}
function yy(A, V) {
if (ye = A, !V && S) throw vm(A), "unwind";
Sm(A);
}
var Im = yy;
function by(A) {
if (A instanceof Iu || A == "unwind") return ye;
g(1, A);
}
var Me = {
unusedWorkers: [],
runningWorkers: [],
tlsInitFunctions: [],
pthreads: {},
init: function () {
S ? Me.initWorker() : Me.initMainThread();
},
initMainThread: function () {
for (var A = 8; A--;) Me.allocateUnusedWorker();
},
initWorker: function () {
ee = false;
},
setExitStatus: function (A) {
ye = A;
},
terminateAllThreads: function () {
for (var A of Object.values(Me.pthreads)) Me.returnWorkerToPool(A);
for (var A of Me.unusedWorkers) A.terminate();
Me.unusedWorkers = [];
},
returnWorkerToPool: function (A) {
var V = A.pthread_ptr;
delete Me.pthreads[V], Me.unusedWorkers.push(A), Me.runningWorkers.splice(Me.runningWorkers.indexOf(A), 1), A.pthread_ptr = 0, w && A.unref(), DC(V);
},
receiveObjectTransfer: function (A) {},
threadInitTLS: function () {
Me.tlsInitFunctions.forEach(A => A());
},
loadWasmModuleToWorker: function (A, V) {
A.onmessage = Le => {
var he = Le.data,
Ne = he.cmd;
if (A.pthread_ptr && (Me.currentProxiedOperationCallerThread = A.pthread_ptr), he.targetThread && he.targetThread != Lm()) {
var Ft = Me.pthreads[he.targetThread];
Ft ? Ft.postMessage(he, he.transferList) : j('Internal error! Worker sent a message "' + Ne + '" to target pthread ' + he.targetThread + ", but that thread no longer exists!"), Me.currentProxiedOperationCallerThread = void 0;
return;
}
Ne === "processProxyingQueue" ? nl(he.queue) : Ne === "spawnThread" ? xy(he) : Ne === "cleanupThread" ? rl(he.thread) : Ne === "killThread" ? hy(he.thread) : Ne === "cancelThread" ? gy(he.thread) : Ne === "loaded" ? (A.loaded = true, w && A.unref(), V && V(A), A.runPthread && A.runPthread()) : Ne === "print" ? U("Thread " + he.threadId + ": " + he.text) : Ne === "printErr" ? j("Thread " + he.threadId + ": " + he.text) : Ne === "alert" ? alert("Thread " + he.threadId + ": " + he.text) : he.target === "setimmediate" ? A.postMessage(he) : Ne === "callHandler" ? u[he.handler](...he.args) : Ne && j("worker sent an unknown command " + Ne), Me.currentProxiedOperationCallerThread = void 0;
}, A.onerror = Le => {
var he = "worker sent an error!";
throw j(he + " " + Le.filename + ":" + Le.lineno + ": " + Le.message), Le;
}, w && (A.on("message", function (Le) {
A.onmessage({
data: Le
});
}), A.on("error", function (Le) {
A.onerror(Le);
}), A.on("detachedExit", function () {}));
var ue = [],
Ee = ["onExit", "onAbort", "print", "printErr"];
for (var Be of Ee) u.hasOwnProperty(Be) && ue.push(Be);
A.postMessage({
cmd: "load",
handlers: ue,
urlOrBlob: u.mainScriptUrlOrBlob || r,
wasmMemory: oe,
wasmModule: ie
});
},
allocateUnusedWorker: function () {
var A,
V = _("tfjs-backend-wasm-threaded-simd.worker.js");
A = new Worker(V), Me.unusedWorkers.push(A);
},
getNewWorker: function () {
return Me.unusedWorkers.length == 0 && (Me.allocateUnusedWorker(), Me.loadWasmModuleToWorker(Me.unusedWorkers[0])), Me.unusedWorkers.pop();
}
};
u.PThread = Me;
function ol(A) {
for (; A.length > 0;) A.shift()(u);
}
function Cy() {
var A = Lm(),
V = s()[A + 52 >>> 2],
ue = s()[A + 56 >>> 2],
Ee = V - ue;
r0(V, Ee), Bm(V);
}
u.establishStackSpace = Cy;
function vm(A) {
if (S) return Si(2, 0, A);
try {
Im(A);
} catch (V) {
by(V);
}
}
var Fp = [];
function wy(A) {
var V = Fp[A];
return V || (A >= Fp.length && (Fp.length = A + 1), Fp[A] = V = sr.get(A)), V;
}
function Sy(A, V) {
var ue = wy(A)(V);
Mo() ? Me.setExitStatus(ue) : t0(ue);
}
u.invokeEntryPoint = Sy;
function Iy(A) {
Me.tlsInitFunctions.push(A);
}
function vy(A) {
Zv(A, !b, 1, !x), Me.threadInitTLS();
}
function ky(A) {
S ? postMessage({
cmd: "cleanupThread",
thread: A
}) : rl(A);
}
function km(A, V, ue, Ee) {
return S ? Si(3, 1, A, V, ue, Ee) : Nm(A, V, ue, Ee);
}
function Nm(A, V, ue, Ee) {
if (typeof SharedArrayBuffer == "undefined") return j("Current environment does not support SharedArrayBuffer, pthreads are not available!"), 6;
var Be = [],
Le = 0;
if (S && (Be.length === 0 || Le)) return km(A, V, ue, Ee);
if (Le) return Le;
var he = {
startRoutine: ue,
pthread_ptr: A,
arg: Ee,
transferList: Be
};
return S ? (he.cmd = "spawnThread", postMessage(he, Be), 0) : xy(he);
}
function Ny() {
return 65536;
}
var Ty = true;
function _y() {
return Ty;
}
function nl(A) {
Atomics.store(s(), A >> 2, 1), Lm() && e0(A), Atomics.compareExchange(s(), A >> 2, 1, 0);
}
u.executeNotifiedProxyingQueue = nl;
function $y(A, V, ue, Ee) {
if (A == V) setTimeout(() => nl(Ee));else if (S) postMessage({
targetThread: A,
cmd: "processProxyingQueue",
queue: Ee
});else {
var Be = Me.pthreads[A];
if (!Be) return;
Be.postMessage({
cmd: "processProxyingQueue",
queue: Ee
});
}
return 1;
}
function Ey(A, V, ue) {
return -1;
}
function Ry() {
Su("");
}
function vu(A) {
vu.shown || (vu.shown = {}), vu.shown[A] || (vu.shown[A] = 1, w && (A = "warning: " + A), j(A));
}
function Dy() {
w || b || vu("Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread");
}
function Ay() {
return Date.now();
}
function Tm() {
return 4294901760;
}
function Fy() {
return Tm();
}
var sl;
w ? sl = () => {
var A = process.hrtime();
return A[0] * 1e3 + A[1] / 1e6;
} : sl = () => performance.timeOrigin + performance.now();
function Py(A, V, ue) {
o().copyWithin(A >>> 0, V >>> 0, V + ue >>> 0);
}
function Oy() {
return w ? eB().cpus().length : navigator.hardwareConcurrency;
}
function My(A) {
var V = AC(),
ue = A();
return Bm(V), ue;
}
function Si(A, V) {
var ue = arguments.length - 2,
Ee = arguments;
return My(() => {
for (var Be = ue, Le = zm(Be * 8), he = Le >> 3, Ne = 0; Ne < ue; Ne++) {
var Ft = Ee[2 + Ne];
p()[he + Ne >>> 0] = Ft;
}
return Jv(A, Be, Le, V);
});
}
var al = [];
function Ly(A, V, ue) {
al.length = V;
for (var Ee = ue >> 3, Be = 0; Be < V; Be++) al[Be] = p()[Ee + Be >>> 0];
var Le = A < 0,
he = Le ? Cm[-A - 1] : qy[A];
return he.apply(null, al);
}
function By(A) {
try {
return oe.grow(A - We.byteLength + 65535 >>> 16), Tt(oe.buffer), 1;
} catch (V) {}
}
function zy(A) {
var V = o().length;
if (A = A >>> 0, A <= V) return false;
var ue = Tm();
if (A > ue) return false;
let Ee = (Ft, to) => Ft + (to - Ft % to) % to;
for (var Be = 1; Be <= 4; Be *= 2) {
var Le = V * (1 + 0.2 / Be);
Le = Math.min(Le, A + 100663296);
var he = Math.min(ue, Ee(Math.max(A, Le), 65536)),
Ne = By(he);
if (Ne) return true;
}
return false;
}
function Vy() {
throw "unwind";
}
function _m(A) {
return S ? Si(4, 1, A) : 52;
}
function $m(A, V, ue, Ee, Be) {
return S ? Si(5, 1, A, V, ue, Ee, Be) : 70;
}
var Wy = [null, [], []];
function Uy(A, V) {
var ue = Wy[A];
V === 0 || V === 10 ? ((A === 1 ? U : j)(Fe(ue, 0)), ue.length = 0) : ue.push(V);
}
function Em(A, V, ue, Ee) {
if (S) return Si(6, 1, A, V, ue, Ee);
for (var Be = 0, Le = 0; Le < ue; Le++) {
var he = a()[V >>> 2],
Ne = a()[V + 4 >>> 2];
V += 8;
for (var Ft = 0; Ft < Ne; Ft++) Uy(A, o()[he + Ft >>> 0]);
Be += Ne;
}
return a()[Ee >>> 2] = Be, 0;
}
function Rm(A) {
var V = u["_" + A];
return V;
}
function Gy(A, V) {
t10().set(A, V >>> 0);
}
function Hy(A, V, ue, Ee, Be) {
var Le = {
string: Mr => {
var Lp = 0;
if (Mr != null && Mr !== 0) {
var s0 = (Mr.length << 2) + 1;
Lp = zm(s0), lt(Mr, Lp, s0);
}
return Lp;
},
array: Mr => {
var Lp = zm(Mr.length);
return Gy(Mr, Lp), Lp;
}
};
function he(Mr) {
return V === "string" ? Pe(Mr) : V === "boolean" ? !!Mr : Mr;
}
var Ne = Rm(A),
Ft = [],
to = 0;
if (Ee) for (var La = 0; La < Ee.length; La++) {
var n0 = Le[ue[La]];
n0 ? (to === 0 && (to = AC()), Ft[La] = n0(Ee[La])) : Ft[La] = Ee[La];
}
var FC = Ne.apply(null, Ft);
function LU(Mr) {
return to !== 0 && Bm(to), he(Mr);
}
return FC = LU(FC), FC;
}
function Ky(A, V, ue, Ee) {
ue = ue || [];
var Be = ue.every(he => he === "number" || he === "boolean"),
Le = V !== "string";
return Le && Be && !Ee ? Rm(A) : function () {
return Hy(A, V, ue, arguments, Ee);
};
}
Me.init();
var qy = [null, Sm, vm, km, _m, $m, Em],
Dm = {
__emscripten_init_main_thread_js: vy,
__emscripten_thread_cleanup: ky,
__pthread_create_js: Nm,
_emscripten_default_pthread_stack_size: Ny,
_emscripten_get_now_is_monotonic: _y,
_emscripten_notify_task_queue: $y,
_emscripten_set_offscreencanvas_size: Ey,
abort: Ry,
emscripten_check_blocking_allowed: Dy,
emscripten_date_now: Ay,
emscripten_get_heap_max: Fy,
emscripten_get_now: sl,
emscripten_memcpy_big: Py,
emscripten_num_logical_cores: Oy,
emscripten_receive_on_main_thread_js: Ly,
emscripten_resize_heap: zy,
emscripten_unwind_to_js_event_loop: Vy,
exit: Im,
fd_close: _m,
fd_seek: $m,
fd_write: Em,
memory: oe || u.wasmMemory
},
Qv = fy(),
jy = u.___wasm_call_ctors = function () {
return (jy = u.___wasm_call_ctors = u.asm.__wasm_call_ctors).apply(null, arguments);
},
Xy = u._init = function () {
return (Xy = u._init = u.asm.init).apply(null, arguments);
},
Yy = u._init_with_threads_count = function () {
return (Yy = u._init_with_threads_count = u.asm.init_with_threads_count).apply(null, arguments);
},
Qy = u._get_threads_count = function () {
return (Qy = u._get_threads_count = u.asm.get_threads_count).apply(null, arguments);
},
Zy = u._register_tensor = function () {
return (Zy = u._register_tensor = u.asm.register_tensor).apply(null, arguments);
},
Jy = u._dispose_data = function () {
return (Jy = u._dispose_data = u.asm.dispose_data).apply(null, arguments);
},
eb = u._dispose = function () {
return (eb = u._dispose = u.asm.dispose).apply(null, arguments);
},
tb = u._Abs = function () {
return (tb = u._Abs = u.asm.Abs).apply(null, arguments);
},
rb = u._Acos = function () {
return (rb = u._Acos = u.asm.Acos).apply(null, arguments);
},
ob = u._Acosh = function () {
return (ob = u._Acosh = u.asm.Acosh).apply(null, arguments);
},
nb = u._Add = function () {
return (nb = u._Add = u.asm.Add).apply(null, arguments);
},
sb = u._AddN = function () {
return (sb = u._AddN = u.asm.AddN).apply(null, arguments);
},
ab = u._All = function () {
return (ab = u._All = u.asm.All).apply(null, arguments);
},
ib = u._Any = function () {
return (ib = u._Any = u.asm.Any).apply(null, arguments);
},
ub = u._ArgMax = function () {
return (ub = u._ArgMax = u.asm.ArgMax).apply(null, arguments);
},
pb = u._ArgMin = function () {
return (pb = u._ArgMin = u.asm.ArgMin).apply(null, arguments);
},
cb = u._Asin = function () {
return (cb = u._Asin = u.asm.Asin).apply(null, arguments);
},
lb = u._Asinh = function () {
return (lb = u._Asinh = u.asm.Asinh).apply(null, arguments);
},
mb = u._Atan = function () {
return (mb = u._Atan = u.asm.Atan).apply(null, arguments);
},
db = u._Atan2 = function () {
return (db = u._Atan2 = u.asm.Atan2).apply(null, arguments);
},
fb = u._Atanh = function () {
return (fb = u._Atanh = u.asm.Atanh).apply(null, arguments);
},
hb = u._AvgPool = function () {
return (hb = u._AvgPool = u.asm.AvgPool).apply(null, arguments);
},
gb = u._AvgPool3D = function () {
return (gb = u._AvgPool3D = u.asm.AvgPool3D).apply(null, arguments);
},
xb = u._AvgPool3DGrad = function () {
return (xb = u._AvgPool3DGrad = u.asm.AvgPool3DGrad).apply(null, arguments);
},
yb = u._BatchMatMul = function () {
return (yb = u._BatchMatMul = u.asm.BatchMatMul).apply(null, arguments);
},
bb = u._Bincount = function () {
return (bb = u._Bincount = u.asm.Bincount).apply(null, arguments);
},
Cb = u._Ceil = function () {
return (Cb = u._Ceil = u.asm.Ceil).apply(null, arguments);
},
wb = u._ClipByValue = function () {
return (wb = u._ClipByValue = u.asm.ClipByValue).apply(null, arguments);
},
Sb = u._Conv2D = function () {
return (Sb = u._Conv2D = u.asm.Conv2D).apply(null, arguments);
},
Ib = u._Conv2DBackpropInput = function () {
return (Ib = u._Conv2DBackpropInput = u.asm.Conv2DBackpropInput).apply(null, arguments);
},
vb = u._Conv3D = function () {
return (vb = u._Conv3D = u.asm.Conv3D).apply(null, arguments);
},
kb = u._Conv3DBackpropFilterV2 = function () {
return (kb = u._Conv3DBackpropFilterV2 = u.asm.Conv3DBackpropFilterV2).apply(null, arguments);
},
Nb = u._Conv3DBackpropInputV2 = function () {
return (Nb = u._Conv3DBackpropInputV2 = u.asm.Conv3DBackpropInputV2).apply(null, arguments);
},
Tb = u._Cos = function () {
return (Tb = u._Cos = u.asm.Cos).apply(null, arguments);
},
_b = u._Cosh = function () {
return (_b = u._Cosh = u.asm.Cosh).apply(null, arguments);
},
$b = u._CropAndResize = function () {
return ($b = u._CropAndResize = u.asm.CropAndResize).apply(null, arguments);
},
Eb = u._Cumprod = function () {
return (Eb = u._Cumprod = u.asm.Cumprod).apply(null, arguments);
},
Rb = u._Cumsum = function () {
return (Rb = u._Cumsum = u.asm.Cumsum).apply(null, arguments);
},
Db = u._DenseBincount = function () {
return (Db = u._DenseBincount = u.asm.DenseBincount).apply(null, arguments);
},
Ab = u._DepthToSpace = function () {
return (Ab = u._DepthToSpace = u.asm.DepthToSpace).apply(null, arguments);
},
Fb = u._DepthwiseConv2dNative = function () {
return (Fb = u._DepthwiseConv2dNative = u.asm.DepthwiseConv2dNative).apply(null, arguments);
},
Pb = u._Diag = function () {
return (Pb = u._Diag = u.asm.Diag).apply(null, arguments);
},
Ob = u._Dilation2D = function () {
return (Ob = u._Dilation2D = u.asm.Dilation2D).apply(null, arguments);
},
Mb = u._Dilation2DBackpropFilter = function () {
return (Mb = u._Dilation2DBackpropFilter = u.asm.Dilation2DBackpropFilter).apply(null, arguments);
},
Lb = u._Dilation2DBackpropInput = function () {
return (Lb = u._Dilation2DBackpropInput = u.asm.Dilation2DBackpropInput).apply(null, arguments);
},
Bb = u._Elu = function () {
return (Bb = u._Elu = u.asm.Elu).apply(null, arguments);
},
zb = u._EluGrad = function () {
return (zb = u._EluGrad = u.asm.EluGrad).apply(null, arguments);
},
Vb = u._Equal = function () {
return (Vb = u._Equal = u.asm.Equal).apply(null, arguments);
},
Wb = u._Exp = function () {
return (Wb = u._Exp = u.asm.Exp).apply(null, arguments);
},
Ub = u._Expm1 = function () {
return (Ub = u._Expm1 = u.asm.Expm1).apply(null, arguments);
},
Gb = u._FlipLeftRight = function () {
return (Gb = u._FlipLeftRight = u.asm.FlipLeftRight).apply(null, arguments);
},
Hb = u._Floor = function () {
return (Hb = u._Floor = u.asm.Floor).apply(null, arguments);
},
Kb = u._FloorDiv = function () {
return (Kb = u._FloorDiv = u.asm.FloorDiv).apply(null, arguments);
},
qb = u._FusedBatchNorm = function () {
return (qb = u._FusedBatchNorm = u.asm.FusedBatchNorm).apply(null, arguments);
},
jb = u._FusedConv2D = function () {
return (jb = u._FusedConv2D = u.asm.FusedConv2D).apply(null, arguments);
},
Xb = u._FusedDepthwiseConv2D = function () {
return (Xb = u._FusedDepthwiseConv2D = u.asm.FusedDepthwiseConv2D).apply(null, arguments);
},
Yb = u._Gather = function () {
return (Yb = u._Gather = u.asm.Gather).apply(null, arguments);
},
Qb = u._GatherNd = function () {
return (Qb = u._GatherNd = u.asm.GatherNd).apply(null, arguments);
},
Zb = u._Greater = function () {
return (Zb = u._Greater = u.asm.Greater).apply(null, arguments);
},
Jb = u._GreaterEqual = function () {
return (Jb = u._GreaterEqual = u.asm.GreaterEqual).apply(null, arguments);
},
eC = u._IsFinite = function () {
return (eC = u._IsFinite = u.asm.IsFinite).apply(null, arguments);
},
tC = u._IsInf = function () {
return (tC = u._IsInf = u.asm.IsInf).apply(null, arguments);
},
rC = u._IsNan = function () {
return (rC = u._IsNan = u.asm.IsNan).apply(null, arguments);
},
oC = u._LRN = function () {
return (oC = u._LRN = u.asm.LRN).apply(null, arguments);
},
nC = u._LRNGrad = function () {
return (nC = u._LRNGrad = u.asm.LRNGrad).apply(null, arguments);
},
sC = u._LeakyRelu = function () {
return (sC = u._LeakyRelu = u.asm.LeakyRelu).apply(null, arguments);
},
aC = u._Less = function () {
return (aC = u._Less = u.asm.Less).apply(null, arguments);
},
iC = u._LessEqual = function () {
return (iC = u._LessEqual = u.asm.LessEqual).apply(null, arguments);
},
uC = u._LinSpace = function () {
return (uC = u._LinSpace = u.asm.LinSpace).apply(null, arguments);
},
pC = u._Log = function () {
return (pC = u._Log = u.asm.Log).apply(null, arguments);
},
cC = u._Log1p = function () {
return (cC = u._Log1p = u.asm.Log1p).apply(null, arguments);
},
lC = u._LogicalAnd = function () {
return (lC = u._LogicalAnd = u.asm.LogicalAnd).apply(null, arguments);
},
mC = u._LogicalNot = function () {
return (mC = u._LogicalNot = u.asm.LogicalNot).apply(null, arguments);
},
dC = u._LogicalOr = function () {
return (dC = u._LogicalOr = u.asm.LogicalOr).apply(null, arguments);
},
fC = u._LogicalXor = function () {
return (fC = u._LogicalXor = u.asm.LogicalXor).apply(null, arguments);
},
hC = u._Max = function () {
return (hC = u._Max = u.asm.Max).apply(null, arguments);
},
gC = u._MaxPool = function () {
return (gC = u._MaxPool = u.asm.MaxPool).apply(null, arguments);
},
xC = u._MaxPool3D = function () {
return (xC = u._MaxPool3D = u.asm.MaxPool3D).apply(null, arguments);
},
yC = u._MaxPool3DGrad = function () {
return (yC = u._MaxPool3DGrad = u.asm.MaxPool3DGrad).apply(null, arguments);
},
bC = u._Maximum = function () {
return (bC = u._Maximum = u.asm.Maximum).apply(null, arguments);
},
CC = u._Mean = function () {
return (CC = u._Mean = u.asm.Mean).apply(null, arguments);
},
wC = u._Min = function () {
return (wC = u._Min = u.asm.Min).apply(null, arguments);
},
SC = u._Minimum = function () {
return (SC = u._Minimum = u.asm.Minimum).apply(null, arguments);
},
IC = u._MirrorPad = function () {
return (IC = u._MirrorPad = u.asm.MirrorPad).apply(null, arguments);
},
vC = u._Multinomial = function () {
return (vC = u._Multinomial = u.asm.Multinomial).apply(null, arguments);
},
kC = u._Multiply = function () {
return (kC = u._Multiply = u.asm.Multiply).apply(null, arguments);
},
NC = u._Neg = function () {
return (NC = u._Neg = u.asm.Neg).apply(null, arguments);
},
TC = u._NonMaxSuppressionV3 = function () {
return (TC = u._NonMaxSuppressionV3 = u.asm.NonMaxSuppressionV3).apply(null, arguments);
},
Am = u._NonMaxSuppressionV4 = function () {
return (Am = u._NonMaxSuppressionV4 = u.asm.NonMaxSuppressionV4).apply(null, arguments);
},
Fm = u._NonMaxSuppressionV5 = function () {
return (Fm = u._NonMaxSuppressionV5 = u.asm.NonMaxSuppressionV5).apply(null, arguments);
},
il = u._NotEqual = function () {
return (il = u._NotEqual = u.asm.NotEqual).apply(null, arguments);
},
_C = u._OneHot = function () {
return (_C = u._OneHot = u.asm.OneHot).apply(null, arguments);
},
$C = u._PadV2 = function () {
return ($C = u._PadV2 = u.asm.PadV2).apply(null, arguments);
},
Pp = u._Pow = function () {
return (Pp = u._Pow = u.asm.Pow).apply(null, arguments);
},
Pm = u._Prelu = function () {
return (Pm = u._Prelu = u.asm.Prelu).apply(null, arguments);
},
Op = u._Prod = function () {
return (Op = u._Prod = u.asm.Prod).apply(null, arguments);
},
Mp = u._RealDiv = function () {
return (Mp = u._RealDiv = u.asm.RealDiv).apply(null, arguments);
},
EC = u._Reciprocal = function () {
return (EC = u._Reciprocal = u.asm.Reciprocal).apply(null, arguments);
},
G = u._Relu = function () {
return (G = u._Relu = u.asm.Relu).apply(null, arguments);
},
ae = u._Relu6 = function () {
return (ae = u._Relu6 = u.asm.Relu6).apply(null, arguments);
},
$e = u._ResizeBilinear = function () {
return ($e = u._ResizeBilinear = u.asm.ResizeBilinear).apply(null, arguments);
},
at = u._ResizeBilinearGrad = function () {
return (at = u._ResizeBilinearGrad = u.asm.ResizeBilinearGrad).apply(null, arguments);
},
_t = u._ResizeNearestNeighbor = function () {
return (_t = u._ResizeNearestNeighbor = u.asm.ResizeNearestNeighbor).apply(null, arguments);
},
$t = u._ResizeNearestNeighborGrad = function () {
return ($t = u._ResizeNearestNeighborGrad = u.asm.ResizeNearestNeighborGrad).apply(null, arguments);
},
Xe = u._Reverse = function () {
return (Xe = u._Reverse = u.asm.Reverse).apply(null, arguments);
},
Ge = u._RotateWithOffset = function () {
return (Ge = u._RotateWithOffset = u.asm.RotateWithOffset).apply(null, arguments);
},
Gt = u._Round = function () {
return (Gt = u._Round = u.asm.Round).apply(null, arguments);
},
eo = u._Rsqrt = function () {
return (eo = u._Rsqrt = u.asm.Rsqrt).apply(null, arguments);
},
Ma = u._ScatterNd = function () {
return (Ma = u._ScatterNd = u.asm.ScatterNd).apply(null, arguments);
},
Om = u._SearchSorted = function () {
return (Om = u._SearchSorted = u.asm.SearchSorted).apply(null, arguments);
},
ul = u._SelectV2 = function () {
return (ul = u._SelectV2 = u.asm.SelectV2).apply(null, arguments);
},
RC = u._Selu = function () {
return (RC = u._Selu = u.asm.Selu).apply(null, arguments);
},
yr = u._Sigmoid = function () {
return (yr = u._Sigmoid = u.asm.Sigmoid).apply(null, arguments);
},
Ii = u._Sign = function () {
return (Ii = u._Sign = u.asm.Sign).apply(null, arguments);
},
Mm = u._Sin = function () {
return (Mm = u._Sin = u.asm.Sin).apply(null, arguments);
},
aU = u._Softmax = function () {
return (aU = u._Softmax = u.asm.Softmax).apply(null, arguments);
},
iU = u._Softplus = function () {
return (iU = u._Softplus = u.asm.Softplus).apply(null, arguments);
},
uU = u._SparseFillEmptyRows = function () {
return (uU = u._SparseFillEmptyRows = u.asm.SparseFillEmptyRows).apply(null, arguments);
},
pU = u._SparseReshape = function () {
return (pU = u._SparseReshape = u.asm.SparseReshape).apply(null, arguments);
},
cU = u._SparseSegmentReduction = function () {
return (cU = u._SparseSegmentReduction = u.asm.SparseSegmentReduction).apply(null, arguments);
},
lU = u._SparseToDense = function () {
return (lU = u._SparseToDense = u.asm.SparseToDense).apply(null, arguments);
},
mU = u._Sqrt = function () {
return (mU = u._Sqrt = u.asm.Sqrt).apply(null, arguments);
},
dU = u._Square = function () {
return (dU = u._Square = u.asm.Square).apply(null, arguments);
},
fU = u._SquaredDifference = function () {
return (fU = u._SquaredDifference = u.asm.SquaredDifference).apply(null, arguments);
},
hU = u._Step = function () {
return (hU = u._Step = u.asm.Step).apply(null, arguments);
},
gU = u._StridedSlice = function () {
return (gU = u._StridedSlice = u.asm.StridedSlice).apply(null, arguments);
},
xU = u._Sub = function () {
return (xU = u._Sub = u.asm.Sub).apply(null, arguments);
},
yU = u._Sum = function () {
return (yU = u._Sum = u.asm.Sum).apply(null, arguments);
},
bU = u._Tan = function () {
return (bU = u._Tan = u.asm.Tan).apply(null, arguments);
},
CU = u._Tanh = function () {
return (CU = u._Tanh = u.asm.Tanh).apply(null, arguments);
},
wU = u._TensorScatterUpdate = function () {
return (wU = u._TensorScatterUpdate = u.asm.TensorScatterUpdate).apply(null, arguments);
},
SU = u._Tile = function () {
return (SU = u._Tile = u.asm.Tile).apply(null, arguments);
},
IU = u._TopK = function () {
return (IU = u._TopK = u.asm.TopK).apply(null, arguments);
},
vU = u._Transform = function () {
return (vU = u._Transform = u.asm.Transform).apply(null, arguments);
},
kU = u._Transpose = function () {
return (kU = u._Transpose = u.asm.Transpose).apply(null, arguments);
},
NU = u.__FusedMatMul = function () {
return (NU = u.__FusedMatMul = u.asm._FusedMatMul).apply(null, arguments);
},
TU = u._malloc = function () {
return (TU = u._malloc = u.asm.malloc).apply(null, arguments);
},
_U = u._free = function () {
return (_U = u._free = u.asm.free).apply(null, arguments);
},
$U = u.__emscripten_tls_init = function () {
return ($U = u.__emscripten_tls_init = u.asm._emscripten_tls_init).apply(null, arguments);
},
Lm = u._pthread_self = function () {
return (Lm = u._pthread_self = u.asm.pthread_self).apply(null, arguments);
},
EU = u.___errno_location = function () {
return (EU = u.___errno_location = u.asm.__errno_location).apply(null, arguments);
},
Zv = u.__emscripten_thread_init = function () {
return (Zv = u.__emscripten_thread_init = u.asm._emscripten_thread_init).apply(null, arguments);
},
RU = u.__emscripten_thread_crashed = function () {
return (RU = u.__emscripten_thread_crashed = u.asm._emscripten_thread_crashed).apply(null, arguments);
},
DU = u._emscripten_main_thread_process_queued_calls = function () {
return (DU = u._emscripten_main_thread_process_queued_calls = u.asm.emscripten_main_thread_process_queued_calls).apply(null, arguments);
},
AU = u._emscripten_main_browser_thread_id = function () {
return (AU = u._emscripten_main_browser_thread_id = u.asm.emscripten_main_browser_thread_id).apply(null, arguments);
},
Jv = u._emscripten_run_in_main_runtime_thread_js = function () {
return (Jv = u._emscripten_run_in_main_runtime_thread_js = u.asm.emscripten_run_in_main_runtime_thread_js).apply(null, arguments);
},
FU = u._emscripten_dispatch_to_thread_ = function () {
return (FU = u._emscripten_dispatch_to_thread_ = u.asm.emscripten_dispatch_to_thread_).apply(null, arguments);
},
e0 = u.__emscripten_proxy_execute_task_queue = function () {
return (e0 = u.__emscripten_proxy_execute_task_queue = u.asm._emscripten_proxy_execute_task_queue).apply(null, arguments);
},
DC = u.__emscripten_thread_free_data = function () {
return (DC = u.__emscripten_thread_free_data = u.asm._emscripten_thread_free_data).apply(null, arguments);
},
t0 = u.__emscripten_thread_exit = function () {
return (t0 = u.__emscripten_thread_exit = u.asm._emscripten_thread_exit).apply(null, arguments);
},
r0 = u._emscripten_stack_set_limits = function () {
return (r0 = u._emscripten_stack_set_limits = u.asm.emscripten_stack_set_limits).apply(null, arguments);
},
AC = u.stackSave = function () {
return (AC = u.stackSave = u.asm.stackSave).apply(null, arguments);
},
Bm = u.stackRestore = function () {
return (Bm = u.stackRestore = u.asm.stackRestore).apply(null, arguments);
},
zm = u.stackAlloc = function () {
return (zm = u.stackAlloc = u.asm.stackAlloc).apply(null, arguments);
},
PU = u.dynCall_iijjiiii = function () {
return (PU = u.dynCall_iijjiiii = u.asm.dynCall_iijjiiii).apply(null, arguments);
},
OU = u.dynCall_jiji = function () {
return (OU = u.dynCall_jiji = u.asm.dynCall_jiji).apply(null, arguments);
};
u.keepRuntimeAlive = Mo, u.wasmMemory = oe, u.cwrap = Ky, u.ExitStatus = Iu, u.PThread = Me;
var Vm;
Oa = function A() {
Vm || o0(), Vm || (Oa = A);
};
function o0(A) {
if (A = A || f, wi > 0) return;
if (S) {
c(u), Xt(), startWorker(u);
return;
}
if (Vs(), wi > 0) return;
function V() {
Vm || (Vm = true, u.calledRun = true, !le && (Xt(), c(u), u.onRuntimeInitialized && u.onRuntimeInitialized(), Pa()));
}
u.setStatus ? (u.setStatus("Running..."), setTimeout(function () {
setTimeout(function () {
u.setStatus("");
}, 1), V();
}, 1)) : V();
}
if (u.preInit) for (typeof u.preInit == "function" && (u.preInit = [u.preInit]); u.preInit.length > 0;) u.preInit.pop()();
o0();
var Wm;
m && (Wm = {
uncaughtException: process.listeners("uncaughtException").filter(function (A) {
return !m.uncaughtException.indexOf(A) > -1;
}),
unhandledRejection: process.listeners("unhandledRejection").filter(function (A) {
return !m.unhandledRejection.indexOf(A) > -1;
})
});
var Um;
if (typeof WasmBackendModule != "undefined") Um = WasmBackendModule;else if (typeof e != "undefined") Um = e;else throw new Error("Could not find wasm module in post.js");
if (Wm) {
var MU = Um._dispose;
Um._dispose = function () {
MU(), Wm.uncaughtException.forEach(function (A) {
process.removeListener("uncaughtException", A);
}), Wm.unhandledRejection.forEach(function (A) {
process.removeListener("unhandledRejection", A);
});
};
}
return e.ready;
};
})();
typeof Bg == "object" && typeof kv == "object" ? kv.exports = vv : typeof define == "function" && __webpack_require__.amdO ? define([], function () {
return vv;
}) : typeof Bg == "object" && (Bg.WasmBackendModuleThreadedSimd = vv);
});
var oB = qt((tAt, rB) => {
rB.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")+"//# sourceURL="+f)},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.startWorker=instance=>{Module=instance;postMessage({"cmd":"loaded"})};self.onmessage=e=>{try{if(e.data.cmd==="load"){Module["wasmModule"]=e.data.wasmModule;for(const handler of e.data.handlers){Module[handler]=function(){postMessage({cmd:"callHandler",handler:handler,args:[...arguments]})}}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)}else if(e.data.cmd==="run"){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 nB = qt((zg, Tv) => {
var Nv = (() => {
var r = typeof document != "undefined" && document.currentScript ? document.currentScript.src : void 0;
return true && (r = r || __filename), function (e) {
e = e || {};
var t10 = typeof e != "undefined" ? e : {},
o,
n;
t10.ready = new Promise(function (G, ae) {
o = G, n = ae;
});
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 = (G, ae) => {
throw ae;
},
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 t10.locateFile ? t10.locateFile(G, d) : d + G;
}
var h, g, x, b;
function w(G) {
if (G instanceof Dp) return;
E("exiting due to exception: " + G);
}
if (m) {
var S = Sv(),
k = Iv();
l ? d = k.dirname(d) + "/" : d = __dirname + "/", h = (G, ae) => (G = Vs(G) ? new URL(G) : k.normalize(G), S.readFileSync(G, ae ? void 0 : "utf8")), x = G => {
var ae = h(G, true);
return ae.buffer || (ae = new Uint8Array(ae)), ae;
}, g = (G, ae, $e) => {
G = Vs(G) ? new URL(G) : k.normalize(G), S.readFile(G, function (at, _t) {
at ? $e(at) : ae(_t.buffer);
});
}, process.argv.length > 1 && (p = process.argv[1].replace(/\\/g, "/")), i = process.argv.slice(2), process.on("uncaughtException", function (G) {
if (!(G instanceof Dp)) throw G;
}), process.on("unhandledRejection", function (G) {
throw G;
}), u = (G, ae) => {
if (it()) throw process.exitCode = G, ae;
w(ae), process.exit(G);
}, t10.inspect = function () {
return "[Emscripten Module object]";
};
} else (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 ae = new XMLHttpRequest();
return ae.open("GET", G, false), ae.send(null), ae.responseText;
}, l && (x = G => {
var ae = new XMLHttpRequest();
return ae.open("GET", G, false), ae.responseType = "arraybuffer", ae.send(null), new Uint8Array(ae.response);
}), g = (G, ae, $e) => {
var at = new XMLHttpRequest();
at.open("GET", G, true), at.responseType = "arraybuffer", at.onload = () => {
if (at.status == 200 || at.status == 0 && at.response) {
ae(at.response);
return;
}
$e();
}, at.onerror = $e, at.send(null);
}, b = G => document.title = G);
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,
D;
t10.wasmBinary && (D = t10.wasmBinary);
var F = t10.noExitRuntime || true;
typeof WebAssembly != "object" && fr("no native wasm support detected");
var O,
M = false,
L;
function B(G, ae) {
G || fr(ae);
}
var z = typeof TextDecoder != "undefined" ? new TextDecoder("utf8") : void 0;
function U(G, ae, $e) {
ae >>>= 0;
for (var at = ae + $e, _t = ae; G[_t] && !(_t >= at);) ++_t;
if (_t - ae > 16 && G.buffer && z) return z.decode(G.subarray(ae, _t));
for (var $t = ""; ae < _t;) {
var Xe = G[ae++];
if (!(Xe & 128)) {
$t += String.fromCharCode(Xe);
continue;
}
var Ge = G[ae++] & 63;
if ((Xe & 224) == 192) {
$t += String.fromCharCode((Xe & 31) << 6 | Ge);
continue;
}
var Gt = G[ae++] & 63;
if ((Xe & 240) == 224 ? Xe = (Xe & 15) << 12 | Ge << 6 | Gt : Xe = (Xe & 7) << 18 | Ge << 12 | Gt << 6 | G[ae++] & 63, Xe < 65536) $t += String.fromCharCode(Xe);else {
var eo = Xe - 65536;
$t += String.fromCharCode(55296 | eo >> 10, 56320 | eo & 1023);
}
}
return $t;
}
function j(G, ae) {
return G >>>= 0, G ? U(ne, G, ae) : "";
}
function H(G, ae, $e, at) {
if ($e >>>= 0, !(at > 0)) return 0;
for (var _t = $e, $t = $e + at - 1, Xe = 0; Xe < G.length; ++Xe) {
var Ge = G.charCodeAt(Xe);
if (Ge >= 55296 && Ge <= 57343) {
var Gt = G.charCodeAt(++Xe);
Ge = 65536 + ((Ge & 1023) << 10) | Gt & 1023;
}
if (Ge <= 127) {
if ($e >= $t) break;
ae[$e++ >>> 0] = Ge;
} else if (Ge <= 2047) {
if ($e + 1 >= $t) break;
ae[$e++ >>> 0] = 192 | Ge >> 6, ae[$e++ >>> 0] = 128 | Ge & 63;
} else if (Ge <= 65535) {
if ($e + 2 >= $t) break;
ae[$e++ >>> 0] = 224 | Ge >> 12, ae[$e++ >>> 0] = 128 | Ge >> 6 & 63, ae[$e++ >>> 0] = 128 | Ge & 63;
} else {
if ($e + 3 >= $t) break;
ae[$e++ >>> 0] = 240 | Ge >> 18, ae[$e++ >>> 0] = 128 | Ge >> 12 & 63, ae[$e++ >>> 0] = 128 | Ge >> 6 & 63, ae[$e++ >>> 0] = 128 | Ge & 63;
}
}
return ae[$e >>> 0] = 0, $e - _t;
}
function X(G, ae, $e) {
return H(G, ne, ae, $e);
}
var J, re, ne, ee, oe, ie, le, ye, _e;
function ve(G) {
J = G, t10.HEAP8 = re = new Int8Array(G), t10.HEAP16 = ee = new Int16Array(G), t10.HEAP32 = ie = new Int32Array(G), t10.HEAPU8 = ne = new Uint8Array(G), t10.HEAPU16 = oe = new Uint16Array(G), t10.HEAPU32 = le = new Uint32Array(G), t10.HEAPF32 = ye = new Float32Array(G), t10.HEAPF64 = _e = new Float64Array(G);
}
var Fe = t10.INITIAL_MEMORY || 16777216,
Pe,
st = [],
lt = [],
We = [],
mt = false;
function it() {
return F;
}
function ht() {
if (t10.preRun) for (typeof t10.preRun == "function" && (t10.preRun = [t10.preRun]); t10.preRun.length;) Mt(t10.preRun.shift());
Oa(st);
}
function gt() {
mt = true, Oa(lt);
}
function Or() {
if (t10.postRun) for (typeof t10.postRun == "function" && (t10.postRun = [t10.postRun]); t10.postRun.length;) or(t10.postRun.shift());
Oa(We);
}
function Mt(G) {
st.unshift(G);
}
function Qr(G) {
lt.unshift(G);
}
function or(G) {
We.unshift(G);
}
var Tt = 0,
nr = null,
sr = null;
function Zr(G) {
Tt++, t10.monitorRunDependencies && t10.monitorRunDependencies(Tt);
}
function Jr(G) {
if (Tt--, t10.monitorRunDependencies && t10.monitorRunDependencies(Tt), Tt == 0 && (nr !== null && (clearInterval(nr), nr = null), sr)) {
var ae = sr;
sr = null, ae();
}
}
function fr(G) {
t10.onAbort && t10.onAbort(G), G = "Aborted(" + G + ")", E(G), M = true, L = 1, G += ". Build with -sASSERTIONS for more info.";
var ae = new WebAssembly.RuntimeError(G);
throw n(ae), ae;
}
var Fa = "data:application/octet-stream;base64,";
function Mo(G) {
return G.startsWith(Fa);
}
function Vs(G) {
return G.startsWith("file://");
}
var Xt;
Xt = "tfjs-backend-wasm.wasm", Mo(Xt) || (Xt = f(Xt));
function Pa(G) {
try {
if (G == Xt && D) return new Uint8Array(D);
if (x) return x(G);
throw "both async and sync fetching of the wasm failed";
} catch (ae) {
fr(ae);
}
}
function el() {
if (!D && (c || l)) {
if (typeof fetch == "function" && !Vs(Xt)) return fetch(Xt, {
credentials: "same-origin"
}).then(function (G) {
if (!G.ok) throw "failed to load wasm binary file at '" + Xt + "'";
return G.arrayBuffer();
}).catch(function () {
return Pa(Xt);
});
if (g) return new Promise(function (G, ae) {
g(Xt, function ($e) {
G(new Uint8Array($e));
}, ae);
});
}
return Promise.resolve().then(function () {
return Pa(Xt);
});
}
function tl() {
var G = {
env: rl,
wasi_snapshot_preview1: rl
};
function ae(Xe, Ge) {
var Gt = Xe.exports;
t10.asm = Gt, O = t10.asm.memory, ve(O.buffer), Pe = t10.asm.__indirect_function_table, Qr(t10.asm.__wasm_call_ctors), Jr("wasm-instantiate");
}
Zr("wasm-instantiate");
function $e(Xe) {
ae(Xe.instance);
}
function at(Xe) {
return el().then(function (Ge) {
return WebAssembly.instantiate(Ge, G);
}).then(function (Ge) {
return Ge;
}).then(Xe, function (Ge) {
E("failed to asynchronously prepare wasm: " + Ge), fr(Ge);
});
}
function _t() {
return !D && typeof WebAssembly.instantiateStreaming == "function" && !Mo(Xt) && !Vs(Xt) && !m && typeof fetch == "function" ? fetch(Xt, {
credentials: "same-origin"
}).then(function (Xe) {
var Ge = WebAssembly.instantiateStreaming(Xe, G);
return Ge.then($e, function (Gt) {
return E("wasm streaming compile failed: " + Gt), E("falling back to ArrayBuffer instantiation"), at($e);
});
}) : at($e);
}
if (t10.instantiateWasm) try {
var $t = t10.instantiateWasm(G, ae);
return $t;
} catch (Xe) {
E("Module.instantiateWasm callback failed with error: " + Xe), n(Xe);
}
return _t().catch(n), {};
}
var jv, wi;
function Dp(G) {
this.name = "ExitStatus", this.message = "Program terminated with exit(" + G + ")", this.status = G;
}
function Oa(G) {
for (; G.length > 0;) G.shift()(t10);
}
function ly() {
fr("");
}
function xm() {
return 4294901760;
}
function Su() {
return xm();
}
function my(G, ae, $e) {
ne.copyWithin(G >>> 0, ae >>> 0, ae + $e >>> 0);
}
function ym(G) {
try {
return O.grow(G - J.byteLength + 65535 >>> 16), ve(O.buffer), 1;
} catch (ae) {}
}
function Ap(G) {
var ae = ne.length;
G = G >>> 0;
var $e = xm();
if (G > $e) return false;
let at = (Gt, eo) => Gt + (eo - Gt % eo) % eo;
for (var _t = 1; _t <= 4; _t *= 2) {
var $t = ae * (1 + 0.2 / _t);
$t = Math.min($t, G + 100663296);
var Xe = Math.min($e, at(Math.max(G, $t), 65536)),
Ge = ym(Xe);
if (Ge) return true;
}
return false;
}
var hr = {
varargs: void 0,
get: function () {
hr.varargs += 4;
var G = ie[hr.varargs - 4 >>> 2];
return G;
},
getStr: function (G) {
var ae = j(G);
return ae;
}
};
function bm(G) {
return 52;
}
function dy(G, ae, $e, at, _t) {
return 70;
}
var fy = [null, [], []];
function Xv(G, ae) {
var $e = fy[G];
ae === 0 || ae === 10 ? ((G === 1 ? _ : E)(U($e, 0)), $e.length = 0) : $e.push(ae);
}
function Yv(G, ae, $e, at) {
for (var _t = 0, $t = 0; $t < $e; $t++) {
var Xe = le[ae >>> 2],
Ge = le[ae + 4 >>> 2];
ae += 8;
for (var Gt = 0; Gt < Ge; Gt++) Xv(G, ne[Xe + Gt >>> 0]);
_t += Ge;
}
return le[at >>> 2] = _t, 0;
}
function Cm(G) {
var ae = t10["_" + G];
return ae;
}
function Iu(G, ae) {
re.set(G, ae >>> 0);
}
function hy(G, ae, $e, at, _t) {
var $t = {
string: yr => {
var Ii = 0;
if (yr != null && yr !== 0) {
var Mm = (yr.length << 2) + 1;
Ii = il(Mm), X(yr, Ii, Mm);
}
return Ii;
},
array: yr => {
var Ii = il(yr.length);
return Iu(yr, Ii), Ii;
}
};
function Xe(yr) {
return ae === "string" ? j(yr) : ae === "boolean" ? !!yr : yr;
}
var Ge = Cm(G),
Gt = [],
eo = 0;
if (at) for (var Ma = 0; Ma < at.length; Ma++) {
var Om = $t[$e[Ma]];
Om ? (eo === 0 && (eo = Am()), Gt[Ma] = Om(at[Ma])) : Gt[Ma] = at[Ma];
}
var ul = Ge.apply(null, Gt);
function RC(yr) {
return eo !== 0 && Fm(eo), Xe(yr);
}
return ul = RC(ul), ul;
}
function gy(G, ae, $e, at) {
$e = $e || [];
var _t = $e.every(Xe => Xe === "number" || Xe === "boolean"),
$t = ae !== "string";
return $t && _t && !at ? Cm(G) : function () {
return hy(G, ae, $e, arguments, at);
};
}
var rl = {
abort: ly,
emscripten_get_heap_max: Su,
emscripten_memcpy_big: my,
emscripten_resize_heap: Ap,
fd_close: bm,
fd_seek: dy,
fd_write: Yv
},
xy = tl(),
wm = t10.___wasm_call_ctors = function () {
return (wm = t10.___wasm_call_ctors = t10.asm.__wasm_call_ctors).apply(null, arguments);
},
Sm = t10._init = function () {
return (Sm = t10._init = t10.asm.init).apply(null, arguments);
},
yy = t10._init_with_threads_count = function () {
return (yy = t10._init_with_threads_count = t10.asm.init_with_threads_count).apply(null, arguments);
},
Im = t10._get_threads_count = function () {
return (Im = t10._get_threads_count = t10.asm.get_threads_count).apply(null, arguments);
},
by = t10._register_tensor = function () {
return (by = t10._register_tensor = t10.asm.register_tensor).apply(null, arguments);
},
Me = t10._dispose_data = function () {
return (Me = t10._dispose_data = t10.asm.dispose_data).apply(null, arguments);
},
ol = t10._dispose = function () {
return (ol = t10._dispose = t10.asm.dispose).apply(null, arguments);
},
Cy = t10._Abs = function () {
return (Cy = t10._Abs = t10.asm.Abs).apply(null, arguments);
},
vm = t10._Acos = function () {
return (vm = t10._Acos = t10.asm.Acos).apply(null, arguments);
},
Fp = t10._Acosh = function () {
return (Fp = t10._Acosh = t10.asm.Acosh).apply(null, arguments);
},
wy = t10._Add = function () {
return (wy = t10._Add = t10.asm.Add).apply(null, arguments);
},
Sy = t10._AddN = function () {
return (Sy = t10._AddN = t10.asm.AddN).apply(null, arguments);
},
Iy = t10._All = function () {
return (Iy = t10._All = t10.asm.All).apply(null, arguments);
},
vy = t10._Any = function () {
return (vy = t10._Any = t10.asm.Any).apply(null, arguments);
},
ky = t10._ArgMax = function () {
return (ky = t10._ArgMax = t10.asm.ArgMax).apply(null, arguments);
},
km = t10._ArgMin = function () {
return (km = t10._ArgMin = t10.asm.ArgMin).apply(null, arguments);
},
Nm = t10._Asin = function () {
return (Nm = t10._Asin = t10.asm.Asin).apply(null, arguments);
},
Ny = t10._Asinh = function () {
return (Ny = t10._Asinh = t10.asm.Asinh).apply(null, arguments);
},
Ty = t10._Atan = function () {
return (Ty = t10._Atan = t10.asm.Atan).apply(null, arguments);
},
_y = t10._Atan2 = function () {
return (_y = t10._Atan2 = t10.asm.Atan2).apply(null, arguments);
},
nl = t10._Atanh = function () {
return (nl = t10._Atanh = t10.asm.Atanh).apply(null, arguments);
},
$y = t10._AvgPool = function () {
return ($y = t10._AvgPool = t10.asm.AvgPool).apply(null, arguments);
},
Ey = t10._AvgPool3D = function () {
return (Ey = t10._AvgPool3D = t10.asm.AvgPool3D).apply(null, arguments);
},
Ry = t10._AvgPool3DGrad = function () {
return (Ry = t10._AvgPool3DGrad = t10.asm.AvgPool3DGrad).apply(null, arguments);
},
vu = t10._BatchMatMul = function () {
return (vu = t10._BatchMatMul = t10.asm.BatchMatMul).apply(null, arguments);
},
Dy = t10._Bincount = function () {
return (Dy = t10._Bincount = t10.asm.Bincount).apply(null, arguments);
},
Ay = t10._Ceil = function () {
return (Ay = t10._Ceil = t10.asm.Ceil).apply(null, arguments);
},
Tm = t10._ClipByValue = function () {
return (Tm = t10._ClipByValue = t10.asm.ClipByValue).apply(null, arguments);
},
Fy = t10._Conv2D = function () {
return (Fy = t10._Conv2D = t10.asm.Conv2D).apply(null, arguments);
},
sl = t10._Conv2DBackpropInput = function () {
return (sl = t10._Conv2DBackpropInput = t10.asm.Conv2DBackpropInput).apply(null, arguments);
},
Py = t10._Conv3D = function () {
return (Py = t10._Conv3D = t10.asm.Conv3D).apply(null, arguments);
},
Oy = t10._Conv3DBackpropFilterV2 = function () {
return (Oy = t10._Conv3DBackpropFilterV2 = t10.asm.Conv3DBackpropFilterV2).apply(null, arguments);
},
My = t10._Conv3DBackpropInputV2 = function () {
return (My = t10._Conv3DBackpropInputV2 = t10.asm.Conv3DBackpropInputV2).apply(null, arguments);
},
Si = t10._Cos = function () {
return (Si = t10._Cos = t10.asm.Cos).apply(null, arguments);
},
al = t10._Cosh = function () {
return (al = t10._Cosh = t10.asm.Cosh).apply(null, arguments);
},
Ly = t10._CropAndResize = function () {
return (Ly = t10._CropAndResize = t10.asm.CropAndResize).apply(null, arguments);
},
By = t10._Cumprod = function () {
return (By = t10._Cumprod = t10.asm.Cumprod).apply(null, arguments);
},
zy = t10._Cumsum = function () {
return (zy = t10._Cumsum = t10.asm.Cumsum).apply(null, arguments);
},
Vy = t10._DenseBincount = function () {
return (Vy = t10._DenseBincount = t10.asm.DenseBincount).apply(null, arguments);
},
_m = t10._DepthToSpace = function () {
return (_m = t10._DepthToSpace = t10.asm.DepthToSpace).apply(null, arguments);
},
$m = t10._DepthwiseConv2dNative = function () {
return ($m = t10._DepthwiseConv2dNative = t10.asm.DepthwiseConv2dNative).apply(null, arguments);
},
Wy = t10._Diag = function () {
return (Wy = t10._Diag = t10.asm.Diag).apply(null, arguments);
},
Uy = t10._Dilation2D = function () {
return (Uy = t10._Dilation2D = t10.asm.Dilation2D).apply(null, arguments);
},
Em = t10._Dilation2DBackpropFilter = function () {
return (Em = t10._Dilation2DBackpropFilter = t10.asm.Dilation2DBackpropFilter).apply(null, arguments);
},
Rm = t10._Dilation2DBackpropInput = function () {
return (Rm = t10._Dilation2DBackpropInput = t10.asm.Dilation2DBackpropInput).apply(null, arguments);
},
Gy = t10._Elu = function () {
return (Gy = t10._Elu = t10.asm.Elu).apply(null, arguments);
},
Hy = t10._EluGrad = function () {
return (Hy = t10._EluGrad = t10.asm.EluGrad).apply(null, arguments);
},
Ky = t10._Equal = function () {
return (Ky = t10._Equal = t10.asm.Equal).apply(null, arguments);
},
qy = t10._Exp = function () {
return (qy = t10._Exp = t10.asm.Exp).apply(null, arguments);
},
Dm = t10._Expm1 = function () {
return (Dm = t10._Expm1 = t10.asm.Expm1).apply(null, arguments);
},
Qv = t10._FlipLeftRight = function () {
return (Qv = t10._FlipLeftRight = t10.asm.FlipLeftRight).apply(null, arguments);
},
jy = t10._Floor = function () {
return (jy = t10._Floor = t10.asm.Floor).apply(null, arguments);
},
Xy = t10._FloorDiv = function () {
return (Xy = t10._FloorDiv = t10.asm.FloorDiv).apply(null, arguments);
},
Yy = t10._FusedBatchNorm = function () {
return (Yy = t10._FusedBatchNorm = t10.asm.FusedBatchNorm).apply(null, arguments);
},
Qy = t10._FusedConv2D = function () {
return (Qy = t10._FusedConv2D = t10.asm.FusedConv2D).apply(null, arguments);
},
Zy = t10._FusedDepthwiseConv2D = function () {
return (Zy = t10._FusedDepthwiseConv2D = t10.asm.FusedDepthwiseConv2D).apply(null, arguments);
},
Jy = t10._Gather = function () {
return (Jy = t10._Gather = t10.asm.Gather).apply(null, arguments);
},
eb = t10._GatherNd = function () {
return (eb = t10._GatherNd = t10.asm.GatherNd).apply(null, arguments);
},
tb = t10._Greater = function () {
return (tb = t10._Greater = t10.asm.Greater).apply(null, arguments);
},
rb = t10._GreaterEqual = function () {
return (rb = t10._GreaterEqual = t10.asm.GreaterEqual).apply(null, arguments);
},
ob = t10._IsFinite = function () {
return (ob = t10._IsFinite = t10.asm.IsFinite).apply(null, arguments);
},
nb = t10._IsInf = function () {
return (nb = t10._IsInf = t10.asm.IsInf).apply(null, arguments);
},
sb = t10._IsNan = function () {
return (sb = t10._IsNan = t10.asm.IsNan).apply(null, arguments);
},
ab = t10._LRN = function () {
return (ab = t10._LRN = t10.asm.LRN).apply(null, arguments);
},
ib = t10._LRNGrad = function () {
return (ib = t10._LRNGrad = t10.asm.LRNGrad).apply(null, arguments);
},
ub = t10._LeakyRelu = function () {
return (ub = t10._LeakyRelu = t10.asm.LeakyRelu).apply(null, arguments);
},
pb = t10._Less = function () {
return (pb = t10._Less = t10.asm.Less).apply(null, arguments);
},
cb = t10._LessEqual = function () {
return (cb = t10._LessEqual = t10.asm.LessEqual).apply(null, arguments);
},
lb = t10._LinSpace = function () {
return (lb = t10._LinSpace = t10.asm.LinSpace).apply(null, arguments);
},
mb = t10._Log = function () {
return (mb = t10._Log = t10.asm.Log).apply(null, arguments);
},
db = t10._Log1p = function () {
return (db = t10._Log1p = t10.asm.Log1p).apply(null, arguments);
},
fb = t10._LogicalAnd = function () {
return (fb = t10._LogicalAnd = t10.asm.LogicalAnd).apply(null, arguments);
},
hb = t10._LogicalNot = function () {
return (hb = t10._LogicalNot = t10.asm.LogicalNot).apply(null, arguments);
},
gb = t10._LogicalOr = function () {
return (gb = t10._LogicalOr = t10.asm.LogicalOr).apply(null, arguments);
},
xb = t10._LogicalXor = function () {
return (xb = t10._LogicalXor = t10.asm.LogicalXor).apply(null, arguments);
},
yb = t10._Max = function () {
return (yb = t10._Max = t10.asm.Max).apply(null, arguments);
},
bb = t10._MaxPool = function () {
return (bb = t10._MaxPool = t10.asm.MaxPool).apply(null, arguments);
},
Cb = t10._MaxPool3D = function () {
return (Cb = t10._MaxPool3D = t10.asm.MaxPool3D).apply(null, arguments);
},
wb = t10._MaxPool3DGrad = function () {
return (wb = t10._MaxPool3DGrad = t10.asm.MaxPool3DGrad).apply(null, arguments);
},
Sb = t10._Maximum = function () {
return (Sb = t10._Maximum = t10.asm.Maximum).apply(null, arguments);
},
Ib = t10._Mean = function () {
return (Ib = t10._Mean = t10.asm.Mean).apply(null, arguments);
},
vb = t10._Min = function () {
return (vb = t10._Min = t10.asm.Min).apply(null, arguments);
},
kb = t10._Minimum = function () {
return (kb = t10._Minimum = t10.asm.Minimum).apply(null, arguments);
},
Nb = t10._MirrorPad = function () {
return (Nb = t10._MirrorPad = t10.asm.MirrorPad).apply(null, arguments);
},
Tb = t10._Multinomial = function () {
return (Tb = t10._Multinomial = t10.asm.Multinomial).apply(null, arguments);
},
_b = t10._Multiply = function () {
return (_b = t10._Multiply = t10.asm.Multiply).apply(null, arguments);
},
$b = t10._Neg = function () {
return ($b = t10._Neg = t10.asm.Neg).apply(null, arguments);
},
Eb = t10._NonMaxSuppressionV3 = function () {
return (Eb = t10._NonMaxSuppressionV3 = t10.asm.NonMaxSuppressionV3).apply(null, arguments);
},
Rb = t10._NonMaxSuppressionV4 = function () {
return (Rb = t10._NonMaxSuppressionV4 = t10.asm.NonMaxSuppressionV4).apply(null, arguments);
},
Db = t10._NonMaxSuppressionV5 = function () {
return (Db = t10._NonMaxSuppressionV5 = t10.asm.NonMaxSuppressionV5).apply(null, arguments);
},
Ab = t10._NotEqual = function () {
return (Ab = t10._NotEqual = t10.asm.NotEqual).apply(null, arguments);
},
Fb = t10._OneHot = function () {
return (Fb = t10._OneHot = t10.asm.OneHot).apply(null, arguments);
},
Pb = t10._PadV2 = function () {
return (Pb = t10._PadV2 = t10.asm.PadV2).apply(null, arguments);
},
Ob = t10._Pow = function () {
return (Ob = t10._Pow = t10.asm.Pow).apply(null, arguments);
},
Mb = t10._Prelu = function () {
return (Mb = t10._Prelu = t10.asm.Prelu).apply(null, arguments);
},
Lb = t10._Prod = function () {
return (Lb = t10._Prod = t10.asm.Prod).apply(null, arguments);
},
Bb = t10._RealDiv = function () {
return (Bb = t10._RealDiv = t10.asm.RealDiv).apply(null, arguments);
},
zb = t10._Reciprocal = function () {
return (zb = t10._Reciprocal = t10.asm.Reciprocal).apply(null, arguments);
},
Vb = t10._Relu = function () {
return (Vb = t10._Relu = t10.asm.Relu).apply(null, arguments);
},
Wb = t10._Relu6 = function () {
return (Wb = t10._Relu6 = t10.asm.Relu6).apply(null, arguments);
},
Ub = t10._ResizeBilinear = function () {
return (Ub = t10._ResizeBilinear = t10.asm.ResizeBilinear).apply(null, arguments);
},
Gb = t10._ResizeBilinearGrad = function () {
return (Gb = t10._ResizeBilinearGrad = t10.asm.ResizeBilinearGrad).apply(null, arguments);
},
Hb = t10._ResizeNearestNeighbor = function () {
return (Hb = t10._ResizeNearestNeighbor = t10.asm.ResizeNearestNeighbor).apply(null, arguments);
},
Kb = t10._ResizeNearestNeighborGrad = function () {
return (Kb = t10._ResizeNearestNeighborGrad = t10.asm.ResizeNearestNeighborGrad).apply(null, arguments);
},
qb = t10._Reverse = function () {
return (qb = t10._Reverse = t10.asm.Reverse).apply(null, arguments);
},
jb = t10._RotateWithOffset = function () {
return (jb = t10._RotateWithOffset = t10.asm.RotateWithOffset).apply(null, arguments);
},
Xb = t10._Round = function () {
return (Xb = t10._Round = t10.asm.Round).apply(null, arguments);
},
Yb = t10._Rsqrt = function () {
return (Yb = t10._Rsqrt = t10.asm.Rsqrt).apply(null, arguments);
},
Qb = t10._ScatterNd = function () {
return (Qb = t10._ScatterNd = t10.asm.ScatterNd).apply(null, arguments);
},
Zb = t10._SearchSorted = function () {
return (Zb = t10._SearchSorted = t10.asm.SearchSorted).apply(null, arguments);
},
Jb = t10._SelectV2 = function () {
return (Jb = t10._SelectV2 = t10.asm.SelectV2).apply(null, arguments);
},
eC = t10._Selu = function () {
return (eC = t10._Selu = t10.asm.Selu).apply(null, arguments);
},
tC = t10._Sigmoid = function () {
return (tC = t10._Sigmoid = t10.asm.Sigmoid).apply(null, arguments);
},
rC = t10._Sign = function () {
return (rC = t10._Sign = t10.asm.Sign).apply(null, arguments);
},
oC = t10._Sin = function () {
return (oC = t10._Sin = t10.asm.Sin).apply(null, arguments);
},
nC = t10._Softmax = function () {
return (nC = t10._Softmax = t10.asm.Softmax).apply(null, arguments);
},
sC = t10._Softplus = function () {
return (sC = t10._Softplus = t10.asm.Softplus).apply(null, arguments);
},
aC = t10._SparseFillEmptyRows = function () {
return (aC = t10._SparseFillEmptyRows = t10.asm.SparseFillEmptyRows).apply(null, arguments);
},
iC = t10._SparseReshape = function () {
return (iC = t10._SparseReshape = t10.asm.SparseReshape).apply(null, arguments);
},
uC = t10._SparseSegmentReduction = function () {
return (uC = t10._SparseSegmentReduction = t10.asm.SparseSegmentReduction).apply(null, arguments);
},
pC = t10._SparseToDense = function () {
return (pC = t10._SparseToDense = t10.asm.SparseToDense).apply(null, arguments);
},
cC = t10._Sqrt = function () {
return (cC = t10._Sqrt = t10.asm.Sqrt).apply(null, arguments);
},
lC = t10._Square = function () {
return (lC = t10._Square = t10.asm.Square).apply(null, arguments);
},
mC = t10._SquaredDifference = function () {
return (mC = t10._SquaredDifference = t10.asm.SquaredDifference).apply(null, arguments);
},
dC = t10._Step = function () {
return (dC = t10._Step = t10.asm.Step).apply(null, arguments);
},
fC = t10._StridedSlice = function () {
return (fC = t10._StridedSlice = t10.asm.StridedSlice).apply(null, arguments);
},
hC = t10._Sub = function () {
return (hC = t10._Sub = t10.asm.Sub).apply(null, arguments);
},
gC = t10._Sum = function () {
return (gC = t10._Sum = t10.asm.Sum).apply(null, arguments);
},
xC = t10._Tan = function () {
return (xC = t10._Tan = t10.asm.Tan).apply(null, arguments);
},
yC = t10._Tanh = function () {
return (yC = t10._Tanh = t10.asm.Tanh).apply(null, arguments);
},
bC = t10._TensorScatterUpdate = function () {
return (bC = t10._TensorScatterUpdate = t10.asm.TensorScatterUpdate).apply(null, arguments);
},
CC = t10._Tile = function () {
return (CC = t10._Tile = t10.asm.Tile).apply(null, arguments);
},
wC = t10._TopK = function () {
return (wC = t10._TopK = t10.asm.TopK).apply(null, arguments);
},
SC = t10._Transform = function () {
return (SC = t10._Transform = t10.asm.Transform).apply(null, arguments);
},
IC = t10._Transpose = function () {
return (IC = t10._Transpose = t10.asm.Transpose).apply(null, arguments);
},
vC = t10.__FusedMatMul = function () {
return (vC = t10.__FusedMatMul = t10.asm._FusedMatMul).apply(null, arguments);
},
kC = t10._malloc = function () {
return (kC = t10._malloc = t10.asm.malloc).apply(null, arguments);
},
NC = t10._free = function () {
return (NC = t10._free = t10.asm.free).apply(null, arguments);
},
TC = t10.___errno_location = function () {
return (TC = t10.___errno_location = t10.asm.__errno_location).apply(null, arguments);
},
Am = t10.stackSave = function () {
return (Am = t10.stackSave = t10.asm.stackSave).apply(null, arguments);
},
Fm = t10.stackRestore = function () {
return (Fm = t10.stackRestore = t10.asm.stackRestore).apply(null, arguments);
},
il = t10.stackAlloc = function () {
return (il = t10.stackAlloc = t10.asm.stackAlloc).apply(null, arguments);
},
_C = t10.dynCall_iijjiiii = function () {
return (_C = t10.dynCall_iijjiiii = t10.asm.dynCall_iijjiiii).apply(null, arguments);
},
$C = t10.dynCall_jiji = function () {
return ($C = t10.dynCall_jiji = t10.asm.dynCall_jiji).apply(null, arguments);
};
t10.cwrap = gy;
var Pp;
sr = function G() {
Pp || Pm(), Pp || (sr = G);
};
function Pm(G) {
if (G = G || i, Tt > 0 || (ht(), Tt > 0)) return;
function ae() {
Pp || (Pp = true, t10.calledRun = true, !M && (gt(), o(t10), t10.onRuntimeInitialized && t10.onRuntimeInitialized(), Or()));
}
t10.setStatus ? (t10.setStatus("Running..."), setTimeout(function () {
setTimeout(function () {
t10.setStatus("");
}, 1), ae();
}, 1)) : ae();
}
if (t10.preInit) for (typeof t10.preInit == "function" && (t10.preInit = [t10.preInit]); t10.preInit.length > 0;) t10.preInit.pop()();
Pm();
var Op;
s && (Op = {
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 Mp;
if (typeof e != "undefined") Mp = e;else if (typeof WasmBackendModuleThreadedSimd != "undefined") Mp = WasmBackendModuleThreadedSimd;else throw new Error("Could not find wasm module in post.js");
if (Op) {
var EC = Mp._dispose;
Mp._dispose = function () {
EC(), Op.uncaughtException.forEach(function (G) {
process.removeListener("uncaughtException", G);
}), Op.unhandledRejection.forEach(function (G) {
process.removeListener("unhandledRejection", G);
});
};
}
return e.ready;
};
})();
typeof zg == "object" && typeof Tv == "object" ? Tv.exports = Nv : typeof define == "function" && __webpack_require__.amdO ? define([], function () {
return Nv;
}) : typeof zg == "object" && (zg.WasmBackendModule = Nv);
});
var Lo = class {
constructor(e, t10) {
this.backend = e, this.dataMover = t10, 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);
}
has(e) {
return this.data.has(e);
}
delete(e) {
return this.dataIdsCount--, this.data.delete(e);
}
numDataIds() {
return this.dataIdsCount;
}
};
var ro = class {
refCount(e) {
return Lr("refCount");
}
incRef(e) {
return Lr("incRef");
}
timerAvailable() {
return true;
}
time(e) {
return Lr("time");
}
read(e) {
return Lr("read");
}
readSync(e) {
return Lr("readSync");
}
readToGPU(e, t10) {
return Lr("readToGPU");
}
numDataIds() {
return Lr("numDataIds");
}
disposeData(e, t10) {
return Lr("disposeData");
}
write(e, t10, o) {
return Lr("write");
}
move(e, t10, o, n, s) {
return Lr("move");
}
createTensorFromGPUData(e, t10, o) {
return Lr("createTensorFromGPUData");
}
memory() {
return Lr("memory");
}
floatPrecision() {
return Lr("floatPrecision");
}
epsilon() {
return this.floatPrecision() === 32 ? 1e-7 : 1e-4;
}
dispose() {
return Lr("dispose");
}
};
function Lr(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 a0(r) {
let e = r.length,
t10 = 0;
for (; e > 0;) t10 = Math.random() * e | 0, e--, Gm(r, e, t10);
}
function HU(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--, Gm(r, t10, o), Gm(e, t10, o);
}
function zp(r, e, t10) {
return Math.max(r, Math.min(e, t10));
}
function KU(r) {
return r % 2 === 0 ? r : r + 1;
}
function Gm(r, e, t10) {
let o = r[e];
r[e] = r[t10], r[t10] = o;
}
function qU(r) {
let e = 0;
for (let t10 = 0; t10 < r.length; t10++) e += r[t10];
return e;
}
function jU(r, e) {
let t10 = Math.random();
return e * t10 + (1 - t10) * r;
}
function XU(r, e) {
let t10 = 0;
for (let o = 0; o < r.length; o++) {
let n = Number(r[o]) - Number(e[o]);
t10 += n * n;
}
return t10;
}
function $(r, e) {
if (!r) throw new Error(typeof e == "string" ? e : e());
}
function xt(r, e, t10 = "") {
$(br(r, e), () => t10 + ` Shapes ${r} and ${e} must match`);
}
function oo(r) {
$(r != null, () => "The input to the tensor constructor must be a non-null value.");
}
function Ue(r) {
if (r.length === 0) return 1;
let e = r[0];
for (let t10 = 1; t10 < r.length; t10++) e *= r[t10];
return e;
}
function YU(r) {
return r.length === 0;
}
function OC(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] !== null && e[t10] !== null && r[t10] !== e[t10]) return false;
return true;
}
function br(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]) return false;
return true;
}
function Ba(r) {
return r % 1 === 0;
}
function QU(r) {
if (Math.tanh != null) return Math.tanh(r);
if (r === 1 / 0) return 1;
if (r === -1 / 0) return -1;
{
let e = Math.exp(2 * r);
return (e - 1) / (e + 1);
}
}
function ZU(r) {
let e = Math.ceil(Math.sqrt(r));
return [e, Math.ceil(r / e)];
}
function JU(r) {
let e = new Uint32Array(r);
for (let t10 = 0; t10 < r; ++t10) e[t10] = t10;
return a0(e), e;
}
function Nu(r, e) {
return e <= r.length ? r : r + " ".repeat(e - r.length);
}
function eG(r, e = n => 0, t10, o) {
return new Promise((n, s) => {
let a = 0,
i = () => {
if (r()) {
n();
return;
}
a++;
let p = e(a);
if (t10 != null && a >= t10) {
s();
return;
}
o != null ? o(i, p) : setTimeout(i, p);
};
i();
});
}
function tG(r, e) {
let t10 = 1,
o = -1;
for (let s = 0; s < r.length; ++s) if (r[s] >= 0) t10 *= 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}`);
o = s;
} 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) throw Error(`Size(${e}) must match the product of shape ${r}`);
return r;
}
if (t10 === 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}`);
let n = r.slice();
return n[o] = e / t10, n;
}
function vi(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 => Ba(o)), () => `All values in axis param must be integers but got axis ${r}`), r.map(o => o < 0 ? t10 + o : o);
}
function MC(r, e) {
let t10 = [],
o = [],
n = e != null && Array.isArray(e) && e.length === 0,
s = e == null || n ? null : vi(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++;
}
r[i] !== 1 && (t10.push(r[i]), o.push(i));
}
return {
newShape: t10,
keptDims: o
};
}
function LC(r, e) {
return Hm(r, e);
}
function Hm(r, e) {
let t10 = null;
if (r == null || r === "float32") t10 = new Float32Array(e);else if (r === "int32") t10 = new Int32Array(e);else if (r === "bool") t10 = new Uint8Array(e);else if (r === "string") t10 = new Array(e);else throw new Error(`Unknown data type ${r}`);
return t10;
}
function BC(r, e) {
for (let t10 = 0; t10 < r.length; t10++) {
let o = r[t10];
if (isNaN(o) || !isFinite(o)) throw Error(`A tensor of type ${e} being uploaded contains ${o}.`);
}
}
function zC(r) {
return r === "bool" || r === "complex64" || r === "float32" || r === "int32" || r === "string";
}
function rG(r, e) {
return !(e === "complex64" || e === "float32" && r !== "complex64" || e === "int32" && r !== "float32" && r !== "complex64" || e === "bool" && r === "bool");
}
function Vp(r) {
if (r === "float32" || r === "int32") return 4;
if (r === "complex64") return 8;
if (r === "bool") return 1;
throw new Error(`Unknown dtype ${r}`);
}
function VC(r) {
if (r == null) return 0;
let e = 0;
return r.forEach(t10 => e += t10.length), e;
}
function Bo(r) {
return typeof r == "string" || r instanceof String;
}
function i0(r) {
return typeof r == "boolean";
}
function u0(r) {
return typeof r == "number";
}
function ki(r) {
return Array.isArray(r) ? ki(r[0]) : r instanceof Float32Array ? "float32" : r instanceof Int32Array || r instanceof Uint8Array || r instanceof Uint8ClampedArray ? "int32" : u0(r) ? "float32" : Bo(r) ? "string" : i0(r) ? "bool" : "float32";
}
function Ws(r) {
return !!(r && r.constructor && r.call && r.apply);
}
function Wp(r, e) {
for (let t10 = e; t10 < r; ++t10) if (r % t10 === 0) return t10;
return r;
}
function Us(r) {
let e = r.length;
if (e < 2) return [];
let t10 = new Array(e - 1);
t10[e - 2] = r[e - 1];
for (let o = e - 3; o >= 0; --o) t10[o] = t10[o + 1] * r[o + 1];
return t10;
}
function p0(r, e, t10, 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];
} 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] = p0(r + p * i, a, t10, o);
}
return n;
}
function ku(r, e, t10 = false) {
if (r.length === 0) return e[0];
let o = r.reduce((n, s) => n * s) * (t10 ? 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 p0(0, r, e, t10);
}
function oG(r, e) {
if (Array.isArray(r)) return r;
if (e === "float32") return r instanceof Float32Array ? r : new Float32Array(r);
if (e === "int32") return r instanceof Int32Array ? r : new Int32Array(r);
if (e === "bool" || e === "string") return Uint8Array.from(new Int32Array(r));
throw new Error(`Unknown dtype ${e}`);
}
function pl(r, e) {
let t10 = Up(r, e);
for (let o = 0; o < t10.length; o++) t10[o] = 1;
return t10;
}
function Up(r, e) {
if (e == null || e === "float32" || e === "complex64") return new Float32Array(r);
if (e === "int32") return new Int32Array(r);
if (e === "bool") return new Uint8Array(r);
throw new Error(`Unknown data type ${e}`);
}
function nG(r, e) {
let t10 = r.reduce((o, n) => o * n, 1);
if (e == null || e === "float32") return ku(r, new Float32Array(t10));
if (e === "int32") return ku(r, new Int32Array(t10));
if (e === "bool") return ku(r, new Uint8Array(t10));
throw new Error(`Unknown data type ${e}`);
}
function Ct(r) {
r.forEach(e => {
$(Number.isInteger(e) && e >= 0, () => `Tensor must have a shape comprised of positive integers but got shape [${r}].`);
});
}
function sG(r, e, t10) {
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];
return o;
}
function aG(r, e, t10) {
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];
return o[o.length - 1] = r, o;
}
function Tu(r) {
return r && r.then && typeof r.then == "function";
}
var c0 = "tfjsflags";
var cl = class {
constructor(e) {
this.global = e, this.flags = {}, this.flagRegistry = {}, this.urlFlags = {}, this.getQueryParams = uG, 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;
}
registerFlag(e, t10, o) {
if (this.flagRegistry[e] = {
evaluationFn: t10,
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);
}
}
async getAsync(e) {
return e in this.flags ? this.flags[e] : (this.flags[e] = await this.evaluateFlag(e), this.flags[e]);
}
get(e) {
if (e in this.flags) return this.flags[e];
let t10 = this.evaluateFlag(e);
if (Tu(t10)) throw new Error(`Flag ${e} cannot be synchronously evaluated. Please use getAsync() instead.`);
return this.flags[e] = t10, this.flags[e];
}
getNumber(e) {
return this.get(e);
}
getBool(e) {
return this.get(e);
}
getString(e) {
return this.get(e);
}
getFlags() {
return this.flags;
}
get features() {
return this.flags;
}
set(e, t10) {
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);
}
evaluateFlag(e) {
if (this.flagRegistry[e] == null) throw new Error(`Cannot evaluate flag '${e}': no evaluation function found.`);
return this.flagRegistry[e].evaluationFn();
}
setFlags(e) {
this.flags = Object.assign({}, e);
}
reset() {
this.flags = {}, this.urlFlags = {}, this.populateURLFlags();
}
populateURLFlags() {
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);
c0 in e && e[c0].split(",").forEach(o => {
let [n, s] = o.split(":");
this.urlFlags[n] = cG(n, s);
});
}
};
function uG(r) {
let e = {};
return r.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g, (t10, ...o) => (pG(e, o[0], o[1]), o.join("="))), e;
}
function pG(r, e, t10) {
r[decodeURIComponent(e)] = decodeURIComponent(t10 || "");
}
function cG(r, e) {
let t10 = e.toLowerCase();
return t10 === "true" || t10 === "false" ? t10 === "true" : `${+t10}` === t10 ? +t10 : e;
}
function P() {
return WC;
}
var WC = null;
function l0(r) {
WC = r;
}
var UC;
function GC() {
if (UC == null) {
let r;
if (typeof window != "undefined") r = window;else if (typeof __webpack_require__.g != "undefined") r = __webpack_require__.g;else if (typeof process != "undefined") r = process;else if (typeof self != "undefined") r = self;else throw new Error("Could not find a global object");
UC = r;
}
return UC;
}
function lG() {
let r = GC();
return r._tfGlobals == null && (r._tfGlobals = /* @__PURE__ */new Map()), r._tfGlobals;
}
function ll(r, e) {
let t10 = lG();
if (t10.has(r)) return t10.get(r);
{
let o = e();
return t10.set(r, o), t10.get(r);
}
}
var Gs = "Abs";
var zo = "Acos";
var Vo = "Acosh";
var no = "Add";
var Wo = "AddN";
var Uo = "All";
var Go = "Any";
var Hs = "ArgMax";
var Ks = "ArgMin";
var Ho = "Asin";
var Ko = "Asinh";
var qo = "Atan";
var jo = "Atanh";
var Xo = "Atan2";
var Yo = "AvgPool";
var Gp = "AvgPoolGrad";
var qs = "AvgPool3D";
var Ni = "AvgPool3DGrad";
var Qo = "BatchMatMul";
var js = "BatchToSpaceND";
var Zo = "Bincount";
var ml = "BitwiseAnd";
var Kpe = "BroadcastTo";
var Xs = "BroadcastArgs";
var ho = "Cast";
var Jo = "Ceil";
var go = "ClipByValue";
var Ti = "Complex";
var _i = "ComplexAbs";
var Ys = "Concat";
var en = "Conv2D";
var $i = "Conv2DBackpropFilter";
var tn = "Conv2DBackpropInput";
var rn = "Conv3D";
var za = "Conv3DBackpropFilterV2";
var on = "Conv3DBackpropInputV2";
var nn = "Cos";
var sn = "Cosh";
var an = "Cumprod";
var un = "Cumsum";
var pn = "CropAndResize";
var Qs = "DenseBincount";
var cn = "DepthToSpace";
var ln = "DepthwiseConv2dNative";
var Ei = "DepthwiseConv2dNativeBackpropFilter";
var Ri = "DepthwiseConv2dNativeBackpropInput";
var Zs = "Diag";
var mn = "Dilation2D";
var Di = "Dilation2DBackpropInput";
var Ai = "Dilation2DBackpropFilter";
var dn = "RealDiv";
var Fi = "Einsum";
var fn = "Elu";
var Va = "EluGrad";
var Wa = "Erf";
var hn = "Equal";
var gn = "Exp";
var Js = "ExpandDims";
var xn = "Expm1";
var Pi = "FFT";
var ea = "Fill";
var yn = "FlipLeftRight";
var bn = "Floor";
var Cn = "FloorDiv";
var wn = "FusedBatchNorm";
var ta = "GatherV2";
var Sn = "GatherNd";
var In = "Greater";
var vn = "GreaterEqual";
var xo = "Identity";
var Oi = "IFFT";
var Mi = "Imag";
var kn = "IsFinite";
var Nn = "IsInf";
var Tn = "IsNan";
var _n = "LeakyRelu";
var $n = "Less";
var En = "LessEqual";
var Rn = "LinSpace";
var Dn = "Log";
var An = "Log1p";
var Fn = "LogicalAnd";
var Pn = "LogicalNot";
var On = "LogicalOr";
var m0 = "LogicalXor";
var qpe = "LogSoftmax";
var jpe = "LowerBound";
var Mn = "LRN";
var Ua = "LRNGrad";
var Xpe = "MatrixBandPart";
var Ln = "Max";
var Bn = "Maximum";
var zn = "MaxPool";
var Hp = "MaxPoolGrad";
var ra = "MaxPool3D";
var Li = "MaxPool3DGrad";
var Bi = "MaxPoolWithArgmax";
var Vn = "Mean";
var Wn = "Min";
var Un = "Minimum";
var Gn = "MirrorPad";
var Ga = "Mod";
var Hn = "Multinomial";
var Kn = "Multiply";
var oa = "Neg";
var qn = "NotEqual";
var jn = "NonMaxSuppressionV3";
var Ha = "NonMaxSuppressionV4";
var Xn = "NonMaxSuppressionV5";
var na = "OnesLike";
var Yn = "OneHot";
var sa = "Pack";
var Qn = "PadV2";
var Ype = "Pool";
var Zn = "Pow";
var Jn = "Prelu";
var es = "Prod";
var Kp = "RaggedGather";
var qp = "RaggedRange";
var jp = "RaggedTensorToTensor";
var aa = "Range";
var zi = "Real";
var ts = "Reciprocal";
var rs = "Relu";
var ia = "Reshape";
var os = "ResizeNearestNeighbor";
var Ka = "ResizeNearestNeighborGrad";
var ns = "ResizeBilinear";
var qa = "ResizeBilinearGrad";
var ss = "Relu6";
var as = "Reverse";
var is = "Round";
var us = "Rsqrt";
var ps = "ScatterNd";
var cs = "TensorScatterUpdate";
var ls = "SearchSorted";
var ua = "Select";
var ms = "Selu";
var pa = "Slice";
var ds = "Sin";
var ja = "Sinh";
var fs = "Sign";
var hs = "Sigmoid";
var gs = "Softplus";
var xs = "Sqrt";
var ys = "Sum";
var ca = "SpaceToBatchND";
var la = "SplitV";
var bs = "Softmax";
var Vi = "SparseFillEmptyRows";
var Xa = "SparseReshape";
var Wi = "SparseSegmentMean";
var Ui = "SparseSegmentSum";
var Cs = "SparseToDense";
var ws = "SquaredDifference";
var Gi = "Square";
var _u = "StaticRegexReplace";
var Ss = "StridedSlice";
var ma = "StringNGrams";
var Hi = "StringSplit";
var Ki = "StringToHashBucketFast";
var Is = "Sub";
var vs = "Tan";
var ks = "Tanh";
var so = "Tile";
var Ns = "TopK";
var Ts = "Transform";
var ao = "Transpose";
var qi = "Unique";
var da = "Unpack";
var ji = "UnsortedSegmentSum";
var Qpe = "UpperBound";
var fa = "ZerosLike";
var yo = "Step";
var $u = "FromPixels";
var _s = "RotateWithOffset";
var bo = "_FusedMatMul";
var Co = "FusedConv2D";
var wo = "FusedDepthwiseConv2D";
function ha(...r) {
P().getBool("IS_TEST") || P().getBool("PROD") || console.warn(...r);
}
function mG(...r) {
P().getBool("IS_TEST") || P().getBool("PROD") || console.log(...r);
}
var Xp = ll("kernelRegistry", () => /* @__PURE__ */new Map());
var dl = ll("gradRegistry", () => /* @__PURE__ */new Map());
function fl(r, e) {
let t10 = KC(r, e);
return Xp.get(t10);
}
function HC(r) {
return dl.get(r);
}
function Km(r) {
let e = Xp.entries(),
t10 = [];
for (;;) {
let {
done: o,
value: n
} = e.next();
if (o) break;
let [s, a] = n,
[i] = s.split("_");
i === r && t10.push(a);
}
return t10;
}
function Ya(r) {
let {
kernelName: e,
backendName: t10
} = r,
o = KC(e, t10);
Xp.has(o) && ha(`The kernel '${e}' for backend '${t10}' is already registered`), Xp.set(o, r);
}
function rce(r) {
let {
kernelName: e
} = r;
dl.has(e) && P().getBool("DEBUG") && ha(`Overriding the gradient for '${e}'`), dl.set(e, r);
}
function oce(r, e) {
let t10 = KC(r, e);
if (!Xp.has(t10)) throw new Error(`The kernel '${r}' for backend '${e}' is not registered`);
Xp.delete(t10);
}
function nce(r) {
if (!dl.has(r)) throw new Error(`The gradient '${r}' for backend is not registered`);
dl.delete(r);
}
function sce(r, e) {
Km(r).forEach(o => {
let n = Object.assign({}, o, {
backendName: e
});
Ya(n);
});
}
function KC(r, e) {
return `${e}_${r}`;
}
var y = {};
He(y, {
arraysEqual: () => br,
arraysEqualWithNull: () => OC,
assert: () => $,
assertNonNegativeIntegerDimensions: () => Ct,
assertNonNull: () => oo,
assertShapesMatch: () => xt,
bytesFromStringArray: () => VC,
bytesPerElement: () => Vp,
checkConversionForErrors: () => BC,
clamp: () => zp,
computeStrides: () => Us,
convertBackendValuesAndArrayBuffer: () => oG,
createScalarValue: () => bG,
createShuffledIndices: () => JU,
decodeString: () => Jp,
distSquared: () => XU,
encodeString: () => Yi,
fetch: () => wG,
fingerPrint64: () => yG,
flatten: () => Es,
getArrayFromDType: () => Hm,
getTypedArrayFromDType: () => LC,
hasEncodingLoss: () => rG,
hexToLong: () => hl,
indexToLoc: () => aG,
inferDtype: () => ki,
inferFromImplicitShape: () => tG,
isBoolean: () => i0,
isFunction: () => Ws,
isInt: () => Ba,
isNumber: () => u0,
isPromise: () => Tu,
isScalarShape: () => YU,
isString: () => Bo,
isTypedArray: () => Pt,
isValidDtype: () => zC,
locToIndex: () => sG,
makeOnesTypedArray: () => pl,
makeZerosNestedTypedArray: () => nG,
makeZerosTypedArray: () => Up,
nearestDivisor: () => Wp,
nearestLargerEven: () => KU,
now: () => Fu,
parseAxisParam: () => vi,
randUniform: () => jU,
repeatedTry: () => eG,
rightPad: () => Nu,
shuffle: () => a0,
shuffleCombo: () => HU,
sizeFromShape: () => Ue,
sizeToSquarishShape: () => ZU,
squeezeShape: () => MC,
sum: () => qU,
swap: () => Gm,
tanh: () => QU,
toNestedArray: () => ku,
toTypedArray: () => Zp
});
function qm(r) {
return r instanceof Float32Array || r instanceof Int32Array || r instanceof Uint8Array || r instanceof Uint8ClampedArray;
}
var YC = Bp(v0());
var Au = YC.default || YC;
function hl(r) {
return Au.fromString(r, true, 16);
}
var N0 = hl("c3a5c85c97cb3127");
var Du = hl("b492b66fbe98f273");
var Cr = hl("9ae16a3b2f90404f");
function XC(r) {
return r.xor(r.shru(47));
}
function T0(r, e, t10) {
let o = r.slice(e, e + t10);
return Au.fromBytes(Array.from(o), true, true);
}
function wt(r, e) {
return T0(r, e, 8);
}
function k0(r, e) {
return T0(r, e, 4);
}
function Yt(r, e) {
return e === 0 ? r : r.shru(e).or(r.shl(64 - e));
}
function Xi(r, e, t10 = hl("9ddfea08eb382d69")) {
let o = r.xor(e).mul(t10);
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;
}
function fG(r, e, t10, o, n, s) {
n = n.add(r), s = Yt(s.add(n).add(o), 21);
let a = n;
return n = n.add(e), n = n.add(t10), s = s.add(Yt(n, 44)), [n.add(o), s.add(a)];
}
function Xm(r, e, t10, o) {
return fG(wt(r, e), wt(r, e + 8), wt(r, e + 16), wt(r, e + 24), t10, o);
}
function hG(r, e = r.length) {
if (e >= 8) {
let t10 = Cr.add(e * 2),
o = wt(r, 0).add(Cr),
n = wt(r, e - 8),
s = Yt(n, 37).mul(t10).add(o),
a = Yt(o, 25).add(n).mul(t10);
return Xi(s, a, t10);
}
if (e >= 4) {
let t10 = Cr.add(e * 2),
o = k0(r, 0);
return Xi(o.shl(3).add(e), k0(r, e - 4), t10);
}
if (e > 0) {
let t10 = r[0],
o = r[e >> 1],
n = r[e - 1],
s = t10 + (o << 8),
a = e + (n << 2);
return XC(Cr.mul(s).xor(N0.mul(a))).mul(Cr);
}
return Cr;
}
function gG(r, e = r.length) {
let t10 = Cr.add(e * 2),
o = wt(r, 0).mul(Du),
n = wt(r, 8),
s = wt(r, e - 8).mul(t10),
a = wt(r, e - 16).mul(Cr);
return Xi(Yt(o.add(n), 43).add(Yt(s, 30)).add(a), o.add(Yt(n.add(Cr), 18)).add(s), t10);
}
function xG(r, e = r.length) {
let t10 = Cr.add(e * 2),
o = wt(r, 0).mul(Cr),
n = wt(r, 8),
s = wt(r, e - 8).mul(t10),
a = wt(r, e - 16).mul(Cr),
i = Yt(o.add(n), 43).add(Yt(s, 30)).add(a),
p = Xi(i, o.add(Yt(n.add(Cr), 18)).add(s), t10),
u = wt(r, 16).mul(t10),
c = wt(r, 24),
l = i.add(wt(r, e - 32)).mul(t10),
m = p.add(wt(r, e - 24)).mul(t10);
return Xi(Yt(u.add(c), 43).add(Yt(l, 30)).add(m), u.add(Yt(c.add(o), 18)).add(l), t10);
}
function yG(r, e = r.length) {
let t10 = Au.fromNumber(81, true);
if (e <= 32) return e <= 16 ? hG(r, e) : gG(r, e);
if (e <= 64) return xG(r, e);
let o = t10,
n = t10.mul(Du).add(113),
s = XC(n.mul(Cr).add(113)).mul(Cr),
a = [Au.UZERO, Au.UZERO],
i = [Au.UZERO, Au.UZERO];
o = o.mul(Cr).add(wt(r, 0));
let p = 0,
u = (e - 1 >> 6) * 64,
c = u + (e - 1 & 63) - 63;
do o = Yt(o.add(n).add(a[0]).add(wt(r, p + 8)), 37).mul(Du), n = Yt(n.add(a[1]).add(wt(r, p + 48)), 42).mul(Du), o = o.xor(i[1]), n = n.add(a[0]).add(wt(r, p + 40)), s = Yt(s.add(i[0]), 33).mul(Du), a = Xm(r, p, a[1].mul(Du), o.add(i[0])), i = Xm(r, p + 32, s.add(i[1]), n.add(wt(r, p + 16))), [s, o] = [o, s], p += 64; while (p !== u);
let l = Du.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 = Yt(o.add(n).add(a[0]).add(wt(r, p + 8)), 37).mul(l), n = Yt(n.add(a[1]).add(wt(r, p + 48)), 42).mul(l), o = o.xor(i[1].mul(9)), n = n.add(a[0].mul(9).add(wt(r, p + 40))), s = Yt(s.add(i[0]), 33).mul(l), a = Xm(r, p, a[1].mul(l), o.add(i[0])), i = Xm(r, p + 32, s.add(i[1]), n.add(wt(r, p + 16))), [s, o] = [o, s], Xi(Xi(a[0], i[0], l).add(XC(n).mul(N0)).add(s), Xi(a[1], i[1], l).add(o), l);
}
function bG(r, e) {
return e === "string" ? Yi(r) : Zp([r], e);
}
function CG(r, e) {
return r instanceof Float32Array && e === "float32" || r instanceof Int32Array && e === "int32" || r instanceof Uint8Array && e === "bool";
}
function Zp(r, e) {
if (e === "string") throw new Error("Cannot convert a string[] to a TypedArray");
if (Array.isArray(r) && (r = Es(r)), P().getBool("DEBUG") && BC(r, e), CG(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;
} else throw new Error(`Unknown data type ${e}`);
}
function Fu() {
return P().platform.now();
}
function wG(r, e) {
return P().platform.fetch(r, e);
}
function Yi(r, e = "utf-8") {
return e = e || "utf-8", P().platform.encode(r, e);
}
function Jp(r, e = "utf-8") {
return e = e || "utf-8", P().platform.decode(r, e);
}
function Pt(r) {
return P().platform.isTypedArray != null ? P().platform.isTypedArray(r) : qm(r);
}
function Es(r, e = [], t10 = false) {
if (e == null && (e = []), typeof r == "boolean" || typeof r == "number" || typeof r == "string" || Tu(r) || r == null || Pt(r) && t10) e.push(r);else if (Array.isArray(r) || Pt(r)) for (let o = 0; o < r.length; ++o) Es(r[o], e, t10);else {
let o = -1;
for (let n of Object.keys(r)) /^([1-9]+[0-9]*|0)$/.test(n) && (o = Math.max(o, Number(n)));
for (let n = 0; n <= o; n++) Es(r[n], e, t10);
}
return e;
}
var Ym = class {
constructor(e, t10) {
this.backendTimer = e, this.logger = t10, t10 == null && (this.logger = new QC());
}
profileKernel(e, t10, o) {
let n,
s = () => {
n = o();
},
a,
i = Fu();
if (this.backendTimer.timerAvailable()) a = this.backendTimer.time(s);else {
s();
for (let u of n) u.dataSync();
a = Promise.resolve({
kernelMs: Fu() - i
});
}
if (P().getBool("CHECK_COMPUTATION_FOR_ERRORS")) for (let u = 0; u < n.length; u++) {
let c = n[u];
c.data().then(l => {
SG(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() : "")
};
}
logKernelProfile(e) {
let {
kernelName: t10,
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]);
});
});
}
};
function SG(r, e, t10) {
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 false;
}
var QC = class {
logKernelProfile(e, t10, o, n, s, a) {
let i = typeof n == "number" ? Nu(`${n}ms`, 9) : n.error,
p = Nu(e, 25),
u = t10.rank,
c = t10.size,
l = Nu(t10.shape.toString(), 14),
m = "";
for (let d in s) {
let f = s[d];
if (f != null) {
let h = f.shape || t10.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 _0(r, e, t10) {
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],
d = false;
for (let f = 0; f < e.length; f++) if (o[m.id]) {
u.outputs.forEach(h => o[h.id] = true), d = true, n[u.id] = true;
break;
}
if (d) break;
}
}
let s = {};
s[t10.id] = true;
let a = {};
for (let p = r.length - 1; p >= 0; p--) {
let u = r[p],
c = u.inputs;
for (let l = 0; l < u.outputs.length; l++) if (s[u.outputs[l].id]) {
for (let m in c) s[c[m].id] = true, a[u.id] = true;
break;
}
}
let i = [];
for (let p = 0; p < r.length; p++) {
let u = r[p];
if (n[u.id] && a[u.id]) {
let c = {};
for (let m in u.inputs) {
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);
}
}
return i;
}
function $0(r, e, t10, o) {
for (let n = e.length - 1; n >= 0; n--) {
let s = e[n],
a = [];
if (s.outputs.forEach(p => {
let u = r[p.id];
u != null ? a.push(u) : a.push(null);
}), s.gradient == null) throw new Error(`Cannot compute gradient: gradient function not found for ${s.kernelName}.`);
let i = s.gradient(a);
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]());
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 (!br(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;else {
let l = r[c.id];
r[c.id] = o(l, u), l.dispose();
}
}
}
}
var E0 = 20;
var gl = 3;
var ZC = 7;
function R0(r, e, t10, o) {
let n = Us(e),
s = IG(r, e, t10, n),
a = e.length,
i = Qm(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(`
`)), p.join(`
`);
}
function IG(r, e, t10, o) {
let n = Ue(e),
s = o[o.length - 1],
a = new Array(s).fill(0),
i = e.length,
p = t10 === "complex64" ? yl(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], xl(p[c + l], 0, t10).length);
}
return a;
}
function xl(r, e, t10) {
let o;
return Array.isArray(r) ? o = `${parseFloat(r[0].toFixed(ZC))} + ${parseFloat(r[1].toFixed(ZC))}j` : Bo(r) ? o = `'${r}'` : t10 === "bool" ? o = D0(r) : o = parseFloat(r.toFixed(ZC)).toString(), Nu(o, e);
}
function D0(r) {
return r === 0 ? "false" : "true";
}
function Qm(r, e, t10, o, n, s = true) {
let a = t10 === "complex64" ? 2 : 1,
i = e[0],
p = e.length;
if (p === 0) {
if (t10 === "complex64") {
let h = yl(r);
return [xl(h[0], 0, t10)];
}
return t10 === "bool" ? [D0(r[0])] : [r[0].toString()];
}
if (p === 1) {
if (i > E0) {
let g = gl * a,
x = Array.from(r.slice(0, g)),
b = Array.from(r.slice((i - gl) * a, i * a));
return t10 === "complex64" && (x = yl(x), b = yl(b)), ["[" + x.map((w, S) => xl(w, n[S], t10)).join(", ") + ", ..., " + b.map((w, S) => xl(w, n[i - gl + S], t10)).join(", ") + "]"];
}
return ["[" + (t10 === "complex64" ? yl(r) : Array.from(r)).map((g, x) => xl(g, n[x], t10)).join(", ") + "]"];
}
let u = e.slice(1),
c = o.slice(1),
l = o[0] * a,
m = [];
if (i > E0) {
for (let h = 0; h < gl; h++) {
let g = h * l,
x = g + l;
m.push(...Qm(r.slice(g, x), u, t10, c, n, false));
}
m.push("...");
for (let h = i - gl; h < i; h++) {
let g = h * l,
x = g + l;
m.push(...Qm(r.slice(g, x), u, t10, c, n, h === i - 1));
}
} else for (let h = 0; h < i; h++) {
let g = h * l,
x = g + l;
m.push(...Qm(r.slice(g, x), u, t10, c, n, h === i - 1));
}
let d = p === 2 ? "," : "";
m[0] = "[" + (i > 0 ? m[0] + d : "");
for (let h = 1; h < m.length - 1; h++) m[h] = " " + m[h] + d;
let f = `,
`;
for (let h = 2; h < p; h++) f += `
`;
return m[m.length - 1] = " " + m[m.length - 1] + "]" + (s ? "" : f), m;
}
function yl(r) {
let e = [];
for (let t10 = 0; t10 < r.length; t10 += 2) e.push([r[t10], r[t10 + 1]]);
return e;
}
var tt = class {
constructor(e, t10, o) {
if (this.dtype = t10, this.shape = e.slice(), this.size = Ue(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}'.`);
}
if (t10 === "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 || Hm(t10, this.size), this.strides = Us(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);
this.values[o] = e;
}
get(...e) {
e.length === 0 && (e = [0]);
let t10 = 0;
for (let n of e) {
if (n < 0 || n >= this.shape[t10]) {
let s = `Requested out of range element at ${e}. Buffer shape=${this.shape}`;
throw new Error(s);
}
t10++;
}
let o = e[e.length - 1];
for (let n = 0; n < e.length - 1; ++n) o += this.strides[n] * e[n];
return this.values[o];
}
locToIndex(e) {
if (this.rank === 0) return 0;
if (this.rank === 1) return e[0];
let t10 = e[e.length - 1];
for (let o = 0; o < e.length - 1; ++o) t10 += this.strides[o] * e[o];
return t10;
}
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;
}
get rank() {
return this.shape.length;
}
toTensor() {
return Rs().makeTensor(this.values, this.shape, this.dtype);
}
};
var Rs = null;
var ec = null;
var vG = null;
function A0(r) {
Rs = r;
}
function F0(r) {
ec = r;
}
function P0(r) {
vG = r;
}
var pt = class {
constructor(e, t10, o, n) {
this.kept = false, this.isDisposedInternal = false, this.shape = e.slice(), this.dtype = t10 || "float32", this.size = Ue(e), this.strides = Us(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 ec.buffer(this.shape, this.dtype, e);
}
bufferSync() {
return ec.buffer(this.shape, this.dtype, this.dataSync());
}
async array() {
let e = await this.data();
return ku(this.shape, e, this.dtype === "complex64");
}
arraySync() {
return ku(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;
try {
return t10.map(o => Jp(o));
} catch (o) {
throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().");
}
}
return e;
}
dataToGPU(e) {
return this.throwIfDisposed(), Rs().readToGPU(this.dataId, e);
}
dataSync() {
this.throwIfDisposed();
let e = Rs().readSync(this.dataId);
if (this.dtype === "string") try {
return e.map(t10 => Jp(t10));
} catch (t10) {
throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().");
}
return e;
}
async bytes() {
this.throwIfDisposed();
let e = await Rs().read(this.dataId);
return this.dtype === "string" ? e : new Uint8Array(e.buffer);
}
dispose() {
this.isDisposed || (Rs().disposeTensor(this), this.isDisposedInternal = true);
}
get isDisposed() {
return this.isDisposedInternal;
}
throwIfDisposed() {
if (this.isDisposed) throw new Error("Tensor is disposed.");
}
print(e = false) {
return ec.print(this, e);
}
clone() {
return this.throwIfDisposed(), ec.clone(this);
}
toString(e = false) {
let t10 = this.dataSync();
return R0(t10, this.shape, this.dtype, e);
}
cast(e) {
return this.throwIfDisposed(), ec.cast(this, e);
}
variable(e = true, t10, o) {
return this.throwIfDisposed(), Rs().makeVariable(this, e, t10, o);
}
};
Object.defineProperty(pt, Symbol.hasInstance, {
value: r => !!r && r.data != null && r.dataSync != null && r.throwIfDisposed != null
});
function kG() {
return ll("Tensor", () => pt);
}
kG();
var Qa = class extends pt {
constructor(e, t10, o, n) {
super(e.shape, e.dtype, e.dataId, n), this.trainable = t10, 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 (!br(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);
}
dispose() {
Rs().disposeVariable(this), this.isDisposedInternal = true;
}
};
Object.defineProperty(Qa, Symbol.hasInstance, {
value: r => r instanceof pt && r.assign != null && r.assign instanceof Function
});
var M0 = {};
He(M0, {
assertTypesMatch: () => nw,
getTensorsInContainer: () => bl,
isTensorInList: () => TG,
makeTypesMatch: () => Oe
});
var JC;
(function (r) {
r.R0 = "R0", r.R1 = "R1", r.R2 = "R2", r.R3 = "R3", r.R4 = "R4", r.R5 = "R5", r.R6 = "R6";
})(JC || (JC = {}));
var ew;
(function (r) {
r.float32 = "float32", r.int32 = "int32", r.bool = "int32", r.complex64 = "complex64";
})(ew || (ew = {}));
var tw;
(function (r) {
r.float32 = "float32", r.int32 = "int32", r.bool = "bool", r.complex64 = "complex64";
})(tw || (tw = {}));
var rw;
(function (r) {
r.float32 = "float32", r.int32 = "float32", r.bool = "float32", r.complex64 = "complex64";
})(rw || (rw = {}));
var ow;
(function (r) {
r.float32 = "complex64", r.int32 = "complex64", r.bool = "complex64", r.complex64 = "complex64";
})(ow || (ow = {}));
var NG = {
float32: rw,
int32: ew,
bool: tw,
complex64: ow
};
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 NG[r][e];
}
function Za(r) {
return dt(r, "int32");
}
function Zm(r) {
return r != null && typeof r == "object" && "texture" in r && r.texture instanceof WebGLTexture;
}
function Jm(r) {
return typeof GPUBuffer != "undefined" && r != null && typeof r == "object" && "buffer" in r && r.buffer instanceof GPUBuffer;
}
function Oe(r, e) {
if (r.dtype === e.dtype) return [r, e];
let t10 = dt(r.dtype, e.dtype);
return [r.cast(t10), e.cast(t10)];
}
function nw(r, e) {
$(r.dtype === e.dtype, () => `The dtypes of the first(${r.dtype}) and second(${e.dtype}) input must match`);
}
function TG(r, e) {
return e.some(t10 => t10.id === r.id);
}
function bl(r) {
let e = [];
return O0(r, e, /* @__PURE__ */new Set()), e;
}
function O0(r, e, t10) {
if (r == null) return;
if (r instanceof pt) {
e.push(r);
return;
}
if (!_G(r)) return;
let o = r;
for (let n in o) {
let s = o[n];
t10.has(s) || (t10.add(s), O0(s, e, t10));
}
}
function _G(r) {
return Array.isArray(r) || typeof r == "object";
}
function sw(r) {
return r.kernelName != null;
}
var ed = 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)));
}
};
}
dispose() {
for (let e in this.registeredVariables) this.registeredVariables[e].dispose();
}
};
var Qi = class {
constructor(e) {
this.ENV = e, this.registry = {}, this.registryFactory = {}, this.pendingBackendInitId = 0, this.state = new ed();
}
async ready() {
if (this.pendingBackendInit != null) return this.pendingBackendInit.then(() => {});
if (this.backendInstance != null) return;
let e = this.getSortedBackends();
for (let t10 = 0; t10 < e.length; t10++) {
let o = e[t10];
if (await this.initializeBackend(o).success) {
await this.setBackend(o);
return;
}
}
throw new Error("Could not initialize any backends, all backend initializations failed.");
}
get backend() {
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) 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);
}
return this.backendInstance;
}
backendNames() {
return Object.keys(this.registryFactory);
}
findBackend(e) {
if (!(e in this.registry)) if (e in this.registryFactory) {
let {
asyncInit: t10
} = this.initializeBackend(e);
if (t10) return null;
} else return null;
return this.registry[e];
}
findBackendFactory(e) {
return e in this.registryFactory ? this.registryFactory[e].factory : null;
}
registerBackend(e, t10, o = 1) {
return e in this.registryFactory ? (ha(`${e} backend was already registered. Reusing existing backend factory.`), false) : (this.registryFactory[e] = {
factory: t10,
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)) return false;
}
return this.backendInstance = this.registry[e], this.setupRegisteredKernels(), this.profiler = new Ym(this.backendInstance), true;
}
setupRegisteredKernels() {
Km(this.backendName).forEach(t10 => {
t10.setupFunc != null && t10.setupFunc(this.backendInstance);
});
}
disposeRegisteredKernels(e) {
Km(e).forEach(o => {
o.disposeFunc != null && o.disposeFunc(this.registry[e]);
});
}
initializeBackend(e) {
let t10 = this.registryFactory[e];
if (t10 == null) throw new Error(`Cannot initialize backend ${e}, no registration found.`);
try {
let o = t10.factory();
if (o && !(o instanceof ro) && 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, ha(`Initialization of backend ${e} failed`), ha(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 ha(`Initialization of backend ${e} failed`), ha(o.stack || o.message), {
success: false,
asyncInit: false
};
}
}
removeBackend(e) {
if (!(e in this.registryFactory)) throw new Error(`${e} backend not found in registry`);
this.backendName === e && this.pendingBackendInit != null && this.pendingBackendInitId++, e in this.registry && (this.disposeRegisteredKernels(e), this.registry[e].dispose(), delete this.registry[e]), delete this.registryFactory[e], this.backendName === e && (this.pendingBackendInit = null, this.backendName = null, this.backendInstance = null);
}
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);
}
initializeBackendsAndReturnBest() {
let e = this.getSortedBackends();
for (let t10 = 0; t10 < e.length; t10++) {
let o = e[t10],
{
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]++;
}
tidy(e, t10) {
let o = null;
if (t10 == null) {
if (typeof e != "function") throw new Error("Please provide a function to tidy()");
t10 = 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") 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));
}
scopedRun(e, t10, o) {
e();
try {
let n = o();
return t10(), n;
} catch (n) {
throw t10(), n;
}
}
nextTensorId() {
return Qi.nextTensorId++;
}
nextVariableId() {
return Qi.nextVariableId++;
}
clone(e) {
let t10 = T.runKernel(xo, {
x: e
}),
o = {
x: e
},
n = a => ({
x: () => {
let i = "float32",
p = {
x: a
},
u = {
dtype: i
};
return T.runKernel(ho, p, u);
}
}),
s = [];
return this.addTapeNode(this.state.activeScope.name, o, [t10], n, s, {}), t10;
}
runKernel(e, t10, o) {
if (this.backendName == null && this.backend, !(fl(e, this.backendName) != null)) throw new Error(`Kernel '${e}' not registered for backend '${this.backendName}'`);
return this.runKernelFunc({
kernelName: e,
inputs: t10,
attrs: o
});
}
shouldCheckForMemLeaks() {
return this.ENV.getBool("IS_TEST");
}
checkKernelForMemLeak(e, t10, 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;
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;
this.shouldCheckForMemLeaks() && this.state.numDataMovesStack.push(0);
let i;
this.backendName == null && this.backend;
let p,
u = sw(e) ? e.kernelName : this.state.activeScope != null ? this.state.activeScope.name : "";
if (sw(e)) {
let {
kernelName: f,
inputs: h,
attrs: g
} = e;
this.backendName == null && this.backend;
let x = fl(f, this.backendName);
$(x != null, () => `Cannot find registered kernel '${f}' for backend '${this.backendName}'`), i = () => {
let b = this.backend.numDataIds();
p = x.kernelFunc({
inputs: h,
attrs: g,
backend: this.backend
});
let w = Array.isArray(p) ? p : [p];
this.shouldCheckForMemLeaks() && this.checkKernelForMemLeak(f, b, w);
let S = w.map(k => k.rank != null ? k : this.makeTensorFromTensorInfo(k));
if (n) {
let k = this.getTensorsForGradient(f, h, S);
o = this.saveTensorsForBackwardMode(k);
}
return S;
};
} else {
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(() => 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 = sw(e) ? null : e.backwardsFunc,
d;
return this.scopedRun(() => this.state.kernelDepth++, () => this.state.kernelDepth--, () => {
!this.ENV.getBool("DEBUG") && !this.state.profiling ? t10 = i() : (d = this.profiler.profileKernel(u, c, () => i()), this.ENV.getBool("DEBUG") && this.profiler.logKernelProfile(d), t10 = d.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(f => c[f] != null ? c[f].shape : null),
outputShapes: t10.map(f => f.shape),
kernelTimeMs: d.timeMs,
extraInfo: d.extraInfo
}), Array.isArray(p) ? t10 : t10[0];
}
saveTensorsForBackwardMode(e) {
return e.map(o => this.keep(this.clone(o)));
}
getTensorsForGradient(e, t10, o) {
let n = HC(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]);
let p = o.filter((u, c) => a[c]);
return i.concat(p);
}
return [];
}
makeTensor(e, t10, 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" && Bo(e[0]) && (s = e.map(p => Yi(p)));
let a = n.write(s, t10, o),
i = new pt(t10, o, a, this.nextTensorId());
if (this.trackTensor(i, n), o === "string") {
let p = this.state.tensorInfo.get(a),
u = VC(s);
this.state.numBytes += u - p.bytes, p.bytes = u;
}
return i;
}
makeTensorFromDataId(e, t10, o, n) {
o = o || "float32";
let s = {
dataId: e,
shape: t10,
dtype: o
};
return this.makeTensorFromTensorInfo(s, n);
}
makeTensorFromTensorInfo(e, t10) {
let {
dataId: o,
shape: n,
dtype: s
} = e,
a = new pt(n, s, o, this.nextTensorId());
return this.trackTensor(a, t10), a;
}
makeVariable(e, t10 = true, o, n) {
o = o || this.nextVariableId().toString(), n != null && n !== e.dtype && (e = e.cast(n));
let s = new Qa(e, t10, 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) {
this.state.numTensors++, e.dtype === "string" && this.state.numStringTensors++;
let o = 0;
e.dtype !== "complex64" && e.dtype !== "string" && (o = e.size * Vp(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 Qa || this.track(e);
}
incRef(e, t10) {
this.trackTensor(e, t10), 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--);
}
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 * Vp(e.dtype);
this.state.numBytes -= o;
}
t10.backend.disposeData(e.dataId) && this.removeDataId(e.dataId, t10.backend);
}
disposeVariables() {
for (let e in this.state.registeredVariables) {
let t10 = this.state.registeredVariables[e];
this.disposeVariable(t10);
}
}
disposeVariable(e) {
this.disposeTensor(e), this.state.registeredVariables[e.name] != null && delete this.state.registeredVariables[e.name];
}
memory() {
let e = this.backend.memory();
return e.numTensors = this.state.numTensors, e.numDataBuffers = this.state.numDataBuffers, e.numBytes = this.state.numBytes, this.state.numStringTensors > 0 && (e.unreliable = true, e.reasons == null && (e.reasons = []), e.reasons.push("Memory usage by string tensors is approximate (2 bytes per character)")), e;
}
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;
for (let n of this.state.activeProfile.kernels) n.kernelTimeMs = await n.kernelTimeMs, n.extraInfo = await n.extraInfo;
return this.state.activeProfile;
}
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 = HC(e);
p != null && (n = p.gradFunc), n != null && (i.gradient = u => (u = u.map((c, l) => {
if (c == null) {
let m = o[l],
d = Up(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);
}
keep(e) {
return e.kept = true, e;
}
startTape() {
this.state.gradientDepth === 0 && (this.state.activeTape = []), this.state.gradientDepth++;
}
endTape() {
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;
}
endScope(e) {
let t10 = bl(e),
o = new Set(t10.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 => {
!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") 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 pt, () => "The result y returned by f() must be a tensor.");
let a = _0(this.state.activeTape, t10, s);
if (!n && a.length === 0 && t10.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 ? $G(s.shape) : o, $0(i, a, u => this.tidy(u), EG);
let p = t10.map(u => i[u.id]);
return this.state.gradientDepth === 0 && (this.state.activeTape.forEach(u => {
for (let c of u.saved) c.dispose();
}), this.state.activeTape = null), {
value: s,
grads: p
};
});
}
customGrad(e) {
return $(Ws(e), () => "The f passed in customGrad(f) must be a function."), (...t10) => {
$(t10.every(i => i instanceof pt), () => "The args passed in customGrad(f)(x1, x2,...) must all be tensors");
let o,
n = {};
t10.forEach((i, p) => {
n[p] = i;
});
let s = (i, p) => (o = e(...t10, p), $(o.value instanceof pt, () => "The function f passed in customGrad(f) must return an object where `obj.value` is a tensor"), $(Ws(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 pt), () => "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, d) => {
l[d] = () => m;
}), l;
};
return this.runKernelFunc({
forwardFunc: s,
backwardsFunc: a,
inputs: n
});
};
}
readSync(e) {
return this.state.tensorInfo.get(e).backend.readSync(e);
}
read(e) {
return this.state.tensorInfo.get(e).backend.read(e);
}
readToGPU(e, t10) {
return this.state.tensorInfo.get(e).backend.readToGPU(e, t10);
}
async time(e) {
let t10 = Fu(),
o = await this.backend.time(e);
return o.wallMs = Fu() - t10, o;
}
track(e) {
return this.state.activeScope != null && (e.scopeId = this.state.activeScope.id, this.state.activeScope.track.push(e)), e;
}
get registeredVariables() {
return this.state.registeredVariables;
}
reset() {
this.pendingBackendInitId++, this.state.dispose(), this.ENV.reset(), this.state = new ed();
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;
}
};
Qi.nextTensorId = 0;
Qi.nextVariableId = 0;
function $G(r) {
let e = pl(Ue(r), "float32");
return T.makeTensor(e, r, "float32");
}
function aw() {
let r = GC();
if (r._tfengine == null) {
let e = new cl(r);
r._tfengine = new Qi(e);
}
return l0(r._tfengine.ENV), A0(() => r._tfengine), r._tfengine;
}
var T = aw();
function EG(r, e) {
let t10 = {
a: r,
b: e
};
return T.runKernel(no, t10);
}
var Zi = {};
He(Zi, {
isBrowser: () => uw,
isMobile: () => AG,
mockIsMobile: () => DG
});
function RG() {
return typeof navigator != "undefined" && navigator != null;
}
var iw;
function DG(r) {
iw = r;
}
function AG(r) {
if (iw !== void 0) return iw;
if (r || RG()) {
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;
}
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 uw() {
return typeof window != "undefined" && window.document != null || typeof WorkerGlobalScope != "undefined";
}
var _r = P();
_r.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.");
});
_r.registerFlag("IS_BROWSER", () => uw());
_r.registerFlag("IS_NODE", () => typeof process != "undefined" && typeof process.versions != "undefined" && typeof process.versions.node != "undefined");
_r.registerFlag("IS_CHROME", () => typeof navigator != "undefined" && navigator != null && navigator.userAgent != null && /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor));
_r.registerFlag("IS_SAFARI", () => typeof navigator != "undefined" && navigator != null && navigator.userAgent != null && /Safari/.test(navigator.userAgent) && /Apple/.test(navigator.vendor));
_r.registerFlag("PROD", () => false);
_r.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY", () => _r.getBool("DEBUG"));
_r.registerFlag("DEPRECATION_WARNINGS_ENABLED", () => true);
_r.registerFlag("IS_TEST", () => false);
_r.registerFlag("CHECK_COMPUTATION_FOR_ERRORS", () => _r.getBool("DEBUG"));
_r.registerFlag("WRAP_TO_IMAGEBITMAP", () => false);
_r.registerFlag("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU", () => false);
_r.registerFlag("USE_SETTIMEOUTCUSTOM", () => false);
function ar(r, e) {
let t10 = r;
if (Pt(r)) return e === "string" ? [] : [r.length];
if (Zm(r)) {
let n = r.channels || "RGBA";
return [r.height, r.width * n.length];
} else if (Jm(r)) return [r.buffer.size / (e == null ? 4 : Vp(e))];
if (!Array.isArray(r)) return [];
let o = [];
for (; Array.isArray(t10) || Pt(t10) && e !== "string";) o.push(t10.length), t10 = t10[0];
return Array.isArray(r) && P().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY") && B0(r, o, []), o;
}
function B0(r, e, t10) {
if (t10 = t10 || [], !Array.isArray(r) && !Pt(r)) {
$(e.length === 0, () => `Element arr[${t10.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`);
let o = e.slice(1);
for (let n = 0; n < r.length; ++n) B0(r[n], o, t10.concat(n));
}
function L0(r, e, t10, 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`);
}
}
function v(r, e, t10, o = "numeric") {
if (r instanceof pt) return L0(o, r.dtype, e, t10), r;
let n = ki(r);
if (n !== "string" && ["bool", "int32", "float32"].indexOf(o) >= 0 && (n = o), L0(o, n, e, t10), r == null || !Pt(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}'`);
}
let s = ar(r, n);
!Pt(r) && !Array.isArray(r) && (r = [r]);
let i = n !== "string" ? Zp(r, n) : Es(r, [], true);
return T.makeTensor(i, s, n);
}
function Ja(r, e, t10, 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));
}
var pw = "__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 + pw;
let n = (...s) => {
T.startScope(t10);
try {
let a = o(...s);
return Tu(a) && console.error("Cannot return a Promise inside of tidy."), T.endScope(a), a;
} catch (a) {
throw T.endScope(null), a;
}
};
return Object.defineProperty(n, "name", {
value: t10,
configurable: true
}), n;
}
function FG(r, e) {
let t10 = v(r, "real", "complex"),
o = v(e, "imag", "complex");
xt(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 T.runKernel(Ti, n);
}
var $r = N({
complex_: FG
});
function wr(r, e, t10, o) {
if (o == null) o = ki(r);else if (o === "complex64") throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");
if (Jm(r) || Zm(r)) {
if (o !== "float32" && o !== "int32") throw new Error(`Creating tensor from GPU data only supports 'float32'|'int32' dtype, while the dtype is ${o}.`);
return T.backend.createTensorFromGPUData(r, e || t10, o);
}
if (!Pt(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) {
Ct(e);
let n = Ue(e),
s = Ue(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 !== Ue(e.slice(a)) : true;
$(t10[a] === e[a] || !p, () => `Error creating a new Tensor. Inferred shape (${t10}) does not match the provided shape (${e}). `);
}
}
return !Pt(r) && !Array.isArray(r) && (r = [r]), e = e || t10, r = o !== "string" ? Zp(r, o) : Es(r, [], true), T.makeTensor(r, e, o);
}
function ir(r, e, t10) {
let o = ar(r, t10);
return wr(r, e, o, t10);
}
var Cl = {
float32: 4,
float16: 2,
int32: 4,
uint16: 2,
uint8: 1,
bool: 1,
complex64: 8
};
var td = 4;
async function V0(r, e) {
let t10 = [],
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") throw new Error(`Unsupported dtype in weight '${i}': ${p.dtype}`);
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(),
d = m.reduce((g, x) => g + x.length, 0) + td * m.length,
f = new Uint8Array(d),
h = 0;
for (let g = 0; g < m.length; g++) {
let x = m[g],
b = new Uint8Array(new Uint32Array([x.length]).buffer);
f.set(b, h), h += td, f.set(x, h), h += x.length;
}
l(f);
});
o.push(c);
} else o.push(p.data());
e != null && (u.group = e), t10.push(u);
}
let s = await Promise.all(o);
return {
data: PG(s),
specs: t10
};
}
function rd(r, e) {
let t10 = {},
o,
n = 0;
for (let s of e) {
let a = s.name,
i = s.dtype,
p = s.shape,
u = Ue(p),
c;
if ("quantization" in s) {
let l = s.quantization;
if (l.dtype === "uint8" || l.dtype === "uint16") {
if (!("min" in l && "scale" in l)) throw new Error(`Weight ${s.name} with quantization ${l.dtype} doesn't have corresponding metadata min and scale.`);
} else if (l.dtype === "float16") {
if (i !== "float32") 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 = Cl[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(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 = BG()), 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(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 = Ue(s.shape);
c = [];
for (let m = 0; m < l; m++) {
let d = new Uint32Array(r.slice(n, n + td))[0];
n += td;
let f = new Uint8Array(r.slice(n, n + d));
c.push(f), n += d;
}
} else {
let l = Cl[i],
m = r.slice(n, n + u * l);
if (i === "float32") c = new Float32Array(m);else if (i === "int32") c = new Int32Array(m);else if (i === "bool") c = new Uint8Array(m);else if (i === "complex64") {
c = new Float32Array(m);
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 = ir(d, p, "float32"),
g = ir(f, p, "float32");
t10[a] = $r(h, g), h.dispose(), g.dispose();
} else throw new Error(`Unsupported dtype in weight '${a}': ${i}`);
n += u * l;
}
i !== "complex64" && (t10[a] = ir(c, p, i));
}
return t10;
}
function PG(r) {
if (r === null) throw new Error(`Invalid input value: ${JSON.stringify(r)}`);
let e = 0,
t10 = [];
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)) throw new Error(`Unsupported TypedArray subtype: ${s.constructor.name}`);
});
let o = new Uint8Array(e),
n = 0;
return t10.forEach(s => {
o.set(new Uint8Array(s.buffer), n), n += s.byteLength;
}), o.buffer;
}
var cw = typeof Buffer != "undefined" && (typeof Blob == "undefined" || typeof atob == "undefined" || typeof btoa == "undefined");
function z0(r) {
return cw ? Buffer.byteLength(r) : new Blob([r]).size;
}
function W0(r) {
if (cw) return Buffer.from(r).toString("base64");
let e = new Uint8Array(r),
t10 = "";
for (let o = 0, n = e.length; o < n; o++) t10 += String.fromCharCode(e[o]);
return btoa(t10);
}
function U0(r) {
if (cw) {
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);
for (let o = 0; o < e.length; ++o) t10.set([e.charCodeAt(o)], o);
return t10.buffer;
}
function tc(r) {
if (r.length === 1) return r[0];
let e = 0;
r.forEach(n => {
e += n.byteLength;
});
let t10 = new Uint8Array(e),
o = 0;
return r.forEach(n => {
t10.set(new Uint8Array(n), o), o += n.byteLength;
}), t10.buffer;
}
function lw(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];
}
function od(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 mw(r, e, t10) {
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) throw new Error("modelJSON has weightsManifest but weightData is null");
o.weightSpecs = e, o.weightData = t10;
}
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 rc(r, e) {
let t10, o;
return r.weightsManifest != null && ([t10, o] = await e(r.weightsManifest)), mw(r, t10, o);
}
function ga(r) {
if (r.modelTopology instanceof ArrayBuffer) throw new Error("Expected JSON model topology, received ArrayBuffer.");
return {
dateSaved: /* @__PURE__ */new Date(),
modelTopologyType: "JSON",
modelTopologyBytes: r.modelTopology == null ? 0 : z0(JSON.stringify(r.modelTopology)),
weightSpecsBytes: r.weightSpecs == null ? 0 : z0(JSON.stringify(r.weightSpecs)),
weightDataBytes: r.weightData == null ? 0 : r.weightData.byteLength
};
}
function nd(r) {
let e = [];
for (let t10 of r) e.push(...t10.weights);
return e;
}
function OG() {
let r = t10 => {
let o = t10 << 13,
n = 0;
for (; !(o & 8388608);) 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);
return e;
}
function MG() {
let r = new Uint32Array(64);
r[0] = 0, r[31] = 1199570944, r[32] = 2147483648, r[63] = 3347054592;
for (let e = 1; e < 31; e++) r[e] = e << 23;
for (let e = 33; e < 63; e++) r[e] = 2147483648 + (e - 32 << 23);
return r;
}
function LG() {
let r = new Uint32Array(64);
for (let e = 0; e < 64; e++) r[e] = 1024;
return r[0] = r[32] = 0, r;
}
function BG() {
let r = OG(),
e = MG(),
t10 = LG();
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];
s[a] = p;
}
return new Float32Array(n);
};
}
var ft = class {
constructor() {
this.saveRouters = [], this.loadRouters = [];
}
static getInstance() {
return ft.instance == null && (ft.instance = new ft()), ft.instance;
}
static registerSaveRouter(e) {
ft.getInstance().saveRouters.push(e);
}
static registerLoadRouter(e) {
ft.getInstance().loadRouters.push(e);
}
static getSaveHandlers(e) {
return ft.getHandlers(e, "save");
}
static getLoadHandlers(e, t10) {
return ft.getHandlers(e, "load", t10);
}
static getHandlers(e, t10, o) {
let n = [];
return (t10 === "load" ? ft.getInstance().loadRouters : ft.getInstance().saveRouters).forEach(a => {
let i = a(e, o);
i !== null && n.push(i);
}), n;
}
};
var G0 = r => ft.registerSaveRouter(r);
var H0 = r => ft.registerLoadRouter(r);
var K0 = r => ft.getSaveHandlers(r);
var q0 = (r, e) => ft.getLoadHandlers(r, e);
var dw = "tensorflowjs";
var fw = 1;
var Pu = "models_store";
var Ji = "model_info_store";
function j0() {
if (!P().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 hw(r) {
let e = r.result;
e.createObjectStore(Pu, {
keyPath: "modelPath"
}), e.createObjectStore(Ji, {
keyPath: "modelPath"
});
}
var xa = class {
constructor(e) {
if (this.indexedDB = j0(), e == null || !e) throw new Error("For IndexedDB, modelPath must not be null, undefined or empty.");
this.modelPath = e;
}
async save(e) {
if (e.modelTopology instanceof ArrayBuffer) throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");
return this.databaseAction(this.modelPath, e);
}
async load() {
return this.databaseAction(this.modelPath);
}
databaseAction(e, t10) {
return new Promise((o, n) => {
let s = this.indexedDB.open(dw, fw);
s.onupgradeneeded = () => hw(s), s.onsuccess = () => {
let a = s.result;
if (t10 == null) {
let i = a.transaction(Pu, "readonly"),
u = i.objectStore(Pu).get(this.modelPath);
u.onsuccess = () => {
if (u.result == null) return a.close(), n(new Error(`Cannot find model with path '${this.modelPath}' in IndexedDB.`));
o(u.result.modelArtifacts);
}, u.onerror = c => (a.close(), n(u.error)), i.oncomplete = () => a.close();
} else {
let i = ga(t10),
p = a.transaction(Ji, "readwrite"),
u = p.objectStore(Ji),
c;
try {
c = u.put({
modelPath: this.modelPath,
modelArtifactsInfo: i
});
} catch (m) {
return n(m);
}
let l;
c.onsuccess = () => {
l = a.transaction(Pu, "readwrite");
let m = l.objectStore(Pu),
d;
try {
d = m.put({
modelPath: this.modelPath,
modelArtifacts: t10,
modelArtifactsInfo: i
});
} catch (f) {
return n(f);
}
d.onsuccess = () => o({
modelArtifactsInfo: i
}), d.onerror = f => {
u = p.objectStore(Ji);
let h = u.delete(this.modelPath);
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();
};
}
}, s.onerror = a => n(s.error);
});
}
};
xa.URL_SCHEME = "indexeddb://";
var X0 = r => P().getBool("IS_BROWSER") && !Array.isArray(r) && r.startsWith(xa.URL_SCHEME) ? zG(r.slice(xa.URL_SCHEME.length)) : null;
ft.registerSaveRouter(X0);
ft.registerLoadRouter(X0);
function zG(r) {
return new xa(r);
}
function VG(r) {
return r.startsWith(xa.URL_SCHEME) ? r.slice(xa.URL_SCHEME.length) : r;
}
var sd = class {
constructor() {
this.indexedDB = j0();
}
async listModels() {
return new Promise((e, t10) => {
let o = this.indexedDB.open(dw, fw);
o.onupgradeneeded = () => hw(o), o.onsuccess = () => {
let n = o.result,
s = n.transaction(Ji, "readonly"),
i = s.objectStore(Ji).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);
});
}
async removeModel(e) {
return e = VG(e), new Promise((t10, o) => {
let n = this.indexedDB.open(dw, fw);
n.onupgradeneeded = () => hw(n), n.onsuccess = () => {
let s = n.result,
a = s.transaction(Ji, "readwrite"),
i = a.objectStore(Ji),
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(Pu, "readwrite");
let d = u.objectStore(Pu).delete(e);
d.onsuccess = () => t10(p.result.modelArtifactsInfo), d.onerror = f => o(p.error);
};
c.onsuccess = l, c.onerror = m => (l(), s.close(), o(p.error));
}
}, p.onerror = c => (s.close(), o(p.error)), a.oncomplete = () => {
u == null ? s.close() : u.oncomplete = () => s.close();
};
}, n.onerror = s => o(n.error);
});
}
};
var ei = "/";
var oc = "tensorflowjs_models";
var Y0 = "info";
var WG = "model_topology";
var UG = "weight_specs";
var GG = "weight_data";
var HG = "model_metadata";
function Q0(r) {
return {
info: [oc, r, Y0].join(ei),
topology: [oc, r, WG].join(ei),
weightSpecs: [oc, r, UG].join(ei),
weightData: [oc, r, GG].join(ei),
modelMetadata: [oc, r, HG].join(ei)
};
}
function Z0(r) {
for (let e of Object.values(r)) window.localStorage.removeItem(e);
}
function KG(r) {
let e = r.split(ei);
if (e.length < 3) throw new Error(`Invalid key format: ${r}`);
return e.slice(1, e.length - 1).join(ei);
}
function qG(r) {
return r.startsWith(ya.URL_SCHEME) ? r.slice(ya.URL_SCHEME.length) : r;
}
var ya = class {
constructor(e) {
if (!P().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 = Q0(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 = ga(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, W0(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 Z0(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}.`);
}
}
}
async load() {
let e = JSON.parse(this.LS.getItem(this.keys.info));
if (e == null) 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));
if (o == null) throw new Error(`In local storage, the topology of model '${this.modelPath}' is missing.`);
t10.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;
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);
}
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 = U0(a), t10;
}
};
ya.URL_SCHEME = "localstorage://";
var J0 = r => P().getBool("IS_BROWSER") && !Array.isArray(r) && r.startsWith(ya.URL_SCHEME) ? jG(r.slice(ya.URL_SCHEME.length)) : null;
ft.registerSaveRouter(J0);
ft.registerLoadRouter(J0);
function jG(r) {
return new ya(r);
}
var ad = 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;
}
async listModels() {
let e = {},
t10 = oc + ei,
o = ei + Y0;
for (let n = 0; n < this.LS.length; ++n) {
let s = this.LS.key(n);
if (s.startsWith(t10) && s.endsWith(o)) {
let a = KG(s);
e[a] = JSON.parse(this.LS.getItem(s));
}
}
return e;
}
async removeModel(e) {
e = qG(e);
let t10 = Q0(e);
if (this.LS.getItem(t10.info) == null) throw new Error(`Cannot find model at path '${e}'`);
let o = JSON.parse(this.LS.getItem(t10.info));
return Z0(t10), o;
}
};
var nc = "://";
var Qt = class {
constructor() {
this.managers = {};
}
static getInstance() {
return Qt.instance == null && (Qt.instance = new Qt()), Qt.instance;
}
static registerManager(e, t10) {
$(e != null, () => "scheme must not be undefined or null."), e.endsWith(nc) && (e = e.slice(0, e.indexOf(nc))), $(e.length > 0, () => "scheme must not be an empty string.");
let o = Qt.getInstance();
$(o.managers[e] == null, () => `A model store manager is already registered for scheme '${e}'.`), o.managers[e] = t10;
}
static getManager(e) {
let t10 = Qt.getInstance().managers[e];
if (t10 == null) throw new Error(`Cannot find model manager for scheme '${e}'`);
return t10;
}
static getSchemes() {
return Object.keys(Qt.getInstance().managers);
}
};
function id(r) {
if (r.indexOf(nc) === -1) throw new Error(`The url string provided does not contain a scheme. Supported schemes are: ${Qt.getSchemes().join(",")}`);
return {
scheme: r.split(nc)[0],
path: r.split(nc)[1]
};
}
async function ek(r, e, t10 = false) {
$(r !== e, () => `Old path and new path are the same: '${r}'`);
let o = ft.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 = ft.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 = id(r).scheme,
p = id(r).path,
u = i === id(r).scheme,
c = await n.load();
t10 && u && (await Qt.getManager(i).removeModel(p));
let l = await a.save(c);
return t10 && !u && (await Qt.getManager(i).removeModel(p)), l.modelArtifactsInfo;
}
async function tk() {
let r = Qt.getSchemes(),
e = {};
for (let t10 of r) {
let o = await Qt.getManager(t10).listModels();
for (let n in o) {
let s = t10 + nc + n;
e[s] = o[n];
}
}
return e;
}
async function rk(r) {
let e = id(r);
return Qt.getManager(e.scheme).removeModel(e.path);
}
async function ok(r, e) {
return ek(r, e, false);
}
async function nk(r, e) {
return ek(r, e, true);
}
var gw = class {
constructor() {
this.messageName = "setTimeoutCustom", this.functionRefs = [], this.handledMessageCount = 0, this.hasEventListener = false;
}
fetch(e, t10) {
return fetch(e, t10);
}
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}`);
return this.textEncoder == null && (this.textEncoder = new TextEncoder()), this.textEncoder.encode(e);
}
decode(e, t10) {
return new TextDecoder(t10).decode(e);
}
setTimeoutCustom(e, t10) {
if (typeof window == "undefined" || !P().getBool("USE_SETTIMEOUTCUSTOM")) {
setTimeout(e, t10);
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 => {
if (o.source === window && o.data.name === this.messageName) {
o.stopPropagation();
let n = this.functionRefs[o.data.index];
n(), this.handledMessageCount++, this.handledMessageCount === this.functionRefs.length && (this.functionRefs = [], this.handledMessageCount = 0);
}
}, true));
}
isTypedArray(e) {
return qm(e);
}
};
if (P().get("IS_BROWSER")) {
P().setPlatform("browser", new gw());
try {
Qt.registerManager(ya.URL_SCHEME, new ad());
} catch (r) {}
try {
Qt.registerManager(xa.URL_SCHEME, new sd());
} catch (r) {}
}
var XG = {
importFetch: () => sk()
};
var xw;
var yw = class {
constructor() {
this.util = ak(), this.textEncoder = new this.util.TextEncoder();
}
fetch(e, t10) {
return P().global.fetch != null ? P().global.fetch(e, t10) : (xw == null && (xw = XG.importFetch()), xw(e, t10));
}
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}`);
return this.textEncoder.encode(e);
}
decode(e, t10) {
return e.length === 0 ? "" : new this.util.TextDecoder(t10).decode(e);
}
isTypedArray(e) {
return this.util.types.isFloat32Array(e) || this.util.types.isInt32Array(e) || this.util.types.isUint8Array(e) || this.util.types.isUint8ClampedArray(e);
}
};
P().get("IS_NODE") && !P().get("IS_BROWSER") && P().setPlatform("node", new yw());
function me(r, e = "float32", t10) {
return e = e || "float32", Ct(r), new tt(r, e, t10);
}
function YG(r, e) {
let t10 = v(r, "x", "cast");
if (!zC(e)) throw new Error(`Failed to cast to unknown dtype ${e}`);
if (e === "string" && t10.dtype !== "string" || e !== "string" && t10.dtype === "string") throw new Error("Only strings can be casted to strings");
let o = {
x: t10
},
n = {
dtype: e
};
return T.runKernel(ho, o, n);
}
var Ye = N({
cast_: YG
});
function QG(r) {
let t10 = {
x: v(r, "x", "clone", "string_or_numeric")
};
return T.runKernel(xo, t10);
}
var Vr = N({
clone_: QG
});
function ud(r, e = false) {
console.log(r.toString(e));
}
aw();
var ZG = {
buffer: me,
cast: Ye,
clone: Vr,
print: ud
};
F0(ZG);
function fme() {
P().set("PROD", true);
}
function hme() {
P().set("DEBUG", true);
}
function gme() {
P().set("DEPRECATION_WARNINGS_ENABLED", false), console.warn("TensorFlow.js deprecation warnings have been disabled.");
}
function bw(r) {
P().getBool("DEPRECATION_WARNINGS_ENABLED") && console.warn(r + " You can disable deprecation warnings with tf.disableDeprecationWarnings().");
}
P0(bw);
function xme() {
T.disposeVariables();
}
function ur() {
return T;
}
function yme() {
return T.memory();
}
function bme(r) {
return T.profile(r);
}
function De(r, e) {
return T.tidy(r, e);
}
function Ot(r) {
bl(r).forEach(t10 => t10.dispose());
}
function Er(r) {
return T.keep(r);
}
function Cme(r) {
return T.time(r);
}
function wme(r) {
return T.setBackend(r);
}
function Sme() {
return T.ready();
}
function Ime() {
return T.backendName;
}
function vme(r) {
T.removeBackend(r);
}
function kme(r) {
return T.findBackend(r);
}
function Nme(r) {
return T.findBackendFactory(r);
}
function eu(r, e, t10 = 1) {
return T.registerBackend(r, e, t10);
}
function Tme() {
return T.backend;
}
function _me(r, e) {
P().setPlatform(r, e);
}
function JG(r, e) {
let t10 = v(r, "a", "add"),
o = v(e, "b", "add");
[t10, o] = Oe(t10, o);
let n = {
a: t10,
b: o
};
return T.runKernel(no, n);
}
var be = N({
add_: JG
});
function e4(r, e) {
let t10 = v(r, "a", "floorDiv"),
o = v(e, "b", "floorDiv");
[t10, o] = Oe(t10, o);
let n = {
a: t10,
b: o
};
return T.runKernel(Cn, n);
}
var pd = N({
floorDiv_: e4
});
function t4(r, e) {
let t10 = v(r, "a", "div"),
o = v(e, "b", "div");
if ([t10, o] = Oe(t10, o), t10.dtype === "int32" && o.dtype === "int32") return pd(t10, o);
let n = {
a: t10,
b: o
},
s = {};
return T.runKernel(dn, n, s);
}
var Ke = N({
div_: t4
});
function r4(r, e) {
let t10 = v(r, "a", "mul"),
o = v(e, "b", "mul");
[t10, o] = Oe(t10, o);
let n = {
a: t10,
b: o
};
return T.runKernel(Kn, n);
}
var se = N({
mul_: r4
});
function o4(r) {
let e = v(r, "x", "abs");
if (e.dtype === "complex64") {
let t10 = {
x: e
};
return T.runKernel(_i, t10);
} else {
let t10 = {
x: e
};
return T.runKernel(Gs, t10);
}
}
var Zt = N({
abs_: o4
});
function n4(r) {
let t10 = {
x: v(r, "x", "acos")
};
return T.runKernel(zo, t10);
}
var ik = N({
acos_: n4
});
function s4(r) {
let t10 = {
x: v(r, "x", "acosh")
};
return T.runKernel(Vo, t10);
}
var uk = N({
acosh_: s4
});
function a4(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];
e.forEach(n => {
if (n.dtype !== t10.dtype) throw new Error("All tensors passed to tf.addN() must have the same dtype");
}), e.forEach(n => {
if (!br(n.shape, t10.shape)) throw new Error("All tensors passed to tf.addN() must have the same shape");
});
let o = e;
return T.runKernel(Wo, o);
}
var pk = N({
addN_: a4
});
function i4(r, e = null, t10 = false) {
let n = {
x: v(r, "x", "all", "bool")
},
s = {
axis: e,
keepDims: t10
};
return T.runKernel(Uo, n, s);
}
var ck = N({
all_: i4
});
function u4(r, e = null, t10 = false) {
let n = {
x: v(r, "x", "any", "bool")
},
s = {
axis: e,
keepDims: t10
};
return T.runKernel(Go, n, s);
}
var lk = N({
any_: u4
});
function p4(r, e = 0) {
let o = {
x: v(r, "x", "argMax")
},
n = {
axis: e
};
return T.runKernel(Hs, o, n);
}
var mk = N({
argMax_: p4
});
function c4(r, e = 0) {
let o = {
x: v(r, "x", "argMin")
},
n = {
axis: e
};
return T.runKernel(Ks, o, n);
}
var dk = N({
argMin_: c4
});
function l4(r) {
let t10 = {
x: v(r, "x", "asin")
};
return T.runKernel(Ho, t10);
}
var fk = N({
asin_: l4
});
function m4(r) {
let t10 = {
x: v(r, "x", "asinh")
};
return T.runKernel(Ko, t10);
}
var hk = N({
asinh_: m4
});
function d4(r) {
let t10 = {
x: v(r, "x", "atan")
};
return T.runKernel(qo, t10);
}
var gk = N({
atan_: d4
});
function f4(r, e) {
let t10 = v(r, "a", "atan2"),
o = v(e, "b", "atan2");
[t10, o] = Oe(t10, o);
let n = {
a: t10,
b: o
};
return T.runKernel(Xo, n);
}
var xk = N({
atan2_: f4
});
function h4(r) {
let t10 = {
x: v(r, "x", "atanh")
};
return T.runKernel(jo, t10);
}
var yk = N({
atanh_: h4
});
function g4(r, e, t10, o, n = "NHWC", s) {
let a = r[3],
i = [...e, a],
p = Ck(n);
return Mu(r, i, t10, s, o, null, null, p);
}
function ww(r, e, t10, o, n, s, a = "channelsLast") {
let [i, p] = wl(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 Mu(r, u, t10, o, n, s, false, a);
}
function x4(r, e, t10, o, n, s, a = "NDHWC") {
let [i, p, u] = Cw(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 bk(r, c, t10, o, n, false, l, s);
}
function Mu(r, e, t10, o, n, s, a = false, i = "channelsLast") {
let [p, u, c, l] = [-1, -1, -1, -1];
if (i === "channelsLast") [p, u, c, l] = r;else if (i === "channelsFirst") [p, l, u, c] = r;else throw new Error(`Unknown dataFormat ${i}`);
let [m, d,, f] = e,
[h, g] = wl(t10),
[x, b] = wl(o),
w = sc(m, x),
S = sc(d, b),
{
padInfo: k,
outHeight: _,
outWidth: E
} = C4(n, u, c, h, g, w, S, s, i),
R = a ? f * l : f,
D;
return i === "channelsFirst" ? D = [p, R, _, E] : i === "channelsLast" && (D = [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: d,
effectiveFilterHeight: w,
effectiveFilterWidth: S,
dilationHeight: x,
dilationWidth: b,
inShape: r,
outShape: D,
filterShape: e
};
}
function bk(r, e, t10, 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;else if (a === "channelsFirst") [p, m, u, c, l] = r;else throw new Error(`Unknown dataFormat ${a}`);
let [d, f, h,, g] = e,
[x, b, w] = Cw(t10),
[S, k, _] = Cw(o),
E = sc(d, S),
R = sc(f, k),
D = sc(h, _),
{
padInfo: F,
outDepth: O,
outHeight: M,
outWidth: L
} = w4(n, u, c, l, x, b, w, E, R, D, i),
B = s ? g * m : g,
z;
return a === "channelsFirst" ? z = [p, B, O, M, L] : a === "channelsLast" && (z = [p, O, M, L, B]), {
batchSize: p,
dataFormat: a,
inDepth: u,
inHeight: c,
inWidth: l,
inChannels: m,
outDepth: O,
outHeight: M,
outWidth: L,
outChannels: B,
padInfo: F,
strideDepth: x,
strideHeight: b,
strideWidth: w,
filterDepth: d,
filterHeight: f,
filterWidth: h,
effectiveFilterDepth: E,
effectiveFilterHeight: R,
effectiveFilterWidth: D,
dilationDepth: S,
dilationHeight: k,
dilationWidth: _,
inShape: r,
outShape: z,
filterShape: e
};
}
function y4(r, e, t10, o, n) {
o == null && (o = Sw(r, e, t10));
let s = r[0],
a = r[1],
i = Sl((s - e + 2 * o) / t10 + 1, n),
p = Sl((a - e + 2 * o) / t10 + 1, n);
return [i, p];
}
function b4(r, e, t10, o, n, s) {
n == null && (n = Sw(r, e[0], o[0]));
let a = [0, 0, 0, t10];
for (let i = 0; i < 3; i++) r[i] + 2 * n >= e[i] && (a[i] = Sl((r[i] - e[i] + 2 * n) / o[i] + 1, s));
return a;
}
function Sw(r, e, t10, o = 1) {
let n = sc(e, o);
return Math.floor((r[0] * (t10 - 1) - t10 + n) / 2);
}
function wl(r) {
return typeof r == "number" ? [r, r, r] : r.length === 2 ? [r[0], r[1], 1] : r;
}
function Cw(r) {
return typeof r == "number" ? [r, r, r] : r;
}
function sc(r, e) {
return e <= 1 ? r : r + (r - 1) * (e - 1);
}
function C4(r, e, t10, 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 d = y4([e, t10], 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),
d = Math.max(0, (l - 1) * n + a - t10),
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);else if (typeof r == "object") {
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 = Sl((e - s + m + d) / o + 1, i), l = Sl((t10 - a + f + h) / n + 1, i);
} else throw Error(`Unknown padding parameter: ${r}`);
return {
padInfo: u,
outHeight: c,
outWidth: l
};
}
function w4(r, e, t10, o, n, s, a, i, p, u, c) {
let l, m, d, f;
if (r === "valid" && (r = 0), typeof r == "number") {
l = {
top: r,
bottom: r,
left: r,
right: r,
front: r,
back: r,
type: r === 0 ? "VALID" : "NUMBER"
};
let g = b4([e, t10, o, 1], [i, p, u], 1, [n, s, a], r, c);
m = g[0], d = g[1], f = g[2];
} else if (r === "same") {
m = Math.ceil(e / n), d = Math.ceil(t10 / s), f = Math.ceil(o / a);
let h = (m - 1) * n + i - e,
g = (d - 1) * s + p - t10,
x = (f - 1) * a + u - o,
b = Math.floor(h / 2),
w = h - b,
S = Math.floor(g / 2),
k = g - S,
_ = Math.floor(x / 2),
E = x - _;
l = {
top: S,
bottom: k,
left: _,
right: E,
front: b,
back: w,
type: "SAME"
};
} else throw Error(`Unknown padding parameter: ${r}`);
return {
padInfo: l,
outDepth: m,
outHeight: d,
outWidth: f
};
}
function Sl(r, e) {
if (!e) return Math.trunc(r);
switch (e) {
case "round":
return Math.round(r);
case "ceil":
return Math.ceil(r);
case "floor":
return Math.floor(r);
default:
throw new Error(`Unknown roundingMode ${e}`);
}
}
function Ou(r) {
let [e, t10, o] = wl(r);
return e === 1 && t10 === 1 && o === 1;
}
function gr(r, e) {
return Ou(r) || Ou(e);
}
function ba(r) {
return wl(r).every(e => e > 0);
}
function Ck(r) {
if (r === "NHWC") return "channelsLast";
if (r === "NCHW") return "channelsFirst";
throw new Error(`Unknown dataFormat ${r}`);
}
function Lt(r, e, t10) {
if (t10 != null) {
if (typeof e == "string") throw Error(`Error in ${r}: pad must be an integer when using dimRoundingMode ${t10} but got pad ${e}.`);
if (typeof e == "number") $(Ba(e), () => `Error in ${r}: pad must be an integer when using dimRoundingMode ${t10} but got pad ${e}.`);else if (typeof e == "object") e.forEach(o => {
o.forEach(n => {
$(Ba(n), () => `Error in ${r}: pad must be an integer when using dimRoundingMode ${t10} but got pad ${n}.`);
});
});else throw Error(`Error in ${r}: Unknown padding parameter: ${e}`);
}
}
function S4(r, e) {
let o = {
x: v(r, "x", "reshape", "string_or_numeric")
},
n = {
shape: e
};
return T.runKernel(ia, o, n);
}
var W = N({
reshape_: S4
});
function I4(r, e, t10, o, n) {
let s = v(r, "x", "avgPool", "float32"),
a = 1;
$(gr(t10, a), () => `Error in avgPool: Either strides or dilations must be 1. Got strides ${t10} and dilations '${a}'`);
let i = s,
p = false;
s.rank === 3 && (p = true, i = W(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}.`), Lt("avgPool", o, n);
let u = {
x: i
},
c = {
filterSize: e,
strides: t10,
pad: o,
dimRoundingMode: n
},
l = T.runKernel(Yo, u, c);
return l = Ye(l, s.dtype), p ? W(l, [l.shape[1], l.shape[2], l.shape[3]]) : l;
}
var cd = N({
avgPool_: I4
});
function v4(r, e, t10, o, n, s = "NDHWC") {
let a = v(r, "x", "avgPool3d", "float32"),
i = a,
p = false;
a.rank === 4 && (p = true, i = W(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}`), $(typeof t10 == "number" && t10 > 0 || Array.isArray(t10) && t10[0] > 0 && t10[1] > 0 && t10[2] > 0, () => `Error in avgPool3d: Stride must be > 0, but got '${t10}'`), Lt("avgPool3d", o, n);
let u = {
x: i
},
c = {
filterSize: e,
strides: t10,
pad: o,
dimRoundingMode: n,
dataFormat: s
},
l = T.runKernel(qs, u, c);
return l = Ye(l, i.dtype), p ? W(l, [l.shape[1], l.shape[2], l.shape[3], l.shape[4]]) : l;
}
var wk = N({
avgPool3d_: v4
});
function k4(r, e = 0) {
$(r.length >= 1, () => "Pass at least one tensor to concat");
let t10 = Ja(r, "tensors", "concat", "string_or_numeric");
if (t10[0].dtype === "complex64" && t10.forEach(s => {
if (s.dtype !== "complex64") throw new Error(`Cannot concatenate complex64 tensors with a tensor
with dtype ${s.dtype}. `);
}), t10.length === 1) return Vr(t10[0]);
let o = t10,
n = {
axis: e
};
return T.runKernel(Ys, o, n);
}
var yt = N({
concat_: k4
});
function N4(r, e, t10 = false, o = false) {
let n = v(r, "a", "matMul"),
s = v(e, "b", "matMul");
[n, s] = Oe(n, s);
let a = {
a: n,
b: s
},
i = {
transposeA: t10,
transposeB: o
};
return T.runKernel(Qo, a, i);
}
var Qe = N({
matMul_: N4
});
function T4(r) {
let t10 = {
x: v(r, "x", "sigmoid", "float32")
};
return T.runKernel(hs, t10);
}
var wa = N({
sigmoid_: T4
});
function _4(r, e, t10) {
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 T.runKernel(pa, n, s);
}
var qe = N({
slice_: _4
});
function $4(r) {
let t10 = {
x: v(r, "x", "tanh", "float32")
};
return T.runKernel(ks, t10);
}
var Il = N({
tanh_: $4
});
function E4(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 = yt([u, l], 1),
d = Qe(m, i),
f = be(d, p),
h = f.shape[0],
g = f.shape[1] / 4,
x = [h, g],
b = qe(f, [0, 0], x),
w = qe(f, [0, g], x),
S = qe(f, [0, g * 2], x),
k = qe(f, [0, g * 3], x),
_ = be(se(wa(b), Il(w)), se(c, wa(be(a, S)))),
E = se(Il(_), wa(k));
return [_, E];
}
var Sk = N({
basicLSTMCell_: E4
});
function R4(r, e, t10) {
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 T.runKernel(js, s, a);
}
var ld = N({
batchToSpaceND_: R4
});
function Ik(r) {
let e;
return r.rank === 0 || r.rank === 1 ? e = W(r, [1, 1, 1, r.size]) : r.rank === 2 ? e = W(r, [1, 1, r.shape[0], r.shape[1]]) : r.rank === 3 ? e = W(r, [1, r.shape[0], r.shape[1], r.shape[2]]) : e = r, e;
}
function D4(r, e, t10, 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;
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: Ik(a),
scale: u,
offset: c,
mean: i,
variance: p
},
d = {
varianceEpsilon: s
},
f = T.runKernel(wn, m, d);
return W(f, a.shape);
}
var tu = N({
batchNorm_: D4
});
function A4(r, e, t10, o, n, s) {
let a = v(r, "x", "batchNorm"),
i = v(e, "mean", "batchNorm"),
p = v(t10, "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}.`), tu(a, i, p, c, u, s);
}
var vk = N({
batchNorm2d_: A4
});
function F4(r, e, t10, o, n, s) {
let a = v(r, "x", "batchNorm"),
i = v(e, "mean", "batchNorm"),
p = v(t10, "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}.`), tu(a, i, p, c, u, s);
}
var kk = N({
batchNorm3d_: F4
});
function P4(r, e, t10, o, n, s) {
let a = v(r, "x", "batchNorm"),
i = v(e, "mean", "batchNorm"),
p = v(t10, "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}.`), tu(a, i, p, c, u, s);
}
var Nk = N({
batchNorm4d_: P4
});
function O4(r, e, t10) {
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 T.runKernel(Zo, s, a);
}
var md = N({
bincount_: O4
});
function M4(r, e) {
let t10 = v(r, "x", "bitwiseAnd"),
o = v(e, "y", "bitwiseAnd");
if (!br(t10.shape, o.shape)) throw new Error(`BitwiseAnd: Tensors must have the same shape. x: ${t10.shape}, y: ${o.shape}`);
if (t10.dtype !== "int32" || o.dtype !== "int32") throw new Error(`BitwiseAnd: Only supports 'int32' values in tensor, found type of x: ${t10.dtype} and type of y: ${o.dtype}`);
let n = {
a: t10,
b: o
};
return T.runKernel(ml, n);
}
var Tk = N({
bitwiseAnd_: M4
});
function L4(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}`);
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 T.runKernel(Xs, n);
}
var _k = N({
broadcastArgs_: L4
});
function B4(r, e) {
let t10 = v(r, "broadcastTo", "x"),
o = t10.shape;
if (Ct(e), 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();
for (; u.length < e.length;) u.unshift(1);
t10 = W(t10, u);
}
let n = t10.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) 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 Vr(t10);
let i = {
x: t10
},
p = {
reps: s
};
return T.runKernel(so, i, p);
}
var ru = N({
broadcastTo_: B4
});
function z4(r) {
let t10 = {
x: v(r, "x", "ceil", "float32")
};
return T.runKernel(Jo, t10);
}
var $k = N({
ceil_: z4
});
function Sa(r, e, t10) {
Ct(r), t10 = t10 || ki(e);
let o = {
shape: r,
value: e,
dtype: t10
};
return T.runKernel(ea, {}, o);
}
function V4(r, e, t10) {
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 Sa(o.shape, e, o.dtype);
let n = {
x: o
},
s = {
clipValueMin: e,
clipValueMax: t10
};
return T.runKernel(go, n, s);
}
var Ek = N({
clipByValue_: V4
});
function W4(r) {
return yt(r, 0);
}
var Rk = N({
concat1d_: W4
});
function U4(r, e) {
return yt(r, e);
}
var Dk = N({
concat2d_: U4
});
function G4(r, e) {
return yt(r, e);
}
var Ak = N({
concat3d_: G4
});
function H4(r, e) {
return yt(r, e);
}
var Fk = N({
concat4d_: H4
});
function K4(r, e, t10, 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 = W(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}.`), Lt("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]}.`), $(gr(t10, s), () => `Error in conv2D: Either strides or dilations must be 1. Got strides ${t10} and dilations '${s}'`), $(ba(s), () => "Error in conv2D: Dilated rates should be larger than 0."), $(ba(t10), () => "Error in conv2D: Strides should be larger than 0.");
let m = {
x: u,
filter: p
},
d = {
strides: t10,
pad: o,
dataFormat: n,
dilations: s,
dimRoundingMode: a
},
f = T.runKernel(en, m, d);
return c ? W(f, [f.shape[1], f.shape[2], f.shape[3]]) : f;
}
var ou = N({
conv2d_: K4
});
function q4(r, e, t10, 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 = W(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}.`), Lt("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]}.`), $(gr(t10, s), () => `Error in conv1D: Either stride or dilation must be 1. Got stride ${t10} and dilation '${s}'`), $(ba(s), () => "Error in conv1D: Dilated rates should be larger than 0."), $(ba(t10), () => "Error in conv1D: Stride should be larger than 0."), $(n === "NWC", () => `Error in conv1d: got dataFormat of ${n} but only NWC is currently supported.`);
let l = W(p, [1, p.shape[0], p.shape[1], p.shape[2]]),
m = W(u, [u.shape[0], 1, u.shape[1], u.shape[2]]),
g = ou(m, l, [1, t10], o, "NHWC", [1, s], a);
return c ? W(g, [g.shape[2], g.shape[3]]) : W(g, [g.shape[0], g.shape[2], g.shape[3]]);
}
var Pk = N({
conv1d_: q4
});
function j4(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`);
let i = r,
p = e,
u = false;
e.rank === 3 && (u = true, p = W(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}`);
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]}.`), Lt("conv2dDerInput", n, a);
let m = {
dy: p,
filter: t10
},
d = {
strides: o,
pad: n,
dataFormat: s,
dimRoundingMode: a,
inputShape: i
},
f = T.runKernel(tn, m, d);
return u ? W(f, [f.shape[1], f.shape[2], f.shape[3]]) : f;
}
var dd = N({
conv2DBackpropInput_: j4
});
function X4(r, e, t10, o, n, s) {
let a = v(r, "x", "conv2dTranspose"),
i = v(e, "filter", "conv2dTranspose");
return dd(t10, a, i, o, n, "NHWC", s);
}
var Ok = N({
conv2dTranspose_: X4
});
function Y4(r, e, t10, 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 = W(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]}.`), $(gr(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.`), $(ba(s), () => "Error in conv3D: Dilated rates should be larger than 0."), $(ba(t10), () => "Error in conv3D: Strides should be larger than 0.");
let c = {
x: p,
filter: i
},
l = {
strides: t10,
pad: o,
dataFormat: n,
dilations: s
},
m = T.runKernel(rn, c, l);
return u ? W(m, [m.shape[1], m.shape[2], m.shape[3], m.shape[4]]) : m;
}
var Mk = N({
conv3d_: Y4
});
function Q4(r, e, t10, o, n) {
$(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 = W(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 = T.runKernel(on, c, l);
return i ? W(m, [m.shape[1], m.shape[2], m.shape[3], m.shape[4]]) : m;
}
var Lk = N({
conv3DBackpropInput_: Q4
});
function Z4(r, e, t10, o, n) {
let s = v(r, "x", "conv3dTranspose"),
a = v(e, "filter", "conv3dTranspose");
return Lk(t10, s, a, o, n);
}
var Bk = N({
conv3dTranspose_: Z4
});
function J4(r) {
let t10 = {
x: v(r, "x", "cos", "float32")
};
return T.runKernel(nn, t10);
}
var zk = N({
cos_: J4
});
function eH(r) {
let t10 = {
x: v(r, "x", "cosh", "float32")
};
return T.runKernel(sn, t10);
}
var Vk = N({
cosh_: eH
});
function tH(r, e = 0, t10 = false, o = false) {
let s = {
x: v(r, "x", "cumprod")
},
a = {
axis: e,
exclusive: t10,
reverse: o
};
return T.runKernel(an, s, a);
}
var Wk = N({
cumprod_: tH
});
function rH(r, e = 0, t10 = false, o = false) {
let s = {
x: v(r, "x", "cumsum")
},
a = {
axis: e,
exclusive: t10,
reverse: o
};
return T.runKernel(un, s, a);
}
var Uk = N({
cumsum_: rH
});
function oH(r, e, t10, 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 T.runKernel(Qs, a, i);
}
var Gk = N({
denseBincount_: oH
});
function nH(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
${n} and ${e} for depthToSpace with input shape
${o.shape}`), $(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 T.runKernel(cn, i, p);
}
var Hk = N({
depthToSpace_: nH
});
function sH(r, e, t10, 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 = W(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}.`);
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]}.`), Lt("depthwiseConv2d", o, a);
let m = {
x: u,
filter: p
},
d = {
strides: t10,
pad: o,
dataFormat: n,
dilations: s,
dimRoundingMode: a
},
f = T.runKernel(ln, m, d);
return c ? W(f, [f.shape[1], f.shape[2], f.shape[3]]) : f;
}
var ac = N({
depthwiseConv2d_: sH
});
function aH(r) {
let t10 = {
x: v(r, "x", "diag")
};
return T.runKernel(Zs, t10);
}
var Kk = N({
diag_: aH
});
function iH(r, e, t10, 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}`);
let p = a,
u = false;
a.rank === 3 && (p = W(a, [1, a.shape[0], a.shape[1], a.shape[2]]), u = true), $(p.shape[3] === i.shape[2], () => `Error in dilation2d: input and filter must have the same depth: ${p.shape[3]} vs ${i.shape[2]}`);
let c = {
x: p,
filter: i
},
l = {
strides: t10,
pad: o,
dilations: n
},
m = T.runKernel(mn, c, l);
return u ? W(m, [m.shape[1], m.shape[2], m.shape[3]]) : m;
}
var qk = N({
dilation2d_: iH
});
var Sr = {};
He(Sr, {
assertAndGetBroadcastShape: () => rt,
getBroadcastDims: () => jk,
getReductionAxes: () => fd
});
function jk(r, e) {
let t10 = r.length,
o = [];
for (let n = 0; n < t10; n++) {
let s = t10 - 1 - n,
a = r[s] || 1;
(e[e.length - 1 - n] || 1) > 1 && a === 1 && o.unshift(s);
}
return o;
}
function fd(r, e) {
let t10 = [];
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);
}
return t10;
}
function rt(r, e) {
let t10 = Math.max(r.length, e.length),
o = new Array(t10);
for (let n = 0; n < t10; 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) o[t10 - n - 1] = a;else if (a === 1) o[t10 - n - 1] = s;else if (s !== a) {
let i = `Operands could not be broadcast together with shapes ${r} and ${e}.`;
throw Error(i);
} else o[t10 - n - 1] = s;
}
return o;
}
function uH(r, e) {
let t10 = v(r, "a", "equal", "string_or_numeric"),
o = v(e, "b", "equal", "string_or_numeric");
[t10, o] = Oe(t10, o), rt(t10.shape, o.shape);
let n = {
a: t10,
b: o
};
return T.runKernel(hn, n);
}
var hd = N({
equal_: uH
});
function pH(r, e, t10) {
let o = v(e, "a", "where"),
n = v(t10, "b", "where"),
s = v(r, "condition", "where", "bool"),
a = rt(rt(s.shape, o.shape), n.shape),
i = ru(s, a),
p = ru(o, a),
u = ru(n, a),
c = {
condition: i,
t: p,
e: u
};
return T.runKernel(ua, c);
}
var io = N({
where_: pH
});
function cH(r) {
let t10 = {
x: v(r, "x", "zerosLike")
};
return T.runKernel(fa, t10);
}
var Ht = N({
zerosLike_: cH
});
function lH(r, e) {
let t10 = v(r, "a", "div"),
o = v(e, "b", "div");
[t10, o] = Oe(t10, o);
let n = Ke(t10, o),
s = Ht(n),
a = hd(o, s);
return io(a, s, n);
}
var Xk = N({
divNoNan_: lH
});
function mH(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 = W(t10, [1, -1]),
i = W(o, [-1, 1]),
p = Qe(a, i);
return W(p, []);
} else if (t10.rank === 1 && o.rank === 2) {
let a = W(t10, [1, -1]),
i = W(o, [o.shape[0], o.shape[1]]),
p = Qe(a, i);
return W(p, [p.size]);
} else if (t10.rank === 2 && o.rank === 1) {
let a = W(o, [-1, 1]),
i = Qe(t10, a);
return W(i, [i.size]);
} else {
let a = W(o, [o.shape[0], o.shape[1]]);
return Qe(t10, a);
}
}
var Yk = N({
dot_: mH
});
function dH(r, ...e) {
let t10 = e.map((n, s) => v(n, `tensors${s}`, "einsum")),
o = {
equation: r
};
return T.runKernel(Fi, t10, o);
}
var Qk = N({
einsum_: dH
});
function fH(r) {
let t10 = {
x: v(r, "x", "elu", "float32")
};
return T.runKernel(fn, t10);
}
var gd = N({
elu_: fH
});
function hH(r, e) {
let t10 = v(r, "x", "ensureShape", "string_or_numeric");
if (!OC(t10.shape, e)) throw new Error(`EnsureShape: Shape of tensor ${t10.shape} is not compatible with expected shape ${e}`);
return r;
}
var Zk = N({
ensureShape_: hH
});
function gH(r) {
let e = v(r, "x", "erf");
$(e.dtype === "int32" || e.dtype === "float32", () => "Input dtype must be `int32` or `float32`."), e.dtype === "int32" && (e = Ye(e, "float32"));
let t10 = {
x: e
};
return T.runKernel(Wa, t10);
}
var Jk = N({
erf_: gH
});
function Iw(r, e) {
for (let t10 = 0; t10 < r.length; ++t10) if (r[r.length - t10 - 1] !== e - 1 - t10) return false;
return true;
}
function e2(r, e, t10) {
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++]);
return n;
}
function xH(r, e) {
let t10 = [],
o = r.length;
for (let s = 0; s < o; s++) e.indexOf(s) === -1 && t10.push(r[s]);
let n = e.map(s => r[s]);
return [t10, n];
}
function ti(r, e) {
let t10 = e.map(o => 1);
return e2(r, t10, e);
}
function yH(r, e, t10) {
$(Iw(e, t10), () => `${r} supports only inner-most axes for now. Got axes ${e} and rank-${t10} input.`);
}
function bH(r, e) {
if (Iw(r, e)) return null;
let t10 = [];
for (let o = 0; o < e; ++o) r.indexOf(o) === -1 && t10.push(o);
return r.forEach(o => t10.push(o)), t10;
}
function CH(r) {
return r.map((e, t10) => [t10, e]).sort((e, t10) => e[1] - t10[1]).map(e => e[0]);
}
function wH(r, e) {
let t10 = [];
for (let o = e - r; o < e; ++o) t10.push(o);
return t10;
}
function IH(r, e = null, t10 = false) {
let n = {
x: v(r, "x", "max")
},
s = {
reductionIndices: e,
keepDims: t10
};
return T.runKernel(Ln, n, s);
}
var Ia = N({
max_: IH
});
function vH(r, e = null, t10 = false) {
let n = {
x: v(r, "x", "min")
},
s = {
axis: e,
keepDims: t10
};
return T.runKernel(Wn, n, s);
}
var vl = N({
min_: vH
});
function kH(r, e) {
let t10 = v(r, "base", "pow"),
o = v(e, "exp", "pow");
[t10, o] = Oe(t10, o);
let n = {
a: t10,
b: o
};
return T.runKernel(Zn, n);
}
var ri = N({
pow_: kH
});
function ke(r, e) {
if ((Pt(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" && Pt(r) && !(r instanceof Uint8Array)) throw new Error("When making a scalar from encoded string, the value must be `Uint8Array`.");
return wr(r, [], [], e);
}
function NH(r) {
let t10 = {
x: v(r, "x", "sqrt", "float32")
};
return T.runKernel(xs, t10);
}
var Rr = N({
sqrt_: NH
});
function TH(r) {
let e = v(r, "x", "square"),
t10 = {};
return T.runKernel("Square", {
x: e
}, t10);
}
var Jt = N({
square_: TH
});
function _H(r, e = null, t10 = false) {
let o = v(r, "x", "sum");
o.dtype === "bool" && (o = Ye(o, "int32"));
let n = {
x: o
},
s = {
axis: e,
keepDims: t10
};
return T.runKernel(ys, n, s);
}
var ot = N({
sum_: _H
});
function $H(r, e = "euclidean", t10 = null, o = false) {
r = v(r, "x", "norm");
let n = t2(r, e, t10),
s = n.shape;
if (o) {
let a = vi(t10, r.shape);
s = ti(n.shape, a);
}
return W(n, s);
}
function t2(r, e, t10 = null) {
if (r.rank === 0) return Zt(r);
if (r.rank !== 1 && t10 === null) return t2(W(r, [-1]), e, t10);
if (r.rank === 1 || typeof t10 == "number" || Array.isArray(t10) && t10.length === 1) {
if (e === 1) return ot(Zt(r), t10);
if (e === 1 / 0) return Ia(Zt(r), t10);
if (e === -1 / 0) return vl(Zt(r), t10);
if (e === "euclidean" || e === 2) return Rr(ot(ri(Zt(r), ke(2, "int32")), t10));
throw new Error(`Error in norm: invalid ord value: ${e}`);
}
if (Array.isArray(t10) && t10.length === 2) {
if (e === 1) return Ia(ot(Zt(r), t10[0]), t10[1] - 1);
if (e === 1 / 0) return Ia(ot(Zt(r), t10[1]), t10[0]);
if (e === -1 / 0) return vl(ot(Zt(r), t10[1]), t10[0]);
if (e === "fro" || e === "euclidean") return Rr(ot(Jt(r), t10));
throw new Error(`Error in norm: invalid ord value: ${e}`);
}
throw new Error(`Error in norm: invalid axis: ${t10}`);
}
var Lu = N({
norm_: $H
});
function EH(r, e = null, t10 = false) {
return Lu(r, "euclidean", e, t10);
}
var r2 = N({
euclideanNorm_: EH
});
function RH(r) {
let t10 = {
x: v(r, "x", "exp")
};
return T.runKernel(gn, t10);
}
var ko = N({
exp_: RH
});
function DH(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 T.runKernel(Js, o, n);
}
var oi = N({
expandDims_: DH
});
function AH(r) {
let t10 = {
x: v(r, "x", "expm1")
};
return T.runKernel(xn, t10);
}
var o2 = N({
expm1_: AH
});
function FH(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 T.runKernel(so, o, n);
}
var nu = N({
tile_: FH
});
function PH(r, e, t10, o = "float32") {
e == null && (e = r);
let n = me([r, e], o),
s = r <= e ? r : e;
for (let i = 0; i < s; ++i) n.set(1, i, i);
let a = W(n.toTensor(), [r, e]);
if (t10 == null) return a;
if (t10.length === 1) return nu(oi(a, 0), [t10[0], 1, 1]);
if (t10.length === 2) return nu(oi(oi(a, 0), 0), [t10[0], t10[1], 1, 1]);
if (t10.length === 3) return nu(oi(oi(oi(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.`);
}
var xd = N({
eye_: PH
});
function OH(r) {
let t10 = {
x: v(r, "x", "floor", "float32")
};
return T.runKernel(bn, t10);
}
var yd = N({
floor_: OH
});
function MH(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 T.runKernel(ta, a, i);
}
var bd = N({
gather_: MH
});
function LH(r, e) {
let t10 = v(r, "a", "greater", "string_or_numeric"),
o = v(e, "b", "greater", "string_or_numeric");
[t10, o] = Oe(t10, o), rt(t10.shape, o.shape);
let n = {
a: t10,
b: o
};
return T.runKernel(In, n);
}
var Bu = N({
greater_: LH
});
function BH(r, e) {
let t10 = v(r, "a", "greaterEqual", "string_or_numeric"),
o = v(e, "b", "greaterEqual", "string_or_numeric");
[t10, o] = Oe(t10, o), rt(t10.shape, o.shape);
let n = {
a: t10,
b: o
};
return T.runKernel(vn, n);
}
var Cd = N({
greaterEqual_: BH
});
function zH(r) {
let t10 = {
input: v(r, "input", "imag")
};
return T.runKernel(Mi, t10);
}
var su = N({
imag_: zH
});
function VH(r) {
let t10 = {
x: v(r, "x", "isFinite")
};
return T.runKernel(kn, t10);
}
var n2 = N({
isFinite_: VH
});
function WH(r) {
let t10 = {
x: v(r, "x", "isInf")
};
return T.runKernel(Nn, t10);
}
var s2 = N({
isInf_: WH
});
function UH(r) {
let t10 = {
x: v(r, "x", "isNaN")
};
return T.runKernel(Tn, t10);
}
var a2 = N({
isNaN_: UH
});
function GH(r, e = 0.2) {
let o = {
x: v(r, "x", "leakyRelu")
},
n = {
alpha: e
};
return T.runKernel(_n, o, n);
}
var wd = N({
leakyRelu_: GH
});
function HH(r, e) {
let t10 = v(r, "a", "less", "string_or_numeric"),
o = v(e, "b", "less", "string_or_numeric");
[t10, o] = Oe(t10, o), rt(t10.shape, o.shape);
let n = {
a: t10,
b: o
};
return T.runKernel($n, n);
}
var kl = N({
less_: HH
});
function KH(r, e) {
let t10 = v(r, "a", "lessEqual", "string_or_numeric"),
o = v(e, "b", "lessEqual", "string_or_numeric");
[t10, o] = Oe(t10, o), rt(t10.shape, o.shape);
let n = {
a: t10,
b: o
};
return T.runKernel(En, n);
}
var ic = N({
lessEqual_: KH
});
function i2(r, e, t10) {
if (t10 <= 0) throw new Error("The number of values should be positive.");
let o = {
start: r,
stop: e,
num: t10
};
return T.runKernel(Rn, {}, o);
}
function qH(r, e = 5, t10 = 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}.`), $(Ba(e), () => `Error in localResponseNormalization: depthRadius must be an integer but got depthRadius ${e}.`);
let a = s,
i = false;
s.rank === 3 && (i = true, a = W(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 = T.runKernel(Mn, p, u);
return i ? W(c, [c.shape[1], c.shape[2], c.shape[3]]) : c;
}
var u2 = N({
localResponseNormalization_: qH
});
function jH(r) {
let t10 = {
x: v(r, "x", "log", "float32")
};
return T.runKernel(Dn, t10);
}
var ni = N({
log_: jH
});
function XH(r) {
let t10 = {
x: v(r, "x", "log1p")
};
return T.runKernel(An, t10);
}
var Sd = N({
log1p_: XH
});
function YH(r) {
return $(Ws(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 T.tidy(() => {
let {
value: s,
grads: a
} = T.gradients(() => r(o), [o], n);
return n != null && xt(s.shape, n.shape, "The shape of dy passed in grad(f)(x, dy) must match the shape returned by f(x)"), Id(a), a[0];
});
};
}
function QH(r) {
return $(Ws(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 = Ja(e, "args", "tf.grads", "string_or_numeric"),
n = t10 != null ? v(t10, "dy", "tf.grads") : null;
return T.tidy(() => {
let {
value: s,
grads: a
} = T.gradients(() => r(...o), o, n);
return n != null && xt(s.shape, n.shape, "The shape of dy passed in grads(f)([x1,...], dy) must match the shape returned by f([x1,...])"), Id(a), a;
});
};
}
function ZH(r) {
return $(Ws(r), () => "The f passed in valueAndGrad(f) must be a function"), (e, t10) => {
$(e instanceof pt, () => "The x passed in valueAndGrad(f)(x) must be a tensor"), $(t10 == null || t10 instanceof pt, () => "The dy passed in valueAndGrad(f)(x, dy) must be a tensor");
let {
grads: o,
value: n
} = T.gradients(() => r(e), [e], t10);
return Id(o), {
grad: o[0],
value: n
};
};
}
function JH(r) {
return $(Ws(r), () => "The f passed in valueAndGrads(f) must be a function"), (e, t10) => {
$(Array.isArray(e) && e.every(n => n instanceof pt), () => "The args passed in valueAndGrads(f)(args) must be array of tensors"), $(t10 == null || t10 instanceof pt, () => "The dy passed in valueAndGrads(f)(args, dy) must be a tensor");
let o = T.gradients(() => r(...e), e, t10);
return t10 != null && xt(o.value.shape, t10.shape, "The shape of dy passed in valueAndGrads(f)([x1,...], dy) must match the shape returned by f([x1,...])"), Id(o.grads), o;
};
}
function vw(r, e) {
$(Ws(r), () => "The f passed in variableGrads(f) must be a function"), $(e == null || Array.isArray(e) && e.every(u => u instanceof Qa), () => "The varList passed in variableGrads(f, varList) must be an array of variables");
let t10 = e != null;
if (!t10) {
e = [];
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
} = T.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 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 Ir(r) {
return T.customGrad(r);
}
function Id(r) {
if (r.filter(t10 => t10 == 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 eK(r) {
let t10 = {
x: v(r, "x", "neg")
};
return T.runKernel(oa, t10);
}
var pr = N({
neg_: eK
});
function tK(r) {
let t10 = {
x: v(r, "x", "softplus")
};
return T.runKernel(gs, t10);
}
var vd = N({
softplus_: tK
});
function rK(r) {
let e = v(r, "x", "logSigmoid");
return Ir(o => ({
value: pr(vd(pr(o))),
gradFunc: a => se(a, wa(pr(o)))
}))(e);
}
var p2 = N({
logSigmoid_: rK
});
function oK(r, e) {
let t10 = v(r, "a", "sub"),
o = v(e, "b", "sub");
[t10, o] = Oe(t10, o);
let n = {
a: t10,
b: o
};
return T.runKernel(Is, n);
}
var Te = N({
sub_: oK
});
function nK(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}`);
return Ir((n, s) => {
let i = Ia(n, e, true),
p = Te(n, i),
u = Te(Ye(p, "float32"), ni(ot(ko(p), e, true)));
return s([u]), {
value: u,
gradFunc: (l, m) => {
let [d] = m,
f = true,
h = ko(d);
return Te(l, se(ot(l, e, f), h));
}
};
})(t10);
}
var c2 = N({
logSoftmax_: nK
});
function sK(r, e = null, t10 = false) {
let o = v(r, "x", "logSumExp"),
n = vi(e, o.shape),
s = Ia(o, n, true),
a = Te(o, s),
i = ko(a),
p = ot(i, n),
u = ni(p),
c = be(W(s, u.shape), u);
if (t10) {
let l = ti(c.shape, n);
return W(c, l);
}
return c;
}
var kd = N({
logSumExp_: sK
});
function aK(r, e) {
let t10 = v(r, "a", "logicalAnd", "bool"),
o = v(e, "b", "logicalAnd", "bool");
rt(t10.shape, o.shape);
let n = {
a: t10,
b: o
};
return T.runKernel(Fn, n);
}
var zu = N({
logicalAnd_: aK
});
function iK(r) {
let t10 = {
x: v(r, "x", "logicalNot", "bool")
};
return T.runKernel(Pn, t10);
}
var Nd = N({
logicalNot_: iK
});
function uK(r, e) {
let t10 = v(r, "a", "logicalOr", "bool"),
o = v(e, "b", "logicalOr", "bool");
rt(t10.shape, o.shape);
let n = {
a: t10,
b: o
};
return T.runKernel(On, n);
}
var Td = N({
logicalOr_: uK
});
function pK(r, e) {
let t10 = v(r, "a", "logicalXor", "bool"),
o = v(e, "b", "logicalXor", "bool");
return rt(t10.shape, o.shape), zu(Td(r, e), Nd(zu(r, e)));
}
var l2 = N({
logicalXor_: pK
});
var _d = 2147483648;
function cK(r, e, t10 = "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 = W(o, [-1, s]),
p = W(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 (Ue(p.shape) >= _d) throw new Error(`values tensor size must less than ${_d}`);
if (i.shape[1] >= _d) throw new Error(`trailing dim_size must less than ${_d} for int32 output type, was ${i.shape[1]}`);
let u = {
sortedSequence: i,
values: p
},
c = {
side: t10
};
return T.runKernel(ls, u, c);
}
var Nl = N({
searchSorted_: cK
});
function m2(r, e) {
return Nl(r, e, "left");
}
function lK(r, e, t10, o, n) {
let s = v(r, "x", "maxPool"),
a = 1,
i = s,
p = false;
s.rank === 3 && (p = true, i = W(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}.`), $(gr(t10, a), () => `Error in maxPool: Either strides or dilations must be 1. Got strides ${t10} and dilations '${a}'`), Lt("maxPool", o, n);
let u = {
x: i
},
c = {
filterSize: e,
strides: t10,
pad: o,
dimRoundingMode: n
},
l = T.runKernel(zn, u, c);
return p ? W(l, [l.shape[1], l.shape[2], l.shape[3]]) : l;
}
var $d = N({
maxPool_: lK
});
function mK(r, e = [1, 1, 1], t10, o, n, s = "NDHWC") {
let a = v(r, "x", "maxPool3d"),
i = a,
p = false;
a.rank === 4 && (p = true, i = W(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}`), Lt("maxPool3d", o, n);
let u = {
x: i
},
c = {
filterSize: e,
strides: t10,
pad: o,
dimRoundingMode: n,
dataFormat: s
},
l = T.runKernel(ra, u, c);
return p ? W(l, [l.shape[1], l.shape[2], l.shape[3], l.shape[4]]) : l;
}
var d2 = N({
maxPool3d_: mK
});
function dK(r, e, t10, o, n = false) {
let a = {
x: v(r, "x", "maxPoolWithArgmax")
},
i = {
filterSize: e,
strides: t10,
pad: o,
includeBatchInIndex: n
},
p = T.runKernel(Bi, a, i);
return {
result: p[0],
indexes: p[1]
};
}
var f2 = N({
maxPoolWithArgmax_: dK
});
function fK(r, e) {
let t10 = v(r, "a", "maximum"),
o = v(e, "b", "maximum");
[t10, o] = Oe(t10, o), t10.dtype === "bool" && (t10 = Ye(t10, "int32"), o = Ye(o, "int32")), rt(t10.shape, o.shape);
let n = {
a: t10,
b: o
};
return T.runKernel(Bn, n);
}
var Ed = N({
maximum_: fK
});
function hK(r, e = null, t10 = false) {
let n = {
x: v(r, "x", "mean")
},
s = {
axis: e,
keepDims: t10
};
return T.runKernel(Vn, n, s);
}
var Vu = N({
mean_: hK
});
function Wr(r, e = "float32") {
if (Ct(r), e === "complex64") {
let o = Wr(r, "float32"),
n = Wr(r, "float32");
return $r(o, n);
}
let t10 = Up(Ue(r), e);
return T.makeTensor(t10, r, e);
}
function va(r, e = "float32") {
if (Ct(r), e === "complex64") {
let o = va(r, "float32"),
n = Wr(r, "float32");
return $r(o, n);
}
let t10 = pl(Ue(r), e);
return T.makeTensor(t10, r, e);
}
function h2(r, e, {
indexing: t10 = "xy"
} = {}) {
if (t10 !== "xy" && t10 !== "ij") throw new TypeError(`${t10} is not a valid third argument to meshgrid`);
if (r === void 0) return [];
let o = v(r, "x", "meshgrid", r instanceof pt ? r.dtype : "float32");
if (e === void 0) return [o];
let n = v(e, "y", "meshgrid", e instanceof pt ? e.dtype : "float32"),
s = Ue(o.shape),
a = Ue(n.shape);
return t10 === "xy" ? (o = W(o, [1, -1]), n = W(n, [-1, 1]), [Qe(va([a, 1], o.dtype), o), Qe(n, va([1, s], n.dtype))]) : (o = W(o, [-1, 1]), n = W(n, [1, -1]), [Qe(o, va([1, a], o.dtype)), Qe(va([s, 1], n.dtype), n)]);
}
function gK(r, e) {
let t10 = v(r, "a", "minimum"),
o = v(e, "b", "minimum");
[t10, o] = Oe(t10, o), t10.dtype === "bool" && (t10 = Ye(t10, "int32"), o = Ye(o, "int32")), rt(t10.shape, o.shape);
let n = {
a: t10,
b: o
};
return T.runKernel(Un, n);
}
var Wu = N({
minimum_: gK
});
function xK(r, e, t10) {
$(t10 === "reflect" || t10 === "symmetric", () => `Invalid mode. Mode must be either reflect or symmetric. Got ${t10}.`);
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;
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 T.runKernel(Gn, a, s);
}
var g2 = N({
mirrorPad_: xK
});
function yK(r, e) {
let t10 = v(r, "a", "mod"),
o = v(e, "b", "mod");
[t10, o] = Oe(t10, o);
let n = {
a: t10,
b: o
};
return T.runKernel(Ga, n);
}
var x2 = N({
mod_: yK
});
function bK(r, e = null, t10 = false) {
r = v(r, "x", "moments");
let o = vi(e, r.shape),
n = Vu(r, o, t10),
s = n.shape;
t10 || (s = ti(n.shape, o));
let a = Jt(Te(Ye(r, "float32"), W(n, s))),
i = Vu(a, o, t10);
return {
mean: n,
variance: i
};
}
var y2 = N({
moments_: bK
});
function CK(r, e, t10, o) {
let n = v(e, "data", "multiRNNCell"),
s = Ja(t10, "c", "multiRNNCell"),
a = Ja(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];
}
let u = [],
c = [];
for (let l = 0; l < p.length; l += 2) u.push(p[l]), c.push(p[l + 1]);
return [u, c];
}
var b2 = N({
multiRNNCell_: CK
});
function wK(r, e, t10, 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 ? W(n, [1, -1]) : n
},
u = {
numSamples: e,
seed: t10,
normalized: o
},
c = T.runKernel(Hn, p, u);
return a === 1 ? W(c, [c.size]) : c;
}
var C2 = N({
multinomial_: wK
});
function SK(r, e) {
let t10 = v(r, "a", "notEqual", "string_or_numeric"),
o = v(e, "b", "notEqual", "string_or_numeric");
[t10, o] = Oe(t10, o), rt(t10.shape, o.shape);
let n = {
a: t10,
b: o
};
return T.runKernel(qn, n);
}
var Rd = N({
notEqual_: SK
});
function IK(r, e, t10 = 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 T.runKernel(Yn, a, i);
}
var Tl = N({
oneHot_: IK
});
function vK(r) {
let t10 = {
x: v(r, "x", "onesLike")
};
return T.runKernel(na, t10);
}
var w2 = N({
onesLike_: vK
});
function kK(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 = W(t10, [-1, 1]),
s = W(o, [1, -1]);
return Qe(n, s);
}
var S2 = N({
outerProduct_: kK
});
function NK(r, e, t10 = 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 T.runKernel(Qn, s, n);
}
var ka = N({
pad_: NK
});
function TK(r, e, t10 = 0) {
return $(e.length === 2, () => "Invalid number of paddings. Must be length of 2."), ka(r, [e], t10);
}
var I2 = N({
pad1d_: TK
});
function _K(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."), ka(r, e, t10);
}
var v2 = N({
pad2d_: _K
});
function $K(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."), ka(r, e, t10);
}
var k2 = N({
pad3d_: $K
});
function EK(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."), ka(r, e, t10);
}
var N2 = N({
pad4d_: EK
});
function RK(r, e, t10) {
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 T.runKernel(ca, n, s);
}
var Dd = N({
spaceToBatchND_: RK
});
function DK(r, e, t10, 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 = W(i, [1, i.shape[0], i.shape[1], i.shape[2]])), $(gr(s, n), () => `Error in pool: Either strides or dilations must be 1. Got strides ${s} and dilations '${n}'`);
let c = ww(p.shape, e, s, n, o),
l = [c.dilationHeight, c.dilationWidth],
m;
o === "same" ? m = FK([c.filterHeight, c.filterWidth], l) : m = [[0, 0], [0, 0]];
let d = l[0] === 1 && l[1] === 1,
[f, h] = AK([c.inHeight, c.inWidth], l, m),
g = d ? o : "valid",
x = d ? p : Dd(p, l, f),
w = (t10 === "avg" ? () => cd(x, e, s, g, a) : () => $d(x, e, s, g, a))(),
S = d ? w : ld(w, l, h);
return u ? W(S, [S.shape[1], S.shape[2], S.shape[3]]) : S;
}
function AK(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]]);
return [p, u];
}
function FK(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 T2 = N({
pool_: DK
});
function PK(r, e) {
let t10 = v(r, "x", "prelu"),
o = v(e, "alpha", "prelu"),
n = {
x: t10,
alpha: o
};
return T.runKernel(Jn, n);
}
var Ad = N({
prelu_: PK
});
function OK(r, e = null, t10 = false) {
let o = v(r, "x", "prod");
o.dtype === "bool" && (o = Ye(o, "int32"));
let n = {
x: o
},
s = {
axis: e,
keepDims: t10
};
return T.runKernel(es, n, s);
}
var _2 = N({
prod_: OK
});
function MK(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 = T.runKernel(Kp, i, p);
return {
outputNestedSplits: u.slice(0, u.length - 1),
outputDenseValues: u[u.length - 1]
};
}
var $2 = N({
raggedGather_: MK
});
function LK(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 = T.runKernel(qp, a);
return {
rtNestedSplits: i[0],
rtDenseValues: i[1]
};
}
var E2 = N({
raggedRange_: LK
});
function BK(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 T.runKernel(jp, u, c);
}
var R2 = N({
raggedTensorToTensor_: BK
});
function zK(r, e, t10) {
Ct(r);
let o = Ue(r),
n = null;
if (t10 == null || t10 === "float32") n = new Float32Array(o);else if (t10 === "int32") n = new Int32Array(o);else if (t10 === "bool") n = new Uint8Array(o);else throw new Error(`Unknown data type ${t10}`);
for (let s = 0; s < o; s++) n[s] = e();
return T.makeTensor(n, r, t10);
}
var D2 = N({
rand_: zK
});
var Ld = Bp(Rw());
var Z2 = {};
He(Z2, {
TEST_EPSILON_FLOAT16: () => X2,
createVideoElement: () => JK,
encodeStrings: () => Q2,
expectArrayBuffersEqual: () => ZK,
expectArraysClose: () => jK,
expectArraysEqual: () => YK,
expectNumbersClose: () => Y2,
expectPromiseToFail: () => XK,
expectValuesInRange: () => QK,
play: () => eq,
testEpsilon: () => Pd
});
var qK = 1e-3;
var X2 = 0.1;
function jK(r, e, t10) {
return t10 == null && (t10 = Pd()), Dw(r, e, (o, n) => Aw(o, n, t10));
}
function Pd() {
return T.backend.floatPrecision() === 32 ? qK : X2;
}
function Dw(r, e, t10) {
let o = true;
if ((Pt(r) || Pt(e)) && (o = false), Pt(r) && Pt(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 = ar(r),
i = ar(e);
if (!br(a, i)) throw new Error(`Arrays have different shapes. Actual: [${a}]. Expected: [${i}]`);
}
let n = Pt(r) ? r : Es(r),
s = Pt(e) ? e : Es(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)) throw new Error(`Arrays differ: actual[${a}] = ${i}, expected[${a}] = ${p}.
Actual: ${n}.
Expected: ${s}.`);
}
typeof expect != "undefined" && expect().nothing();
}
function XK(r, e) {
r().then(() => e.fail(), () => e()), typeof expect != "undefined" && expect().nothing();
}
function YK(r, e) {
let t10 = typeof e == "string" || typeof e == "number" || typeof e == "boolean" ? [e] : e;
return Bo(r) || Bo(r[0]) || Bo(e) || Bo(e[0]) ? Dw(r, t10, (o, n) => o == n) : Dw(r, e, (o, n) => Aw(o, n, 0));
}
function Y2(r, e, t10) {
if (t10 == null && (t10 = Pd()), !Aw(r, e, t10)) throw new Error(`Numbers differ: actual === ${r}, expected === ${e}`);
typeof expect != "undefined" && expect().nothing();
}
function Aw(r, e, t10) {
return !isFinite(r) && !isFinite(e) ? true : !(isNaN(r) || isNaN(e) || Math.abs(r - e) > t10);
}
function QK(r, e, t10) {
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}`);
}
function ZK(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}`);
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`);
}
function Q2(r) {
for (let e = 0; e < r.length; e++) {
let t10 = r[e];
Array.isArray(t10) ? Q2(t10) : r[e] = Yi(t10);
}
return r;
}
function JK(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();
});
}
async function eq(r) {
await r.play(), "requestVideoFrameCallback" in r && (await new Promise(e => {
r.requestVideoFrameCallback(e);
}));
}
var Gu = 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);
let a = s || Math.random();
this.random = Ld.alea(a.toString());
}
nextValue() {
if (!isNaN(this.nextVal)) {
let n = this.nextVal;
return this.nextVal = NaN, n;
}
let e,
t10,
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);
}
return (!this.truncated || this.isValidTruncated(t10)) && (this.nextVal = this.convertValue(t10)), this.convertValue(e);
}
convertValue(e) {
return this.dtype == null || this.dtype === "float32" ? e : Math.round(e);
}
isValidTruncated(e) {
return e <= this.upper && e >= this.lower;
}
};
var Od = class {
constructor(e, t10, o, n) {
this.alpha = e, this.beta = 1 / t10, this.dtype = o;
let s = n || Math.random();
this.randu = Ld.alea(s.toString()), this.randn = new Gu(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;
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) break;
}
return a = 1 / this.beta * this.d * a, this.alpha < 1 && (a *= Math.pow(this.randu(), 1 / this.alpha)), this.convertValue(a);
}
convertValue(e) {
return this.dtype === "float32" ? e : Math.round(e);
}
};
var Md = 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 = Ld.alea(n);
}
convertValue(e) {
return this.canReturnFloat() ? e : Math.round(e);
}
nextValue() {
return this.convertValue(this.min + this.range * this.random());
}
};
function tq(r, e, t10 = 1, o = "float32", n) {
if (Ct(r), t10 == null && (t10 = 1), o == null && (o = "float32"), o !== "float32" && o !== "int32") throw new Error(`Unsupported data type ${o}`);
let s = new Od(e, t10, o, n),
a = me(r, o);
for (let i = 0; i < a.values.length; i++) a.values[i] = s.nextValue();
return a.toTensor();
}
var J2 = N({
randomGamma_: tq
});
function rq(r, e = 0, t10 = 1, o, n) {
if (Ct(r), o != null && o === "bool") throw new Error(`Unsupported data type ${o}`);
let s = new Gu(e, t10, o, false, n),
a = me(r, o);
for (let i = 0; i < a.values.length; i++) a.values[i] = s.nextValue();
return a.toTensor();
}
var Bd = N({
randomNormal_: rq
});
function oq(r, e, t10) {
if (e != null && e === "bool") throw new Error(`Unsupported data type ${e}`);
return Bd(r, 0, 1, e, t10);
}
var e1 = N({
randomStandardNormal_: oq
});
function nq(r, e = 0, t10 = 1, o = "float32", n) {
Ct(r);
let s = me(r, o),
a = new Md(e, t10, null, n);
for (let i = 0; i < s.values.length; i++) s.values[i] = a.nextValue();
return s.toTensor();
}
var uc = N({
randomUniform_: nq
});
function sq(r, e, t10, o) {
return uc(r, e, t10, "int32", o);
}
var t1 = N({
randomUniformInt_: sq
});
function au(r, e, t10 = 1, o = "float32") {
if (t10 === 0) throw new Error("Cannot have a step of zero");
let n = {
start: r,
stop: e,
step: t10,
dtype: o
};
return T.runKernel(aa, {}, n);
}
function aq(r) {
let t10 = {
input: v(r, "input", "real")
};
return T.runKernel(zi, t10);
}
var si = N({
real_: aq
});
function iq(r) {
let t10 = {
x: v(r, "x", "reciprocal")
};
return T.runKernel(ts, t10);
}
var r1 = N({
reciprocal_: iq
});
function uq(r) {
let t10 = {
x: v(r, "x", "relu")
};
return T.runKernel(rs, t10);
}
var iu = N({
relu_: uq
});
function pq(r) {
let t10 = {
x: v(r, "x", "relu6")
};
return T.runKernel(ss, t10);
}
var zd = N({
relu6_: pq
});
function cq(r, e) {
let o = {
x: v(r, "x", "reverse")
},
n = {
dims: e
};
return T.runKernel(as, o, n);
}
var uo = N({
reverse_: cq
});
function lq(r) {
let e = v(r, "x", "reverse");
return $(e.rank === 1, () => `Error in reverse1D: x must be rank 1 but got rank ${e.rank}.`), uo(e, 0);
}
var o1 = N({
reverse1d_: lq
});
function mq(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}.`), uo(t10, e);
}
var n1 = N({
reverse2d_: mq
});
function dq(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}.`), uo(t10, e);
}
var s1 = N({
reverse3d_: dq
});
function fq(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}.`), uo(t10, e);
}
var a1 = N({
reverse4d_: fq
});
function hq(r) {
let t10 = {
x: v(r, "x", "round")
};
return T.runKernel(is, t10);
}
var Vd = N({
round_: hq
});
function gq(r) {
let t10 = {
x: v(r, "x", "rsqrt", "float32")
};
return T.runKernel(us, t10);
}
var i1 = N({
rsqrt_: gq
});
function xq(r) {
let t10 = {
x: v(r, "x", "selu")
};
return T.runKernel(ms, t10);
}
var u1 = N({
selu_: xq
});
function yq(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;
if (i.rank === 3 && (l = true, c = W(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],
d = p.shape[3];
$(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 = ac(c, p, o, n, a, s),
g = ou(f, u, 1, "valid", a);
return l ? W(g, [g.shape[1], g.shape[2], g.shape[3]]) : g;
}
var p1 = N({
separableConv2d_: yq
});
async function bq(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;
for (let c = 0; c < n.length; c++) a.has(n[c]) || i++;
let p = new tt([i], t10.dtype),
u = new tt([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 c1 = bq;
function Cq(r) {
let t10 = {
x: v(r, "x", "sign")
};
return T.runKernel(fs, t10);
}
var l1 = N({
sign_: Cq
});
function wq(r) {
let t10 = {
x: v(r, "x", "sin", "float32")
};
return T.runKernel(ds, t10);
}
var m1 = N({
sin_: wq
});
function Sq(r) {
let t10 = {
x: v(r, "x", "sinh")
};
return T.runKernel(ja, t10);
}
var d1 = N({
sinh_: Sq
});
function Iq(r, e, t10) {
let o = v(r, "x", "slice1d");
return $(o.rank === 1, () => `slice1d expects a rank-1 tensor, but got a rank-${o.rank} tensor`), qe(o, [e], [t10]);
}
var f1 = N({
slice1d_: Iq
});
function vq(r, e, t10) {
let o = v(r, "x", "slice2d");
return $(o.rank === 2, () => `slice2d expects a rank-2 tensor, but got a rank-${o.rank} tensor`), qe(o, e, t10);
}
var h1 = N({
slice2d_: vq
});
function kq(r, e, t10) {
let o = v(r, "x", "slice3d");
return $(o.rank === 3, () => `slice3d expects a rank-3 tensor, but got a rank-${o.rank} tensor`), qe(o, e, t10);
}
var g1 = N({
slice3d_: kq
});
function Nq(r, e, t10) {
let o = v(r, "x", "slice4d");
return $(o.rank === 4, () => `slice4d expects a rank-4 tensor, but got a rank-${o.rank} tensor`), qe(o, e, t10);
}
var x1 = N({
slice4d_: Nq
});
function Tq(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 T.runKernel(bs, o, n);
}
var y1 = N({
softmax_: Tq
});
function _q(r) {
$(r.dtype === "complex64", () => `The dtype for tf.spectral.fft() must be complex64 but got ${r.dtype}.`);
let e = {
input: r
};
return T.runKernel(Pi, e);
}
var pc = N({
fft_: _q
});
function $q(r) {
$(r.dtype === "complex64", () => `The dtype for tf.spectral.ifft() must be complex64 but got ${r.dtype}.`);
let e = {
input: r
};
return T.runKernel(Oi, e);
}
var Hu = N({
ifft_: $q
});
function Eq(r) {
let e = r.shape[r.shape.length - 1],
t10 = r.size / e,
o;
if (e <= 2) {
let n = W(r, [t10, e]);
o = Hu(n);
} else {
let n = [t10, 2 * (e - 1)],
s = W(si(r), [t10, e]),
a = W(su(r), [t10, e]),
i = uo(qe(s, [0, 1], [t10, e - 2]), 1),
p = se(uo(qe(a, [0, 1], [t10, e - 2]), 1), ke(-1)),
u = yt([s, i], 1),
c = yt([a, p], 1),
l = W($r(u, c), [n[0], n[1]]);
o = Hu(l);
}
if (o = si(o), r.rank === 3 && r.shape[0] !== 0) {
let n = o,
s = r.shape[0];
o = W(o, [s, o.shape[0] / s, o.shape[1]]), n.dispose();
}
return o;
}
var Wd = N({
irfft_: Eq
});
function Rq(r, e, t10 = 0) {
let n = {
x: v(r, "x", "split")
},
s = {
numOrSizeSplits: e,
axis: t10
};
return T.runKernel(la, n, s);
}
var ai = N({
split_: Rq
});
function Dq(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 f = r.shape.map(g => 0),
h = r.shape.map(g => g);
h[r.shape.length - 1] = e, n = qe(r, f, h), t10 = e;
} else if (e != null && e > t10) {
let f = r.shape.map(h => h);
f[r.shape.length - 1] = e - t10, n = yt([r, Wr(f)], r.shape.length - 1), t10 = e;
} else n = r;
let s = Ht(n),
a = W($r(n, s), [o, t10]),
i = pc(a),
p = Math.floor(t10 / 2) + 1,
u = si(i),
c = su(i),
l = ai(u, [p, t10 - p], u.shape.length - 1),
m = ai(c, [p, t10 - p], c.shape.length - 1),
d = n.shape.slice();
return d[n.shape.length - 1] = p, W($r(l[0], m[0]), d);
}
var cc = N({
rfft_: Dq
});
function Aq(r, e) {
let t10 = v(r, "a", "squaredDifference"),
o = v(e, "b", "squaredDifference");
[t10, o] = Oe(t10, o), rt(t10.shape, o.shape);
let n = {
a: t10,
b: o
},
s = {};
return T.runKernel(ws, n, s);
}
var Ud = N({
squaredDifference_: Aq
});
function Fq(r, e) {
let t10 = v(r, "x", "squeeze", "string_or_numeric");
return W(t10, MC(t10.shape, e).newShape);
}
var lc = N({
squeeze_: Fq
});
function Pq(r, e = 0) {
let t10 = Ja(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 T.runKernel(sa, o, n);
}
var vr = N({
stack_: Pq
});
function Oq(r, e = 0) {
let o = {
x: v(r, "x", "step")
},
n = {
alpha: e
};
return T.runKernel(yo, o, n);
}
var Gd = N({
step_: Oq
});
function Mq(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 T.runKernel(Ss, c, l);
}
var b1 = N({
stridedSlice_: Mq
});
function Lq(r) {
let t10 = {
x: v(r, "x", "tan", "float32")
};
return T.runKernel(vs, t10);
}
var C1 = N({
tan_: Lq
});
function xr(r, e) {
oo(r);
let t10 = ar(r, e);
if (t10.length !== 1) throw new Error("tensor1d() requires values to be a flat/TypedArray");
return wr(r, null, t10, e);
}
function uu(r, e, t10) {
if (oo(r), e != null && e.length !== 2) throw new Error("tensor2d() requires shape to have two numbers");
let o = ar(r, t10);
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 wr(r, e, o, t10);
}
function Hd(r, e, t10) {
if (oo(r), e != null && e.length !== 3) throw new Error("tensor3d() requires shape to have three numbers");
let o = ar(r, t10);
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 wr(r, e, o, t10);
}
function w1(r, e, t10) {
if (oo(r), e != null && e.length !== 4) throw new Error("tensor4d() requires shape to have four numbers");
let o = ar(r, t10);
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 wr(r, e, o, t10);
}
function S1(r, e, t10) {
if (oo(r), e != null && e.length !== 5) throw new Error("tensor5d() requires shape to have five numbers");
let o = ar(r, t10);
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 wr(r, e, o, t10);
}
function I1(r, e, t10) {
if (oo(r), e != null && e.length !== 6) throw new Error("tensor6d() requires shape to have six numbers");
let o = ar(r, t10);
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, wr(r, e, o, t10);
}
var pu = {};
He(pu, {
calculateShapes: () => v1,
validateInput: () => mc,
validateUpdateShape: () => Fw
});
function Fw(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) 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) 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]})`);
}
function mc(r, e, t10) {
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 (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}`);
}
Fw(t10, e, r);
}
function v1(r, e, t10) {
let o = e.shape.length,
n = o > 1 ? e.shape[o - 1] : 1,
s = t10.length,
a = 1;
for (let l = n; l < s; ++l) a *= t10[l];
let i = n < 1 ? 1 : n,
p = Ue(e.shape) / i,
u = [...Us(t10.slice(0, n)), 1],
c = Ue(t10);
return {
sliceRank: n,
numUpdates: p,
sliceSize: a,
strides: u,
outputSize: c
};
}
function Bq(r, e, t10) {
let o = v(r, "tensor", "tensorScatterupdate"),
n = v(e, "indices", "tensorScatterupdate", "int32"),
s = v(t10, "updates", "tensorScatterupdate");
if (mc(s, n, o.shape), o.dtype !== s.dtype) throw new Error(`tensor and updates must have the same dtype, instead they are ${o.dtype} and ${s.dtype}.`);
let a = {
tensor: o,
indices: n,
updates: s
},
i = {};
return T.runKernel(cs, a, i);
}
var k1 = N({
tensorScatterUpdate_: Bq
});
function zq(r, e = 1, t10 = 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");
let n = o.shape[o.shape.length - 1];
if (e < 0) 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] = T.runKernel(Ns, s, a);
return {
values: i,
indices: p
};
}
var N1 = N({
topk_: zq
});
function Vq(r, e = 0, t10 = 1, o, n) {
if (Ct(r), o != null && o === "bool") throw new Error("Unsupported data type $ { dtype }");
let s = new Gu(e, t10, o, true, n),
a = me(r, o);
for (let i = 0; i < a.values.length; i++) a.values[i] = s.nextValue();
return a.toTensor();
}
var T1 = N({
truncatedNormal_: Vq
});
function Wq(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] = T.runKernel(qi, o, n);
return {
values: s,
indices: a
};
}
var _1 = N({
unique_: Wq
});
function Uq(r, e, t10) {
let o = v(r, "x", "unsortedSegmentSum"),
n = v(e, "segmentIds", "unsortedSegmentSum", "int32");
$(Ba(t10), () => "numSegments must be of dtype int");
let s = {
x: o,
segmentIds: n
},
a = {
numSegments: t10
};
return T.runKernel(ji, s, a);
}
var $1 = N({
unsortedSegmentSum_: Uq
});
function Gq(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 T.runKernel(da, o, n);
}
var po = N({
unstack_: Gq
});
function E1(r, e) {
return Nl(r, e, "right");
}
function R1(r, e = true, t10, o) {
return T.makeVariable(r, e, t10, o);
}
function Kd(r, e) {
let t10 = [];
for (let s = 0; s < e.length; s++) e[s] && t10.push(s);
let o = me(r, "int32"),
n = me([t10.length, r.length], "int32");
for (let s = 0; s < t10.length; s++) {
let a = o.indexToLoc(t10[s]),
i = s * r.length;
n.values.set(a, i);
}
return n.toTensor();
}
async function Hq(r) {
let e = v(r, "condition", "whereAsync", "bool"),
t10 = await e.data(),
o = Kd(e.shape, t10);
return r !== e && e.dispose(), o;
}
var qd = Hq;
async function Kq(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"), xt(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 = W(o, u),
l = W(n, [-1]),
m = await qd(l),
d = lc(m, [1]),
f = bd(c, d, s);
return r !== o && o.dispose(), e !== n && n.dispose(), d.dispose(), c.dispose(), l.dispose(), m.dispose(), f;
}
var qq = Kq;
function jq(r, e, t10) {
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}`);
}), o.rank <= 1) return o.clone();
let n = {
x: o
},
s = {
perm: e
};
return o.dtype === "complex64" ? De(() => {
let a = si(o),
i = su(o);
return a = T.runKernel(ao, {
x: a
}, s), i = T.runKernel(ao, {
x: i
}, s), t10 && (i = pr(i)), $r(a, i);
}) : T.runKernel(ao, n, s);
}
var dc = N({
transpose_: jq
});
function Xq(r, e, t10, o, n = true) {
let s = v(r, "v", "movingAverage"),
a = v(e, "x", "movingAverage"),
i = v(t10, "decay", "movingAverage");
nw(s, a), $(br(s.shape, a.shape), () => "Shape mismatch in v and x");
let p = ke(1),
u = Te(p, i),
c = se(Te(a, s), u);
if (n) {
$(o != null, () => "When using zeroDebias: true, step is required.");
let l = v(o, "step", "movingAverage");
c = Ke(c, Te(p, ri(i, l)));
}
return be(s, c);
}
var Yq = N({
movingAverage_: Xq
});
function Qq(r, e, t10) {
Ct(t10);
let o = v(r, "indices", "scatterND", "int32"),
n = v(e, "updates", "scatterND");
mc(n, o, t10);
let s = {
indices: o,
updates: n
},
a = {
shape: t10
};
return T.runKernel(ps, s, a);
}
var Zq = N({
scatterND_: Qq
});
function D1(r, e, t10, 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}.`);
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 e6(r, e, t10, o = 0) {
Ct(t10);
let n = v(r, "sparseIndices", "sparseToDense", "int32"),
s = v(e, "sparseValues", "sparseToDense", "string_or_numeric"),
a = v(o, "defaultValue", "sparseToDense", s.dtype);
D1(n, s, t10, a);
let i = {
sparseIndices: n,
sparseValues: s,
defaultValue: a
},
p = {
outputShape: t10
};
return T.runKernel(Cs, i, p);
}
var t6 = N({
sparseToDense_: e6
});
function r6(r, e) {
let t10 = v(e, "indices", "gatherND", "int32"),
n = {
params: v(r, "x", "gatherND", "string_or_numeric"),
indices: t10
};
return T.runKernel(Sn, n);
}
var o6 = N({
gatherND_: r6
});
function A1(r, e) {
if (e == null) return r.shape.slice();
if (br(r.shape, e)) return e;
if (r.shape.length === e.length) {
let t10 = [];
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;
}
return e;
}
function n6(r, e, t10, 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 pt ? n.clone() : n;
let s = A1(n, t10),
a = 1 - e,
i = Ke(yd(be(uc(s, 0, 1, "float32", o), a)), a);
return se(n, i);
}
var s6 = N({
dropout_: n6
});
function Pw(r) {
return Math.floor(Math.pow(2, Math.ceil(Math.log(r) / Math.log(2))));
}
function _l(r, e, t10) {
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);
}
return xr(n, "float32");
}
async function a6(r, e, t10 = 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}`), xt(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 = LC("bool", p);
for (let l = 0; l < p; 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 < t10; h++) if (f[h].index === i[l]) {
c[l] = 1;
break;
}
}
return r !== o && o.dispose(), e !== n && n.dispose(), ir(c, n.shape, "bool");
}
var i6 = a6;
var Ow = {};
He(Ow, {
conv2d: () => P1,
depthwiseConv2d: () => L1,
matMul: () => B1
});
function u6(r, e, t10, o, n, s = "NHWC", a) {
let i = r;
r.rank === 3 && (i = W(r, [1, r.shape[0], r.shape[1], r.shape[2]]));
let p = e;
p.rank === 3 && (p = W(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}.`);
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]}).`), Lt("conv2dDerFilter", n, a);
let l = {
x: i,
dy: p
},
m = {
strides: o,
pad: n,
dataFormat: s,
dimRoundingMode: a,
filterShape: t10
};
return T.runKernel($i, l, m);
}
var F1 = N({
conv2DBackpropFilter_: u6
});
function Ku(r, e, t10) {
if (t10 == null || t10 === "linear") return r;
if (t10 === "relu") return se(r, Gd(e));
throw new Error(`Cannot compute gradient for fused activation ${t10}.`);
}
function qu(r, e) {
let t10 = e,
o = fd(r.shape, e.shape);
return o.length > 0 && (t10 = ot(t10, o)), W(t10, r.shape);
}
function ju(r, e, t10, o) {
if (e === "linear") return r;
if (e === "relu") return iu(r);
if (e === "elu") return gd(r);
if (e === "relu6") return zd(r);
if (e === "prelu") return Ad(r, t10);
if (e === "leakyrelu") return wd(r, o);
if (e === "sigmoid") return wa(r);
throw new Error(`Unknown fused activation ${e}.`);
}
var Xu = (r, e) => !(r > 0) || e === "linear";
function p6({
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", Xu(T.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 _ = ou(r, e, t10, o, n, s, a);
return i != null && (_ = be(_, i)), ju(_, p, u, c);
}
let l = v(r, "x", "conv2d", "float32"),
m = v(e, "filter", "conv2d", "float32"),
d = l,
f = false;
l.rank === 3 && (f = true, d = W(l, [1, l.shape[0], l.shape[1], l.shape[2]])), $(d.rank === 4, () => `Error in fused conv2d: input must be rank 4, but got rank ${d.rank}.`), $(m.rank === 4, () => `Error in fused conv2d: filter must be rank 4, but got rank ${m.rank}.`), Lt("fused conv2d", o, a);
let h = n === "NHWC" ? d.shape[3] : d.shape[1];
$(m.shape[2] === h, () => `Error in conv2d: depth of input (${h}) must match input depth for filter ${m.shape[2]}.`), $(gr(t10, s), () => `Error in conv2D: Either strides or dilations must be 1. Got strides ${t10} and dilations '${s}'`);
let g = Mu(d.shape, m.shape, t10, s, o, a),
x;
i != null && (x = v(i, "bias", "fused conv2d"), [x] = Oe(x, l), n === "NHWC" ? rt(g.outShape, x.shape) : ($(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}.`), $(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}).`);else if (_.length === 3) try {
rt(_, 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);
}
b = v(u, "prelu weights", "fused conv2d");
}
let w = (_, E) => {
$(n === "NHWC", () => `Error in gradient of fused conv2D: got dataFormat of ${n} but only NHWC is currently supported.`);
let [R, D, F, O] = E,
M = Ku(_, F, p);
$(Ou(s), () => `Error in gradient of fused conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${s}'`);
let L = dd(D.shape, M, R, t10, o),
B = F1(D, M, R.shape, t10, o),
z = [L, B];
if (O != null) {
let U = qu(O, M);
z.push(U);
}
return z;
},
S = {
x: d,
filter: m,
bias: x,
preluActivationWeights: b
},
k = {
strides: t10,
pad: o,
dataFormat: n,
dilations: s,
dimRoundingMode: a,
activation: p,
leakyreluAlpha: c
};
return i == null ? Ir((E, R, D) => {
let F = T.runKernel(Co, S, k);
return D([R, E, F]), f && (F = W(F, [F.shape[1], F.shape[2], F.shape[3]])), {
value: F,
gradFunc: w
};
})(d, m) : Ir((E, R, D, F) => {
let O = T.runKernel(Co, S, k);
return F([R, E, O, D]), f && (O = W(O, [O.shape[1], O.shape[2], O.shape[3]])), {
value: O,
gradFunc: w
};
})(d, m, x);
}
var P1 = N({
fusedConv2d_: p6
});
function c6(r, e, t10, o, n, s = [1, 1], a) {
let i = r;
r.rank === 3 && (i = W(r, [1, r.shape[0], r.shape[1], r.shape[2]]));
let p = e;
p.rank === 3 && (p = W(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 T.runKernel(Ei, u, c);
}
var O1 = N({
depthwiseConv2dNativeBackpropFilter_: c6
});
function l6(r, e, t10, o, n, s = [1, 1], a) {
let i = e,
p = false;
e.rank === 3 && (p = true, i = W(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 = T.runKernel(Ri, u, c);
return p ? W(l, [l.shape[1], l.shape[2], l.shape[3]]) : l;
}
var M1 = N({
depthwiseConv2dNativeBackpropInput_: l6
});
function m6({
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 (Xu(T.state.gradientDepth, p) === false) {
let k = ac(r, e, t10, o, n, s, a);
return i != null && (k = be(k, i)), ju(k, p, u, c);
}
let l = v(r, "x", "depthwiseConv2d", "float32"),
m = v(e, "filter", "depthwiseConv2d", "float32"),
d = l,
f = false;
l.rank === 3 && (f = true, d = W(l, [1, l.shape[0], l.shape[1], l.shape[2]])), $(d.rank === 4, () => `Error in fused depthwiseConv2d: input must be rank 4, but got rank ${d.rank}.`), $(m.rank === 4, () => `Error in fused depthwiseConv2d: filter must be rank 4, but got rank ${m.rank}.`), $(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]), $(gr(t10, s), () => `Error in fused depthwiseConv2d: Either strides or dilations must be 1. Got strides ${t10} and dilations '${s}'`), Lt("fused depthwiseConv2d", o, a);
let h = Mu(d.shape, m.shape, t10, s, o, a, true),
g;
i != null && (g = v(i, "bias", "fused conv2d"), [g] = Oe(g, l), rt(h.outShape, g.shape));
let x;
u != null && (x = v(u, "prelu weights", "fused depthwiseConv2d"));
let b = (k, _) => {
$(Ou(s), () => `Error in gradient of fused depthwiseConv2d: dilation rates greater than 1 are not yet supported. Got dilations '${s}'`);
let [E, R, D, F] = _,
O = Ku(k, D, p),
M = M1(R.shape, O, E, t10, o, s, a),
L = O1(R, O, E.shape, t10, o, s, a);
if (F != null) {
let B = qu(g, O);
return [M, L, B];
}
return [M, L];
},
w = {
x: d,
filter: m,
bias: g,
preluActivationWeights: x
},
S = {
strides: t10,
pad: o,
dataFormat: n,
dilations: s,
dimRoundingMode: a,
activation: p,
leakyreluAlpha: c
};
return i == null ? Ir((_, E, R) => {
let D = T.runKernel(wo, w, S);
return R([E, _, D]), f && (D = W(D, [D.shape[1], D.shape[2], D.shape[3]])), {
value: D,
gradFunc: b
};
})(d, m) : Ir((_, E, R, D) => {
let F = T.runKernel(wo, w, S);
return D([E, _, F, R]), f && (F = W(F, [F.shape[1], F.shape[2], F.shape[3]])), {
value: F,
gradFunc: b
};
})(d, m, g);
}
var L1 = N({
fusedDepthwiseConv2d_: m6
});
function d6({
a: r,
b: e,
transposeA: t10 = false,
transposeB: o = false,
bias: n,
activation: s = "linear",
preluActivationWeights: a,
leakyreluAlpha: i = 0.2
}) {
if (Xu(T.state.gradientDepth, s) === false) {
let O = Qe(r, e, t10, o);
return n != null && (O = be(O, n)), ju(O, s, a, i);
}
let p = v(r, "a", "fused matMul"),
u = v(e, "b", "fused matMul");
[p, u] = Oe(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],
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 = Ue(f),
x = Ue(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 w = rt(p.shape.slice(0, -2), u.shape.slice(0, -2)).concat([m, d]),
S = t10 ? W(p, [g, c, m]) : W(p, [g, m, c]),
k = o ? W(u, [x, d, l]) : W(u, [x, l, d]),
_;
n != null && (_ = v(n, "bias", "fused matMul"), [_] = Oe(_, p), rt(w, _.shape));
let E;
a != null && (E = v(a, "prelu weights", "fused matMul"));
let R = (O, M) => {
let [L, B, z, U] = M,
j = Ku(W(O, z.shape), z, s),
H,
X;
if (!t10 && !o ? (H = Qe(j, B, false, true), X = Qe(L, j, true, false)) : !t10 && o ? (H = Qe(j, B, false, false), X = Qe(j, L, true, false)) : t10 && !o ? (H = Qe(B, j, false, true), X = Qe(L, j, false, false)) : (H = Qe(B, j, true, true), X = Qe(j, L, true, true)), n != null) {
let J = qu(U, j);
return [H, X, J];
} else return [H, X];
},
D = {
a: S,
b: k,
bias: _,
preluActivationWeights: E
},
F = {
transposeA: t10,
transposeB: o,
activation: s,
leakyreluAlpha: i
};
return n == null ? Ir((M, L, B) => {
let z = T.runKernel(bo, D, F);
return B([M, L, z]), {
value: W(z, w),
gradFunc: R
};
})(S, k) : Ir((M, L, B, z) => {
let U = T.runKernel(bo, D, F);
return z([M, L, U, B]), {
value: W(U, w),
gradFunc: R
};
})(S, k, _);
}
var B1 = N({
fusedMatMul_: d6
});
function f6(r) {
return _l(r, 0.54, 0.46);
}
var z1 = N({
hammingWindow_: f6
});
function h6(r) {
return _l(r, 0.5, 0.5);
}
var jd = N({
hannWindow_: h6
});
function g6(r, e, t10, o = false, n = 0) {
let s = 0,
a = [];
for (; s + e <= r.size;) a.push(qe(r, s, e)), s += t10;
if (o) for (; s < r.size;) {
let i = s + e - r.size,
p = yt([qe(r, s, e - i), Sa([i], n)]);
a.push(p), s += t10;
}
return a.length === 0 ? uu([], [0, e]) : W(yt(a), [a.length, e]);
}
var Xd = N({
frame_: g6
});
function x6(r, e, t10, o, n = jd) {
o == null && (o = Pw(e));
let s = Xd(r, e, t10),
a = se(s, n(e));
return cc(a, o);
}
var V1 = N({
stft_: x6
});
function y6(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}`);
let c = {
image: a,
boxes: i,
boxInd: p
},
l = {
method: n,
extrapolationValue: s,
cropSize: o
};
return T.runKernel(pn, c, l);
}
var W1 = N({
cropAndResize_: y6
});
function b6(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 T.runKernel(yn, t10, {});
}
var U1 = N({
flipLeftRight_: b6
});
function C6(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}.`);
let n = new Array(e.rank);
return n.fill(1, 0, t10), n[t10] = 3, nu(e, n);
}
var G1 = N({
grayscaleToRGB_: C6
});
function w6(r, e, t10 = 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 T.runKernel(_s, s, a);
}
var H1 = N({
rotateWithOffset_: w6
});
function No(r, e, t10, 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
};
}
function S6(r, e, t10, o = 0.5, n = Number.NEGATIVE_INFINITY) {
let s = v(r, "boxes", "nonMaxSuppression", "float32"),
a = v(e, "scores", "nonMaxSuppression", "float32"),
i = No(s, a, t10, o, n);
t10 = i.maxOutputSize, o = i.iouThreshold, n = i.scoreThreshold;
let p = {
maxOutputSize: t10,
iouThreshold: o,
scoreThreshold: n
};
return T.runKernel(jn, {
boxes: s,
scores: a
}, p);
}
var K1 = N({
nonMaxSuppression_: S6
});
function q1(r, e, t10) {
let o = I6(r, e, t10),
n = o < 0 ? -(o + 1) : o;
r.splice(n, 0, e);
}
function I6(r, e, t10) {
return k6(r, e, t10 || v6);
}
function v6(r, e) {
return r > e ? 1 : r < e ? -1 : 0;
}
function k6(r, e, t10) {
let o = 0,
n = r.length,
s = 0,
a = false;
for (; o < n;) {
s = o + (n - o >>> 1);
let i = t10(e, r[s]);
i > 0 ? o = s + 1 : (n = s, a = !i);
}
return a ? o : -o - 1;
}
function Yd(r, e, t10, o, n) {
return Mw(r, e, t10, o, n, 0);
}
function Qd(r, e, t10, o, n, s) {
return Mw(r, e, t10, o, n, 0, false, s, true);
}
function Zd(r, e, t10, o, n, s) {
return Mw(r, e, t10, o, n, s, true);
}
function Mw(r, e, t10, 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(j1);
let c = s > 0 ? -0.5 / s : 0,
l = [],
m = [];
for (; l.length < t10 && u.length > 0;) {
let g = u.pop(),
{
score: x,
boxIndex: b,
suppressBeginIndex: w
} = g;
if (x < n) break;
let S = false;
for (let k = l.length - 1; k >= w; --k) {
let _ = N6(r, b, l[k]);
if (_ >= o) {
S = true;
break;
}
if (g.score = g.score * T6(o, c, _), g.score <= n) break;
}
g.suppressBeginIndex = l.length, S || (g.score === x ? (l.push(b), m.push(g.score)) : g.score > n && q1(u, g, j1));
}
let d = l.length,
f = t10 - 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 = d), h;
}
function N6(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]),
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),
x = Math.min(i, l),
b = Math.min(p, m),
w = Math.max(x - h, 0) * Math.max(b - g, 0);
return w / (d + f - w);
}
function T6(r, e, t10) {
let o = Math.exp(e * t10 * t10);
return t10 <= r ? o : 0;
}
function j1(r, e) {
return r.score - e.score || r.score === e.score && e.boxIndex - r.boxIndex;
}
async function _6(r, e, t10, o = 0.5, n = Number.NEGATIVE_INFINITY) {
let s = v(r, "boxes", "nonMaxSuppressionAsync"),
a = v(e, "scores", "nonMaxSuppressionAsync"),
i = No(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
} = Yd(u, c, t10, o, n);
return s !== r && s.dispose(), a !== e && a.dispose(), xr(l, "int32");
}
var X1 = _6;
function $6(r, e, t10, o = 0.5, n = Number.NEGATIVE_INFINITY, s = 0) {
let a = v(r, "boxes", "nonMaxSuppression"),
i = v(e, "scores", "nonMaxSuppression"),
p = No(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 = T.runKernel(Xn, u, c);
return {
selectedIndices: l[0],
selectedScores: l[1]
};
}
var Y1 = N({
nonMaxSuppressionWithScore_: $6
});
async function E6(r, e, t10, o = 0.5, n = Number.NEGATIVE_INFINITY, s = 0) {
let a = v(r, "boxes", "nonMaxSuppressionAsync"),
i = v(e, "scores", "nonMaxSuppressionAsync"),
p = No(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: d
} = Zd(c, l, t10, o, n, s);
return a !== r && a.dispose(), i !== e && i.dispose(), {
selectedIndices: xr(m, "int32"),
selectedScores: xr(d)
};
}
var Q1 = E6;
function R6(r, e, t10, o = 0.5, n = Number.NEGATIVE_INFINITY, s = false) {
let a = v(r, "boxes", "nonMaxSuppression"),
i = v(e, "scores", "nonMaxSuppression"),
p = No(a, i, t10, 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(Ha, m, d);
return {
selectedIndices: f[0],
validOutputs: f[1]
};
}
var Z1 = N({
nonMaxSuppressionPadded_: R6
});
async function D6(r, e, t10, o = 0.5, n = Number.NEGATIVE_INFINITY, s = false) {
let a = v(r, "boxes", "nonMaxSuppressionAsync"),
i = v(e, "scores", "nonMaxSuppressionAsync"),
p = No(a, i, t10, 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
} = Qd(m, d, u, c, l, s);
return a !== r && a.dispose(), i !== e && i.dispose(), {
selectedIndices: xr(f, "int32"),
validOutputs: ke(h, "int32")
};
}
var J1 = D6;
function A6(r, e, t10 = 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.");
let s = n,
a = false;
n.rank === 3 && (a = true, s = W(n, [1, n.shape[0], n.shape[1], n.shape[2]]));
let [] = e,
i = {
images: s
},
p = {
alignCorners: t10,
halfPixelCenters: o,
size: e
},
u = T.runKernel(ns, i, p);
return a ? W(u, [u.shape[1], u.shape[2], u.shape[3]]) : u;
}
var eN = N({
resizeBilinear_: A6
});
function F6(r, e, t10 = 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.");
let s = n,
a = false;
n.rank === 3 && (a = true, s = W(n, [1, n.shape[0], n.shape[1], n.shape[2]]));
let [] = e,
i = {
images: s
},
p = {
alignCorners: t10,
halfPixelCenters: o,
size: e
},
u = T.runKernel(os, i, p);
return a ? W(u, [u.shape[1], u.shape[2], u.shape[3]]) : u;
}
var tN = N({
resizeNearestNeighbor_: F6
});
function P6(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 = se(xr([o]), 255),
c,
l,
m,
d;
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] = ai(n, [1, 1, 1], -1);
let g = se(c, s),
x = se(l, a),
b = se(m, i);
d = be(be(g, x), b);
} else d = r;
if (e === "otsu") {
let g = md(Ye(Vd(d), "int32"), ir([]), 256);
u = O6(g, p);
}
let f = t10 ? ic(d, u) : Bu(d, u);
return Ye(se(f, 255), "int32");
}
function O6(r, e) {
let t10 = xr([-1]),
o = xr([0]),
n = xr([0]),
s,
a,
i,
p,
u,
c;
for (let l = 0; l < r.size - 1; l++) {
s = qe(r, 0, l + 1), a = qe(r, l + 1), u = Ke(ot(s), e), c = Ke(ot(a), e);
let m = ot(se(s, au(0, s.size)));
i = Ke(m, ot(s));
let d = Sa(a.shape, s.size),
f = be(au(0, a.size), d),
h = se(a, f);
p = Ke(ot(h), ot(a));
let g = Te(i, p),
x = Te(i, p),
b = se(u, c);
n = se(se(b, g), x);
let w = Bu(n, o);
o = io(w, n, o), t10 = io(w, xr([l]), t10);
}
return t10;
}
var rN = N({
threshold_: P6
});
function M6(r, e, t10 = "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 T.runKernel(Ts, p, u);
}
var oN = N({
transform_: M6
});
function L6(r, e, t10) {
let o = v(r, "a", "bandPart");
$(o.rank >= 2, () => `bandPart(): Rank must be at least 2, got ${o.rank}.`);
let n = o.shape,
[s, a] = o.shape.slice(-2),
i,
p;
typeof e == "number" ? ($(e % 1 === 0, () => `bandPart(): numLower must be an integer, got ${e}.`), $(e <= s, () => `bandPart(): numLower (${e}) must not be greater than the number of rows (${s}).`), i = v(e < 0 ? s : e, "numLower", "bandPart")) : ($(e.dtype === "int32", () => "bandPart(): numLower's dtype must be an int32."), i = io(kl(e, 0), s, Wu(e, s))), typeof t10 == "number" ? ($(t10 % 1 === 0, () => `bandPart(): numUpper must be an integer, got ${t10}.`), $(t10 <= a, () => `bandPart(): numUpper (${t10}) must not be greater than the number of columns (${a}).`), p = v(t10 < 0 ? a : t10, "numUpper", "bandPart")) : ($(t10.dtype === "int32", () => "bandPart(): numUpper's dtype must be an int32."), p = io(kl(t10, 0), a, Wu(t10, a)));
let u = W(au(0, s, 1, "int32"), [-1, 1]),
c = au(0, a, 1, "int32"),
l = Te(u, c),
m = zu(ic(l, i), Cd(l, pr(p))),
d = Wr([s, a], o.dtype);
return W(vr(po(W(o, [-1, s, a])).map(f => io(m, f, d))), n);
}
var nN = N({
bandPart_: L6
});
function B6(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");
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})`);
} else e = true, r = ai(r, r.shape[0], 0).map(n => lc(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;
for (let n = 0; n < r.length; ++n) t10.push(T.tidy(() => {
let s = o[n];
if (n > 0) for (let a = 0; a < n; ++a) {
let i = se(ot(se(t10[a], s)), t10[a]);
s = Te(s, i);
}
return Ke(s, Lu(s, "euclidean"));
}));
return e ? vr(t10, 0) : t10;
}
var sN = N({
gramSchmidt_: B6
});
function z6(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 aN(r, e);
{
let t10 = r.shape.slice(0, r.shape.length - 2).reduce((p, u) => p * u),
o = po(W(r, [t10, r.shape[r.shape.length - 2], r.shape[r.shape.length - 1]]), 0),
n = [],
s = [];
o.forEach(p => {
let [u, c] = aN(p, e);
n.push(u), s.push(c);
});
let a = W(vr(n, 0), r.shape),
i = W(vr(s, 0), r.shape);
return [a, i];
}
}
function aN(r, e = false) {
return T.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 = xd(t10),
s = Vr(r),
a = uu([[1]], [1, 1]),
i = Vr(a),
p = t10 >= o ? o : t10;
for (let u = 0; u < p; ++u) {
let c = s,
l = i,
m = n;
[i, s, n] = T.tidy(() => {
let d = qe(s, [u, u], [t10 - u, 1]),
f = Lu(d),
h = qe(s, [u, u], [1, 1]),
g = io(Bu(h, 0), uu([[-1]]), uu([[1]])),
x = Te(h, se(g, f)),
b = Ke(d, x);
b.shape[0] === 1 ? i = Vr(a) : i = yt([a, qe(b, [1, 0], [b.shape[0] - 1, b.shape[1]])], 0);
let w = pr(Ke(Qe(g, x), f)),
S = qe(s, [u, 0], [t10 - u, o]),
k = se(w, i),
_ = dc(i);
if (u === 0) s = Te(S, Qe(k, Qe(_, S)));else {
let D = Te(S, Qe(k, Qe(_, S)));
s = yt([qe(s, [0, 0], [u, o]), D], 0);
}
let E = dc(k),
R = qe(n, [0, u], [t10, n.shape[1] - u]);
if (u === 0) n = Te(R, Qe(Qe(R, i), E));else {
let D = Te(R, Qe(Qe(R, i), E));
n = yt([qe(n, [0, 0], [t10, u]), D], 1);
}
return [i, s, n];
}), Ot([c, l, m]);
}
return !e && t10 > o && (n = qe(n, [0, 0], [t10, o]), s = qe(s, [0, 0], [o, o])), [n, s];
});
}
var iN = N({
qr_: z6
});
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 V6(r, e, t10 = 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 : se(o, n);
if (t10 === Et.NONE) return s;
if (t10 === Et.SUM) return ot(s);
if (t10 === Et.MEAN) {
if (n == null) return Vu(s);
{
let a = o.size / n.size,
i = Ke(ot(s), ot(n));
return a > 1 ? Ke(i, ke(a)) : i;
}
}
if (t10 === Et.SUM_BY_NONZERO_WEIGHTS) {
if (n == null) return Ke(ot(s), ke(o.size));
{
let a = se(n, va(o.shape)),
i = Ye(ot(Rd(a, ke(0))), "float32");
return Ke(ot(s), i);
}
}
throw Error(`Unknown reduction: ${t10}`);
}
var cr = N({
computeWeightedLoss_: V6
});
function W6(r, e, t10, 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")), xt(n.shape, s.shape, "Error in absoluteDifference: ");
let i = Zt(Te(n, s));
return cr(i, a, o);
}
var uN = N({
absoluteDifference_: W6
});
function U6(r, e, t10, 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")), xt(s.shape, a.shape, "Error in cosineDistance: ");
let p = ke(1),
u = Te(p, ot(se(s, a), t10, true));
return cr(u, i, n);
}
var pN = N({
cosineDistance_: U6
});
function G6(r, e, t10, 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")), xt(n.shape, s.shape, "Error in hingeLoss: ");
let i = ke(1);
n = Te(se(ke(2), n), i);
let p = iu(Te(i, se(n, s)));
return cr(p, a, o);
}
var cN = N({
hingeLoss_: G6
});
function H6(r, e, t10, 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")), xt(s.shape, a.shape, "Error in huberLoss: ");
let p = ke(o),
u = Zt(Te(a, s)),
c = Wu(u, p),
l = Te(u, c),
m = be(se(ke(0.5), Jt(c)), se(p, l));
return cr(m, i, n);
}
var lN = N({
huberLoss_: H6
});
function K6(r, e, t10, 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")), xt(s.shape, a.shape, "Error in logLoss: ");
let p = ke(1),
u = ke(o),
c = pr(se(s, ni(be(a, u)))),
l = se(Te(p, s), ni(be(Te(p, a), u))),
m = Te(c, l);
return cr(m, i, n);
}
var mN = N({
logLoss_: K6
});
function q6(r, e, t10, 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")), xt(n.shape, s.shape, "Error in meanSquaredError: ");
let i = Ud(n, s);
return cr(i, a, o);
}
var dN = N({
meanSquaredError_: q6
});
function j6(r, e) {
let t10 = v(r, "labels", "sigmoidCrossEntropyWithLogits"),
o = v(e, "logits", "sigmoidCrossEntropyWithLogits");
xt(t10.shape, o.shape, "Error in sigmoidCrossEntropyWithLogits: ");
let n = iu(o),
s = se(o, t10),
a = Sd(ko(pr(Zt(o))));
return be(Te(n, s), a);
}
function X6(r, e, t10, 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")), xt(s.shape, a.shape, "Error in sigmoidCrossEntropy: "), o > 0) {
let u = ke(o),
c = ke(1),
l = ke(0.5);
s = be(se(s, Te(c, u)), se(l, u));
}
let p = j6(s, a);
return cr(p, i, n);
}
var fN = N({
sigmoidCrossEntropy_: X6
});
function Y6(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}`);
return Ir((n, s, a) => {
let p = kd(s, [t10], true),
u = Te(Ye(s, "float32"), p);
a([n, u]);
let c = pr(se(u, n));
return {
value: ot(c, [t10]),
gradFunc: (d, f) => {
let [h, g] = f,
x = ti(d.shape, [t10]);
return [se(W(d, x), Te(Ye(h, "float32"), ko(g))), se(W(d, x), Te(ko(g), Ye(h, "float32")))];
}
};
})(r, e);
}
function Q6(r, e, t10, 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")), xt(s.shape, a.shape, "Error in softmaxCrossEntropy: "), o > 0) {
let u = ke(o),
c = ke(1),
l = ke(s.shape[1]);
s = be(se(s, Te(c, u)), Ke(u, l));
}
let p = Y6(s, a);
return cr(p, i, n);
}
var hN = N({
softmaxCrossEntropy_: Q6
});
function Z6(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);
if (n.rank !== 2) throw new Error(`Indices should be Tensor2D but received shape
${n.shape}`);
if (s.rank !== 1) throw new Error(`Values should be Tensor1D but received shape ${s.shape}`);
if (a.rank !== 1) 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 = T.runKernel(Vi, p);
return {
outputIndices: u[0],
outputValues: u[1],
emptyRowIndicator: u[2],
reverseIndexMap: u[3]
};
}
var gN = N({
sparseFillEmptyRows_: Z6
});
function J6(r, e, t10) {
let o = v(r, "inputIndices", "sparseReshape", "int32"),
n = v(e, "inputShape", "sparseReshape", "int32"),
s = v(t10, "newShape", "sparseReshape", "int32");
if (o.rank !== 2) throw new Error(`Input indices should be Tensor2D but received shape
${o.shape}`);
if (n.rank !== 1) 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 = T.runKernel(Xa, a);
return {
outputIndices: i[0],
outputShape: i[1]
};
}
var xN = N({
sparseReshape_: J6
});
function ej(r, e, t10) {
let o = v(r, "data", "sparseSegmentMean"),
n = v(e, "indices", "sparseSegmentMean", "int32"),
s = v(t10, "segmentIds", "sparseSegmentMean", "int32");
if (o.rank < 1) throw new Error("Data should be at least 1 dimensional but received scalar");
if (n.rank !== 1) throw new Error(`Indices should be Tensor1D but received shape
${n.shape}`);
if (s.rank !== 1) throw new Error(`Segment ids should be Tensor1D but received shape
${s.shape}`);
let a = {
data: o,
indices: n,
segmentIds: s
};
return T.runKernel(Wi, a);
}
var yN = N({
sparseSegmentMean_: ej
});
function tj(r, e, t10) {
let o = v(r, "data", "sparseSegmentSum"),
n = v(e, "indices", "sparseSegmentSum", "int32"),
s = v(t10, "segmentIds", "sparseSegmentSum", "int32");
if (o.rank < 1) throw new Error("Data should be at least 1 dimensional but received scalar");
if (n.rank !== 1) throw new Error(`Indices should be Tensor1D but received shape
${n.shape}`);
if (s.rank !== 1) throw new Error(`Segment ids should be Tensor1D but received shape
${s.shape}`);
let a = {
data: o,
indices: n,
segmentIds: s
};
return T.runKernel(Ui, a);
}
var bN = N({
sparseSegmentSum_: tj
});
function rj(r, e, t10, 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");
if (p.shape.length !== 1) throw new Error(`Data must be a vector, saw: ${p.shape}`);
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 = T.runKernel(ma, l, c);
return {
nGrams: m[0],
nGramsSplits: m[1]
};
}
var CN = N({
stringNGrams_: rj
});
function oj(r, e, t10 = 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 = T.runKernel(Hi, a, s);
return {
indices: i[0],
values: i[1],
shape: i[2]
};
}
var wN = N({
stringSplit_: oj
});
function nj(r, e) {
let t10 = 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 T.runKernel(Ki, n, o);
}
var SN = N({
stringToHashBucketFast_: nj
});
function sj(r, e, t10, o = true) {
let n = v(r, "input", "staticRegexReplace", "string"),
s = {
pattern: e,
rewrite: t10,
replaceGlobal: o
};
return T.runKernel(_u, {
x: n
}, s);
}
var IN = N({
staticRegexReplace_: sj
});
var aj = {
fft: pc,
ifft: Hu,
rfft: cc,
irfft: Wd
};
var ij = {
hammingWindow: z1,
hannWindow: jd,
frame: Xd,
stft: V1
};
var uj = {
flipLeftRight: U1,
grayscaleToRGB: G1,
resizeNearestNeighbor: tN,
resizeBilinear: eN,
rotateWithOffset: H1,
cropAndResize: W1,
nonMaxSuppression: K1,
nonMaxSuppressionAsync: X1,
nonMaxSuppressionWithScore: Y1,
nonMaxSuppressionWithScoreAsync: Q1,
nonMaxSuppressionPadded: Z1,
nonMaxSuppressionPaddedAsync: J1,
threshold: rN,
transform: oN
};
var pj = {
bandPart: nN,
gramSchmidt: sN,
qr: iN
};
var cj = {
absoluteDifference: uN,
computeWeightedLoss: cr,
cosineDistance: pN,
hingeLoss: cN,
huberLoss: lN,
logLoss: mN,
meanSquaredError: dN,
sigmoidCrossEntropy: fN,
softmaxCrossEntropy: hN
};
var lj = {
sparseFillEmptyRows: gN,
sparseReshape: xN,
sparseSegmentMean: yN,
sparseSegmentSum: bN
};
var mj = {
stringNGrams: CN,
stringSplit: wN,
stringToHashBucketFast: SN,
staticRegexReplace: IN
};
var vN = {};
He(vN, {
Serializable: () => $l,
SerializationMap: () => Na,
registerClass: () => Lw
});
var $l = class {
getClassName() {
return this.constructor.className;
}
static fromConfig(e, t10) {
return new e(t10);
}
};
var Na = class {
constructor() {
this.classNameMap = {};
}
static getMap() {
return Na.instance == null && (Na.instance = new Na()), Na.instance;
}
static register(e) {
Na.getMap().classNameMap[e.className] = [e, e.fromConfig];
}
};
function Lw(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."), Na.register(r);
}
var kr = class extends $l {
minimize(e, t10 = 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 Ot(s), t10 ? n : (n.dispose(), null);
}
get iterations() {
return this.iterations_ == null && (this.iterations_ = 0), this.iterations_;
}
incrementIterations() {
this.iterations_ = this.iterations + 1;
}
computeGradients(e, t10) {
return vw(e, t10);
}
dispose() {
this.iterations_ != null && Ot(this.iterations_);
}
async saveIterations() {
return this.iterations_ == null && (this.iterations_ = 0), {
name: "iter",
tensor: ke(this.iterations_, "int32")
};
}
async getWeights() {
throw new Error("getWeights() is not implemented for this optimizer yet.");
}
async setWeights(e) {
throw new Error(`setWeights() is not implemented for this optimizer class ${this.getClassName()}`);
}
async extractIterations(e) {
return this.iterations_ = (await e[0].tensor.data())[0], e.slice(1);
}
};
Object.defineProperty(kr, Symbol.hasInstance, {
value: r => r.minimize != null && r.computeGradients != null && r.applyGradients != null
});
var Yu = class extends kr {
static get className() {
return "Adadelta";
}
constructor(e, t10, o = null) {
super(), this.learningRate = e, this.rho = t10, 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 = T.registeredVariables[o],
a = false;
this.accumulatedGrads[n] == null && (this.accumulatedGrads[n] = {
originalName: `${o}/accum_grad`,
variable: De(() => Ht(s).variable(a))
}), this.accumulatedUpdates[n] == null && (this.accumulatedUpdates[n] = {
originalName: `${o}/accum_var`,
variable: De(() => Ht(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;
De(() => {
let c = be(se(p, this.rho), se(Jt(i), 1 - this.rho)),
l = se(Ke(Rr(be(u, this.epsilon)), Rr(be(p, this.epsilon))), i),
m = be(se(u, this.rho), se(Jt(l), 1 - this.rho));
p.assign(c), u.assign(m);
let d = be(se(l, -this.learningRate), s);
s.assign(d);
});
}), this.incrementIterations();
}
dispose() {
this.accumulatedUpdates != null && (Ot(this.accumulatedGrads.map(e => e.variable)), Ot(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
})));
}
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)
}));
}
getConfig() {
return {
learningRate: this.learningRate,
rho: this.rho,
epsilon: this.epsilon
};
}
static fromConfig(e, t10) {
return new e(t10.learningRate, t10.rho, t10.epsilon);
}
};
var Qu = class extends kr {
static get className() {
return "Adagrad";
}
constructor(e, t10 = 0.1) {
super(), this.learningRate = e, this.initialAccumulatorValue = t10, this.accumulatedGrads = [];
}
applyGradients(e) {
(Array.isArray(e) ? e.map(o => o.name) : Object.keys(e)).forEach((o, n) => {
let s = T.registeredVariables[o];
this.accumulatedGrads[n] == null && (this.accumulatedGrads[n] = {
originalName: `${o}/accumulator`,
variable: De(() => Sa(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;
De(() => {
let p = be(i, Jt(a));
i.assign(p);
let u = be(se(Ke(a, Rr(be(p, T.backend.epsilon()))), -this.learningRate), s);
s.assign(u);
});
}), this.incrementIterations();
}
dispose() {
this.accumulatedGrads != null && Ot(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)
}));
}
getConfig() {
return {
learningRate: this.learningRate,
initialAccumulatorValue: this.initialAccumulatorValue
};
}
static fromConfig(e, t10) {
return new e(t10.learningRate, t10.initialAccumulatorValue);
}
};
var Zu = class extends kr {
static get className() {
return "Adam";
}
constructor(e, t10, o, n = null) {
super(), this.learningRate = e, this.beta1 = t10, this.beta2 = o, this.epsilon = n, this.accumulatedFirstMoment = [], this.accumulatedSecondMoment = [], De(() => {
this.accBeta1 = ke(t10).variable(), this.accBeta2 = ke(o).variable();
}), n == null && (this.epsilon = T.backend.epsilon());
}
applyGradients(e) {
let t10 = Array.isArray(e) ? e.map(o => o.name) : Object.keys(e);
De(() => {
let o = Te(1, this.accBeta1),
n = Te(1, this.accBeta2);
t10.forEach((s, a) => {
let i = T.registeredVariables[s],
p = false;
this.accumulatedFirstMoment[a] == null && (this.accumulatedFirstMoment[a] = {
originalName: `${s}/m`,
variable: De(() => Ht(i).variable(p))
}), this.accumulatedSecondMoment[a] == null && (this.accumulatedSecondMoment[a] = {
originalName: `${s}/v`,
variable: De(() => Ht(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 = be(se(c, this.beta1), se(u, 1 - this.beta1)),
d = be(se(l, this.beta2), se(Jt(u), 1 - this.beta2)),
f = Ke(m, o),
h = Ke(d, n);
c.assign(m), l.assign(d);
let g = be(se(Ke(f, be(Rr(h), this.epsilon)), -this.learningRate), i);
i.assign(g);
}), this.accBeta1.assign(se(this.accBeta1, this.beta1)), this.accBeta2.assign(se(this.accBeta2, this.beta2));
}), this.incrementIterations();
}
dispose() {
this.accBeta1.dispose(), this.accBeta2.dispose(), this.accumulatedFirstMoment != null && Ot(this.accumulatedFirstMoment.map(e => e.variable)), this.accumulatedSecondMoment != null && Ot(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
})));
}
async setWeights(e) {
e = await this.extractIterations(e), De(() => {
this.accBeta1.assign(ri(this.beta1, this.iterations_ + 1)), this.accBeta2.assign(ri(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)
}));
}
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);
}
};
var Ju = class extends kr {
static get className() {
return "Adamax";
}
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 = [], De(() => {
this.iteration = ke(0).variable(), this.accBeta1 = ke(t10).variable();
}), n == null && (this.epsilon = T.backend.epsilon());
}
applyGradients(e) {
let t10 = Array.isArray(e) ? e.map(o => o.name) : Object.keys(e);
De(() => {
let o = Te(1, this.accBeta1),
n = Ke(-this.learningRate, be(se(this.iteration, this.decay), 1));
t10.forEach((s, a) => {
let i = T.registeredVariables[s],
p = false;
this.accumulatedFirstMoment[a] == null && (this.accumulatedFirstMoment[a] = {
originalName: `${s}/m`,
variable: Ht(i).variable(p)
}), this.accumulatedWeightedInfNorm[a] == null && (this.accumulatedWeightedInfNorm[a] = {
originalName: `${s}/v`,
variable: Ht(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 = be(se(c, this.beta1), se(u, 1 - this.beta1)),
d = se(l, this.beta2),
f = Zt(u),
h = Ed(d, f);
c.assign(m), l.assign(h);
let g = be(se(Ke(n, o), Ke(m, be(h, this.epsilon))), i);
i.assign(g);
}), this.iteration.assign(be(this.iteration, 1)), this.accBeta1.assign(se(this.accBeta1, this.beta1));
}), this.incrementIterations();
}
dispose() {
this.accBeta1.dispose(), this.iteration.dispose(), this.accumulatedFirstMoment != null && Ot(this.accumulatedFirstMoment.map(e => e.variable)), this.accumulatedWeightedInfNorm != null && Ot(this.accumulatedWeightedInfNorm.map(e => e.variable));
}
async getWeights() {
throw new Error("getWeights() is not implemented for Adamax yet.");
}
async setWeights(e) {
throw new Error("setWeights() is not implemented for Adamax yet.");
}
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);
}
};
var ii = class extends kr {
static get className() {
return "SGD";
}
constructor(e) {
super(), this.learningRate = e, this.setLearningRate(e);
}
applyGradients(e) {
(Array.isArray(e) ? e.map(o => o.name) : Object.keys(e)).forEach((o, n) => {
let s = Array.isArray(e) ? e[n].tensor : e[o];
if (s == null) return;
let a = T.registeredVariables[o];
De(() => {
let i = be(se(this.c, s), a);
a.assign(i);
});
}), this.incrementIterations();
}
setLearningRate(e) {
this.learningRate = e, this.c != null && this.c.dispose(), this.c = Er(ke(-e));
}
dispose() {
this.c.dispose();
}
async getWeights() {
return [await this.saveIterations()];
}
async setWeights(e) {
if (e = await this.extractIterations(e), e.length !== 0) throw new Error("SGD optimizer does not have settable weights.");
}
getConfig() {
return {
learningRate: this.learningRate
};
}
static fromConfig(e, t10) {
return new e(t10.learningRate);
}
};
var ep = class extends ii {
static get className() {
return "Momentum";
}
constructor(e, t10, o = false) {
super(e), this.learningRate = e, this.momentum = t10, this.useNesterov = o, this.accumulations = [], this.m = ke(this.momentum);
}
applyGradients(e) {
(Array.isArray(e) ? e.map(o => o.name) : Object.keys(e)).forEach((o, n) => {
let s = T.registeredVariables[o];
this.accumulations[n] == null && (this.accumulations[n] = {
originalName: `${o}/momentum`,
variable: De(() => Ht(s).variable(false))
});
let a = this.accumulations[n].variable,
i = Array.isArray(e) ? e[n].tensor : e[o];
i != null && De(() => {
let p,
u = be(se(this.m, a), i);
this.useNesterov ? p = be(se(this.c, be(i, se(u, this.m))), s) : p = be(se(this.c, u), s), a.assign(u), s.assign(p);
});
}), this.incrementIterations();
}
dispose() {
this.m.dispose(), this.accumulations != null && Ot(this.accumulations.map(e => e.variable));
}
setMomentum(e) {
this.momentum = e;
}
async getWeights() {
return [await this.saveIterations()].concat(this.accumulations.map(e => ({
name: e.originalName,
tensor: e.variable
})));
}
async setWeights(e) {
e = await this.extractIterations(e);
let t10 = false;
this.accumulations = e.map(o => ({
originalName: o.name,
variable: o.tensor.variable(t10)
}));
}
getConfig() {
return {
learningRate: this.learningRate,
momentum: this.momentum,
useNesterov: this.useNesterov
};
}
static fromConfig(e, t10) {
return new e(t10.learningRate, t10.momentum, t10.useNesterov);
}
};
var tp = class extends kr {
static get className() {
return "RMSProp";
}
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 = 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 = T.registeredVariables[o],
a = false;
this.accumulatedMeanSquares[n] == null && (this.accumulatedMeanSquares[n] = {
originalName: `${o}/rms`,
variable: De(() => Ht(s).variable(a))
}), this.accumulatedMoments[n] == null && (this.accumulatedMoments[n] = {
originalName: `${o}/momentum`,
variable: De(() => Ht(s).variable(a))
}), this.accumulatedMeanGrads[n] == null && this.centered && (this.accumulatedMeanGrads[n] = {
originalName: `${o}/mg`,
variable: De(() => Ht(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;
De(() => {
let c = be(se(p, this.decay), se(Jt(i), 1 - this.decay));
if (this.centered) {
let l = this.accumulatedMeanGrads[n].variable,
m = be(se(l, this.decay), se(i, 1 - this.decay)),
d = Ke(se(i, this.learningRate), Rr(Te(c, be(Jt(m), this.epsilon)))),
f = be(se(u, this.momentum), d);
p.assign(c), l.assign(m), u.assign(f);
let h = Te(s, f);
s.assign(h);
} else {
let l = be(se(p, this.decay), se(Jt(i), 1 - this.decay)),
m = be(se(u, this.momentum), Ke(se(i, this.learningRate), Rr(be(l, this.epsilon))));
p.assign(l), u.assign(m);
let d = Te(s, m);
s.assign(d);
}
});
}), this.incrementIterations();
}
dispose() {
this.accumulatedMeanSquares != null && Ot(this.accumulatedMeanSquares.map(e => e.variable)), this.accumulatedMeanGrads != null && this.centered && Ot(this.accumulatedMeanGrads.map(e => e.variable)), this.accumulatedMoments != null && Ot(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
})));
}
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)
})));
}
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);
}
};
var dj = [Yu, Qu, Zu, Ju, ep, tp, ii];
function kN() {
for (let r of dj) Lw(r);
}
var pi = {};
He(pi, {
browserFiles: () => TN,
browserHTTPRequest: () => EN,
concatenateArrayBuffers: () => tc,
copyModel: () => ok,
decodeWeights: () => rd,
encodeWeights: () => V0,
fromMemory: () => RN,
fromMemorySync: () => Gw,
getLoadHandlers: () => q0,
getModelArtifactsForJSON: () => rc,
getModelArtifactsForJSONSync: () => mw,
getModelArtifactsInfoForJSON: () => ga,
getSaveHandlers: () => K0,
getWeightSpecs: () => nd,
http: () => tf,
isHTTPScheme: () => ef,
listModels: () => tk,
loadWeights: () => _N,
moveModel: () => nk,
registerLoadRouter: () => H0,
registerSaveRouter: () => G0,
removeModel: () => rk,
weightsLoaderFactory: () => Ww,
withSaveHandler: () => DN,
withSaveHandlerSync: () => AN
});
var fj = "model";
var hj = ".json";
var gj = ".weights.bin";
function NN(r) {
return new Promise(e => setTimeout(e)).then(r);
}
var ui = class {
constructor(e) {
if (!P().getBool("IS_BROWSER")) throw new Error("browserDownloads() cannot proceed because the current environment is not a browser.");
e.startsWith(ui.URL_SCHEME) && (e = e.slice(ui.URL_SCHEME.length)), (e == null || e.length === 0) && (e = fj), this.modelJsonFileName = e + hj, this.weightDataFileName = e + gj;
}
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"
}));
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 = od(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 NN(() => 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 NN(() => i.dispatchEvent(new MouseEvent("click")));
}
return {
modelArtifactsInfo: ga(e)
};
}
}
};
ui.URL_SCHEME = "downloads://";
var Bw = 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) => {
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}`));
return;
}
if (s.weightsManifest == null) {
t10(new Error(`weightManifest field is missing from file ${this.jsonFile.name}`));
return;
}
if (this.weightsFiles.length === 0) {
e({
modelTopology: a
});
return;
}
let p = rc(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);
});
}
loadWeights(e) {
let t10 = [],
o = [];
for (let a of e) t10.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, tc(a)]);
}
loadWeightsFile(e, t10) {
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);
});
}
checkManifestAndWeightFiles(e) {
let t10 = [],
o = this.weightsFiles.map(s => lw(s.name)),
n = {};
for (let s of e) s.paths.forEach(a => {
let i = lw(a);
if (t10.indexOf(i) !== -1) throw new Error(`Duplicate file basename found in weights manifest: '${i}'`);
if (t10.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}).`);
return n;
}
};
var xj = r => P().getBool("IS_BROWSER") && !Array.isArray(r) && r.startsWith(ui.URL_SCHEME) ? yj(r.slice(ui.URL_SCHEME.length)) : null;
ft.registerSaveRouter(xj);
function yj(r = "model") {
return new ui(r);
}
function TN(r) {
return new Bw(r);
}
var Jd = class {
constructor(e) {
if (this.shards = [], this.previousShardIndex = 0, e instanceof Array || (e = [e]), e = e.map(o => Pt(o) ? o.buffer : o), e.length === 0) return;
this.bufferUniformSize = e[0].byteLength;
let t10 = 0;
for (let o = 0; o < e.length; o++) {
let n = e[o];
o !== e.length - 1 && n.byteLength !== this.bufferUniformSize && (this.bufferUniformSize = void 0);
let s = t10 + n.byteLength;
this.shards.push({
buffer: n,
start: t10,
end: s
}), t10 = s;
}
this.shards.length === 0 && (this.byteLength = 0), this.byteLength = this.shards[this.shards.length - 1].end;
}
slice(e = 0, t10 = this.byteLength) {
if (e = isNaN(Number(e)) ? 0 : e, t10 = isNaN(Number(t10)) ? 0 : t10, e = Math.max(0, e), t10 = Math.min(this.byteLength, t10), t10 <= e) return new ArrayBuffer(0);
let o = this.findShardForByte(e);
if (o === -1) throw new Error(`Could not find start shard for byte ${e}`);
let n = t10 - e,
s = new ArrayBuffer(n),
a = new Uint8Array(s),
i = 0;
for (let p = o; p < this.shards.length; p++) {
let u = this.shards[p],
l = e + i - u.start,
m = i,
f = Math.min(t10, u.end) - u.start,
h = new Uint8Array(u.buffer.slice(l, f));
if (a.set(h, m), i += h.length, t10 < u.end) break;
}
return s;
}
findShardForByte(e) {
if (this.shards.length === 0 || e < 0 || e >= this.byteLength) return -1;
if (this.bufferUniformSize != null) return this.previousShardIndex = Math.floor(e / this.bufferUniformSize), this.previousShardIndex;
function t10(n) {
return e < n.start ? -1 : e >= n.end ? 1 : 0;
}
if (t10(this.shards[this.previousShardIndex]) === 0) return this.previousShardIndex;
let o = bj(this.shards, t10);
return o === -1 ? -1 : (this.previousShardIndex = o, this.previousShardIndex);
}
};
function bj(r, e) {
let t10 = 0,
o = r.length;
for (; t10 <= o;) {
let n = Math.floor((o - t10) / 2) + t10,
s = e(r[n]);
if (s === 0) return n;
s < 0 ? o = n : t10 = n + 1;
}
return -1;
}
function zw(r, e, t10, o) {
a(r), t10 = t10 == null ? 0 : t10, o = o == null ? 1 : o, i(t10, o);
let n = 0,
s = p => (p.then(u => {
let c = t10 + ++n / r.length * (o - t10);
return e(c), u;
}), p);
function a(p) {
$(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}`);
}
return Promise.all(r.map(s));
}
async function Vw(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 zw(o, e.onProgress, n, s)).map(l => l.arrayBuffer()),
p = 0.5,
u = 1;
return e.onProgress == null ? await Promise.all(i) : await zw(i, e.onProgress, p, u);
}
async function _N(r, e = "", t10, o) {
return Ww(a => Vw(a, {
requestInit: o
}))(r, e, t10);
}
function Ww(r) {
return async (e, t10 = "", o) => {
let n = e.map(() => false),
s = {},
a = o != null ? o.map(() => false) : [],
i = [];
if (e.forEach((d, f) => {
let h = 0;
d.weights.forEach(g => {
let x = "quantization" in g ? g.quantization.dtype : g.dtype,
b = Cl[x] * Ue(g.shape),
w = () => {
n[f] = true, s[f] == null && (s[f] = []), s[f].push({
manifestEntry: g,
groupOffset: h,
sizeBytes: b
});
};
o != null ? o.forEach((S, k) => {
S === g.name && (w(), a[k] = true);
}) : w(), i.push(g.name), h += b;
});
}), !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((d, f, h) => (f && d.push(h), d), []),
u = [];
p.forEach(d => {
e[d].paths.forEach(f => {
let h = t10 + (t10.endsWith("/") ? "" : "/") + f;
u.push(h);
});
});
let c = await r(u),
l = {},
m = 0;
return p.forEach(d => {
let f = e[d].paths.length,
h = new Jd(c.slice(m, m + f));
s[d].forEach(x => {
let b = h.slice(x.groupOffset, x.groupOffset + x.sizeBytes),
w = rd(b, [x.manifestEntry]);
for (let S in w) l[S] = w[S];
}), m += f;
}), l;
};
}
var Cj = "application/octet-stream";
var wj = "application/json";
var El = 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) throw new Error("requestInit is expected to have no pre-existing body, but has one.");
this.requestInit = t10.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 = od(e, o);
t10.body.append("model.json", new Blob([JSON.stringify(n)], {
type: wj
}), "model.json"), e.weightData != null && t10.body.append("model.weights.bin", new Blob([e.weightData], {
type: Cj
}), "model.weights.bin");
let s = await this.fetch(this.path, t10);
if (s.ok) return {
modelArtifactsInfo: ga(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;
try {
t10 = 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;
if (o == null && n == null) throw new Error(`The JSON from HTTP path ${this.path} contains neither model topology or manifest for weights.`);
return rc(t10, s => this.loadWeights(s));
}
async loadWeights(e) {
let t10 = Array.isArray(this.path) ? this.path[1] : this.path,
[o, n] = Sj(t10),
s = this.weightPathPrefix || o,
a = nd(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 Vw(i, {
requestInit: this.requestInit,
fetchFunc: this.fetch,
onProgress: this.onProgress
});
return [a, tc(u)];
}
};
El.URL_SCHEME_REGEX = /^https?:\/\//;
function Sj(r) {
let e = r.lastIndexOf("/"),
t10 = r.lastIndexOf("?"),
o = r.substring(0, e),
n = t10 > e ? r.substring(t10) : "";
return [o + "/", n];
}
function ef(r) {
return r.match(El.URL_SCHEME_REGEX) != null;
}
var $N = (r, e) => {
if (typeof fetch == "undefined" && (e == null || e.fetchFunc == null)) return null;
{
let t10 = true;
if (Array.isArray(r) ? t10 = r.every(o => ef(o)) : t10 = ef(r), t10) return tf(r, e);
}
return null;
};
ft.registerSaveRouter($N);
ft.registerLoadRouter($N);
function tf(r, e) {
return new El(r, e);
}
function EN(r, e) {
return tf(r, e);
}
var Rl = class {
constructor(e) {
this.modelArtifacts = e;
}
load() {
return this.modelArtifacts;
}
};
var rf = class {
constructor(e) {
this.saveHandler = e;
}
save(e) {
return this.saveHandler(e);
}
};
var Uw = class {
constructor(e) {
e.load && (this.load = () => Promise.resolve(e.load())), e.save && (this.save = t10 => Promise.resolve(e.save(t10)));
}
};
function RN(r, e, t10, o) {
let n = arguments;
return new Uw(Gw(...n));
}
function Gw(r, e, t10, o) {
return arguments.length === 1 ? r.modelTopology != null || r.weightSpecs != null ? new Rl(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 Rl({
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 Rl({
modelTopology: r,
weightSpecs: e,
weightData: t10,
trainingConfig: o
}));
}
function DN(r) {
return new rf(r);
}
function AN(r) {
return new rf(r);
}
var PN = {};
He(PN, {
confusionMatrix: () => FN
});
function Ij(r, e, t10) {
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 = Tl(Ye(o, "int32"), t10),
a = Tl(Ye(n, "int32"), t10),
i = dc(s),
p = Qe(i, a);
return Ye(p, "int32");
}
var FN = N({
confusionMatrix_: Ij
});
var MN = {};
He(MN, {
fromPixels: () => Ej,
fromPixelsAsync: () => _j,
toPixels: () => $j
});
var rp;
function ON(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;
if (r.data instanceof Uint8Array) t10 = true;else if (typeof ImageData != "undefined" && r instanceof ImageData) o = true;else if (typeof HTMLVideoElement != "undefined" && r instanceof HTMLVideoElement) n = true;else if (typeof HTMLImageElement != "undefined" && r instanceof HTMLImageElement) s = true;else if (r.getContext != null) a = true;else if (typeof ImageBitmap != "undefined" && r instanceof ImageBitmap) 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 (fl($u, T.backendName) != null) {
let f = {
pixels: r
},
h = {
numChannels: e
};
return T.runKernel($u, 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) l = r.data;else if (s || n || i) {
if (rp == null) if (typeof document == "undefined") {
if (typeof OffscreenCanvas != "undefined" && typeof OffscreenCanvasRenderingContext2D != "undefined") rp = new OffscreenCanvas(1, 1).getContext("2d");else throw new Error("Cannot parse input in current context. Reason: OffscreenCanvas Context2D rendering is not supported.");
} else rp = document.createElement("canvas").getContext("2d", {
willReadFrequently: true
});
rp.canvas.width = u, rp.canvas.height = c, rp.drawImage(r, 0, 0, u, c), l = rp.getImageData(0, 0, u, c).data;
}
let m;
if (e === 4) m = new Int32Array(l);else {
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 Hd(m, [c, u, e], "int32");
}
function vj(r) {
return r != null && r.data instanceof Uint8Array;
}
function kj() {
return typeof window != "undefined" && typeof ImageBitmap != "undefined" && window.hasOwnProperty("createImageBitmap");
}
function Nj(r) {
return r != null && r.width !== 0 && r.height !== 0;
}
function Tj(r) {
return kj() && !(r instanceof ImageBitmap) && Nj(r) && !vj(r);
}
async function _j(r, e = 3) {
let t10 = null;
if (P().getBool("WRAP_TO_IMAGEBITMAP") && Tj(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;
} else t10 = r;
return ON(t10, e);
}
async function $j(r, e) {
let t10 = v(r, "img", "toPixels");
if (!(r instanceof pt)) {
let u = t10;
t10 = Ye(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 (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);
for (let u = 0; u < o * n; ++u) {
let c = [0, 0, 0, 255];
for (let m = 0; m < s; m++) {
let d = a[u * s + m];
if (t10.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 (t10.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]);
}
if (e != null) {
e.width = n, e.height = o;
let u = e.getContext("2d"),
c = new ImageData(p, n, o);
u.putImageData(c, 0, 0);
}
return t10 !== r && t10.dispose(), p;
}
var Ej = N({
fromPixels_: ON
});
var of = {};
He(of, {
prepareAndValidate: () => LN
});
function LN(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}.`);
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 (Ue(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) a *= n[l];
let i = r.shape,
p = n.slice();
p.pop();
let u = 1;
for (let l = s; l < t10; ++l) u *= i[l], p.push(i[l]);
let c = [...Us(r.shape).map(l => l / u), 1].slice(0, s);
return [p, a, u, c];
}
var ct = {};
He(ct, {
assertParamsValid: () => Dj,
computeFlatOffset: () => Mj,
computeOutShape: () => Fj,
getNormalizedAxes: () => Pj,
isSliceContinous: () => Oj,
maskToAxes: () => Aj,
parseSliceParams: () => Lj,
sliceInfo: () => Bj,
startForAxis: () => KN,
startIndicesWithElidedDims: () => UN,
stopForAxis: () => qN,
stopIndicesWithElidedDims: () => GN,
stridesForAxis: () => HN,
stridesWithElidedDims: () => zN
});
var Hw = -2;
var Rj = -1;
function Dj(r, e, t10) {
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}).`);
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]})`);
}
function Aj(r) {
let e = [],
t10 = 0;
for (; r > 0;) r & 1 && e.push(t10), r /= 2, t10++;
return e;
}
function Fj(r, e, t10) {
let o = [];
for (let n = 0; n < r.length; n++) o[n] = Math.ceil((e[n] - r[n]) / t10[n]);
return o;
}
function zN(r, e, t10, o) {
let n = [...r];
for (let s = n.length; s < o.length; s++) n.push(1);
for (let s = 0; s < t10; s++) s === 0 ? n[e] = 1 : (n.splice(e, 0, 1), n.pop());
return n;
}
function VN(r, e, t10) {
return t10 <= r ? t10 : t10 - (e - 1);
}
function WN(r, e) {
let t10 = [];
for (let o = 0; o < r; o++) t10.push(e + o);
return t10;
}
function Pj(r, e, t10, 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 d = e[0],
f = t10 + 1;
c = UN(a, d, f, o, r), l = GN(i, d, f, n, r), m = zN(s, d, f, r);
} else for (let d = 0; d < u; d++) c[d] = KN(a, o, s, r, d, p), l[d] = qN(i, n, s, r, d, p), m[d] = HN(s, d, p);
return {
begin: c,
end: l,
strides: m
};
}
function UN(r, e, t10, o, n) {
let s = [...n],
a = WN(t10, e);
for (let i = 0; i < s.length; i++) if (a.indexOf(i) > -1) s[i] = 0;else {
let p = VN(e, t10, i),
u = o[p];
r & 1 << p && (u = 0), s[i] = u;
}
return s;
}
function GN(r, e, t10, o, n) {
let s = [...n],
a = WN(t10, e);
for (let i = 0; i < s.length; i++) if (a.indexOf(i) > -1) s[i] = Number.MAX_SAFE_INTEGER;else {
let p = VN(e, t10, i),
u = o[p];
r & 1 << p && (u = Number.MAX_SAFE_INTEGER), s[i] = u;
}
for (let i = 0; i < s.length; i++) {
let p = n[i];
s[i] < 0 && (s[i] += p), s[i] = zp(0, s[i], n[i]);
}
return s;
}
function HN(r, e, t10) {
let o = r[e];
return (t10 & 1 << e || o == null) && (o = 1), o;
}
function KN(r, e, t10, o, n, s) {
let a = e[n],
i = t10[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 = zp(0, a, p - 1), a;
}
function qN(r, e, t10, o, n, s) {
let a = e[n],
i = t10[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 = zp(0, a, p) : a = zp(-1, a, p - 1), a;
}
function Oj(r, e, t10) {
let o = t10.length;
for (let n = 0; n < t10.length; n++) if (t10[n] > 1) {
o = n;
break;
}
for (let n = o + 1; n < t10.length; n++) if (e[n] > 0 || t10[n] !== r[n]) return false;
return true;
}
function Mj(r, e) {
let t10 = r.length > 0 ? r[r.length - 1] : 1;
for (let o = 0; o < r.length - 1; o++) t10 += r[o] * e[o];
return t10;
}
function Lj(r, e, t10) {
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.");
});
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];
}
function Bj(r, e, t10, 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) 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
};
for (let w = 0; w < l.dims; w++) c && 1 << w & i && l.numAddAxisAfterEllipsis++, 1 << w & a && (c = true);
c || (l.ellipsisMask |= 1 << l.dims, l.dims++);
let m = {
dims: r.length,
beginMask: 0,
endMask: 0,
beginValid: false,
endValid: false
};
zj(l, m);
let d = true,
f = true,
h = true,
g = [],
x = [];
for (let w = 0; w < r.length; ++w) {
if (m.strides[w] === 0) throw Error(`strides[${w}] must be non-zero`);
let S = !!(m.shrinkAxisMask & 1 << w),
k = r[w];
if (k === -1) {
g.push(S ? 1 : -1);
continue;
}
let _ = [m.beginMask & 1 << w, m.endMask & 1 << w],
E = [m.strides[w] > 0 ? 0 : -1, m.strides[w] > 0 ? k : k - 1];
if (S && m.strides[w] <= 0) throw Error("only stride 1 allowed on non-range indexing.");
h = h && m.strides[w] === 1;
let R = !!(m.beginMask & 1 << w && m.endMask & 1 << w);
if (m.beginValid && m.endValid) {
if (S) {
let M = m.begin[w] < 0 ? k + m.begin[w] : m.begin[w];
if (m.begin[w] = M, m.end[w] = m.begin[w] + 1, M < 0 || M >= k) throw Error(`slice index ${m.begin[w]} of dimension ${w} out of bounds.`);
} else m.begin[w] = BN(m.begin[w], 0, m.strides[w], k, _, E), m.end[w] = BN(m.end[w], 1, m.strides[w], k, _, E);
let O = m.strides[w] === 1 && m.begin[w] === 0 && m.end[w] === k;
d = d && O, f = f && (w === 0 && m.strides[w] === 1 || O);
} else d = d && m.strides[w] === 1 && R, f = f && (w === 0 && m.strides[w] === 1 || R);
let D,
F = false;
if (m.beginValid && m.endValid ? (D = m.end[w] - m.begin[w], F = true) : S ? (D = 1, F = true) : R && k >= 0 && (m.strides[w] < 0 ? D = -k : D = k, F = true), F) {
let O;
D === 0 || D < 0 != m.strides[w] < 0 ? O = 0 : O = Math.trunc(D / m.strides[w]) + (D % m.strides[w] !== 0 ? 1 : 0), g.push(O);
} else g.push(-1);
}
for (let w = 0; w < m.finalShapeGatherIndices.length; ++w) {
let S = m.finalShapeGatherIndices[w];
S >= 0 ? x.push(g[S]) : S === Hw && x.push(1);
}
return {
finalShapeSparse: x.filter((w, S) => m.finalShapeGatherIndices[S] !== Hw),
finalShape: x,
isIdentity: d,
sliceDim0: f,
isSimpleSlice: h,
begin: m.begin,
end: m.end,
strides: m.strides
};
}
function zj(r, e) {
e.beginMask = 0, e.endMask = 0, e.shrinkAxisMask = 0;
let t10 = 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;
} else if (1 << o & r.newAxisMask) e.finalShapeGatherIndices.push(Hw), 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(Rj), e.finalShapeGatherIndicesSparse.push(-1), e.shrinkAxisMask |= 1 << t10) : (e.finalShapeGatherIndices.push(t10), e.finalShapeGatherIndicesSparse.push(o)), e.inputShapeGatherIndicesSparse[t10] = o, t10++;
}
}
function BN(r, e, t10, o, n, s) {
if (n[e]) return t10 > 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 Vj = "4.5.0";
var Dl = class {
static sgd(e) {
return new ii(e);
}
static momentum(e, t10, o = false) {
return new ep(e, t10, o);
}
static rmsprop(e, t10 = 0.9, o = 0, n = null, s = false) {
return new tp(e, t10, o, n, s);
}
static adam(e = 1e-3, t10 = 0.9, o = 0.999, n = null) {
return new Zu(e, t10, o, n);
}
static adadelta(e = 1e-3, t10 = 0.95, o = null) {
return new Yu(e, t10, o);
}
static adamax(e = 2e-3, t10 = 0.9, o = 0.999, n = null, s = 0) {
return new Ju(e, t10, o, n, s);
}
static adagrad(e, t10 = 0.1) {
return new Qu(e, t10);
}
};
var CUe = Dl;
var Wj = (() => typeof requestAnimationFrame != "undefined" ? requestAnimationFrame : typeof setImmediate != "undefined" ? setImmediate : r => r())();
function Kw() {
return new Promise(r => Wj(() => r()));
}
var C = {};
He(C, {
ERF_A1: () => sX,
ERF_A2: () => aX,
ERF_A3: () => iX,
ERF_A4: () => uX,
ERF_A5: () => pX,
ERF_P: () => nX,
PARALLELIZE_THRESHOLD: () => nf,
RowPartitionType: () => Ta,
SELU_SCALE: () => oX,
SELU_SCALEALPHA: () => rX,
applyActivation: () => ju,
assertAndGetBroadcastShape: () => rt,
assertAxesAreInnerMostDims: () => yH,
assertParamsConsistent: () => Uj,
assignToTypedArray: () => hX,
axesAreInnerMostDims: () => Iw,
calculateShapes: () => v1,
checkEinsumDimSizes: () => wX,
checkPadOnDimRoundingMode: () => Lt,
combineLocations: () => e2,
combineRaggedTensorToTensorShapes: () => Hj,
complexWithEvenIndex: () => mX,
complexWithOddIndex: () => dX,
computeConv2DInfo: () => Mu,
computeConv3DInfo: () => bk,
computeDefaultPad: () => Sw,
computeDilation2DInfo: () => g4,
computeOptimalWindowSize: () => Xj,
computeOutAndReduceShapes: () => xH,
computeOutShape: () => Gj,
computePool2DInfo: () => ww,
computePool3DInfo: () => x4,
convertConv2DDataFormat: () => Ck,
decodeEinsumEquation: () => bX,
eitherStridesOrDilationsAreOne: () => gr,
expandShapeToKeepDim: () => ti,
exponent: () => xX,
exponents: () => gX,
fromStringArrayToUint8: () => WX,
fromUint8ToStringArray: () => VX,
getAxesPermutation: () => bH,
getBroadcastDims: () => jk,
getComplexWithIndex: () => fX,
getEinsumComputePath: () => SX,
getEinsumPermutation: () => CX,
getFusedBiasGradient: () => qu,
getFusedDyActivation: () => Ku,
getImageCenter: () => Yj,
getInnerMostAxes: () => wH,
getPermuted: () => Zj,
getRaggedRank: () => qj,
getReductionAxes: () => fd,
getReshaped: () => Qj,
getReshapedPermuted: () => Jj,
getRowPartitionTypesHelper: () => Kj,
getSliceBeginCoords: () => eX,
getSliceSize: () => tX,
getSparseFillEmptyRowsIndicesDenseShapeMismatch: () => NX,
getSparseFillEmptyRowsNegativeIndexErrorMessage: () => TX,
getSparseFillEmptyRowsOutOfRangeIndexErrorMessage: () => _X,
getSparseReshapeEmptyTensorZeroOutputDimErrorMessage: () => RX,
getSparseReshapeInputOutputMismatchErrorMessage: () => AX,
getSparseReshapeInputOutputMultipleErrorMessage: () => DX,
getSparseReshapeMultipleNegativeOneOutputDimErrorMessage: () => $X,
getSparseReshapeNegativeOutputDimErrorMessage: () => EX,
getSparseSegmentReductionIndicesOutOfRangeErrorMessage: () => MX,
getSparseSegmentReductionNegativeSegmentIdsErrorMessage: () => FX,
getSparseSegmentReductionNonIncreasingSegmentIdsErrorMessage: () => PX,
getSparseSegmentReductionSegmentIdOutOfRangeErrorMessage: () => OX,
getUndoAxesPermutation: () => CH,
isIdentityPermutation: () => IX,
log: () => mG,
mergeRealAndImagArrays: () => cX,
prepareAndValidate: () => LN,
prepareSplitSize: () => kX,
segment_util: () => jw,
shouldFuse: () => Xu,
slice_util: () => ct,
splitRealAndImagArrays: () => lX,
stridesOrDilationsArePositive: () => ba,
tupleValuesAreOne: () => Ou,
upcastType: () => dt,
validateDefaultValueShape: () => jj,
validateInput: () => mc,
validateUpdateShape: () => Fw,
warn: () => ha
});
function Uj(r, e) {
let t10 = 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}.`);
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}.`);
});
}
function Gj(r, e) {
let t10 = r[0].slice();
for (let o = 1; o < r.length; o++) t10[e] += r[o][e];
return t10;
}
var Ta;
(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";
})(Ta || (Ta = {}));
function Hj(r, e, t10) {
let o = new Array();
if (t10 == null && e == null) return o;
if (e == null) for (; o.length < r + t10.length;) o.push(-1);else o = e.slice();
if (t10 == 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 (s >= 0) if (i >= 0) {
if (i !== s) throw new Error(`rt input.shape and shape=${e} are incompatible: rt input.shape[${n + r}] = ${s} but shape[${n + r}] = ${i}`);
} else o[a] = s;
}
return o;
}
function Kj(r) {
let e = {
FIRST_DIM_SIZE: Ta.FIRST_DIM_SIZE,
VALUE_ROWIDS: Ta.VALUE_ROWIDS,
ROW_LENGTHS: Ta.ROW_LENGTHS,
ROW_SPLITS: Ta.ROW_SPLITS,
ROW_LIMITS: Ta.ROW_LIMITS,
ROW_STARTS: Ta.ROW_STARTS
},
t10 = [];
for (let o of r) if (o in e) t10.push(e[o]);else break;
return t10;
}
function qj(r) {
return r.length === 0 ? 0 : r[0] === Ta.FIRST_DIM_SIZE ? r.length - 1 : r.length;
}
function jj(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 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 nf = 30;
function Xj(r) {
return r <= nf ? r : Wp(r, Math.floor(Math.sqrt(r)));
}
function Yj(r, e, t10) {
let o = t10 * (typeof r == "number" ? r : r[0]),
n = e * (typeof r == "number" ? r : r[1]);
return [o, n];
}
function Qj(r, e, t10, o = true) {
let n = [];
if (o) n = n.concat(e.slice(0)), n.push(r[0] / t10), n = n.concat(r.slice(1));else {
n = n.concat(r[0]);
let s = e.length;
for (let a = 0; a < s; ++a) n = n.concat([r[a + 1] / e[a], e[a]]);
n = n.concat(r.slice(s + 1));
}
return n;
}
function Zj(r, e, t10 = true) {
let o = [];
if (t10) {
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);
} else {
let n = [],
s = [];
for (let a = 1; a < r; ++a) a >= e * 2 + 1 || a % 2 === 1 ? s.push(a) : n.push(a);
o.push(...n), o.push(0), o.push(...s);
}
return o;
}
function Jj(r, e, t10, o = true) {
let n = [];
o ? n.push(r[0] / t10) : n.push(r[0] * t10);
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 eX(r, e) {
let t10 = [0];
for (let o = 0; o < e; ++o) t10.push(r[o][0]);
return t10;
}
function tX(r, e, t10) {
let o = r.slice(0, 1);
for (let n = 0; n < t10; ++n) o.push(r[n + 1] - e[n][0] - e[n][1]);
return o;
}
var rX = 1.7580993408473768;
var oX = 1.0507009873554805;
var nX = 0.3275911;
var sX = 0.254829592;
var aX = -0.284496736;
var iX = 1.421413741;
var uX = -1.453152027;
var pX = 1.061405429;
function cX(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;
}
function lX(r) {
let e = new Float32Array(r.length / 2),
t10 = 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
};
}
function mX(r) {
let e = Math.ceil(r.length / 4),
t10 = 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
};
}
function dX(r) {
let e = Math.floor(r.length / 4),
t10 = 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
};
}
function fX(r, e) {
let t10 = r[e * 2],
o = r[e * 2 + 1];
return {
real: t10,
imag: o
};
}
function hX(r, e, t10, o) {
r[o * 2] = e, r[o * 2 + 1] = t10;
}
function gX(r, e) {
let t10 = 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);
}
return {
real: t10,
imag: o
};
}
function xX(r, e, t10) {
let o = (t10 ? 2 : -2) * Math.PI * (r / e),
n = Math.cos(o),
s = Math.sin(o);
return {
real: n,
imag: s
};
}
var qw = "->";
var yX = /->/g;
var jN = ",";
var XN = "...";
function bX(r, e) {
r = r.replace(/\s/g, "");
let t10 = (r.length - r.replace(yX, "").length) / qw.length;
if (t10 < 1) throw new Error("Equations without an arrow are not supported.");
if (t10 > 1) throw new Error(`Equation must contain exactly one arrow ("${qw}").`);
let [o, n] = r.split(qw);
$(o.indexOf(XN) === -1, () => `The ellipsis notation ("${XN}") is not supported yet.`);
let s = o.split(jN),
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 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 d = o[m];
i.indexOf(d) === -1 && d !== jN && 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 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 CX(r, e) {
let t10 = new Array(r);
t10.fill(-1);
for (let n = 0; n < e.length; ++n) t10[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
};
}
function wX(r, e, t10) {
let o = new Array(r);
for (let n = 0; n < t10.length; ++n) {
let s = t10[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]}`);
}
}
function SX(r, e) {
let t10 = r,
o = [],
n = 0;
r.length === 0 && t10.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 = vX(e, i);
for (let u of p) s.indexOf(u) === -1 && (o[a].push(u), s.push(u));
}
return {
path: t10,
steps: o
};
}
function IX(r) {
return r.every((e, t10) => e === t10);
}
function vX(r, e) {
let t10 = [];
for (let o = 0; o < r.length; ++o) (r[o].length === 0 || r[o].indexOf(e) !== -1 || e === -1) && t10.push(o);
return t10;
}
function kX(r, e, t10 = 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);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.");
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;
}
$(r.shape[t10] === e.reduce((a, i) => a + i), () => "The sum of sizes must match the size of the axis dimension."), o = e;
}
return o;
}
function NX(r) {
return `Received SparseTensor with denseShape[0] = 0 but
indices.shape[0] = ${r}`;
}
function TX(r, e) {
return `indices(${r}, 0) is invalid: ${e} < 0`;
}
function _X(r, e, t10) {
return `indices(${r}, 0) is invalid: ${e} >= ${t10}`;
}
function $X(r, e) {
return `only one output dimension may be -1, not both ${r} and ${e}`;
}
function EX(r, e) {
return `size ${r} must be non-negative, not ${e}`;
}
function RX() {
return "reshape cannot infer the missing input size for an empty tensor unless all specified input sizes are non-zero";
}
function DX(r, e) {
let t10 = Ue(r),
o = Ue(e);
return `Input to reshape is a SparseTensor with ${t10}
dense values, but the requested shape requires a multiple of ${o}. inputShape=${r} outputShape= ${e}`;
}
function AX(r, e) {
let t10 = Ue(r),
o = Ue(e);
return `Input to reshape is a tensor with ${t10} dense values, but the requested shape has ${o}. inputShape=${r} outputShape=${e}`;
}
function FX() {
return "segment ids must be >= 0";
}
function PX() {
return "segment ids are not increasing";
}
function OX(r, e) {
return `Segment id ${r} out of range [0, ${e}), possibly because segmentIds input is not sorted.`;
}
function MX(r, e, t10) {
return `Bad: indices[${r}] == ${e} out of range [0, ${t10})`;
}
var jw = {};
He(jw, {
collectGatherOpShapeInfo: () => zX,
computeOutShape: () => BX,
segOpComputeOptimalWindowSize: () => LX
});
function LX(r, e) {
let t10 = false,
o;
for (r <= nf ? (o = r, t10 = true) : o = Wp(r, Math.floor(Math.sqrt(r))); !t10;) o > e || o === r ? t10 = true : o = Wp(r, o + 1);
return o;
}
function BX(r, e, t10) {
let o = [],
n = r.length;
for (let s = 0; s < n; s++) s !== e ? o.push(r[s]) : o.push(t10);
return o;
}
function zX(r, e, t10, 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}).`);
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;
for (let l = 0; l < o; ++l) i.push(r.shape[l]), p *= r.shape[l];
for (let l = o; l < t10; 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++) i.push(r.shape[l]), c *= r.shape[l];
return {
batchSize: p,
sliceSize: c,
outerSize: u,
dimSize: a,
outputShape: i
};
}
function VX(r) {
try {
return r.map(e => Jp(e));
} catch (e) {
throw new Error(`Failed to decode encoded string bytes into utf-8, error: ${e}`);
}
}
function WX(r) {
return r.map(e => Yi(e));
}
var Wt = {};
He(Wt, {
nonMaxSuppressionV3Impl: () => Yd,
nonMaxSuppressionV4Impl: () => Qd,
nonMaxSuppressionV5Impl: () => Zd,
whereImpl: () => Kd
});
kN();
var UX = P();
UX.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 co;
(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";
})(co || (co = {}));
var YN;
(function (r) {
let e;
(function (t10) {
t10[t10.LEGACY = 0] = "LEGACY", t10[t10.V1 = 1] = "V1", t10[t10.V2 = 2] = "V2";
})(e = r.CheckpointFormatVersion || (r.CheckpointFormatVersion = {}));
})(YN || (YN = {}));
var Yw = {};
function HX(r, e) {
let t10 = {
tfOpName: r,
category: "custom",
inputs: [],
attrs: [],
customExecutor: e
};
Yw[r] = t10;
}
function sf(r) {
return Yw[r];
}
function KX(r) {
delete Yw[r];
}
function I(r, e, t10, 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,
u = i < 0 ? e.inputNames.length + i : i;
if (s.type === "tensor") return Bt(e.inputNames[u], t10, o, n);
if (s.type === "tensors") {
let m = e.inputs.slice(i, p);
return e.inputNames.slice(i, p).filter((f, h) => {
var g;
return ((g = m[h]) === null || g === void 0 ? void 0 : g.op) !== "NoOp";
}).map(f => Bt(f, t10, o, n));
}
let c = Bt(e.inputNames[u], t10, o, n),
l = c.dataSync();
return s.type === "number" ? l[0] : y.toNestedArray(c.shape, l);
}
let a = e.attrParams[r];
return a && a.value;
}
function Bt(r, e, t10, o) {
let [n, s] = Nr(r, t10);
if (o != null) {
let i = o.getHashTableHandleByName(n);
if (i != null) return i;
}
let a = t10.currentContextIds.find(i => !!e[af(n, i)]);
return a !== void 0 ? e[af(n, a)][s] : void 0;
}
function Qw(r, e, t10) {
return e[af(r, t10.currentContextId)];
}
function Ds(r, e) {
let [t10, o, n] = Nr(r, e);
return [af(t10, e && e.currentContextId), o, n];
}
function af(r, e) {
return e ? `${r}-${e}` : r;
}
function Nr(r, e) {
if (r === "") return ["", 0, void 0];
let t10 = e != null && e.parseNodeNameCache != null;
if (t10) {
let s = e.parseNodeNameCache.get(r);
if (s != null) return s;
}
let o = r.split(":"),
n;
if (o.length === 1) n = [r, 0, void 0];else {
let s = o[0],
a = o.length === 3 ? o[1] : void 0,
i = Number(o[o.length - 1]);
n = [s, i, a];
}
return t10 && e.parseNodeNameCache.set(r, n), n;
}
function Al(r, e, t10) {
let o = I("pad", r, e, t10);
if (o === "explicit") {
o = I("explicitPaddings", r, e, t10);
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];
return n;
}
return o;
}
function As(r) {
return r.kept ? r : Vr(r);
}
var Zw = {};
He(Zw, {
json: () => qX
});
var qX = [{
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 Jw = {};
He(Jw, {
json: () => jX
});
var jX = [{
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: "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
}]
}, {
tfOpName: "IsFinite",
category: "basic_math",
inputs: [{
start: 0,
name: "x",
type: "tensor"
}],
attrs: [{
tfName: "T",
name: "dtype",
type: "dtype",
notSupported: true
}]
}, {
tfOpName: "IsInf",
category: "basic_math",
inputs: [{
start: 0,
name: "x",
type: "tensor"
}],
attrs: [{
tfName: "T",
name: "dtype",
type: "dtype",
notSupported: true
}]
}];
var eS = {};
He(eS, {
json: () => XX
});
var XX = [{
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 tS = {};
He(tS, {
json: () => YX
});
var YX = [{
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 rS = {};
He(rS, {
json: () => QX
});
var QX = [{
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: "RandomUniformInt",
category: "creation",
inputs: [{
start: 0,
name: "shape",
type: "number[]"
}],
attrs: [{
tfName: "minval",
name: "minval",
type: "number"
}, {
tfName: "maxval",
name: "maxval",
type: "number"
}, {
tfName: "seed",
name: "seed",
type: "number",
defaultValue: 0
}, {
tfName: "seed2",
name: "seed2",
type: "number",
defaultValue: 0,
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 oS = {};
He(oS, {
json: () => ZX
});
var ZX = [{
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 nS = {};
He(nS, {
json: () => JX
});
var JX = [{
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 sS = {};
He(sS, {
json: () => e5
});
var e5 = [{
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 aS = {};
He(aS, {
json: () => t5
});
var t5 = [{
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 iS = {};
He(iS, {
json: () => r5
});
var r5 = [{
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 uS = {};
He(uS, {
json: () => o5
});
var o5 = [{
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
}]
}, {
tfOpName: "BitwiseAnd",
category: "logical",
inputs: [{
start: 0,
name: "x",
type: "tensor"
}, {
start: 1,
name: "y",
type: "tensor"
}]
}];
var pS = {};
He(pS, {
json: () => n5
});
var n5 = [{
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"
}]
}, {
tfOpName: "MatrixBandPart",
category: "matrices",
inputs: [{
start: 0,
name: "a",
type: "tensor"
}, {
start: 1,
name: "numLower",
type: "tensor"
}, {
start: 1,
name: "numUpper",
type: "tensor"
}]
}];
var cS = {};
He(cS, {
json: () => s5
});
var s5 = [{
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"
}]
}];
var lS = {};
He(lS, {
json: () => a5
});
var a5 = [{
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"
}, {
tfName: "T",
name: "dtype",
type: "dtype",
notSupported: true
}]
}, {
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 mS = {};
He(mS, {
json: () => i5
});
var i5 = [{
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
}]
}, {
tfOpName: "TensorScatterUpdate",
category: "slice_join",
inputs: [{
start: 0,
name: "tensor",
type: "tensor"
}, {
start: 1,
name: "indices",
type: "tensor"
}, {
start: 2,
name: "values",
type: "tensor"
}]
}];
var dS = {};
He(dS, {
json: () => u5
});
var u5 = [{
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 fS = {};
He(fS, {
json: () => p5
});
var p5 = [{
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 hS = {};
He(hS, {
json: () => c5
});
var c5 = [{
tfOpName: "StaticRegexReplace",
category: "string",
inputs: [{
start: 0,
name: "input",
type: "tensor"
}],
attrs: [{
tfName: "pattern",
name: "pattern",
type: "string"
}, {
tfName: "rewrite",
name: "rewrite",
type: "string"
}, {
tfName: "replace_global",
name: "replaceGlobal",
type: "bool"
}]
}, {
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 gS = {};
He(gS, {
json: () => l5
});
var l5 = [{
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: "EnsureShape",
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 Fl = class {
static get Instance() {
return this._instance || (this._instance = new this());
}
constructor() {
let e = [Zw, Jw, eS, tS, rS, oS, nS, sS, aS, iS, uS, pS, cS, lS, mS, dS, fS, hS, gS],
t10 = [].concat(...e.map(o => o.json));
this.opMappers = t10.reduce((o, n) => (o[n.tfOpName] = n, o), {});
}
transformGraph(e, t10 = {}) {
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));
let m = Object.keys(i);
m.forEach(h => {
let g = i[h];
g.inputNames.forEach((x, b) => {
let [w,, S] = Ds(x),
k = i[w];
if (k.outputs != null) {
let _ = k.outputs.indexOf(S);
if (_ !== -1) {
let E = `${w}:${_}`;
g.inputNames[b] = E;
}
}
g.inputs.push(k), k.children.push(g);
});
}), Object.keys(l).length === 0 ? m.forEach(h => {
let g = i[h];
g.children.length === 0 && u.push(g);
}) : Object.keys(l).forEach(h => {
let [g] = Ds(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] = Ds(h),
x = i[g];
x && (x.signatureKey = c[h], p.push(x));
}) : p = n;
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: t10,
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), {});
}
mapNode(e) {
let t10 = sf(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 a = s.type,
i;
switch (s.type) {
case "string":
i = uf(e.attr, s.tfName, s.defaultValue), i === void 0 && s.tfDeprecatedName && (i = uf(e.attr, s.tfDeprecatedName, s.defaultValue));
break;
case "string[]":
i = hf(e.attr, s.tfName, s.defaultValue), i === void 0 && s.tfDeprecatedName && (i = hf(e.attr, s.tfDeprecatedName, s.defaultValue));
break;
case "number":
i = cf(e.attr, s.tfName, s.defaultValue || 0), i === void 0 && s.tfDeprecatedName && (i = cf(e.attr, s.tfDeprecatedName, s.defaultValue));
break;
case "number[]":
i = ff(e.attr, s.tfName, s.defaultValue), i === void 0 && s.tfDeprecatedName && (i = ff(e.attr, s.tfDeprecatedName, s.defaultValue));
break;
case "bool":
i = pf(e.attr, s.tfName, s.defaultValue), i === void 0 && s.tfDeprecatedName && (i = pf(e.attr, s.tfDeprecatedName, s.defaultValue));
break;
case "bool[]":
i = xf(e.attr, s.tfName, s.defaultValue), i === void 0 && s.tfDeprecatedName && (i = xf(e.attr, s.tfDeprecatedName, s.defaultValue));
break;
case "shape":
i = df(e.attr, s.tfName, s.defaultValue), i === void 0 && s.tfDeprecatedName && (i = df(e.attr, s.tfDeprecatedName, s.defaultValue));
break;
case "shape[]":
i = gf(e.attr, s.tfName, s.defaultValue), i === void 0 && s.tfDeprecatedName && (i = gf(e.attr, s.tfDeprecatedName, s.defaultValue));
break;
case "dtype":
i = lf(e.attr, s.tfName, s.defaultValue), i === void 0 && s.tfDeprecatedName && (i = lf(e.attr, s.tfDeprecatedName, s.defaultValue));
break;
case "dtype[]":
i = mf(e.attr, s.tfName, s.defaultValue), i === void 0 && s.tfDeprecatedName && (i = mf(e.attr, s.tfDeprecatedName, s.defaultValue));
break;
case "func":
i = QN(e.attr, s.tfName, s.defaultValue), i === void 0 && s.tfDeprecatedName && (i = QN(e.attr, s.tfDeprecatedName, s.defaultValue));
break;
case "tensor":
case "tensors":
break;
default:
throw new Error(`Unsupported param type: ${s.type} for op: ${e.op}`);
}
return n[s.name] = {
value: i,
type: a
}, n;
}, {})), 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 a = [],
i = [];
e.signature.inputArg.forEach(l => {
let [m] = Ds(l.name),
d = {
name: m,
op: "Placeholder",
inputs: [],
inputNames: [],
category: "graph",
inputParams: {},
attrParams: {
dtype: {
value: xS(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((d, f) => {
let [h,, g] = Ds(d),
x = s[h];
if (x.outputs != null) {
let b = x.outputs.indexOf(g);
if (b !== -1) {
let w = `${h}:${b}`;
m.inputNames[f] = w;
}
}
m.inputs.push(x), x.children.push(m);
});
});
let u = e.ret;
e.signature.outputArg.forEach(l => {
let [m, d] = Ds(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), {})
};
}
mapArgToTensorInfo(e, t10) {
let o = e.name;
return t10 != null && (o = t10[o]), {
name: o,
dtype: e.type
};
}
};
function m5(r) {
let e = P().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 ZN(r, e) {
let t10 = Array.isArray(r) ? String.fromCharCode.apply(null, r) : m5(r);
return e ? t10 : t10.toLowerCase();
}
function uf(r, e, t10, o = false) {
let n = r[e];
return n != null ? ZN(n.s, o) : t10;
}
function pf(r, e, t10) {
let o = r[e];
return o ? o.b : t10;
}
function cf(r, e, t10) {
let o = r[e] || {},
n = o.i != null ? o.i : o.f != null ? o.f : t10;
return typeof n == "number" ? n : parseInt(n, 10);
}
function xS(r) {
switch (typeof r == "string" && (r = co[r]), r) {
case co.DT_FLOAT:
case co.DT_HALF:
return "float32";
case co.DT_INT32:
case co.DT_INT64:
case co.DT_INT8:
case co.DT_UINT8:
return "int32";
case co.DT_BOOL:
return "bool";
case co.DT_DOUBLE:
return "float32";
case co.DT_STRING:
return "string";
default:
return null;
}
}
function QN(r, e, t10) {
let o = r[e];
return o && o.func ? o.func.name : t10;
}
function lf(r, e, t10) {
let o = r[e];
return o && o.type ? xS(o.type) : t10;
}
function mf(r, e, t10) {
let o = r[e];
return o && o.list && o.list.type ? o.list.type.map(n => xS(n)) : t10;
}
function JN(r) {
if (!r.unknownRank) return r.dim != null ? r.dim.map(e => typeof e.size == "number" ? e.size : parseInt(e.size, 10)) : [];
}
function df(r, e, t10) {
let o = r[e];
return o && o.shape ? JN(o.shape) : t10;
}
function ff(r, e, t10) {
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;
}
function hf(r, e, t10, o = false) {
let n = r[e];
return n && n.list && n.list.s ? n.list.s.map(s => ZN(s, o)) : t10;
}
function gf(r, e, t10) {
let o = r[e];
return o && o.list && o.list.shape ? o.list.shape.map(n => JN(n)) : t10;
}
function xf(r, e, t10) {
let o = r[e];
return o && o.list && o.list.b ? o.list.b : t10;
}
var yf = 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), {}));
}
getInput(e) {
return Bt(e, this.tensorMap, this.context);
}
getAttr(e, t10) {
let o = this.node.rawAttrs[e];
if (o.tensor != null) return Bt(e, this.tensorMap, this.context);
if (o.i != null || o.f != null) return cf(this.node.rawAttrs, e, t10);
if (o.s != null) return uf(this.node.rawAttrs, e, t10);
if (o.b != null) return pf(this.node.rawAttrs, e, t10);
if (o.shape != null) return df(this.node.rawAttrs, e, t10);
if (o.type != null) return lf(this.node.rawAttrs, e, t10);
if (o.list != null) {
if (o.list.i != null || o.list.f != null) return ff(this.node.rawAttrs, e, t10);
if (o.list.s != null) return hf(this.node.rawAttrs, e, t10);
if (o.list.shape != null) return gf(this.node.rawAttrs, e, t10);
if (o.list.b != null) return xf(this.node.rawAttrs, e, t10);
if (o.list.type != null) return mf(this.node.rawAttrs, e, t10);
}
return t10;
}
};
var Ze = {};
He(Ze, {
OP_SCOPE_SUFFIX: () => pw,
abs: () => Zt,
acos: () => ik,
acosh: () => uk,
add: () => be,
addN: () => pk,
all: () => ck,
any: () => lk,
argMax: () => mk,
argMin: () => dk,
asin: () => fk,
asinh: () => hk,
atan: () => gk,
atan2: () => xk,
atanh: () => yk,
avgPool: () => cd,
avgPool3d: () => wk,
basicLSTMCell: () => Sk,
batchNorm: () => tu,
batchNorm2d: () => vk,
batchNorm3d: () => kk,
batchNorm4d: () => Nk,
batchToSpaceND: () => ld,
bincount: () => md,
bitwiseAnd: () => Tk,
booleanMaskAsync: () => qq,
broadcastArgs: () => _k,
broadcastTo: () => ru,
buffer: () => me,
cast: () => Ye,
ceil: () => $k,
clipByValue: () => Ek,
clone: () => Vr,
complex: () => $r,
concat: () => yt,
concat1d: () => Rk,
concat2d: () => Dk,
concat3d: () => Ak,
concat4d: () => Fk,
conv1d: () => Pk,
conv2d: () => ou,
conv2dTranspose: () => Ok,
conv3d: () => Mk,
conv3dTranspose: () => Bk,
cos: () => zk,
cosh: () => Vk,
cosineWindow: () => _l,
cumprod: () => Wk,
cumsum: () => Uk,
denseBincount: () => Gk,
depthToSpace: () => Hk,
depthwiseConv2d: () => ac,
diag: () => Kk,
dilation2d: () => qk,
div: () => Ke,
divNoNan: () => Xk,
dot: () => Yk,
dropout: () => s6,
einsum: () => Qk,
elu: () => gd,
enclosingPowerOfTwo: () => Pw,
ensureShape: () => Zk,
equal: () => hd,
erf: () => Jk,
euclideanNorm: () => r2,
exp: () => ko,
expandDims: () => oi,
expm1: () => o2,
eye: () => xd,
fft: () => pc,
fill: () => Sa,
floor: () => yd,
floorDiv: () => pd,
fused: () => Ow,
gather: () => bd,
gatherND: () => o6,
greater: () => Bu,
greaterEqual: () => Cd,
ifft: () => Hu,
imag: () => su,
image: () => uj,
inTopKAsync: () => i6,
irfft: () => Wd,
isFinite: () => n2,
isInf: () => s2,
isNaN: () => a2,
leakyRelu: () => wd,
less: () => kl,
lessEqual: () => ic,
linalg: () => pj,
linspace: () => i2,
localResponseNormalization: () => u2,
log: () => ni,
log1p: () => Sd,
logSigmoid: () => p2,
logSoftmax: () => c2,
logSumExp: () => kd,
logicalAnd: () => zu,
logicalNot: () => Nd,
logicalOr: () => Td,
logicalXor: () => l2,
losses: () => cj,
lowerBound: () => m2,
matMul: () => Qe,
max: () => Ia,
maxPool: () => $d,
maxPool3d: () => d2,
maxPoolWithArgmax: () => f2,
maximum: () => Ed,
mean: () => Vu,
meshgrid: () => h2,
min: () => vl,
minimum: () => Wu,
mirrorPad: () => g2,
mod: () => x2,
moments: () => y2,
movingAverage: () => Yq,
mul: () => se,
multiRNNCell: () => b2,
multinomial: () => C2,
neg: () => pr,
norm: () => Lu,
notEqual: () => Rd,
oneHot: () => Tl,
ones: () => va,
onesLike: () => w2,
op: () => N,
outerProduct: () => S2,
pad: () => ka,
pad1d: () => I2,
pad2d: () => v2,
pad3d: () => k2,
pad4d: () => N2,
pool: () => T2,
pow: () => ri,
prelu: () => Ad,
print: () => ud,
prod: () => _2,
raggedGather: () => $2,
raggedRange: () => E2,
raggedTensorToTensor: () => R2,
rand: () => D2,
randomGamma: () => J2,
randomNormal: () => Bd,
randomStandardNormal: () => e1,
randomUniform: () => uc,
randomUniformInt: () => t1,
range: () => au,
real: () => si,
reciprocal: () => r1,
relu: () => iu,
relu6: () => zd,
reshape: () => W,
reverse: () => uo,
reverse1d: () => o1,
reverse2d: () => n1,
reverse3d: () => s1,
reverse4d: () => a1,
rfft: () => cc,
round: () => Vd,
rsqrt: () => i1,
scalar: () => ke,
scatterND: () => Zq,
searchSorted: () => Nl,
selu: () => u1,
separableConv2d: () => p1,
setdiff1dAsync: () => c1,
sigmoid: () => wa,
sign: () => l1,
signal: () => ij,
sin: () => m1,
sinh: () => d1,
slice: () => qe,
slice1d: () => f1,
slice2d: () => h1,
slice3d: () => g1,
slice4d: () => x1,
softmax: () => y1,
softplus: () => vd,
spaceToBatchND: () => Dd,
sparse: () => lj,
sparseToDense: () => t6,
spectral: () => aj,
split: () => ai,
sqrt: () => Rr,
square: () => Jt,
squaredDifference: () => Ud,
squeeze: () => lc,
stack: () => vr,
step: () => Gd,
stridedSlice: () => b1,
string: () => mj,
sub: () => Te,
sum: () => ot,
tan: () => C1,
tanh: () => Il,
tensor: () => ir,
tensor1d: () => xr,
tensor2d: () => uu,
tensor3d: () => Hd,
tensor4d: () => w1,
tensor5d: () => S1,
tensor6d: () => I1,
tensorScatterUpdate: () => k1,
tile: () => nu,
topk: () => N1,
transpose: () => dc,
truncatedNormal: () => T1,
unique: () => _1,
unsortedSegmentSum: () => $1,
unstack: () => po,
upperBound: () => E1,
variable: () => R1,
where: () => io,
whereAsync: () => qd,
zeros: () => Wr,
zerosLike: () => Ht
});
var eT = (r, e, t10, o = Ze) => {
switch (r.op) {
case "BiasAdd":
case "AddV2":
case "Add":
return [o.add(I("a", r, e, t10), I("b", r, e, t10))];
case "AddN":
return [o.addN(I("tensors", r, e, t10))];
case "FloorMod":
case "Mod":
return [o.mod(I("a", r, e, t10), I("b", r, e, t10))];
case "Mul":
return [o.mul(I("a", r, e, t10), I("b", r, e, t10))];
case "RealDiv":
case "Div":
return [o.div(I("a", r, e, t10), I("b", r, e, t10))];
case "DivNoNan":
return [o.divNoNan(I("a", r, e, t10), I("b", r, e, t10))];
case "FloorDiv":
return [o.floorDiv(I("a", r, e, t10), I("b", r, e, t10))];
case "Sub":
return [o.sub(I("a", r, e, t10), I("b", r, e, t10))];
case "Minimum":
return [o.minimum(I("a", r, e, t10), I("b", r, e, t10))];
case "Maximum":
return [o.maximum(I("a", r, e, t10), I("b", r, e, t10))];
case "Pow":
return [o.pow(I("a", r, e, t10), I("b", r, e, t10))];
case "SquaredDifference":
return [o.squaredDifference(I("a", r, e, t10), I("b", r, e, t10))];
default:
throw TypeError(`Node type ${r.op} is not implemented`);
}
};
var tT = (r, e, t10, o = Ze) => {
switch (r.op) {
case "Abs":
case "ComplexAbs":
return [o.abs(I("x", r, e, t10))];
case "Acos":
return [o.acos(I("x", r, e, t10))];
case "Acosh":
return [o.acosh(I("x", r, e, t10))];
case "Asin":
return [o.asin(I("x", r, e, t10))];
case "Asinh":
return [o.asinh(I("x", r, e, t10))];
case "Atan":
return [o.atan(I("x", r, e, t10))];
case "Atan2":
return [o.atan2(I("x", r, e, t10), I("y", r, e, t10))];
case "Atanh":
return [o.atanh(I("x", r, e, t10))];
case "Ceil":
return [o.ceil(I("x", r, e, t10))];
case "Complex":
return [o.complex(I("real", r, e, t10), I("imag", r, e, t10))];
case "Cos":
return [o.cos(I("x", r, e, t10))];
case "Cosh":
return [o.cosh(I("x", r, e, t10))];
case "Elu":
return [o.elu(I("x", r, e, t10))];
case "Erf":
return [o.erf(I("x", r, e, t10))];
case "Exp":
return [o.exp(I("x", r, e, t10))];
case "Expm1":
return [o.expm1(I("x", r, e, t10))];
case "Floor":
return [o.floor(I("x", r, e, t10))];
case "Log":
return [o.log(I("x", r, e, t10))];
case "Log1p":
return [o.log1p(I("x", r, e, t10))];
case "Imag":
return [o.imag(I("x", r, e, t10))];
case "Neg":
return [o.neg(I("x", r, e, t10))];
case "Reciprocal":
return [o.reciprocal(I("x", r, e, t10))];
case "Real":
return [o.real(I("x", r, e, t10))];
case "Relu":
return [o.relu(I("x", r, e, t10))];
case "Round":
return [o.round(I("x", r, e, t10))];
case "Selu":
return [o.selu(I("x", r, e, t10))];
case "Sigmoid":
return [o.sigmoid(I("x", r, e, t10))];
case "Sin":
return [o.sin(I("x", r, e, t10))];
case "Sign":
return [o.sign(I("x", r, e, t10))];
case "Sinh":
return [o.sinh(I("x", r, e, t10))];
case "Softplus":
return [o.softplus(I("x", r, e, t10))];
case "Sqrt":
return [o.sqrt(I("x", r, e, t10))];
case "Square":
return [o.square(I("x", r, e, t10))];
case "Tanh":
return [o.tanh(I("x", r, e, t10))];
case "Tan":
return [o.tan(I("x", r, e, t10))];
case "ClipByValue":
return [o.clipByValue(I("x", r, e, t10), I("clipValueMin", r, e, t10), I("clipValueMax", r, e, t10))];
case "Relu6":
return [o.relu6(I("x", r, e, t10))];
case "Rsqrt":
return [o.rsqrt(Bt(r.inputNames[0], e, t10))];
case "LeakyRelu":
return [o.leakyRelu(I("x", r, e, t10), I("alpha", r, e, t10))];
case "Prelu":
return [o.prelu(I("x", r, e, t10), I("alpha", r, e, t10))];
case "IsNan":
return [o.isNaN(Bt(r.inputNames[0], e, t10))];
case "IsInf":
return [o.isInf(Bt(r.inputNames[0], e, t10))];
case "IsFinite":
return [o.isFinite(Bt(r.inputNames[0], e, t10))];
default:
throw TypeError(`Node type ${r.op} is not implemented`);
}
};
function Ur(r, e, t10 = "") {
if (!(typeof r == "number" || typeof e == "number")) {
y.assert(r.length === e.length, () => t10 + ` Shapes ${r} and ${e} must match`);
for (let o = 0; o < r.length; o++) {
let n = r[o],
s = e[o];
y.assert(n < 0 || s < 0 || n === s, () => t10 + ` Shapes ${r} and ${e} must match`);
}
}
}
function rT(r) {
return !(typeof r == "number" || r.some(e => e < 0));
}
function fc(r, e, t10) {
let o = bf(r, t10),
n = !rT(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 = bf(s.shape, o);
}), !rT(o)) throw new Error(`Non-fully-defined elementShape: ${o}`);
return o;
}
function bf(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 = [];
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;
}
return t10;
}
var Cf = 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 = ke(0), Er(this.idTensor);
}
get id() {
return this.idTensor.id;
}
get closed() {
return this.closed_;
}
clearAndClose(e) {
this.tensors.forEach(t10 => {
(e == null || !e.has(t10.tensor.id)) && t10.tensor.dispose();
}), this.tensors = [], this.closed_ = true, this.idTensor.dispose();
}
size() {
return this.tensors.length;
}
read(e) {
if (this.closed_) 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) 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;
}
readMany(e) {
return e.map(t10 => this.read(t10));
}
write(e, t10) {
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) 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) 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, Er(t10), 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]));
}
gather(e, t10) {
if (t10 && t10 !== this.dtype) throw new Error(`TensorArray dtype is ${this.dtype} but gather requested dtype ${t10}`);
if (e) e = e.slice(0, this.size());else {
e = [];
for (let n = 0; n < this.size(); n++) e.push(n);
}
if (e.length === 0) return ir([], [0].concat(this.elementShape));
let o = this.readMany(e);
return Ur(this.elementShape, o[0].shape, "TensorArray shape mismatch: "), vr(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 ir([], [0].concat(this.elementShape));
let t10 = [];
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})`), yt(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]}`);
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, po(t10, 0));
}
split(e, t10) {
if (t10.dtype !== this.dtype) throw new Error(`TensorArray dtype is ${this.dtype} but tensor has dtype ${t10.dtype}`);
let o = 0,
n = e.map(p => (o += p, o));
if (o !== t10.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}`);
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 = [];
De(() => {
t10 = W(t10, [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] = W(qe(t10, c, l), this.elementShape);
}
return a;
});
let i = [];
for (let p = 0; p < e.length; p++) i[p] = p;
this.writeMany(i, a);
}
};
var ci = class {
get id() {
return this.idTensor.id;
}
constructor(e, t10, o, n = -1) {
this.tensors = e, this.elementShape = t10, 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: "), Er(s);
}), this.idTensor = ke(0), this.maxNumElements = n, Er(this.idTensor);
}
copy() {
return new ci([...this.tensors], this.elementShape, this.elementDtype);
}
clearAndClose(e) {
this.tensors.forEach(t10 => {
(e == null || !e.has(t10.id)) && t10.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}`);
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 = fc(this.elementShape, this.tensors, e);
return De(() => {
let s = this.tensors.map(a => W(a, n));
return vr(s, 0);
});
}
popBack(e, t10) {
if (t10 !== this.elementDtype) throw new Error(`Invalid data types; op elements ${t10}, but list elements ${this.elementDtype}`);
if (this.size() === 0) throw new Error("Trying to pop from an empty list.");
let o = fc(this.elementShape, this.tensors, e),
n = this.tensors.pop();
return n.kept = false, Ur(n.shape, e, "TensorList shape mismatch: "), W(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()) throw new Error("Trying to push element into a full list.");
Er(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 ci([], this.elementShape, this.elementDtype, this.maxNumElements);
t10.tensors.length = e;
for (let o = 0; o < Math.min(this.tensors.length, e); ++o) t10.tensors[o] = this.tensors[o];
return t10;
}
getItem(e, t10, 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 = fc(this.elementShape, this.tensors, t10);
return W(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}`);
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: "), Er(t10), this.tensors[e] != null && (this.tensors[e].kept = false), this.tensors[e] = t10;
}
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 = fc(this.elementShape, this.tensors, o);
return e.length === 0 ? ir([], [0].concat(n)) : De(() => {
let s = e.map(a => W(this.tensors[a], n));
return vr(s, 0);
});
}
concat(e, t10) {
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 = fc(this.elementShape, this.tensors, t10);
return this.size() === 0 ? ir([], [0].concat(o)) : De(() => {
let n = this.tensors.map(s => W(s, o));
return yt(n, 0);
});
}
};
function oT(r, e, t10) {
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}`);
let n = r.shape.slice(1);
Ur(n, e, "TensorList shape mismatch: ");
let s = po(r);
return new ci(s, e, o);
}
function nT(r, e, t10, o) {
return new ci([], r, e, o);
}
function sT(r, e, t10, 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 ci([], t10, r.dtype, o),
a = po(r, 0);
return e.forEach((i, p) => {
s.setItem(i, a[p]);
}), s;
}
function aT(r, e, t10) {
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 = bf(s, t10),
i = o === 0 ? 0 : r.size / o,
p = De(() => {
let c = [];
r = W(r, [1, o, i]);
for (let l = 0; l < e.length; ++l) {
let d = [0, l === 0 ? 0 : n[l - 1], 0],
f = [1, e[l], i];
c[l] = W(qe(r, d, f), a);
}
return r.dispose(), c;
}),
u = new ci([], t10, r.dtype, e.length);
for (let c = 0; c < p.length; c++) u.setItem(c, p[c]);
return u;
}
var iT = async (r, e, t10) => {
switch (r.op) {
case "If":
case "StatelessIf":
{
let o = I("thenBranch", r, e, t10),
n = I("elseBranch", r, e, t10),
s = I("cond", r, e, t10),
a = I("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);
}
case "While":
case "StatelessWhile":
{
let o = I("body", r, e, t10),
n = I("cond", r, e, t10),
s = I("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();
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(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(d => {
!d.kept && i.indexOf(d.id) === -1 && l.indexOf(d.id) === -1 && d.dispose();
});
}
return u;
}
case "LoopCond":
{
let o = I("pred", r, e, t10);
return [As(o)];
}
case "Switch":
{
let o = I("pred", r, e, t10),
n = I("data", r, e, t10);
return n.kept || (n = As(n)), (await o.data())[0] ? [void 0, n] : [n, void 0];
}
case "Merge":
{
let o = r.inputNames.find(n => Bt(n, e, t10) !== void 0);
if (o) {
let n = Bt(o, e, t10);
return [As(n)];
}
return;
}
case "Enter":
{
let o = I("frameName", r, e, t10),
n = I("tensor", r, e, t10);
return t10.enterFrame(o), [As(n)];
}
case "Exit":
{
let o = I("tensor", r, e, t10);
return t10.exitFrame(), [As(o)];
}
case "NextIteration":
{
let o = I("tensor", r, e, t10);
return t10.nextIteration(), [As(o)];
}
case "TensorArrayV3":
{
let o = I("size", r, e, t10),
n = I("dtype", r, e, t10),
s = I("elementShape", r, e, t10),
a = I("dynamicSize", r, e, t10),
i = I("clearAfterRead", r, e, t10),
p = I("identicalElementShapes", r, e, t10),
u = I("name", r, e, t10),
c = new Cf(u, n, o, s, p, a, i);
return t10.addTensorArray(c), [c.idTensor, ke(1)];
}
case "TensorArrayWriteV3":
{
let o = I("tensorArrayId", r, e, t10),
n = I("index", r, e, t10),
s = I("tensor", r, e, t10),
a = t10.getTensorArray(o.id);
return a.write(n, s), [a.idTensor];
}
case "TensorArrayReadV3":
{
let o = I("tensorArrayId", r, e, t10),
n = I("index", r, e, t10);
return [t10.getTensorArray(o.id).read(n)];
}
case "TensorArrayGatherV3":
{
let o = I("tensorArrayId", r, e, t10),
n = I("indices", r, e, t10),
s = I("dtype", r, e, t10);
return [t10.getTensorArray(o.id).gather(n, s)];
}
case "TensorArrayScatterV3":
{
let o = I("tensorArrayId", r, e, t10),
n = I("indices", r, e, t10),
s = I("tensor", r, e, t10),
a = t10.getTensorArray(o.id);
return a.scatter(n, s), [a.idTensor];
}
case "TensorArrayConcatV3":
{
let o = I("tensorArrayId", r, e, t10),
n = t10.getTensorArray(o.id),
s = I("dtype", r, e, t10);
return [n.concat(s)];
}
case "TensorArraySplitV3":
{
let o = I("tensorArrayId", r, e, t10),
n = I("tensor", r, e, t10),
s = I("lengths", r, e, t10),
a = t10.getTensorArray(o.id);
return a.split(s, n), [a.idTensor];
}
case "TensorArraySizeV3":
{
let o = I("tensorArrayId", r, e, t10),
n = t10.getTensorArray(o.id);
return [ke(n.size(), "int32")];
}
case "TensorArrayCloseV3":
{
let o = I("tensorArrayId", r, e, t10),
n = t10.getTensorArray(o.id);
return n.clearAndClose(), [n.idTensor];
}
case "TensorListSetItem":
{
let o = I("tensorListId", r, e, t10),
n = I("index", r, e, t10),
s = I("tensor", r, e, t10),
a = t10.getTensorList(o.id);
return a.setItem(n, s), [a.idTensor];
}
case "TensorListGetItem":
{
let o = I("tensorListId", r, e, t10),
n = I("index", r, e, t10),
s = I("elementShape", r, e, t10),
a = I("elementDType", r, e, t10);
return [t10.getTensorList(o.id).getItem(n, s, a)];
}
case "TensorListScatterV2":
case "TensorListScatter":
{
let o = I("indices", r, e, t10),
n = I("tensor", r, e, t10),
s = I("elementShape", r, e, t10),
a = I("numElements", r, e, t10),
i = sT(n, o, s, a);
return t10.addTensorList(i), [i.idTensor];
}
case "TensorListReserve":
case "EmptyTensorList":
{
let o = I("elementShape", r, e, t10),
n = I("elementDType", r, e, t10),
s;
r.op === "TensorListReserve" ? s = "numElements" : s = "maxNumElements";
let a = I(s, r, e, t10),
i = r.op === "TensorListReserve" ? -1 : a,
p = nT(o, n, a, i);
return t10.addTensorList(p), [p.idTensor];
}
case "TensorListGather":
{
let o = I("tensorListId", r, e, t10),
n = I("indices", r, e, t10),
s = I("elementShape", r, e, t10),
a = I("elementDType", r, e, t10);
return [t10.getTensorList(o.id).gather(n, a, s)];
}
case "TensorListStack":
{
let o = I("tensorListId", r, e, t10),
n = I("elementShape", r, e, t10),
s = I("elementDType", r, e, t10),
a = I("numElements", r, e, t10);
return [t10.getTensorList(o.id).stack(n, s, a)];
}
case "TensorListFromTensor":
{
let o = I("tensor", r, e, t10),
n = I("elementShape", r, e, t10),
s = I("elementDType", r, e, t10),
a = oT(o, n, s);
return t10.addTensorList(a), [a.idTensor];
}
case "TensorListConcat":
case "TensorListConcatV2":
{
let o = I("tensorListId", r, e, t10),
n = t10.getTensorList(o.id),
s = I("dtype", r, e, t10),
a = I("elementShape", r, e, t10);
return [n.concat(s, a)];
}
case "TensorListPushBack":
{
let o = I("tensorListId", r, e, t10),
n = I("tensor", r, e, t10),
s = t10.getTensorList(o.id);
return s.pushBack(n), [s.idTensor];
}
case "TensorListPopBack":
{
let o = I("tensorListId", r, e, t10),
n = I("elementShape", r, e, t10),
s = I("elementDType", r, e, t10);
return [t10.getTensorList(o.id).popBack(n, s)];
}
case "TensorListSplit":
{
let o = I("tensor", r, e, t10),
n = I("elementShape", r, e, t10),
s = I("lengths", r, e, t10),
a = aT(o, s, n);
return t10.addTensorList(a), [a.idTensor];
}
case "TensorListLength":
{
let o = I("tensorListId", r, e, t10),
n = t10.getTensorList(o.id);
return [ke(n.size(), "int32")];
}
case "TensorListResize":
{
let o = I("tensorListId", r, e, t10),
n = I("size", r, e, t10),
a = t10.getTensorList(o.id).resize(n);
return t10.addTensorList(a), [a.idTensor];
}
default:
throw TypeError(`Node type ${r.op} is not implemented`);
}
};
function uT(r, e, t10) {
let [o, n] = I("fusedOps", r, e, t10),
s = o === "biasadd",
a = !s,
i = n === "prelu",
p = o === "fusedbatchnorm",
u = I("numArgs", r, e, t10);
if (s) {
if (i && u !== 2) throw new Error("FusedConv2d and DepthwiseConv2d with BiasAdd and Prelu must have two extra arguments: bias and alpha.");
if (!i && s && u !== 1) throw new Error("FusedConv2d and DepthwiseConv2d with BiasAdd must have one extra argument: bias.");
}
if (p) throw new Error("FusedConv2d and DepthwiseConv2d with FusedBatchNorm is not supported");
let c = I("strides", r, e, t10),
l = Al(r, e, t10),
m = I("dataFormat", r, e, t10).toUpperCase(),
d = I("dilations", r, e, t10),
[f, h] = I("args", r, e, t10);
a && (h = f, f = void 0);
let g = I("leakyreluAlpha", r, e, t10);
return {
stride: c,
pad: l,
dataFormat: m,
dilations: d,
biasArg: f,
preluArg: h,
activationFunc: n,
leakyreluAlpha: g
};
}
var pT = (r, e, t10, o = Ze) => {
switch (r.op) {
case "Conv1D":
{
let n = I("stride", r, e, t10),
s = I("pad", r, e, t10),
a = I("dataFormat", r, e, t10).toUpperCase(),
i = I("dilation", r, e, t10);
return [o.conv1d(I("x", r, e, t10), I("filter", r, e, t10), n, s, a, i)];
}
case "Conv2D":
{
let n = I("strides", r, e, t10),
s = Al(r, e, t10),
a = I("dataFormat", r, e, t10).toUpperCase(),
i = I("dilations", r, e, t10);
return [o.conv2d(I("x", r, e, t10), I("filter", r, e, t10), [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
} = uT(r, e, t10);
return [o.fused.conv2d({
x: I("x", r, e, t10),
filter: I("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
})];
}
case "FusedDepthwiseConv2dNative":
{
let {
stride: n,
pad: s,
dataFormat: a,
dilations: i,
biasArg: p,
preluArg: u,
activationFunc: c,
leakyreluAlpha: l
} = uT(r, e, t10);
return [o.fused.depthwiseConv2d({
x: I("x", r, e, t10),
filter: I("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
})];
}
case "Conv2DBackpropInput":
case "Conv2dTranspose":
{
let n = I("outputShape", r, e, t10),
s = I("strides", r, e, t10),
a = Al(r, e, t10);
return [o.conv2dTranspose(I("x", r, e, t10), I("filter", r, e, t10), n, [s[1], s[2]], a)];
}
case "DepthwiseConv2dNative":
case "DepthwiseConv2d":
{
let n = I("strides", r, e, t10),
s = Al(r, e, t10),
a = I("dilations", r, e, t10),
i = I("dataFormat", r, e, t10).toUpperCase();
return [o.depthwiseConv2d(I("input", r, e, t10), I("filter", r, e, t10), [n[1], n[2]], s, i, [a[1], a[2]])];
}
case "Conv3D":
{
let n = I("strides", r, e, t10),
s = I("pad", r, e, t10),
a = I("dataFormat", r, e, t10).toUpperCase(),
i = I("dilations", r, e, t10);
return [o.conv3d(I("x", r, e, t10), I("filter", r, e, t10), [n[1], n[2], n[3]], s, a, [i[1], i[2], i[3]])];
}
case "AvgPool":
{
let n = I("strides", r, e, t10),
s = I("pad", r, e, t10),
a = I("kernelSize", r, e, t10);
return [o.avgPool(I("x", r, e, t10), [a[1], a[2]], [n[1], n[2]], s)];
}
case "MaxPool":
{
let n = I("strides", r, e, t10),
s = I("pad", r, e, t10),
a = I("kernelSize", r, e, t10);
return [o.maxPool(I("x", r, e, t10), [a[1], a[2]], [n[1], n[2]], s)];
}
case "MaxPoolWithArgmax":
{
let n = I("strides", r, e, t10),
s = I("pad", r, e, t10),
a = I("kernelSize", r, e, t10),
i = I("includeBatchInIndex", r, e, t10),
{
result: p,
indexes: u
} = o.maxPoolWithArgmax(I("x", r, e, t10), [a[1], a[2]], [n[1], n[2]], s, i);
return [p, u];
}
case "AvgPool3D":
{
let n = I("strides", r, e, t10),
s = I("pad", r, e, t10),
a = I("kernelSize", r, e, t10);
return [o.avgPool3d(I("x", r, e, t10), [a[1], a[2], a[3]], [n[1], n[2], n[3]], s)];
}
case "MaxPool3D":
{
let n = I("strides", r, e, t10),
s = I("pad", r, e, t10),
a = I("kernelSize", r, e, t10);
return [o.maxPool3d(I("x", r, e, t10), [a[1], a[2], a[3]], [n[1], n[2], n[3]], s)];
}
case "Dilation2D":
{
let n = I("strides", r, e, t10),
s = I("pad", r, e, t10),
a = I("dilations", r, e, t10),
i = n[1],
p = n[2],
u = a[1],
c = a[2];
return [o.dilation2d(I("x", r, e, t10), I("filter", r, e, t10), [i, p], s, [u, c], "NHWC")];
}
default:
throw TypeError(`Node type ${r.op} is not implemented`);
}
};
var cT = (r, e, t10, o = Ze) => {
switch (r.op) {
case "Fill":
{
let n = I("shape", r, e, t10),
s = I("dtype", r, e, t10),
a = I("value", r, e, t10);
return [o.fill(n, a, s)];
}
case "LinSpace":
{
let n = I("start", r, e, t10),
s = I("stop", r, e, t10),
a = I("num", r, e, t10);
return [o.linspace(n, s, a)];
}
case "Multinomial":
{
let n = I("logits", r, e, t10),
s = I("numSamples", r, e, t10),
a = I("seed", r, e, t10);
return [o.multinomial(n, s, a)];
}
case "OneHot":
{
let n = I("indices", r, e, t10),
s = I("depth", r, e, t10),
a = I("onValue", r, e, t10),
i = I("offValue", r, e, t10),
p = I("dtype", r, e, t10);
return [o.oneHot(n, s, a, i, p)];
}
case "Ones":
return [o.ones(I("shape", r, e, t10), I("dtype", r, e, t10))];
case "OnesLike":
return [o.onesLike(I("x", r, e, t10))];
case "RandomStandardNormal":
return [o.randomStandardNormal(I("shape", r, e, t10), I("dtype", r, e, t10), I("seed", r, e, t10))];
case "RandomUniform":
return [o.randomUniform(I("shape", r, e, t10), I("minval", r, e, t10), I("maxval", r, e, t10), I("dtype", r, e, t10))];
case "RandomUniformInt":
return [o.randomUniformInt(I("shape", r, e, t10), I("minval", r, e, t10), I("maxval", r, e, t10), I("seed", r, e, t10))];
case "Range":
{
let n = I("start", r, e, t10),
s = I("stop", r, e, t10),
a = I("step", r, e, t10);
return [o.range(n, s, a, I("dtype", r, e, t10))];
}
case "TruncatedNormal":
{
let n = I("shape", r, e, t10),
s = I("mean", r, e, t10),
a = I("stdDev", r, e, t10),
i = I("seed", r, e, t10);
return [o.truncatedNormal(n, s, a, I("dtype", r, e, t10), i)];
}
case "Zeros":
return [o.zeros(I("shape", r, e, t10), I("dtype", r, e, t10))];
case "ZerosLike":
return [o.zerosLike(I("x", r, e, t10))];
default:
throw TypeError(`Node type ${r.op} is not implemented`);
}
};
function yS(r, e, t10) {
let o = I("boxes", r, e, t10),
n = I("scores", r, e, t10),
s = I("maxOutputSize", r, e, t10),
a = I("iouThreshold", r, e, t10),
i = I("scoreThreshold", r, e, t10),
p = I("softNmsSigma", r, e, t10);
return {
boxes: o,
scores: n,
maxOutputSize: s,
iouThreshold: a,
scoreThreshold: i,
softNmsSigma: p
};
}
var lT = async (r, e, t10, o, n = Ze) => {
switch (r.op) {
case "NonMaxSuppressionV5":
{
let {
boxes: s,
scores: a,
maxOutputSize: i,
iouThreshold: p,
scoreThreshold: u,
softNmsSigma: c
} = yS(r, e, t10),
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
} = yS(r, e, t10),
c = I("padToMaxOutputSize", r, e, t10),
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
} = yS(r, e, t10);
return [await n.image.nonMaxSuppressionAsync(s, a, i, p, u)];
}
case "Where":
{
let s = n.cast(I("condition", r, e, t10), "bool"),
a = [await n.whereAsync(s)];
return s.dispose(), a;
}
case "ListDiff":
return n.setdiff1dAsync(I("x", r, e, t10), I("y", r, e, t10));
default:
throw TypeError(`Node type ${r.op} is not implemented`);
}
};
var mT = (r, e, t10, o = Ze) => {
switch (r.op) {
case "LowerBound":
{
let n = I("sortedSequence", r, e, t10),
s = I("values", r, e, t10);
return [o.lowerBound(n, s)];
}
case "TopKV2":
{
let n = I("x", r, e, t10),
s = I("k", r, e, t10),
a = I("sorted", r, e, t10),
i = o.topk(n, s, a);
return [i.values, i.indices];
}
case "UpperBound":
{
let n = I("sortedSequence", r, e, t10),
s = I("values", r, e, t10);
return [o.upperBound(n, s)];
}
case "Unique":
{
let n = I("x", r, e, t10),
s = o.unique(n);
return [s.values, s.indices];
}
case "UniqueV2":
{
let n = I("x", r, e, t10),
s = I("axis", r, e, t10),
a = o.unique(n, s);
return [a.values, a.indices];
}
default:
throw TypeError(`Node type ${r.op} is not implemented`);
}
};
var dT = (r, e, t10, o = Ze) => {
switch (r.op) {
case "Const":
return e[r.name];
case "PlaceholderWithDefault":
let n = I("default", r, e, t10);
return [Bt(r.name, e, t10) || n];
case "Placeholder":
return [Bt(r.name, e, t10)];
case "Identity":
case "StopGradient":
case "FakeQuantWithMinMaxVars":
{
let c = I("x", r, e, t10);
return [As(c)];
}
case "IdentityN":
return I("x", r, e, t10).map(c => As(c));
case "Snapshot":
let s = I("x", r, e, t10);
return [As(s)];
case "Shape":
return [o.tensor1d(I("x", r, e, t10).shape, "int32")];
case "ShapeN":
return I("x", r, e, t10).map(c => o.tensor1d(c.shape));
case "Size":
return [o.scalar(I("x", r, e, t10).size, "int32")];
case "Rank":
return [o.scalar(I("x", r, e, t10).rank, "int32")];
case "NoOp":
return [o.scalar(1)];
case "Print":
let a = I("x", r, e, t10),
i = I("data", r, e, t10),
p = I("message", r, e, t10),
u = I("summarize", r, e, t10);
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));
return [a];
default:
throw TypeError(`Node type ${r.op} is not implemented`);
}
};
var wf = class {
get id() {
return this.handle.id;
}
constructor(e, t10) {
this.keyDType = e, this.valueDType = t10, this.handle = ke(0), this.tensorMap = /* @__PURE__ */new Map(), Er(this.handle);
}
clearAndClose() {
this.tensorMap.forEach(e => e.dispose()), this.tensorMap.clear(), this.handle.dispose();
}
size() {
return this.tensorMap.size;
}
tensorSize() {
return ke(this.size(), "int32");
}
async import(e, t10) {
this.checkKeyAndValueTensor(e, t10);
let o = await e.data();
return this.tensorMap.forEach(n => n.dispose()), this.tensorMap.clear(), De(() => {
let n = po(t10),
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];
Er(u), this.tensorMap.set(p, u);
}
return this.handle;
});
}
async find(e, t10) {
this.checkKeyAndValueTensor(e, t10);
let o = await e.data();
return De(() => {
let n = [];
for (let s = 0; s < o.length; s++) {
let a = o[s],
i = this.findWithDefault(a, t10);
n.push(i);
}
return vr(n);
});
}
findWithDefault(e, t10) {
let o = this.tensorMap.get(e);
return o != null ? o : t10;
}
checkKeyAndValueTensor(e, t10) {
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}`);
}
};
var fT = async (r, e, t10, o) => {
switch (r.op) {
case "HashTable":
case "HashTableV2":
{
let n = o.getHashTableHandleByName(r.name);
if (n != null) return [n];
{
let s = I("keyDType", r, e, t10),
a = I("valueDType", r, e, t10),
i = new wf(s, a);
return o.addHashTable(r.name, i), [i.handle];
}
}
case "InitializeTable":
case "InitializeTableV2":
case "LookupTableImport":
case "LookupTableImportV2":
{
let n = I("tableHandle", r, e, t10, o),
s = I("keys", r, e, t10),
a = I("values", r, e, t10);
return [await o.getHashTableById(n.id).import(s, a)];
}
case "LookupTableFind":
case "LookupTableFindV2":
{
let n = I("tableHandle", r, e, t10, o),
s = I("keys", r, e, t10),
a = I("defaultValue", r, e, t10);
return [await o.getHashTableById(n.id).find(s, a)];
}
case "LookupTableSize":
case "LookupTableSizeV2":
{
let n = I("tableHandle", r, e, t10, o);
return [o.getHashTableById(n.id).tensorSize()];
}
default:
throw TypeError(`Node type ${r.op} is not implemented`);
}
};
var hT = (r, e, t10, o = Ze) => {
switch (r.op) {
case "ResizeBilinear":
{
let n = I("images", r, e, t10),
s = I("size", r, e, t10),
a = I("alignCorners", r, e, t10),
i = I("halfPixelCenters", r, e, t10);
return [o.image.resizeBilinear(n, [s[0], s[1]], a, i)];
}
case "ResizeNearestNeighbor":
{
let n = I("images", r, e, t10),
s = I("size", r, e, t10),
a = I("alignCorners", r, e, t10),
i = I("halfPixelCenters", r, e, t10);
return [o.image.resizeNearestNeighbor(n, [s[0], s[1]], a, i)];
}
case "CropAndResize":
{
let n = I("image", r, e, t10),
s = I("boxes", r, e, t10),
a = I("boxInd", r, e, t10),
i = I("cropSize", r, e, t10),
p = I("method", r, e, t10),
u = I("extrapolationValue", r, e, t10);
return [o.image.cropAndResize(n, s, a, i, p, u)];
}
case "ImageProjectiveTransformV3":
{
let n = I("images", r, e, t10),
s = I("transforms", r, e, t10),
a = I("outputShape", r, e, t10),
i = I("fillValue", r, e, t10),
p = I("interpolation", r, e, t10),
u = I("fillMode", r, e, t10);
return [o.image.transform(n, s, p.toLowerCase(), u.toLowerCase(), i, a)];
}
default:
throw TypeError(`Node type ${r.op} is not implemented`);
}
};
var gT = (r, e, t10, o = Ze) => {
switch (r.op) {
case "Equal":
return [o.equal(I("a", r, e, t10), I("b", r, e, t10))];
case "NotEqual":
return [o.notEqual(I("a", r, e, t10), I("b", r, e, t10))];
case "Greater":
return [o.greater(I("a", r, e, t10), I("b", r, e, t10))];
case "GreaterEqual":
return [o.greaterEqual(I("a", r, e, t10), I("b", r, e, t10))];
case "Less":
return [o.less(I("a", r, e, t10), I("b", r, e, t10))];
case "LessEqual":
return [o.lessEqual(I("a", r, e, t10), I("b", r, e, t10))];
case "LogicalAnd":
return [o.logicalAnd(I("a", r, e, t10), I("b", r, e, t10))];
case "LogicalNot":
return [o.logicalNot(I("a", r, e, t10))];
case "LogicalOr":
return [o.logicalOr(I("a", r, e, t10), I("b", r, e, t10))];
case "Select":
case "SelectV2":
return [o.where(I("condition", r, e, t10), I("a", r, e, t10), I("b", r, e, t10))];
case "BitwiseAnd":
return [o.bitwiseAnd(I("a", r, e, t10), I("b", r, e, t10))];
default:
throw TypeError(`Node type ${r.op} is not implemented`);
}
};
var xT = (r, e, t10, o = Ze) => {
switch (r.op) {
case "BatchMatMul":
case "BatchMatMulV2":
case "MatMul":
return [o.matMul(I("a", r, e, t10), I("b", r, e, t10), I("transposeA", r, e, t10), I("transposeB", r, e, t10))];
case "Einsum":
return [o.einsum(I("equation", r, e, t10), ...I("tensors", r, e, t10))];
case "Transpose":
return [o.transpose(I("x", r, e, t10), I("perm", r, e, t10))];
case "_FusedMatMul":
let [n, s] = I("fusedOps", r, e, t10),
a = n === "biasadd",
i = s === "prelu",
p = I("numArgs", r, e, t10),
u = I("leakyreluAlpha", r, e, t10);
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] = I("args", r, e, t10);
return [o.fused.matMul({
a: I("a", r, e, t10),
b: I("b", r, e, t10),
transposeA: I("transposeA", r, e, t10),
transposeB: I("transposeB", r, e, t10),
bias: c,
activation: s,
preluActivationWeights: l,
leakyreluAlpha: u
})];
case "MatrixBandPart":
return [o.linalg.bandPart(I("a", r, e, t10), I("numLower", r, e, t10), I("numUpper", r, e, t10))];
default:
throw TypeError(`Node type ${r.op} is not implemented`);
}
};
var yT = (r, e, t10, o = Ze) => {
switch (r.op) {
case "EuclideanNorm":
return [o.euclideanNorm(I("x", r, e, t10), I("axis", r, e, t10), I("keepDims", r, e, t10))];
case "FusedBatchNorm":
case "FusedBatchNormV2":
return [o.batchNorm(I("x", r, e, t10), I("mean", r, e, t10), I("variance", r, e, t10), I("offset", r, e, t10), I("scale", r, e, t10), I("epsilon", r, e, t10))];
case "FusedBatchNormV3":
return [o.batchNorm(I("x", r, e, t10), I("mean", r, e, t10), I("variance", r, e, t10), I("offset", r, e, t10), I("scale", r, e, t10), I("epsilon", r, e, t10))];
case "LRN":
return [o.localResponseNormalization(I("x", r, e, t10), I("radius", r, e, t10), I("bias", r, e, t10), I("alpha", r, e, t10), I("beta", r, e, t10))];
case "Softmax":
return [o.softmax(I("x", r, e, t10))];
case "LogSoftmax":
return [o.logSoftmax(I("x", r, e, t10))];
default:
throw TypeError(`Node type ${r.op} is not implemented`);
}
};
var bT = (r, e, t10, o = Ze) => {
switch (r.op) {
case "RaggedGather":
{
let {
outputNestedSplits: n,
outputDenseValues: s
} = o.raggedGather(I("paramsNestedSplits", r, e, t10), I("paramsDenseValues", r, e, t10), I("indices", r, e, t10), I("outputRaggedRank", r, e, t10));
return n.concat(s);
}
case "RaggedRange":
{
let {
rtNestedSplits: n,
rtDenseValues: s
} = o.raggedRange(I("starts", r, e, t10), I("limits", r, e, t10), I("splits", r, e, t10));
return [n, s];
}
case "RaggedTensorToTensor":
return [o.raggedTensorToTensor(I("shape", r, e, t10), I("values", r, e, t10), I("defaultValue", r, e, t10), I("rowPartitionTensors", r, e, t10), I("rowPartitionTypes", r, e, t10))];
default:
throw TypeError(`Node type ${r.op} is not implemented`);
}
};
var CT = (r, e, t10, o = Ze) => {
switch (r.op) {
case "Max":
{
let i = I("axis", r, e, t10),
p = I("keepDims", r, e, t10);
return [o.max(I("x", r, e, t10), i, p)];
}
case "Mean":
{
let i = I("axis", r, e, t10),
p = I("keepDims", r, e, t10);
return [o.mean(I("x", r, e, t10), i, p)];
}
case "Min":
{
let i = I("axis", r, e, t10),
p = I("keepDims", r, e, t10);
return [o.min(I("x", r, e, t10), i, p)];
}
case "Sum":
{
let i = I("axis", r, e, t10),
p = I("keepDims", r, e, t10);
return [o.sum(I("x", r, e, t10), i, p)];
}
case "All":
{
let i = I("axis", r, e, t10),
p = I("keepDims", r, e, t10);
return [o.all(I("x", r, e, t10), i, p)];
}
case "Any":
{
let i = I("axis", r, e, t10),
p = I("keepDims", r, e, t10);
return [o.any(I("x", r, e, t10), i, p)];
}
case "ArgMax":
{
let i = I("axis", r, e, t10);
return [o.argMax(I("x", r, e, t10), i)];
}
case "ArgMin":
{
let i = I("axis", r, e, t10);
return [o.argMin(I("x", r, e, t10), i)];
}
case "Prod":
{
let i = I("axis", r, e, t10),
p = I("keepDims", r, e, t10);
return [o.prod(I("x", r, e, t10), i, p)];
}
case "Cumprod":
{
let i = I("axis", r, e, t10),
p = I("exclusive", r, e, t10),
u = I("reverse", r, e, t10);
return [o.cumprod(I("x", r, e, t10), i, p, u)];
}
case "Cumsum":
{
let i = I("axis", r, e, t10),
p = I("exclusive", r, e, t10),
u = I("reverse", r, e, t10);
return [o.cumsum(I("x", r, e, t10), i, p, u)];
}
case "Bincount":
let n = I("x", r, e, t10),
s = I("weights", r, e, t10),
a = I("size", r, e, t10);
return [o.bincount(n, s, a)];
case "DenseBincount":
{
let i = I("x", r, e, t10),
p = I("weights", r, e, t10),
u = I("size", r, e, t10),
c = I("binaryOutput", r, e, t10);
return [o.denseBincount(i, p, u, c)];
}
default:
throw TypeError(`Node type ${r.op} is not implemented`);
}
};
var wT = (r, e, t10, o = Ze) => {
switch (r.op) {
case "ConcatV2":
case "Concat":
{
let n = I("n", r, e, t10),
s = I("axis", r, e, t10),
a = I("tensors", r, e, t10);
return a = a.slice(0, n), [o.concat(a, s)];
}
case "Gather":
{
let n = I("x", r, e, t10),
s = I("indices", r, e, t10);
return [o.gather(n, o.cast(s, "int32"), 0)];
}
case "GatherV2":
{
let n = I("axis", r, e, t10),
s = I("batchDims", r, e, t10),
a = I("x", r, e, t10),
i = I("indices", r, e, t10);
return [o.gather(a, o.cast(i, "int32"), n, s)];
}
case "Reverse":
{
let n = I("dims", r, e, t10),
s = [];
for (let i = 0; i < n.length; i++) n[i] && s.push(i);
let a = I("x", r, e, t10);
return [o.reverse(a, s)];
}
case "ReverseV2":
{
let n = I("axis", r, e, t10),
s = I("x", r, e, t10);
return [o.reverse(s, n)];
}
case "Slice":
{
let n = I("begin", r, e, t10),
s = I("size", r, e, t10);
return [o.slice(I("x", r, e, t10), n, s)];
}
case "StridedSlice":
{
let n = I("begin", r, e, t10),
s = I("end", r, e, t10),
a = I("strides", r, e, t10),
i = I("beginMask", r, e, t10),
p = I("endMask", r, e, t10),
u = I("ellipsisMask", r, e, t10),
c = I("newAxisMask", r, e, t10),
l = I("shrinkAxisMask", r, e, t10),
m = I("x", r, e, t10);
return [o.stridedSlice(m, n, s, a, i, p, u, c, l)];
}
case "Pack":
return De(() => {
let n = I("axis", r, e, t10),
s = I("tensors", r, e, t10),
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 = I("axis", r, e, t10),
s = I("tensor", r, e, t10);
return o.unstack(s, n);
}
case "Tile":
{
let n = I("reps", r, e, t10);
return [o.tile(I("x", r, e, t10), n)];
}
case "Split":
case "SplitV":
{
let n = I("axis", r, e, t10),
s = I("numOrSizeSplits", r, e, t10),
a = I("x", r, e, t10);
return o.split(a, s, n);
}
case "ScatterNd":
{
let n = I("indices", r, e, t10),
s = I("values", r, e, t10),
a = I("shape", r, e, t10);
return [o.scatterND(n, s, a)];
}
case "GatherNd":
{
let n = I("x", r, e, t10),
s = I("indices", r, e, t10);
return [o.gatherND(n, s)];
}
case "SparseToDense":
{
let n = I("sparseIndices", r, e, t10),
s = I("outputShape", r, e, t10),
a = I("sparseValues", r, e, t10),
i = I("defaultValue", r, e, t10);
return [o.sparseToDense(n, a, s, a.dtype === i.dtype ? i : o.cast(i, a.dtype))];
}
case "TensorScatterUpdate":
{
let n = I("indices", r, e, t10),
s = I("values", r, e, t10),
a = I("tensor", r, e, t10);
return [o.tensorScatterUpdate(a, n, s)];
}
default:
throw TypeError(`Node type ${r.op} is not implemented`);
}
};
var ST = (r, e, t10, o = Ze) => {
switch (r.op) {
case "SparseFillEmptyRows":
{
let {
outputIndices: n,
outputValues: s,
emptyRowIndicator: a,
reverseIndexMap: i
} = o.sparse.sparseFillEmptyRows(I("indices", r, e, t10), I("values", r, e, t10), I("denseShape", r, e, t10), I("defaultValue", r, e, t10));
return [n, s, a, i];
}
case "SparseReshape":
{
let {
outputIndices: n,
outputShape: s
} = o.sparse.sparseReshape(I("inputIndices", r, e, t10), I("inputShape", r, e, t10), I("newShape", r, e, t10));
return [n, s];
}
case "SparseSegmentMean":
return [o.sparse.sparseSegmentMean(I("data", r, e, t10), I("indices", r, e, t10), I("segmentIds", r, e, t10))];
case "SparseSegmentSum":
return [o.sparse.sparseSegmentSum(I("data", r, e, t10), I("indices", r, e, t10), I("segmentIds", r, e, t10))];
default:
throw TypeError(`Node type ${r.op} is not implemented`);
}
};
var IT = (r, e, t10, o = Ze) => {
switch (r.op) {
case "FFT":
return [o.fft(I("x", r, e, t10))];
case "IFFT":
return [o.ifft(I("x", r, e, t10))];
case "RFFT":
return [o.rfft(I("x", r, e, t10))];
case "IRFFT":
return [o.irfft(I("x", r, e, t10))];
default:
throw TypeError(`Node type ${r.op} is not implemented`);
}
};
var vT = (r, e, t10, o = Ze) => {
switch (r.op) {
case "StaticRegexReplace":
return [o.string.staticRegexReplace(I("input", r, e, t10), I("pattern", r, e, t10), I("rewrite", r, e, t10), I("replaceGlobal", r, e, t10))];
case "StringNGrams":
{
let {
nGrams: n,
nGramsSplits: s
} = o.string.stringNGrams(I("data", r, e, t10), I("dataSplits", r, e, t10), I("separator", r, e, t10), I("nGramWidths", r, e, t10), I("leftPad", r, e, t10), I("rightPad", r, e, t10), I("padWidth", r, e, t10), I("preserveShortSequences", r, e, t10));
return [n, s];
}
case "StringSplit":
{
let {
indices: n,
values: s,
shape: a
} = o.string.stringSplit(I("input", r, e, t10), I("delimiter", r, e, t10), I("skipEmpty", r, e, t10));
return [n, s, a];
}
case "StringToHashBucketFast":
return [o.string.stringToHashBucketFast(I("input", r, e, t10), I("numBuckets", r, e, t10))];
default:
throw TypeError(`Node type ${r.op} is not implemented`);
}
};
var kT = (r, e, t10, o = Ze) => {
switch (r.op) {
case "Cast":
return [o.cast(I("x", r, e, t10), I("dtype", r, e, t10))];
case "ExpandDims":
{
let n = I("axis", r, e, t10);
return [o.expandDims(I("x", r, e, t10), n)];
}
case "Squeeze":
{
let n = I("axis", r, e, t10);
return [o.squeeze(I("x", r, e, t10), n)];
}
case "Reshape":
return [o.reshape(I("x", r, e, t10), I("shape", r, e, t10))];
case "EnsureShape":
return [o.ensureShape(I("x", r, e, t10), I("shape", r, e, t10))];
case "MirrorPad":
return [o.mirrorPad(I("x", r, e, t10), I("padding", r, e, t10), I("mode", r, e, t10))];
case "PadV2":
case "Pad":
return [o.pad(I("x", r, e, t10), I("padding", r, e, t10), I("constantValue", r, e, t10))];
case "SpaceToBatchND":
{
let n = I("blockShape", r, e, t10),
s = I("paddings", r, e, t10);
return [o.spaceToBatchND(I("x", r, e, t10), n, s)];
}
case "BatchToSpaceND":
{
let n = I("blockShape", r, e, t10),
s = I("crops", r, e, t10);
return [o.batchToSpaceND(I("x", r, e, t10), n, s)];
}
case "DepthToSpace":
{
let n = I("blockSize", r, e, t10),
s = I("dataFormat", r, e, t10).toUpperCase();
return [o.depthToSpace(I("x", r, e, t10), n, s)];
}
case "BroadcastTo":
return [o.broadcastTo(I("x", r, e, t10), I("shape", r, e, t10))];
case "BroadcastArgs":
return [o.broadcastArgs(I("s0", r, e, t10), I("s1", r, e, t10))];
default:
throw TypeError(`Node type ${r.op} is not implemented`);
}
};
function bS(r, e, t10, o, n = De) {
let s = ((a, i, p) => {
switch (a.category) {
case "arithmetic":
return n(() => eT(a, i, p));
case "basic_math":
return n(() => tT(a, i, p));
case "control":
return iT(a, i, p);
case "convolution":
return n(() => pT(a, i, p));
case "creation":
return n(() => cT(a, i, p));
case "dynamic":
return lT(a, i, p);
case "evaluation":
return n(() => mT(a, i, p));
case "image":
return n(() => hT(a, i, p));
case "graph":
return n(() => dT(a, i, p));
case "logical":
return n(() => gT(a, i, p));
case "matrices":
return n(() => xT(a, i, p));
case "normalization":
return n(() => yT(a, i, p));
case "ragged":
return n(() => bT(a, i, p));
case "reduction":
return n(() => CT(a, i, p));
case "slice_join":
return n(() => wT(a, i, p));
case "sparse":
return n(() => ST(a, i, p));
case "spectral":
return n(() => IT(a, i, p));
case "string":
return n(() => vT(a, i, p));
case "transformation":
return n(() => kT(a, i, p));
case "hash_table":
return fT(a, i, p, o);
case "custom":
let u = sf(a.op);
if (u && u.customExecutor) return u.customExecutor(new yf(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 y.isPromise(s) ? s.then(a => [].concat(a)) : [].concat(s);
}
var Pl = class {
constructor(e = {}, t10 = {}, o = {}, n = {}, s) {
this.weightMap = e, this.tensorArrayMap = t10, this.tensorListMap = o, this.functionMap = n, this.parseNodeNameCache = s, 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
};
}
set currentContext(e) {
this.contexts !== e && (this.contexts = e, this.generateCurrentContextIds());
}
get currentContext() {
return this.contexts;
}
get currentContextId() {
return this._currentContextIds[0];
}
get currentContextIds() {
return this._currentContextIds;
}
generateCurrentContextIds() {
let e = [];
for (let t10 = 0; t10 < this.contexts.length - 1; t10++) {
let o = this.contexts.slice(0, this.contexts.length - t10);
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("/") : "";
}
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)));
}
exitFrame() {
if (this.contexts && this.contexts.length > 1) this.contexts = this.contexts.slice(), this.contexts.splice(-1), this.currentContextIds.shift();else throw new Error("Cannot exit frame, the context is empty");
}
nextIteration() {
if (this.contexts && this.contexts.length > 0) {
this.contexts = this.contexts.slice(), this.lastId++;
let e = Object.assign({}, this.contexts[this.contexts.length - 1]);
e.iterationId += 1, e.id = this.lastId, this.contexts.splice(-1, 1, e), this._currentContextIds.splice(0, 1, this.contextIdforContexts(this.contexts));
} else throw new Error("Cannot increase frame iteration, the context is empty");
}
getWeight(e) {
return this.weightMap[e];
}
addTensorArray(e) {
this.tensorArrayMap[e.id] = e;
}
getTensorArray(e) {
return this.tensorArrayMap[e];
}
addTensorList(e) {
this.tensorListMap[e.id] = e;
}
getTensorList(e) {
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);
}
};
function CS(r, e, t10, o) {
let n = /* @__PURE__ */new Set(),
s = [],
a = null,
i = null,
p = /* @__PURE__ */new Set(),
u = new Set(Object.keys(r).map(m => Nr(m)[0]));
o = o || [];
let c = new Set(o.map(m => Nr(m.name)[0])),
l = [...e];
for (; l.length > 0;) {
let m = l.pop();
if ((cu(m) || L5(m) || B5(m)) && a == null && (a = m, i = a.children.map(d => d.name).filter(d => n.has(d))), n.add(m.name), t10[m.name] == null && !u.has(m.name) && !c.has(m.name)) {
if (m.inputs.length === 0) {
s.push(m.name);
continue;
}
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 NT(r, e) {
let {
usedNodes: t10,
inputs: o
} = e,
n = Object.keys(o).map(g => Nr(g)[0]).map(g => r.nodes[g]),
s = r.initNodes || [],
a = g => t10.has(typeof g == "string" ? g : g.name);
function i(g) {
return [...new Map(g.map(x => [x.name, x])).values()];
}
let p = i([...n, ...r.weights, ...s]).filter(a),
u = i([...p, ...Object.values(r.nodes)]).filter(a),
c = new Map(u.map(g => [g.name, g])),
l = {};
for (let g of u) {
l[g.name] = l[g.name] || 0;
for (let x of g.children) a(x) || (l[x.name] = Number.POSITIVE_INFINITY), l[x.name] = (l[x.name] || 0) + 1;
}
let m = Object.entries(l).filter(([, g]) => g === 0).map(([g]) => g),
d = [...m];
for (; m.length > 0;) {
let g = m.pop(),
x = c.get(g);
for (let b of x.children.filter(a)) --l[b.name] === 0 && (d.push(b.name), m.push(b.name));
}
let f = d.map(g => c.get(g)),
h = A5(f, p);
return F5(h, p), h;
}
function A5(r, e) {
let t10 = new Map(r.map(a => [a.name, a])),
o = e.map(a => a.name),
n = new Set(o);
for (; o.length > 0;) {
let a = o.pop(),
i = t10.get(a);
for (let p of i.children) !t10.has(p.name) || n.has(p.name) || (n.add(p.name), o.push(p.name));
}
return r.filter(a => n.has(a.name));
}
var hc = class extends Error {
constructor(e) {
super(`NodesExecutionOrderError: ${e}`);
}
};
function F5(r, e) {
let t10 = new Map(r.map((i, p) => [i.name, p])),
o = new Set(e.map(i => i.name)),
n = i => o.has(typeof i == "string" ? i : i.name),
s = new Set(r.map(i => i.name)),
a = i => s.has(typeof i == "string" ? i : i.name);
for (let i of r) {
for (let p of i.children.filter(a)) {
if (!t10.has(p.name)) throw new hc(`Child ${p.name} of node ${i.name} is unreachable.`);
if (t10.get(i.name) > t10.get(p.name)) throw new hc(`Node ${i.name} is scheduled to run after its child ${p.name}.`);
}
if (!n(i)) for (let p of i.inputs) {
if (!t10.has(p.name)) throw new hc(`Input ${p.name} of node ${i.name} is unreachable.`);
if (t10.get(p.name) > t10.get(i.name)) throw new hc(`Node ${i.name} is scheduled to run before its input ${p.name}.`);
}
}
}
function TT(r) {
let e = new Map(r.map((i, p) => [i.name, p])),
t10 = Number.MAX_SAFE_INTEGER,
o = r.map((i, p) => cu(i) ? t10 : p),
n = i => {
let p = o[e.get(i.name)];
return p == null ? -1 : p;
},
s = r.map((i, p) => i.children.map(n).reduce((u, c) => Math.max(u, c), o[p])),
a = /* @__PURE__ */new Map();
for (let i = 0; i < r.length; ++i) {
let p = s[i];
if (p === t10) continue;
let u = r[i],
c = r[p];
a.has(c.name) || a.set(c.name, []), a.get(c.name).push(u);
}
return a;
}
var P5 = /* @__PURE__ */new Set(["Switch", "Merge", "Enter", "Exit", "NextIteration", "StatelessIf", "StatelessWhile", "if", "While"]);
var O5 = /* @__PURE__ */new Set(["NonMaxSuppressionV2", "NonMaxSuppressionV3", "NonMaxSuppressionV5", "Where"]);
var M5 = /* @__PURE__ */new Set(["HashTable", "HashTableV2", "LookupTableImport", "LookupTableImportV2", "LookupTableFind", "LookupTableFindV2", "LookupTableSize", "LookupTableSizeV2"]);
function cu(r) {
return P5.has(r.op);
}
function L5(r) {
return O5.has(r.op);
}
function B5(r) {
return M5.has(r.op);
}
var op = class {
get weightIds() {
return this.parent ? this.parent.weightIds : this._weightIds;
}
get functionExecutorMap() {
return this.parent ? this.parent.functionExecutorMap : this._functionExecutorMap;
}
get weightMap() {
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;
}
set resourceManager(e) {
this._resourceManager = e;
}
get inputs() {
return this._inputs.map(e => ({
name: e.name,
shape: e.attrParams.shape ? e.attrParams.shape.value : void 0,
dtype: e.attrParams.dtype ? e.attrParams.dtype.value : void 0
}));
}
get outputs() {
return this._outputs.map(e => ({
name: e.name,
shape: e.attrParams.shape ? e.attrParams.shape.value : void 0,
dtype: e.attrParams.dtype ? e.attrParams.dtype.value : void 0
}));
}
get inputNodes() {
return this._inputs.map(e => e.signatureKey || e.name);
}
get outputNodes() {
return this._outputs.map(e => {
let t10 = e.signatureKey || e.name;
return e.defaultOutput ? `${t10}:${e.defaultOutput}` : t10;
});
}
get functions() {
return Object.keys(this._functions).reduce((e, t10) => (e[t10] = this._functions[t10].signature, e), {});
}
constructor(e, t10) {
this.graph = e, this.parent = t10, this.compiledMap = /* @__PURE__ */new Map(), this.parseNodeNameCache = /* @__PURE__ */new Map(), this._weightMap = {}, this.SEPARATOR = ",", 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 op(e.functions[o], this);
});
}
getCompilationKey(e, t10) {
let o = e.map(s => s.name).sort(),
n = t10.map(s => s.name).sort();
return o.join(this.SEPARATOR) + "--" + n.join(this.SEPARATOR);
}
compile(e, t10) {
let o = CS(e, t10, 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 u = t10.map(l => l.name),
c = Object.keys(e);
throw new Error(`Cannot compute the outputs [${u}] from the provided inputs [${c}]. Missing the following inputs: [${n}]`);
}
let i = NT(this.graph, o),
p = TT(i);
return {
orderedNodes: i,
nodeLiveUntilMap: p
};
}
cloneAndKeepTensor(e) {
if (e == null) return null;
let t10 = e.clone();
return Er(t10), t10;
}
cloneTensorList(e) {
return e ? e.map(o => this.cloneAndKeepTensor(o)) : null;
}
cloneTensorMap(e) {
return Object.fromEntries(Object.entries(e).map(([t10, o]) => [t10, this.cloneTensorList(o)]));
}
execute(e, t10) {
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(m => this.graph.nodes[Nr(m)[0]]),
s = t10.map(m => Nr(m)[0]),
a = new Set(s),
i = s.map(m => this.graph.nodes[m]);
i.length === 0 && (i = this._outputs);
let p = this.getCompilationKey(n, i),
u = this.compiledMap.get(p);
u == null && (u = this.compile(e, i), this.compiledMap.set(p, u));
try {
this.keepIntermediateTensors = P().getBool("KEEP_INTERMEDIATE_TENSORS");
} catch (m) {
this.keepIntermediateTensors = false, console.warn(m.message);
}
let c = {},
l = {};
return De(() => {
let m = new Pl(this.weightMap, c, l, this.functionExecutorMap, this.parseNodeNameCache),
d = Object.assign({}, this.weightMap);
this.keepIntermediateTensors && (this.clonedTensorsMap = this.cloneTensorMap(this.weightMap)), Object.keys(e).forEach(x => {
let [b, w] = Nr(x, m),
S = [];
S[w] = e[x], d[b] = S, this.keepIntermediateTensors && (this.clonedTensorsMap[b] = this.cloneTensorList(S));
});
let f = this.getFrozenTensorIds(d),
{
orderedNodes: h,
nodeLiveUntilMap: g
} = u;
for (let x of h) {
if (d[x.name]) continue;
let b = bS(x, d, m, this._resourceManager);
if (y.isPromise(b)) throw new Error(`The execution of the op '${x.op}' returned a promise. Please use model.executeAsync() instead.`);
d[x.name] = b, this.keepIntermediateTensors && (this.clonedTensorsMap[x.name] = this.cloneTensorList(b)), this.checkTensorForDisposalWithNodeLiveUntilInfo(x, d, m, f, a, g.get(x.name));
}
return this.parent == null && m.dispose(f), t10.map(x => Bt(x, d, m));
});
}
getFrozenTensorIds(e) {
let t10 = [].concat.apply([], Object.keys(e).map(o => e[o]).map(o => o.map(n => n.id)));
return new Set(t10);
}
checkTensorForDisposal(e, t10, o, n, s, a, i) {
if (!(cu(t10) || a.has(e))) {
for (let p of o[e]) p != null && (i[p.id] = (i[p.id] || 0) + t10.children.length);
for (let p of t10.inputs) {
if (cu(p)) continue;
let u = Qw(p.name, o, n);
if (u != null) for (let c of u) {
if (!c || c.kept || s.has(c.id)) continue;
let l = i[c.id];
l === 1 ? (c.dispose(), delete i[c.id]) : l != null && i[c.id]--;
}
}
}
}
checkTensorForDisposalWithNodeLiveUntilInfo(e, t10, o, n, s, a) {
function i(p) {
return cu(p) || s.has(p.name);
}
if (!(cu(e) || a == null)) for (let p of a) {
if (i(p)) continue;
let u = Qw(p.name, t10, o);
for (let c of u) !c || c.kept || n.has(c.id) || c.dispose();
}
}
async executeAsync(e, t10) {
return this._executeAsync(e, t10);
}
disposeIntermediateTensors() {
this.clonedTensorsMap && (Object.values(this.clonedTensorsMap).forEach(e => {
for (let t10 of e) t10 && !t10.isDisposed && t10.dispose();
}), this.clonedTensorsMap = null);
}
getIntermediateTensors() {
return this.clonedTensorsMap;
}
async _executeAsync(e, t10, o = false, n = {}, s = {}) {
this.disposeIntermediateTensors(), o || (e = this.mapInputs(e), this.checkInputs(e), this.checkInputShapeAndType(e), t10 = this.mapOutputs(t10), this.checkOutputs(t10));
try {
this.keepIntermediateTensors = P().getBool("KEEP_INTERMEDIATE_TENSORS");
} catch (m) {
this.keepIntermediateTensors = false, console.warn(m.message);
}
let a = new Pl(this.weightMap, n, s, this.functionExecutorMap, this.parseNodeNameCache);
this.keepIntermediateTensors && (this.clonedTensorsMap = this.cloneTensorMap(this.weightMap));
let i = await this.executeWithControlFlow(e, a, t10, o),
p = t10.map(m => Bt(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) {
let n = e.reduce((s, a, i) => (s[this.inputs[i].name] = a, s), {});
return this._executeAsync(n, this.outputNodes, true, t10, o);
}
async executeWithControlFlow(e, t10, o, n) {
let s = Object.keys(e),
a = s.map(S => this.graph.nodes[Nr(S)[0]]),
i = o.map(S => Nr(S)[0]),
p = new Set(i),
u = i.map(S => this.graph.nodes[S]);
u.length === 0 && (u = this._outputs);
let {
usedNodes: c,
missingInputs: l,
dynamicNode: m,
syncInputs: d
} = CS(e, u, this.weightMap, this._initNodes),
f = [...a, ...this.graph.weights, ...(this._initNodes || [])].map(S => ({
node: S,
contexts: t10.currentContext
})),
h = Object.assign({}, this.weightMap);
Object.keys(e).forEach(S => {
let [k, _] = Nr(S),
E = [];
E[_] = e[S], h[k] = E;
});
let g = {},
x = this.getFrozenTensorIds(h),
b = {};
for (; f.length > 0;) {
let S = this.processStack(a, f, t10, h, b, x, p, g, c);
await Promise.all(S);
}
m == 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 w = u.filter(S => !cu(S) && !Bt(S.name, h, t10)).map(S => S.name);
if (w.length > 0) {
let S = "";
throw m != null && (S = `Alternatively, to avoid the dynamic ops, use model.execute() and specify the inputs [${d}]`), new Error(`Cannot compute the outputs [${w}] from the provided inputs [${s}]. Consider providing the following inputs: [${l}]. ${S}`);
}
return h;
}
processStack(e, t10, o, n, s, a, i, p, u) {
let c = [];
for (; t10.length > 0;) {
let l = t10.pop();
o.currentContext = l.contexts;
let m = "";
if (l.node.op === "Enter" && I("isConstant", l.node, n, o) && ([m] = Ds(l.node.name, o)), n[l.node.name] == null) {
let d = bS(l.node, n, o, this._resourceManager);
m || ([m] = Ds(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, t10, 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, t10, o, n, s, u));
} else this.processChildNodes(l.node, t10, o, n, s, u);
}
return c;
}
processChildNodes(e, t10, o, n, s, a) {
e.children.forEach(i => {
let [p] = Ds(i.name, o);
s[p] || !a.has(i.name) || (i.op === "Merge" ? i.inputNames.some(u => !!Bt(u, n, o)) && (s[p] = true, t10.push({
contexts: o.currentContext,
node: i
})) : i.inputNames.every(u => !!Bt(u, n, o)) && (s[p] = true, t10.push({
contexts: o.currentContext,
node: i
})));
});
}
dispose() {
Object.keys(this.weightMap).forEach(e => this.weightMap[e].forEach(t10 => t10.dispose()));
}
checkInputShapeAndType(e) {
Object.keys(e).forEach(t10 => {
let o = e[t10],
[n] = Nr(t10),
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);
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 && 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) {
var t10, o;
let n = {};
for (let s in e) {
let a = (o = (t10 = this._signature) === null || t10 === void 0 ? void 0 : t10.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] = Nr(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`);
}
mapOutputs(e) {
return e.map(t10 => {
var o, n;
let s = (n = (o = this._signature) === null || o === void 0 ? void 0 : o.outputs) === null || n === void 0 ? void 0 : n[t10];
return s != null ? s.name : t10;
}, {});
}
checkOutputs(e) {
e.forEach(t10 => {
let [o] = Nr(t10);
if (!this.graph.nodes[o]) throw new Error(`The output '${t10}' is not found in the graph`);
});
}
};
var Sf = class {
constructor(e = {}, t10 = {}) {
this.hashTableNameToHandle = e, this.hashTableMap = t10;
}
addHashTable(e, t10) {
this.hashTableNameToHandle[e] = t10.handle, this.hashTableMap[t10.id] = t10;
}
getHashTableHandleByName(e) {
return this.hashTableNameToHandle[e];
}
getHashTableById(e) {
return this.hashTableMap[e];
}
dispose() {
for (let e in this.hashTableMap) this.hashTableMap[e].clearAndClose(), delete this.hashTableMap[e];
for (let e in this.hashTableNameToHandle) this.hashTableNameToHandle[e].dispose(), delete this.hashTableNameToHandle[e];
}
};
var z5 = "?tfjs-format=file";
var V5 = "model.json";
var Ol = class {
get modelVersion() {
return this.version;
}
get inputNodes() {
return this.executor.inputNodes;
}
get outputNodes() {
return this.executor.outputNodes;
}
get inputs() {
return this.executor.inputs;
}
get outputs() {
return this.executor.outputs;
}
get weights() {
return this.executor.weightMap;
}
get metadata() {
return this.artifacts.userDefinedMetadata;
}
get modelSignature() {
return this.signature;
}
get modelStructuredOutputKeys() {
return this.structuredOutputKeys;
}
constructor(e, t10 = {}, o = pi) {
this.modelUrl = e, this.loadOptions = t10, this.version = "n/a", this.io = o, t10 == null && (this.loadOptions = {}), this.resourceManager = new Sf();
}
findIOHandler() {
let e = this.modelUrl;
if (e.load != null) this.handler = e;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];
}
}
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 y.isPromise(e) ? e.then(t10 => this.loadSync(t10)) : this.loadSync(e);
}
loadSync(e) {
this.artifacts = e;
let t10 = 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}`;
let n = this.io.decodeWeights(this.artifacts.weightData, this.artifacts.weightSpecs);
if (this.executor = new op(Fl.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 = Fl.Instance.transformGraph(e.modelInitializer);
this.initializer = new op(s), this.initializer.weightMap = this.executor.weightMap, this.initializer.resourceManager = this.resourceManager, this.initializerSignature = e.initializerSignature;
}
return true;
}
async save(e, t10) {
if (typeof e == "string") {
let o = this.io.getSaveHandlers(e);
if (o.length === 0) throw new Error(`Cannot find any save handlers for URL '${e}'`);
if (o.length > 1) throw new Error(`Found more than one (${o.length}) save handlers for URL '${e}'`);
e = o[0];
}
if (e.save == null) throw new Error("GraphModel.save() cannot proceed because the IOHandler provided does not have the `save` attribute defined.");
return e.save(this.artifacts);
}
addStructuredOutputNames(e) {
if (this.structuredOutputKeys) {
let t10 = e instanceof pt ? [e] : e,
o = {};
return t10.forEach((n, s) => o[this.structuredOutputKeys[s]] = n), o;
}
return e;
}
predict(e, t10) {
let o = this.execute(e, this.outputNodes);
return this.addStructuredOutputNames(o);
}
async predictAsync(e, t10) {
let o = await this.executeAsync(e, this.outputNodes);
return this.addStructuredOutputNames(o);
}
normalizeInputs(e) {
var t10;
if (!(e instanceof pt) && !Array.isArray(e)) {
let s = (t10 = this.signature) === null || t10 === void 0 ? void 0 : t10.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 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) {
return e = e || this.outputNodes, Array.isArray(e) ? e : [e];
}
executeInitializerGraph() {
return this.initializer == null ? [] : this.initializerSignature == null ? this.initializer.execute({}, []) : this.initializer.execute({}, Object.keys(this.initializerSignature.outputs));
}
async executeInitializerGraphAsync() {
return this.initializer == null ? [] : this.initializerSignature == null ? this.initializer.executeAsync({}, []) : this.initializer.executeAsync({}, Object.keys(this.initializerSignature.outputs));
}
setResourceIdToCapturedInput(e) {
if (this.resourceIdToCapturedInput = {}, this.initializerSignature) {
let t10 = this.initializerSignature.outputs,
o = Object.keys(t10);
for (let n = 0; n < o.length; n++) {
let s = o[n],
a = t10[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);
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);
return o.length > 1 ? o : o[0];
}
getIntermediateTensors() {
return this.executor.getIntermediateTensors();
}
disposeIntermediateTensors() {
this.executor.disposeIntermediateTensors();
}
convertTensorMapToTensorsMap(e) {
return Object.keys(e).reduce((t10, o) => (t10[o] = [e[o]], t10), {});
}
dispose() {
this.executor.dispose(), this.initializer && (this.initializer.dispose(), this.resourceIdToCapturedInput && Ot(this.resourceIdToCapturedInput)), this.resourceManager.dispose();
}
};
async function W5(r, e = {}, t10 = pi) {
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 = G5(r));
let o = new Ol(r, e, t10);
return await o.load(), o;
}
function U5(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;
if (r instanceof Array) {
let [o, n] = r;
if (!o) throw new Error("modelJSON must be the first element of the array");
if (!n || !(n instanceof ArrayBuffer)) throw new Error("An ArrayBuffer of weights must be the second element of the array");
if (!("modelTopology" in o)) throw new Error("Model JSON is missing 'modelTopology'");
if (!("weightsManifest" in o)) throw new Error("Model JSON is missing 'weightsManifest'");
let s = pi.getWeightSpecs(o.weightsManifest),
a = pi.getModelArtifactsForJSONSync(o, s, n);
e = pi.fromMemorySync(a);
} else if ("load" in r) e = r;else if ("modelTopology" in r && "weightSpecs" in r && "weightData" in r) e = pi.fromMemorySync(r);else throw new Error("Unknown model format");
let t10 = new Ol(e);
return t10.load(), t10;
}
function G5(r) {
return r.endsWith("/") || (r = r + "/"), `${r}${V5}${z5}`;
}
var H5 = "4.5.0";
function Y(r, e) {
Array.isArray(r) || (r = [r]), r.forEach(t10 => {
t10 != null && y.assert(t10.dtype !== "complex64", () => `${e} does not support complex64 tensors in the CPU backend.`);
});
}
var K5 = Wt.whereImpl;
var lu = class extends ro {
nextDataId() {
return lu.nextDataId++;
}
constructor() {
super(), this.blockSize = 48, this.firstUse = true, this.data = new Lo(this, ur());
}
write(e, t10, o) {
this.firstUse && (this.firstUse = false, P().get("IS_NODE") && C.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) {
let n;
if (t10 === "string" && o != null && o.length > 0 && y.isString(o[0])) {
let s = o.map(a => y.encodeString(a));
n = this.write(s, e, t10);
} else n = this.write(o, e, t10);
return {
dataId: n,
shape: e,
dtype: t10
};
}
refCount(e) {
return this.data.has(e) ? this.data.get(e).refCount : 0;
}
incRef(e) {
let t10 = this.data.get(e);
t10.refCount++;
}
decRef(e) {
if (this.data.has(e)) {
let t10 = this.data.get(e);
t10.refCount--;
}
}
move(e, t10, o, n, s) {
this.data.set(e, {
values: t10,
dtype: n,
refCount: s
});
}
numDataIds() {
return this.data.numDataIds();
}
async read(e) {
return this.readSync(e);
}
readSync(e) {
let {
dtype: t10,
complexTensorInfos: o
} = this.data.get(e);
if (t10 === "complex64") {
let n = this.readSync(o.real.dataId),
s = this.readSync(o.imag.dataId);
return C.mergeRealAndImagArrays(n, s);
}
return y.convertBackendValuesAndArrayBuffer(this.data.get(e).values, t10);
}
bufferSync(e) {
let t10 = this.readSync(e.dataId);
if (e.dtype === "string") try {
let o = t10.map(n => y.decodeString(n));
return me(e.shape, e.dtype, o);
} catch (o) {
throw new Error("Failed to decode encoded string bytes into utf-8");
}
return me(e.shape, e.dtype, t10);
}
makeOutput(e, t10, o) {
return ur().makeTensorFromTensorInfo(this.makeTensorInfo(t10, o, e), this);
}
disposeData(e, t10 = false) {
if (this.data.has(e)) {
if (this.data.get(e).refCount--, !t10 && 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);
}
return true;
}
disposeIntermediateTensorInfo(e) {
this.disposeData(e.dataId);
}
async time(e) {
let t10 = y.now();
return e(), {
kernelMs: y.now() - t10
};
}
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) {
Y([e], "where");
let t10 = this.readSync(e.dataId);
return K5(e.shape, t10);
}
dispose() {}
floatPrecision() {
return 32;
}
epsilon() {
return super.epsilon();
}
};
lu.nextDataId = 0;
var Sc = {};
He(Sc, {
addImpl: () => IS,
bincountImpl: () => yc,
bincountReduceImpl: () => If,
bitwiseAndImpl: () => vS,
castImpl: () => SS,
ceilImpl: () => kS,
concatImpl: () => np,
equalImpl: () => NS,
expImpl: () => _S,
expm1Impl: () => ES,
floorDivImpl: () => DS,
floorImpl: () => RS,
gatherNdImpl: () => vf,
gatherV2Impl: () => kf,
greaterEqualImpl: () => FS,
greaterImpl: () => AS,
lessEqualImpl: () => OS,
lessImpl: () => PS,
linSpaceImpl: () => Nf,
logImpl: () => MS,
maxImpl: () => Tf,
maximumImpl: () => LS,
minimumImpl: () => BS,
multiplyImpl: () => Ml,
negImpl: () => zS,
notEqualImpl: () => VS,
prodImpl: () => WS,
raggedGatherImpl: () => _f,
raggedRangeImpl: () => $f,
raggedTensorToTensorImpl: () => Ef,
rangeImpl: () => ap,
rsqrtImpl: () => US,
scatterImpl: () => Fs,
sigmoidImpl: () => n_,
simpleAbsImpl: () => wS,
sliceImpl: () => ip,
sparseFillEmptyRowsImpl: () => Rf,
sparseReshapeImpl: () => Df,
sparseSegmentReductionImpl: () => wc,
sqrtImpl: () => i_,
squaredDifferenceImpl: () => HS,
staticRegexReplaceImpl: () => KS,
stridedSliceImpl: () => Af,
stringNGramsImpl: () => up,
stringSplitImpl: () => pp,
stringToHashBucketFastImpl: () => cp,
subImpl: () => jS,
tileImpl: () => Ff,
topKImpl: () => Pf,
transposeImpl: () => bc,
uniqueImpl: () => lp
});
function wS(r) {
let e = new Float32Array(r.length);
for (let t10 = 0; t10 < r.length; ++t10) e[t10] = Math.abs(r[t10]);
return e;
}
var q5 = r => {
let {
x: e
} = r.inputs,
t10 = r.backend;
Y(e, "abs");
let o = new Float32Array(y.sizeFromShape(e.shape)),
n = t10.data.get(e.dataId).values;
return o = wS(n), t10.makeOutput(o, e.shape, e.dtype);
};
var _T = {
kernelName: Gs,
backendName: "cpu",
kernelFunc: q5
};
function ze(r) {
return (e, t10, o, n, s) => {
let a = C.assertAndGetBroadcastShape(e, t10),
i = a.length,
p = y.computeStrides(a),
u = y.sizeFromShape(a),
c = y.getTypedArrayFromDType(s, u),
l = e.length,
m = t10.length,
d = y.computeStrides(e),
f = y.computeStrides(t10),
h = C.getBroadcastDims(e, a),
g = C.getBroadcastDims(t10, a);
if (h.length + g.length === 0) for (let x = 0; x < c.length; ++x) c[x] = r(o[x % o.length], n[x % n.length]);else for (let x = 0; x < c.length; ++x) {
let b = y.indexToLoc(x, i, p),
w = b.slice(-l);
h.forEach(E => w[E] = 0);
let S = y.locToIndex(w, l, d),
k = b.slice(-m);
g.forEach(E => k[E] = 0);
let _ = y.locToIndex(k, m, f);
c[x] = r(o[S], n[_]);
}
return [c, a];
};
}
function Kt(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;
}
var $T = {
kernelName: Ti,
backendName: "cpu",
kernelFunc: Kt
};
function gc(r, e, t10 = "float32") {
if (t10 === "complex64") {
let n = gc(r, e, "float32"),
s = gc(r, e, "float32");
return Kt({
inputs: {
real: n,
imag: s
},
backend: r
});
}
let o = y.makeZerosTypedArray(y.sizeFromShape(e), t10);
return r.makeTensorInfo(e, t10, o);
}
function lr(r) {
let {
inputs: e,
backend: t10
} = r,
{
x: o
} = e;
return t10.incRef(o.dataId), {
dataId: o.dataId,
shape: o.shape,
dtype: o.dtype
};
}
var ET = {
kernelName: xo,
backendName: "cpu",
kernelFunc: lr
};
function To(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 RT = {
kernelName: zi,
backendName: "cpu",
kernelFunc: To
};
function SS(r, e, t10, o) {
if (o === "int32") {
let n = Int32Array.from(r);
return [e, "int32", n];
}
if (o === "bool") {
let n = y.toTypedArray([0], t10),
[s, a] = ze((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 _o(r) {
let {
inputs: e,
backend: t10,
attrs: o
} = r,
{
x: n
} = e,
{
dtype: s
} = o;
if (s === "complex64") {
if (n.dtype === "complex64") return lr({
inputs: {
x: n
},
backend: t10
});
let c = gc(t10, n.shape, n.dtype),
l = _o({
inputs: {
x: n
},
backend: t10,
attrs: {
dtype: "float32"
}
}),
m = Kt({
inputs: {
real: l,
imag: c
},
backend: t10
});
return t10.disposeIntermediateTensorInfo(c), t10.disposeIntermediateTensorInfo(l), m;
}
if (n.dtype === "complex64") {
let c = To({
inputs: {
input: n
},
backend: t10
}),
l = _o({
inputs: {
x: c
},
backend: t10,
attrs: {
dtype: s
}
});
return t10.disposeIntermediateTensorInfo(c), l;
}
if (!y.hasEncodingLoss(n.dtype, s)) {
let c = lr({
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] = SS(a, n.shape, n.dtype, s);
return t10.makeTensorInfo(i, p, u);
}
var DT = {
kernelName: ho,
backendName: "cpu",
kernelFunc: _o
};
function je(r, e, t10, o) {
return t10 == null ? ({
inputs: n,
backend: s
}) => {
let {
a,
b: i
} = n,
p = s;
Y([a, i], r);
let u = p.data.get(a.dataId).values,
c = p.data.get(i.dataId).values,
l = a.dtype === "string" ? C.fromUint8ToStringArray(u) : u,
m = a.dtype === "string" ? C.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 = _o({
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 = _o({
inputs: {
x: i
},
backend: p,
attrs: {
dtype: "complex64"
}
}),
g = p.data.get(h.dataId),
x = g.complexTensorInfos.real,
b = g.complexTensorInfos.imag,
w = p.data.get(x.dataId).values,
S = p.data.get(b.dataId).values,
[k, _, E] = t10(a.shape, i.shape, d, f, w, S),
R = p.makeTensorInfo(E, "float32", k),
D = p.makeTensorInfo(E, "float32", _),
F = Kt({
inputs: {
real: R,
imag: D
},
backend: p
});
return p.disposeIntermediateTensorInfo(u), p.disposeIntermediateTensorInfo(h), p.disposeIntermediateTensorInfo(R), p.disposeIntermediateTensorInfo(D), F;
} else {
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 xc(r) {
return (e, t10, o, n, s, a) => {
let i = C.assertAndGetBroadcastShape(e, t10),
p = y.sizeFromShape(i),
u = i.length,
c = y.computeStrides(i),
l = y.getTypedArrayFromDType("float32", p),
m = y.getTypedArrayFromDType("float32", p),
d = C.getBroadcastDims(e, i),
f = C.getBroadcastDims(t10, i),
h = C.mergeRealAndImagArrays(o, n),
g = C.mergeRealAndImagArrays(s, a),
x = e.length,
b = y.computeStrides(e),
w = t10.length,
S = y.computeStrides(t10);
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;
} else for (let k = 0; k < l.length; k++) {
let _ = y.indexToLoc(k, u, c),
E = _.slice(-x);
d.forEach(M => E[M] = 0);
let R = y.locToIndex(E, x, b),
D = _.slice(-w);
f.forEach(M => D[M] = 0);
let F = y.locToIndex(D, w, S),
O = r(h[R * 2], h[R * 2 + 1], g[F * 2], g[F * 2 + 1]);
l[k] = O.real, m[k] = O.imag;
}
return [l, m, i];
};
}
var IS = ze((r, e) => r + e);
var j5 = xc((r, e, t10, o) => ({
real: r + t10,
imag: e + o
}));
var _a = je(no, IS, j5);
var AT = {
kernelName: no,
backendName: "cpu",
kernelFunc: _a
};
function yc(r, e, t10, o, n) {
let s = y.sizeFromShape(o),
a = y.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 If(r, e, t10, o = false) {
let n = r.shape[0],
s = r.shape[1],
a = me([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;
}
var vS = ze((r, e) => r & e);
var X5 = je(ml, vS);
var FT = {
kernelName: ml,
backendName: "cpu",
kernelFunc: X5
};
function jt(r) {
return (e, t10, o) => {
let n = y.getArrayFromDType(t10, e.length);
for (let s = 0; s < e.length; ++s) n[s] = r(e[s], o);
return n;
};
}
function Ie(r, e, t10) {
let o = jt(e);
return Dr(r, o, t10);
}
function Dr(r, e, t10) {
return ({
inputs: o,
attrs: n,
backend: s
}) => {
let {
x: a
} = o;
Y(a, r);
let i = s,
p = i.data.get(a.dataId).values,
u;
if (a.dtype === "string") {
if (!Array.isArray(p)) throw new Error("String tensor's value was not an instance of Array");
u = C.fromUint8ToStringArray(p);
} else u = p;
let c = t10 || a.dtype,
l = e(u, c, n);
return i.makeTensorInfo(a.shape, c, l);
};
}
var kS = jt(r => Math.ceil(r));
var Y5 = Dr(Jo, kS);
var PT = {
kernelName: Jo,
backendName: "cpu",
kernelFunc: Y5
};
function np(r, e, t10, o) {
let n = y.getArrayFromDType(t10, y.sizeFromShape(e));
if (o && t10 !== "string") {
let s = 0;
r.forEach(a => {
let i = y.sizeFromShape(a.shape);
n.set(a.vals, s), s += i;
});
} else {
let s = 0;
r.forEach(a => {
let i = t10 === "string" ? C.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 NS = ze((r, e) => r === e ? 1 : 0);
var TS = je(hn, NS, null, "bool");
var OT = {
kernelName: hn,
backendName: "cpu",
kernelFunc: TS
};
var _S = jt(r => Math.exp(r));
var $S = Dr(gn, _S, "float32");
var MT = {
kernelName: gn,
backendName: "cpu",
kernelFunc: $S
};
var ES = jt(r => Math.expm1(r));
var Q5 = Dr(xn, ES);
var LT = {
kernelName: xn,
backendName: "cpu",
kernelFunc: Q5
};
var RS = jt(r => Math.floor(r));
var Z5 = Dr(bn, RS);
var BT = {
kernelName: bn,
backendName: "cpu",
kernelFunc: Z5
};
var DS = ze((r, e) => Math.floor(r / e));
var J5 = je(Cn, DS, null, "int32");
var zT = {
kernelName: Cn,
backendName: "cpu",
kernelFunc: J5
};
function vf(r, e, t10, o, n, s, a, i, p) {
let u = me([o, s], t10);
for (let c = 0; c < o; c++) {
let l = [],
m = 0;
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 d = 0; d < s; d++) u.values[c * s + d] = e.get(...e.indexToLoc(m * s + d));
}
return u;
}
function kf(r, e, t10) {
let o = me(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 AS = ze((r, e) => r > e ? 1 : 0);
var e8 = je(In, AS, null, "bool");
var VT = {
kernelName: In,
backendName: "cpu",
kernelFunc: e8
};
var FS = ze((r, e) => r >= e ? 1 : 0);
var t8 = je(vn, FS, null, "bool");
var WT = {
kernelName: vn,
backendName: "cpu",
kernelFunc: t8
};
var PS = ze((r, e) => r < e ? 1 : 0);
var r8 = je($n, PS, null, "bool");
var UT = {
kernelName: $n,
backendName: "cpu",
kernelFunc: r8
};
var OS = ze((r, e) => r <= e ? 1 : 0);
var o8 = je(En, OS, null, "bool");
var GT = {
kernelName: En,
backendName: "cpu",
kernelFunc: o8
};
function Nf(r, e, t10) {
let o = (e - r) / (t10 - 1),
n = y.makeZerosTypedArray(t10, "float32");
n[0] = r;
for (let s = 1; s < n.length; s++) n[s] = n[s - 1] + o;
return n;
}
var MS = jt(r => Math.log(r));
var n8 = Dr(Dn, MS);
var HT = {
kernelName: Dn,
backendName: "cpu",
kernelFunc: n8
};
function Tf(r, e, t10, o) {
let n = y.getTypedArrayFromDType(o, y.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 LS = ze((r, e) => Math.max(r, e));
var s8 = je(Bn, LS);
var KT = {
kernelName: Bn,
backendName: "cpu",
kernelFunc: s8
};
var BS = ze((r, e) => Math.min(r, e));
var a8 = je(Un, BS);
var qT = {
kernelName: Un,
backendName: "cpu",
kernelFunc: a8
};
var Ml = ze((r, e) => r * e);
var i8 = xc((r, e, t10, o) => ({
real: r * t10 - e * o,
imag: r * o + e * t10
}));
var sp = je(Kn, Ml, i8);
var jT = {
kernelName: Kn,
backendName: "cpu",
kernelFunc: sp
};
function zS(r, e, t10) {
let o = y.createScalarValue(-1, t10);
return Ml([], e, o, r, t10);
}
function u8(r) {
let {
inputs: e,
backend: t10
} = r,
{
x: o
} = e;
Y(o, "neg");
let n = t10.data.get(o.dataId).values,
[s, a] = zS(n, o.shape, o.dtype);
return t10.makeTensorInfo(a, o.dtype, s);
}
var XT = {
kernelName: oa,
backendName: "cpu",
kernelFunc: u8
};
var VS = ze((r, e) => r !== e ? 1 : 0);
var p8 = je(qn, VS, null, "bool");
var YT = {
kernelName: qn,
backendName: "cpu",
kernelFunc: p8
};
function bc(r, e, t10, o, n) {
let s = e.length,
a = y.sizeFromShape(e),
i = y.computeStrides(e),
p = y.computeStrides(n),
u = y.getTypedArrayFromDType(t10, y.sizeFromShape(n));
for (let c = 0; c < a; ++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 St(r) {
let {
inputs: e,
attrs: t10,
backend: o
} = r,
{
x: n
} = e,
{
perm: s
} = t10;
Y(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 = bc(p, n.shape, n.dtype, s, i);
return {
dataId: o.write(u, i, n.dtype),
shape: i,
dtype: n.dtype
};
}
var QT = {
kernelName: ao,
backendName: "cpu",
kernelFunc: St
};
function WS(r, e, t10, o) {
let [n, s] = C.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];
i[u] = l;
}
return {
outVals: i,
outShape: n,
outDtype: a
};
}
function c8(r) {
let {
inputs: e,
backend: t10,
attrs: o
} = r,
{
x: n
} = e,
{
axis: s,
keepDims: a
} = o;
Y(n, "prod");
let i = n.shape.length,
p = y.parseAxisParam(s, n.shape),
u = C.getAxesPermutation(p, i),
c = p,
l = n,
m = [];
u != null && (l = St({
inputs: {
x: n
},
backend: t10,
attrs: {
perm: u
}
}), m.push(l), c = C.getInnerMostAxes(c.length, i));
let d = t10.data.get(l.dataId).values,
{
outVals: f,
outShape: h,
outDtype: g
} = WS(l.shape, l.dtype, d, c),
x = h;
return a && (x = C.expandShapeToKeepDim(h, p)), m.forEach(b => t10.disposeIntermediateTensorInfo(b)), t10.makeTensorInfo(x, g, f);
}
var ZT = {
kernelName: es,
backendName: "cpu",
kernelFunc: c8
};
function l8(r, e, t10) {
r.forEach((o, n) => {
if (o < 0 || o >= t10) {
let s = y.indexToLoc(n, e.length, y.computeStrides(e)).join(",");
throw new Error(`indices[${s}] = ${o} is not in [0, ${t10})`);
}
});
}
function m8(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 d8(r, e, t10, o) {
let n = [],
s = 0,
a = e.length - 1 + t10.length,
i = new Array(a).fill(null).map(() => [0]);
m8(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 d = t10[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 = d[c], l = d[l];
}
l !== c && (n.push([c, l]), s += l - c);
}
return {
outSplits: i,
valueSlices: n,
numValues: s
};
}
function f8(r) {
let e = [];
for (let t10 = 0; t10 < r.length; ++t10) {
let o = r[t10].length,
n = y.getArrayFromDType("int32", o);
e.push(n), r[t10].forEach((s, a) => n[a] = s);
}
return e;
}
function JT(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 h8(r, e, t10, o, n, s) {
let a = JT(e, 2)[1],
i = JT(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 g8(r, e, t10, o, n) {
let s = e.slice();
s[0] = n;
let a = y.getArrayFromDType(t10, y.sizeFromShape(s)),
i = r.length,
p = i === 0 ? 0 : i / e[0];
return h8(r, e, o, p, a, s), [a, s];
}
function _f(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 (l8(s, a, p), o.length === 0) throw new Error("params.rank must be nonzero");
let u = o[0],
{
outSplits: c,
valueSlices: l,
numValues: m
} = d8(s, a, r, u),
d = f8(c),
f = g8(t10, o, n, l, m);
return [d, f[0], f[1]];
}
var e_ = 2147483647;
function $f(r, e, t10, o, n, s, a) {
if (e.length > 1) throw new Error("starts must be a scalar or vector");
if (n.length > 1) throw new Error("limits must be a scalar or vector");
if (a.length > 1) throw new Error("deltas must be a scalar or vector");
let i = e.length === 0,
p = n.length === 0,
u = a.length === 0,
c = [];
i || c.push(e[0]), p || c.push(n[0]), u || c.push(a[0]);
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 = y.getArrayFromDType("int32", l + 1);
m[0] = 0;
for (let g = 0; g < l; ++g) {
let x = i ? r[0] : r[g],
b = p ? o[0] : o[g],
w = u ? s[0] : s[g];
if (w === 0) throw new Error("Requires delta != 0");
let S;
if (w > 0 && b < x || w < 0 && b > x) S = 0;else if (S = Math.ceil(Math.abs((b - x) / w)), S > e_) throw new Error(`Requires ((limit - start) / delta) <= ${e_}`);
m[g + 1] = m[g] + S;
}
let d = m[l],
f = y.getArrayFromDType(t10, d),
h = 0;
for (let g = 0; g < l; ++g) {
let x = m[g + 1] - m[g],
b = i ? r[0] : r[g],
w = u ? s[0] : s[g];
for (let S = 0; S < x; ++S) f[h++] = b, b += w;
}
return [m, f];
}
var $o = C.RowPartitionType;
var Cc = 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 = C.getRowPartitionTypesHelper(c), this.raggedRank = C.getRaggedRank(this.rowPartitionTypes);
}
getRowPartitionTypeByDimension(e) {
return this.rowPartitionTypes[0] === $o.FIRST_DIM_SIZE ? this.rowPartitionTypes[e + 1] : this.rowPartitionTypes[e];
}
getRowPartitionTensor(e) {
return this.rowPartitionTypes[0] === $o.FIRST_DIM_SIZE ? this.rowPartitionValues[e + 1] : this.rowPartitionValues[e];
}
getMaxWidth(e) {
let t10 = this.getRowPartitionTensor(e - 1);
switch (this.getRowPartitionTypeByDimension(e - 1)) {
case $o.VALUE_ROWIDS:
return Cc.getMaxWidthValueRowID(t10);
case $o.ROW_SPLITS:
return Cc.getMaxWidthRowSplit(t10);
default:
throw new Error(`Cannot handle partition type ${$o[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 r_(e, o);
}
calculateOutputSize(e) {
let t10 = this.valuesShape,
o = this.defaultValueShape;
C.validateDefaultValueShape(o, t10);
let n = this.tensorShapeFromTensor(this.shape, this.shapeShape),
a = C.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 y.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 $o.VALUE_ROWIDS:
return this.calculateOutputIndexValueRowID(s, t10, o, n);
case $o.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: ${$o[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 $o.FIRST_DIM_SIZE:
return e[0];
case $o.VALUE_ROWIDS:
throw new Error("Cannot handle VALUE_ROWIDS in first dimension.");
case $o.ROW_SPLITS:
return this.rowPartitionValuesShapes[0][0] - 1;
default:
throw new Error(`Cannot handle type ${$o[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 = r_(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]);
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 = y.sizeFromShape(i),
u = t10.length,
c = this.defaultValue;
if (c.length !== p && c.length !== 1) {
let f = this.defaultValueShape;
De(() => {
let h = W(c, f);
c = ru(h, i).dataSync();
});
}
let l = 0,
m = 0,
d = 0;
for (let f = 0; f <= u; ++f) {
let h = f < u ? t10[f] : -1;
if (h === d) {
++d;
continue;
}
if (m < d) {
let g = s.subarray(l * p),
x = a.subarray(m * p),
b = (d - m) * p;
t_(x, g, b);
}
if (f >= u) {
let g = o.length;
h = Math.floor(g / p);
}
if (h > d) if (this.defaultValue.length === 1) a.subarray(d * p, h * p).fill(this.defaultValue[0]), d = h;else for (; h > d;) {
let g = a.slice(d * p);
t_(g, c, p), ++d;
}
h < 0 ? (l = f + 1, m = d) : (l = f, m = d, d = m + 1);
}
}
};
function t_(r, e, t10) {
for (let o = 0; o < t10; o++) r[o] = e[o];
}
function r_(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 Ef(r, e, t10, o, n, s, a, i, p, u) {
return new Cc(r, e, t10, o, n, s, a, i, p, u).compute();
}
function ap(r, e, t10, o) {
let n = r === e,
s = r < e && t10 < 0,
a = e < r && t10 > 1;
if (n || s || a) return y.makeZerosTypedArray(0, o);
let i = Math.abs(Math.ceil((e - r) / t10)),
p = y.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 US = jt(r => 1 / Math.sqrt(r));
var x8 = Dr(us, US);
var o_ = {
kernelName: us,
backendName: "cpu",
kernelFunc: x8
};
function Fs(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 me(t10, e.dtype);
let d = p instanceof tt ? p : me(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 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 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 d;
}
var n_ = jt(r => 1 / (1 + Math.exp(-r)));
var GS = Ie(hs, r => 1 / (1 + Math.exp(-r)));
var s_ = {
kernelName: hs,
backendName: "cpu",
kernelFunc: GS
};
function ip(r, e, t10, o, n) {
let s = ct.isSliceContinous(o, e, t10),
a = y.sizeFromShape(t10),
i = y.computeStrides(o);
if (s) {
let l = ct.computeFlatOffset(e, i);
return n === "string" ? r.slice(l, l + a) : r.subarray(l, l + a);
}
let p = n === "string" ? C.fromUint8ToStringArray(r) : r,
u = me(o, n, p),
c = me(t10, n);
for (let l = 0; l < c.size; ++l) {
let m = c.indexToLoc(l),
d = m.map((f, h) => f + e[h]);
c.set(u.get(...d), ...m);
}
return n === "string" ? C.fromStringArrayToUint8(c.values) : c.values;
}
function Eo(r) {
let {
inputs: e,
backend: t10,
attrs: o
} = r,
{
x: n
} = e,
{
begin: s,
size: a
} = o;
Y(n, "slice");
let [i, p] = ct.parseSliceParams(n, s, a);
ct.assertParamsValid(n, i, p);
let u = t10.data.get(n.dataId).values,
c = ip(u, i, p, n.shape, n.dtype);
return t10.makeTensorInfo(p, n.dtype, c);
}
var a_ = {
kernelName: pa,
backendName: "cpu",
kernelFunc: Eo
};
function Rf(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(C.getSparseFillEmptyRowsIndicesDenseShapeMismatch(i));
let g = y.getArrayFromDType(t10, 0),
x = y.getArrayFromDType(n, 0);
return [g, [0, l], x, u, c];
}
let m = true,
d = 0,
f = new Array(p).fill(0);
for (let g = 0; g < i; ++g) {
let x = r[g * l];
if (x < 0) throw new Error(C.getSparseFillEmptyRowsNegativeIndexErrorMessage(g, x));
if (x >= p) throw new Error(C.getSparseFillEmptyRowsOutOfRangeIndexErrorMessage(g, x, p));
++f[x], m = m && x >= d, d = x;
}
let h = true;
for (let g = 0; g < p; ++g) {
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,
x = o;
for (let b = 0; b < i; ++b) c[b] = b;
return [g, [i, l], x, u, c];
} else {
let g = f[p - 1],
x = y.getArrayFromDType(t10, g * l),
b = y.getArrayFromDType(n, g),
w = new Array(p).fill(0);
for (let S = 0; S < i; ++S) {
let k = r[S * l],
_ = w[k],
E = (k === 0 ? 0 : f[k - 1]) + _;
w[k]++;
for (let R = 0; R < l; ++R) x[E * l + R] = r[S * l + R];
b[E] = o[S], c[S] = E;
}
for (let S = 0; S < p; ++S) if (w[S] === 0) {
let _ = S === 0 ? 0 : f[S - 1];
x[_ * l + 0] = S;
for (let E = 1; E < l; ++E) x[_ * l + E] = 0;
b[_] = a;
}
return [x, [g, l], b, u, c];
}
}
function Df(r, e, t10, 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 x = n[g];
if (x === -1) {
if (c !== -1) throw new Error(C.getSparseReshapeMultipleNegativeOneOutputDimErrorMessage(c, g));
c = g, p.push(1);
} else {
if (x < 0) throw new Error(C.getSparseReshapeNegativeOutputDimErrorMessage(g, x));
u *= x, p.push(x);
}
}
if (c !== -1) {
if (u <= 0) throw new Error(C.getSparseReshapeEmptyTensorZeroOutputDimErrorMessage());
let g = Math.trunc(s / u);
if (u * g !== s) throw new Error(C.getSparseReshapeInputOutputMultipleErrorMessage(o, p));
p[c] = g;
}
if (y.sizeFromShape(p) !== s) throw new Error(C.getSparseReshapeInputOutputMismatchErrorMessage(o, p));
let m = o.length,
d = [];
if (m > 0) {
d[m - 1] = 1;
for (let g = m - 2; g >= 0; --g) d[g] = d[g + 1] * o[g + 1];
}
let f = [];
if (i > 0) {
f[i - 1] = 1;
for (let g = i - 2; g >= 0; --g) f[g] = f[g + 1] * p[g + 1];
}
let h = y.getArrayFromDType(t10, a * i);
for (let g = 0; g < a; ++g) {
let x = 0;
for (let b = 0; b < m; ++b) x += r[g * m + b] * d[b];
for (let b = 0; b < i; ++b) h[g * i + b] = Math.trunc(x / f[b]), x %= f[b];
}
return [h, [a, i], p];
}
function wc(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(C.getSparseSegmentReductionNegativeSegmentIdsErrorMessage());
let m = e.slice();
m[0] = l;
let d = m.reduce((w, S) => w * S, 1),
f = y.getArrayFromDType(t10, d);
if (i === 0) return l > 0 && f.fill(a), [f, m];
if (l <= 0) throw new Error(C.getSparseSegmentReductionNegativeSegmentIdsErrorMessage());
let h = 0,
g = 1,
x = 0,
b = n[h];
for (;;) {
let w = 0;
if (g < i) {
if (w = n[g], b === w) {
++g;
continue;
}
if (b >= w) throw new Error(C.getSparseSegmentReductionNonIncreasingSegmentIdsErrorMessage());
}
if (b < 0 || b >= l) throw new Error(C.getSparseSegmentReductionSegmentIdOutOfRangeErrorMessage(b, l));
b > x && f.fill(a, x * u, b * u);
for (let S = h; S < g; ++S) {
let k = o[S];
if (k < 0 || k >= p[0]) throw new Error(C.getSparseSegmentReductionIndicesOutOfRangeErrorMessage(S, o[S], p[0]));
for (let _ = 0; _ < u; _++) f[b * u + _] += r[k * u + _];
}
if (s) for (let S = 0; S < u; S++) f[b * u + S] /= g - h;
if (h = g, ++g, x = b + 1, b = w, g > i) break;
}
return x < l && f.fill(a, x * u, l * u), [f, m];
}
var i_ = jt(r => Math.sqrt(r));
var y8 = Ie(xs, r => Math.sqrt(r));
var u_ = {
kernelName: xs,
backendName: "cpu",
kernelFunc: y8
};
var HS = ze((r, e) => {
let t10 = r - e;
return t10 * t10;
});
var b8 = je(ws, HS);
var p_ = {
kernelName: ws,
backendName: "cpu",
kernelFunc: b8
};
var KS = jt((r, e) => {
let {
pattern: t10,
replaceGlobal: o,
rewrite: n
} = e;
return r.replace(new RegExp(t10, o ? "g" : ""), n);
});
var C8 = Dr(_u, KS);
var c_ = {
kernelName: _u,
backendName: "cpu",
kernelFunc: C8
};
function Af(r, e, t10, o) {
let n = me(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 qS = class {
constructor(e, t10, o, n, s, a) {
this.separator = y.encodeString(e), this.nGramWidths = t10, 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);
}
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),
d = 0;
d += u * this.leftPad.length;
for (let b = 0; b < l; ++b) 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(w => h[g++] = w);
for (let b = 0; b < u; ++b) x(this.leftPad), x(this.separator);
for (let b = 0; b < l - 1; ++b) x(e[m + b]), x(this.separator);
if (l > 0) {
x(e[m + l - 1]);
for (let b = 0; b < c; ++b) x(this.separator), x(this.rightPad);
} else {
for (let b = 0; b < c - 1; ++b) x(this.rightPad), x(this.separator);
x(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 = y.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],
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];
if (l === 0) continue;
let m = l + 2 * this.padWidth,
d = 1;
this.createNGrams(e, u, i, c, d, m);
}
}
return [i, a];
}
};
function up(r, e, t10, o, n, s, a, i) {
return new qS(t10, o, n, s, a, i).compute(r, e);
}
function w8(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 pp(r, e, t10) {
let o = r.length,
n = [],
s = 0,
a = 0,
i = new Array(o);
for (let m = 0; m < o; ++m) {
let d = n.length;
w8(r[m], e, t10, n);
let f = n.length - d;
i[m] = f, s += f, a = Math.max(a, f);
}
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 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 cp(r, e) {
let t10 = y.getArrayFromDType("int32", r.length);
for (let o = 0; o < r.length; ++o) t10[o] = y.fingerPrint64(r[o]).modulo(e).getLowBitsUnsigned();
return t10;
}
var jS = ze((r, e) => r - e);
var S8 = xc((r, e, t10, o) => ({
real: r - t10,
imag: e - o
}));
var Ll = je(Is, jS, S8);
var l_ = {
kernelName: Is,
backendName: "cpu",
kernelFunc: Ll
};
function Ff(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 = me(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 Bl = (r, e) => {
let t10 = e.value - r.value;
return t10 === 0 ? r.index - e.index : t10;
};
function m_(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)),
d = Math.min(o, Math.floor(e + (i - p) * c / i + l));
m_(r, e, m, d);
}
let n = r[e],
s = t10,
a = o;
for (y.swap(r, t10, e), Bl(r[o], n) > 0 && y.swap(r, t10, o); s < a;) {
for (y.swap(r, s, a), s++, a--; Bl(r[s], n) < 0;) s = s + 1;
for (; Bl(r[a], n) > 0;) a = a - 1;
}
Bl(r[t10], n) === 0 ? y.swap(r, t10, a) : (a = a + 1, y.swap(r, a, o)), a <= e && (t10 = a + 1), e <= a && (o = a - 1);
}
}
function Pf(r, e, t10, o, n) {
let s = e[e.length - 1],
[a, i] = [r.length / s, s],
p = y.getTypedArrayFromDType(t10, a * o),
u = y.getTypedArrayFromDType("int32", a * o);
for (let l = 0; l < a; l++) {
let m = l * i,
d = r.subarray(m, m + i),
f = new Array(d.length);
d.forEach((b, w) => f[w] = {
value: b,
index: w
}), o < f.length && (m_(f, o), f = f.slice(0, o)), n && f.sort(Bl);
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] = f[b].value, x[b] = f[b].index;
}
let c = e.slice();
return c[c.length - 1] = o, [me(c, t10, p), me(c, "int32", u)];
}
function lp(r, e, t10, o) {
let n = y.parseAxisParam(e, t10)[0],
s = [1, t10[0], 1];
for (let f = 0; f < n; f++) s[0] *= t10[f];
s[1] = t10[n];
for (let f = n + 1; f < t10.length; f++) s[2] *= t10[f];
let a = /* @__PURE__ */new Map(),
i = new Int32Array(t10[n]),
p = new tt(s, o, r),
u = [],
c = s[0] === 1 && s[2] === 1;
for (let f = 0; f < t10[n]; f++) {
let h;
if (c) h = r[f].toString();else {
let x = [];
for (let b = 0; b < s[0]; b++) for (let w = 0; w < s[2]; w++) x.push(p.get(b, f, w));
h = x.join(",");
}
let g = a.get(h);
if (g != null) i[f] = g;else {
let x = a.size;
a.set(h, x), i[f] = x, u.push(f);
}
}
let l = s.slice();
l[1] = a.size;
let m = new tt(l, o);
u.forEach((f, h) => {
for (let g = 0; g < s[0]; g++) for (let x = 0; x < s[2]; x++) m.set(p.get(g, f, x), g, h, x);
});
let d = t10.slice();
return d[n] = l[1], {
outputValues: m.values,
outputShape: d,
indices: i
};
}
var I8 = "4.5.0";
eu("cpu", () => new lu(), 1);
var XS = Ie(fn, r => r >= 0 ? r : Math.exp(r) - 1);
var d_ = {
kernelName: fn,
backendName: "cpu",
kernelFunc: XS
};
function YS(r) {
let {
inputs: e,
backend: t10,
attrs: o
} = r,
{
x: n
} = e,
{
alpha: s
} = o;
Y([n], "leakyRelu");
let a = y.sizeFromShape(n.shape),
i = t10.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);
}
var f_ = {
kernelName: _n,
backendName: "cpu",
kernelFunc: YS
};
var v8 = ze((r, e) => r < 0 ? e * r : r);
function QS(r) {
let {
inputs: e,
backend: t10
} = r,
{
x: o,
alpha: n
} = e;
Y([o, n], "prelu");
let s = t10.data.get(o.dataId).values,
a = t10.data.get(n.dataId).values,
[i, p] = v8(o.shape, n.shape, s, a, "float32");
return t10.makeTensorInfo(p, "float32", i);
}
var h_ = {
kernelName: Jn,
backendName: "cpu",
kernelFunc: QS
};
var ZS = Ie(rs, r => Math.max(0, r));
var g_ = {
kernelName: rs,
backendName: "cpu",
kernelFunc: ZS
};
var JS = Ie(ss, r => Math.min(Math.max(0, r), 6));
var x_ = {
kernelName: ss,
backendName: "cpu",
kernelFunc: JS
};
function mp(r, e, t10, o, n) {
if (t10 === "linear") return lr({
inputs: {
x: e
},
backend: r
});
if (t10 === "relu") return ZS({
inputs: {
x: e
},
backend: r
});
if (t10 === "elu") return XS({
inputs: {
x: e
},
backend: r
});
if (t10 === "relu6") return JS({
inputs: {
x: e
},
backend: r
});
if (t10 === "prelu") return QS({
inputs: {
x: e,
alpha: o
},
backend: r
});
if (t10 === "leakyrelu") return YS({
inputs: {
x: e
},
backend: r,
attrs: {
alpha: n
}
});
if (t10 === "sigmoid") return GS({
inputs: {
x: e
},
backend: r
});
throw new Error(`Activation ${t10} has not been implemented for the CPU backend.`);
}
function Ve(r) {
let {
inputs: e,
backend: t10,
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.`), t10.incRef(n.dataId);
let u = t10.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 y_ = {
kernelName: ia,
backendName: "cpu",
kernelFunc: Ve
};
function eI(r) {
let {
inputs: e,
backend: t10,
attrs: o
} = r,
{
a: n,
b: s
} = e,
{
transposeA: a,
transposeB: i
} = o;
Y([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],
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),
w = Sr.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 S = a ? [g, c, m] : [g, m, c],
k = i ? [x, d, l] : [x, l, d],
_ = Ve({
inputs: {
x: n
},
backend: t10,
attrs: {
shape: S
}
}),
E = Ve({
inputs: {
x: s
},
backend: t10,
attrs: {
shape: k
}
}),
R = a ? _.shape[1] : _.shape[2],
D = a ? _.shape[2] : _.shape[1],
F = i ? E.shape[1] : E.shape[2],
O = Math.max(g, x),
M = t10.data.get(_.dataId).values,
L = t10.data.get(E.dataId).values,
B = y.computeStrides(_.shape),
z = y.computeStrides(E.shape),
[U, j, H] = a ? [B[0], 1, B[1]] : [B[0], B[1], 1],
[X, J, re] = i ? [1, z[1], z[0]] : [z[1], 1, z[0]],
ne = D * F,
ee = me([O, D, F], _.dtype),
oe = ee.values,
ie = t10.blockSize;
for (let le = 0; le < O; le++) {
let ye = le % g,
_e = le % x;
for (let ve = 0; ve < D; ve += ie) {
let Fe = Math.min(ve + ie, D);
for (let Pe = 0; Pe < F; Pe += ie) {
let st = Math.min(Pe + ie, F);
for (let lt = 0; lt < R; lt += ie) {
let We = Math.min(lt + ie, R);
for (let mt = ve; mt < Fe; mt++) for (let it = Pe; it < st; it++) {
let ht = 0;
for (let gt = lt; gt < We; gt++) {
let Or = M[ye * U + mt * j + gt * H],
Mt = L[gt * X + it * J + _e * re];
ht += Or * Mt;
}
oe[le * ne + (mt * F + it)] += ht;
}
}
}
}
}
return t10.disposeIntermediateTensorInfo(_), t10.disposeIntermediateTensorInfo(E), t10.makeTensorInfo(w, ee.dtype, ee.values);
}
var b_ = {
kernelName: Qo,
backendName: "cpu",
kernelFunc: eI
};
function k8(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,
d,
f,
h = [];
m = eI({
inputs: {
a: n,
b: s
},
attrs: {
transposeA: p,
transposeB: u
},
backend: t10
}), a && (d = _a({
inputs: {
a: m,
b: a
},
backend: t10
}), h.push(m), m = d), c && (f = mp(t10, m, c, i, l), h.push(m), m = f);
for (let x of h) t10.disposeIntermediateTensorInfo(x);
return m;
}
var C_ = {
kernelName: bo,
backendName: "cpu",
kernelFunc: k8
};
var N8 = Ie(zo, r => Math.acos(r));
var w_ = {
kernelName: zo,
backendName: "cpu",
kernelFunc: N8
};
var T8 = Ie(Vo, r => Math.acosh(r));
var S_ = {
kernelName: Vo,
backendName: "cpu",
kernelFunc: T8
};
function _8(r) {
let {
inputs: e,
backend: t10
} = r,
o = e;
Y(e, "addN");
let n = o.map(i => t10.data.get(i.dataId).values),
s = me(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);
}
var I_ = {
kernelName: Wo,
backendName: "cpu",
kernelFunc: _8
};
function $8(r) {
let {
inputs: e,
backend: t10,
attrs: o
} = r,
{
x: n
} = e,
{
axis: s,
keepDims: a
} = o;
Y(n, "all");
let i = y.parseAxisParam(s, n.shape),
p = i,
u = C.getAxesPermutation(p, n.shape.length),
c = n;
u != null && (c = St({
inputs: {
x: n
},
backend: t10,
attrs: {
perm: u
}
}), p = C.getInnerMostAxes(p.length, n.shape.length)), C.assertAxesAreInnerMostDims("all", p, c.shape.length);
let [l, m] = C.computeOutAndReduceShapes(c.shape, p),
d = y.sizeFromShape(m),
f = y.makeZerosTypedArray(y.sizeFromShape(l), c.dtype),
h = t10.data.get(c.dataId).values;
for (let x = 0; x < f.length; ++x) {
let b = x * d,
w = h[b];
for (let S = 0; S < d; ++S) {
let k = h[b + S];
w = w && k;
}
f[x] = w;
}
u != null && t10.disposeIntermediateTensorInfo(c);
let g = t10.makeTensorInfo(l, c.dtype, f);
if (a) {
let x = C.expandShapeToKeepDim(l, i),
b = Ve({
inputs: {
x: g
},
backend: t10,
attrs: {
shape: x
}
});
return t10.disposeIntermediateTensorInfo(g), b;
}
return g;
}
var v_ = {
kernelName: Uo,
backendName: "cpu",
kernelFunc: $8
};
function E8(r) {
let {
inputs: e,
backend: t10,
attrs: o
} = r,
{
x: n
} = e,
{
axis: s,
keepDims: a
} = o;
Y(n, "any");
let i = y.parseAxisParam(s, n.shape),
p = i,
u = C.getAxesPermutation(p, n.shape.length),
c = n;
u != null && (c = St({
inputs: {
x: n
},
backend: t10,
attrs: {
perm: u
}
}), p = C.getInnerMostAxes(p.length, n.shape.length)), C.assertAxesAreInnerMostDims("any", p, c.shape.length);
let [l, m] = C.computeOutAndReduceShapes(c.shape, p),
d = y.sizeFromShape(m),
f = y.makeZerosTypedArray(y.sizeFromShape(l), c.dtype),
h = t10.data.get(c.dataId).values;
for (let x = 0; x < f.length; ++x) {
let b = x * d,
w = h[b];
for (let S = 0; S < d; ++S) {
let k = h[b + S];
w = w || k;
}
f[x] = w;
}
u != null && t10.disposeIntermediateTensorInfo(c);
let g = t10.makeTensorInfo(l, c.dtype, f);
if (a) {
let x = C.expandShapeToKeepDim(l, i),
b = Ve({
inputs: {
x: g
},
backend: t10,
attrs: {
shape: x
}
});
return t10.disposeIntermediateTensorInfo(g), b;
}
return g;
}
var k_ = {
kernelName: Go,
backendName: "cpu",
kernelFunc: E8
};
function R8(r) {
let {
inputs: e,
backend: t10,
attrs: o
} = r,
{
x: n
} = e,
{
axis: s
} = o;
Y(n, "argMax");
let a = y.parseAxisParam(s, n.shape),
i = C.getAxesPermutation(a, n.shape.length),
p = n,
u = [];
i != null && (p = St({
inputs: {
x: n
},
backend: t10,
attrs: {
perm: i
}
}), u.push(p), a = C.getInnerMostAxes(a.length, p.shape.length)), a = [a[0]], C.assertAxesAreInnerMostDims("argMax", a, p.shape.length);
let [c, l] = C.computeOutAndReduceShapes(p.shape, a),
m = y.sizeFromShape(c),
d = y.makeZerosTypedArray(m, "int32"),
f = y.sizeFromShape(l),
h = t10.data.get(p.dataId).values;
for (let g = 0; g < d.length; ++g) {
let x = g * f,
b = h[x],
w = 0;
for (let S = 0; S < f; ++S) {
let k = h[x + S];
k > b && (b = k, w = S);
}
d[g] = w;
}
return u.forEach(g => t10.disposeIntermediateTensorInfo(g)), t10.makeTensorInfo(c, "int32", d);
}
var N_ = {
kernelName: Hs,
backendName: "cpu",
kernelFunc: R8
};
function D8(r) {
let {
inputs: e,
backend: t10,
attrs: o
} = r,
{
x: n
} = e,
{
axis: s
} = o;
Y(n, "argMin");
let a = y.parseAxisParam(s, n.shape),
i = C.getAxesPermutation(a, n.shape.length),
p = n,
u = [];
i != null && (p = St({
inputs: {
x: n
},
backend: t10,
attrs: {
perm: i
}
}), u.push(p), a = C.getInnerMostAxes(a.length, p.shape.length)), a = [a[0]], C.assertAxesAreInnerMostDims("argMin", a, p.shape.length);
let [c, l] = C.computeOutAndReduceShapes(p.shape, a),
m = y.sizeFromShape(c),
d = y.makeZerosTypedArray(m, "int32"),
f = y.sizeFromShape(l),
h = t10.data.get(p.dataId).values;
for (let g = 0; g < d.length; ++g) {
let x = g * f,
b = h[x],
w = 0;
for (let S = 0; S < f; ++S) {
let k = h[x + S];
k < b && (b = k, w = S);
}
d[g] = w;
}
return u.forEach(g => t10.disposeIntermediateTensorInfo(g)), t10.makeTensorInfo(c, "int32", d);
}
var T_ = {
kernelName: Ks,
backendName: "cpu",
kernelFunc: D8
};
var A8 = Ie(Ho, r => Math.asin(r));
var __ = {
kernelName: Ho,
backendName: "cpu",
kernelFunc: A8
};
var F8 = Ie(Ko, r => Math.asinh(r));
var $_ = {
kernelName: Ko,
backendName: "cpu",
kernelFunc: F8
};
var P8 = Ie(qo, r => Math.atan(r));
var E_ = {
kernelName: qo,
backendName: "cpu",
kernelFunc: P8
};
var O8 = ze((r, e) => Math.atan2(r, e));
var M8 = je(Xo, O8);
var R_ = {
kernelName: Xo,
backendName: "cpu",
kernelFunc: M8
};
var L8 = Ie(jo, r => Math.atanh(r));
var D_ = {
kernelName: jo,
backendName: "cpu",
kernelFunc: L8
};
function Ic(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,
d = n.padInfo.left,
f = s === "max" ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY,
h = me(n.outShape, t10),
g = h.values,
x = n.outShape[1] * n.outShape[2] * n.outShape[3],
b = n.outShape[2] * n.outShape[3],
w = n.outShape[3];
for (let S = 0; S < n.batchSize; ++S) {
let k = S * x,
_ = S * o[0];
for (let E = 0; E < n.inChannels; ++E) for (let R = 0; R < n.outHeight; ++R) {
let D = R * a - m,
F = Math.max(0, D),
O = Math.min(n.inHeight, c + D),
M = k + R * b;
for (let L = 0; L < n.outWidth; ++L) {
let B = L * i - d,
z = Math.max(0, B),
U = Math.min(n.inWidth, l + B),
j = f,
H = 0,
X = 0;
for (let re = F; re < O; re += p) {
let ne = _ + re * o[1];
for (let ee = z; ee < U; ee += u) {
let oe = ne + ee * o[2],
ie = r[oe + E];
s === "max" && ie > j ? j = ie : s === "avg" && (H += ie, X++);
}
if (isNaN(j)) break;
}
let J = M + L * w + E;
g[J] = s === "avg" ? H / X : j;
}
}
}
return h;
}
function Of(r, e, t10, o, n = false, s = false) {
let a = me(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 = me(e, t10, r);
for (let g = 0; g < o.batchSize; ++g) for (let x = 0; x < o.inChannels; ++x) for (let b = 0; b < o.outHeight; ++b) {
let w = b * i - d,
S = w;
for (; S < 0;) S += u;
let k = Math.min(o.inHeight, l + w);
for (let _ = 0; _ < o.outWidth; ++_) {
let E = _ * p - f,
R = E;
for (; R < 0;) R += c;
let D = Math.min(o.inWidth, m + E),
F = Number.NEGATIVE_INFINITY,
O = -1;
for (let M = S; M < k; M += u) {
let L = M - w;
for (let B = R; B < D; B += c) {
let z = B - E,
U = h.get(g, M, B, x);
U > F && (F = U, n ? O = s ? ((g * o.inHeight + M) * o.inWidth + B) * o.inChannels + x : (M * o.inWidth + B) * o.inChannels + x : O = L * m + z);
}
}
a.set(O, g, b, _, x);
}
}
return a;
}
function Mf(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,
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,
w = me(n.outShape, t10),
S = w.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 D = 0; D < n.batchSize; ++D) {
let F = D * k,
O = D * o[0];
for (let M = 0; M < n.inChannels; ++M) for (let L = 0; L < n.outDepth; ++L) {
let B = L * a - h,
z = B;
for (; z < 0;) z += u;
let U = Math.min(n.inDepth, m + B),
j = F + L * _;
for (let H = 0; H < n.outHeight; ++H) {
let X = H * i - g,
J = X;
for (; J < 0;) J += c;
let re = Math.min(n.inHeight, d + X),
ne = j + H * E;
for (let ee = 0; ee < n.outWidth; ++ee) {
let oe = ee * p - x,
ie = oe;
for (; ie < 0;) ie += l;
let le = Math.min(n.inWidth, f + oe),
ye = ne + ee * R,
_e = b,
ve = 0,
Fe = 0;
for (let st = z; st < U; st += u) {
let lt = O + st * o[1];
for (let We = J; We < re; We += c) {
let mt = lt + We * o[2];
for (let it = ie; it < le; it += l) {
let ht = mt + it * o[3],
gt = r[ht + M];
if (s === "max" && gt > _e ? _e = gt : s === "avg" && (ve += gt, Fe++), isNaN(_e)) break;
}
if (isNaN(_e)) break;
}
if (isNaN(_e)) break;
}
let Pe = ye + M;
S[Pe] = s === "avg" ? ve / Math.max(Fe, 1) : _e;
}
}
}
}
return w;
}
function A_(r, e) {
let t10 = me(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 x = 0; x < e.outDepth; ++x) {
let b = x * o - m,
w = b;
for (; w < 0;) w += a;
let S = Math.min(e.inDepth, u + b);
for (let k = 0; k < e.outHeight; ++k) {
let _ = k * n - d,
E = _;
for (; E < 0;) E += i;
let R = Math.min(e.inHeight, c + _);
for (let D = 0; D < e.outWidth; ++D) {
let F = D * s - f,
O = F;
for (; O < 0;) O += p;
let M = Math.min(e.inWidth, l + F),
L = Number.NEGATIVE_INFINITY,
B = -1;
for (let z = w; z < S; z += a) {
let U = z - b;
for (let j = E; j < R; j += i) {
let H = j - _;
for (let X = O; X < M; X += p) {
let J = X - F,
re = r.get(h, z, j, X, g);
re >= L && (L = re, B = U * c * l + H * c + J);
}
}
}
t10.set(B, h, x, k, D, g);
}
}
}
return t10;
}
function B8(r) {
let {
inputs: e,
backend: t10,
attrs: o
} = r,
{
x: n
} = e;
Y(n, "avgPool");
let {
filterSize: s,
strides: a,
pad: i,
dimRoundingMode: p
} = o,
u = 1;
y.assert(C.eitherStridesOrDilationsAreOne(a, u), () => `Error in avgPool: Either strides or dilations must be 1. Got strides ${a} and dilations '${u}'`);
let c = C.computePool2DInfo(n.shape, s, a, u, i, p),
l;
if (c.filterWidth === 1 && c.filterHeight === 1 && y.arraysEqual(c.inShape, c.outShape)) l = lr({
inputs: {
x: n
},
backend: t10
});else {
let m = t10.data.get(n.dataId).values,
d = y.computeStrides(n.shape),
f = Ic(m, n.shape, n.dtype, d, c, "avg");
l = t10.makeTensorInfo(c.outShape, n.dtype, f.values);
}
return l;
}
var F_ = {
kernelName: Yo,
backendName: "cpu",
kernelFunc: B8
};
function z8(r) {
let {
inputs: e,
backend: t10,
attrs: o
} = r,
{
x: n
} = e,
{
filterSize: s,
strides: a,
pad: i,
dimRoundingMode: p,
dataFormat: u
} = o;
Y(n, "avgPool3d");
let c = C.computePool3DInfo(n.shape, s, a, 1, i, p, u),
l = t10.data.get(n.dataId).values,
m = Mf(l, n.shape, n.dtype, y.computeStrides(n.shape), c, "avg");
return t10.makeTensorInfo(m.shape, "float32", m.values);
}
var P_ = {
kernelName: qs,
backendName: "cpu",
kernelFunc: z8
};
function V8(r) {
let {
inputs: e,
backend: t10,
attrs: o
} = r,
{
dy: n,
input: s
} = e,
{
filterSize: a,
strides: i,
pad: p,
dimRoundingMode: u
} = o;
Y([n, s], "avgPool3DGrad");
let c = C.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,
w = c.dilationWidth,
S = c.effectiveFilterDepth,
k = c.effectiveFilterHeight,
_ = c.effectiveFilterWidth,
E = S - 1 - c.padInfo.front,
R = _ - 1 - c.padInfo.left,
D = k - 1 - c.padInfo.top,
F = me(s.shape, "float32"),
O = 1 / (f * h * g),
M = t10.bufferSync(n);
for (let L = 0; L < c.batchSize; ++L) for (let B = 0; B < c.inChannels; ++B) for (let z = 0; z < c.inDepth; ++z) for (let U = 0; U < c.inHeight; ++U) for (let j = 0; j < c.inWidth; ++j) {
let H = z - E,
X = U - D,
J = j - R,
re = 0;
for (let ne = 0; ne < S; ne += x) {
let ee = (H + ne) / l;
if (!(ee < 0 || ee >= c.outDepth || Math.floor(ee) !== ee)) for (let oe = 0; oe < k; oe += b) {
let ie = (X + oe) / m;
if (!(ie < 0 || ie >= c.outHeight || Math.floor(ie) !== ie)) for (let le = 0; le < _; le += w) {
let ye = (J + le) / d;
if (ye < 0 || ye >= c.outWidth || Math.floor(ye) !== ye) continue;
let _e = M.get(L, ee, ie, ye, B);
re += _e;
}
}
}
F.set(re * O, L, z, U, j, B);
}
return t10.makeTensorInfo(F.shape, F.dtype, F.values);
}
var O_ = {
kernelName: Ni,
backendName: "cpu",
kernelFunc: V8
};
function W8(r) {
let {
inputs: e,
backend: t10,
attrs: o
} = r,
{
dy: n,
input: s
} = e,
a = s;
Y([n, s], "avgPoolGrad");
let {
filterSize: i,
strides: p,
pad: u
} = o,
c = C.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,
w = b - 1 - c.padInfo.left,
S = x - 1 - c.padInfo.top,
k = me(a.shape, "float32"),
_ = 1 / (d * f),
E = t10.data.get(n.dataId).values,
R = me(n.shape, "float32", E);
for (let D = 0; D < c.batchSize; ++D) for (let F = 0; F < c.inChannels; ++F) for (let O = 0; O < c.inHeight; ++O) for (let M = 0; M < c.inWidth; ++M) {
let L = O - S,
B = M - w,
z = 0;
for (let U = 0; U < x; U += h) {
let j = (L + U) / l;
if (!(j < 0 || j >= c.outHeight || Math.floor(j) !== j)) for (let H = 0; H < b; H += g) {
let X = (B + H) / m;
if (X < 0 || X >= c.outWidth || Math.floor(X) !== X) continue;
let J = R.get(D, j, X, F);
z += J;
}
}
k.set(z * _, D, O, M, F);
}
return t10.makeTensorInfo(k.shape, k.dtype, k.values);
}
var M_ = {
kernelName: Gp,
backendName: "cpu",
kernelFunc: W8
};
function U8(r) {
let {
inputs: e,
backend: t10,
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."), Y([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,
d = s ? t10.data.get(s.dataId).values : new Float32Array([1]),
f = a ? t10.data.get(a.dataId).values : new Float32Array([0]),
h = new Float32Array(c.length),
g = f.length,
x = d.length,
b = m.length,
w = l.length,
S = 0,
k = 0,
_ = 0,
E = 0;
for (let R = 0; R < c.length; ++R) h[R] = f[S++] + (c[R] - l[k++]) * d[_++] / Math.sqrt(m[E++] + u), S >= g && (S = 0), k >= w && (k = 0), _ >= x && (_ = 0), E >= b && (E = 0);
return t10.makeTensorInfo(n.shape, n.dtype, h);
}
var L_ = {
kernelName: wn,
backendName: "cpu",
kernelFunc: U8
};
function G8(r) {
let {
inputs: e,
backend: t10,
attrs: o
} = r,
{
x: n
} = e,
{
blockShape: s,
crops: a
} = o;
Y([n], "batchToSpaceND");
let i = s.reduce((x, b) => x * b),
p = C.getReshaped(n.shape, s, i),
u = C.getPermuted(p.length, s.length),
c = C.getReshapedPermuted(n.shape, s, i),
l = C.getSliceBeginCoords(a, s.length),
m = C.getSliceSize(c, a, s.length),
d = Ve({
inputs: {
x: n
},
backend: t10,
attrs: {
shape: p
}
}),
f = St({
inputs: {
x: d
},
backend: t10,
attrs: {
perm: u
}
}),
h = Ve({
inputs: {
x: f
},
backend: t10,
attrs: {
shape: c
}
}),
g = Eo({
inputs: {
x: h
},
backend: t10,
attrs: {
begin: l,
size: m
}
});
return t10.disposeIntermediateTensorInfo(d), t10.disposeIntermediateTensorInfo(f), t10.disposeIntermediateTensorInfo(h), g;
}
var B_ = {
kernelName: js,
backendName: "cpu",
kernelFunc: G8
};
function H8(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 = yc(i, p, s.dtype, s.shape, a);
return t10.makeTensorInfo([a], s.dtype, u);
}
var z_ = {
kernelName: Zo,
backendName: "cpu",
kernelFunc: H8
};
function K8(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 = C.assertAndGetBroadcastShape(Array.from(s), Array.from(a));
return t10.makeTensorInfo([i.length], "int32", Int32Array.from(i));
}
var V_ = {
kernelName: Xs,
backendName: "cpu",
kernelFunc: K8
};
var q8 = Ie(go, (r, e) => {
let t10 = e;
return r > t10.clipValueMax ? t10.clipValueMax : r < t10.clipValueMin ? t10.clipValueMin : r;
});
var W_ = {
kernelName: go,
backendName: "cpu",
kernelFunc: q8
};
var j8 = r => {
let {
x: e
} = r.inputs,
t10 = r.backend,
o = new Float32Array(y.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;
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");
};
var U_ = {
kernelName: _i,
backendName: "cpu",
kernelFunc: j8
};
function $a(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 G_ = {
kernelName: Mi,
backendName: "cpu",
kernelFunc: $a
};
function mu(r) {
let {
inputs: e,
backend: t10,
attrs: o
} = r,
{
axis: n
} = o,
s = y.parseAxisParam(n, e[0].shape)[0],
a = e.map(h => h.shape);
C.assertParamsConsistent(a, s);
let i = C.computeOutShape(e.map(h => h.shape), s);
if (y.sizeFromShape(i) === 0) return t10.makeTensorInfo(i, e[0].dtype, []);
let p = e.filter(h => y.sizeFromShape(h.shape) > 0);
if (p.length === 1) return lr({
inputs: {
x: p[0]
},
backend: t10
});
if (p[0].dtype === "complex64") {
let h = p.map(S => To({
inputs: {
input: S
},
backend: t10
})),
g = p.map(S => $a({
inputs: {
input: S
},
backend: t10
})),
x = mu({
inputs: h,
backend: t10,
attrs: {
axis: s
}
}),
b = mu({
inputs: g,
backend: t10,
attrs: {
axis: s
}
}),
w = Kt({
inputs: {
real: x,
imag: b
},
backend: t10
});
return h.forEach(S => t10.disposeIntermediateTensorInfo(S)), g.forEach(S => t10.disposeIntermediateTensorInfo(S)), t10.disposeIntermediateTensorInfo(x), t10.disposeIntermediateTensorInfo(b), w;
}
let u = p.map(h => {
let x = [-1, y.sizeFromShape(h.shape.slice(s))];
return Ve({
inputs: {
x: h
},
backend: t10,
attrs: {
shape: x
}
});
}),
c = u.map(h => ({
vals: t10.data.get(h.dataId).values,
shape: h.shape
}));
i = C.computeOutShape(u.map(h => h.shape), 1);
let l = u[0].shape[0] === 1,
m = np(c, i, e[0].dtype, l),
d = C.computeOutShape(p.map(h => h.shape), s),
f = t10.makeTensorInfo(d, e[0].dtype, m);
return u.forEach(h => t10.disposeIntermediateTensorInfo(h)), f;
}
var H_ = {
kernelName: Ys,
backendName: "cpu",
kernelFunc: mu
};
function tI(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;
Y([n, s], "conv2d");
let l = C.convertConv2DDataFormat(p),
m = C.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,
w = m.dataFormat === "channelsLast",
S = new tt(m.outShape, n.dtype),
k = y.computeStrides(n.shape),
_ = y.computeStrides(s.shape),
E = k[0],
R = w ? k[1] : k[2],
D = w ? k[2] : 1,
F = w ? 1 : k[1],
O = S.strides[0],
M = w ? S.strides[1] : S.strides[2],
L = w ? S.strides[2] : 1,
B = w ? 1 : S.strides[1],
z = t10.data.get(n.dataId).values,
U = t10.data.get(s.dataId).values,
j = S.values;
for (let H = 0; H < m.batchSize; ++H) {
let X = H * E,
J = H * O;
for (let re = 0; re < m.outHeight; ++re) {
let ne = J + re * M,
ee = re * m.strideHeight - b;
for (let oe = 0; oe < d; ++oe) {
let ie = ee + oe * h;
if (ie < 0 || ie >= m.inHeight) continue;
let le = oe * _[0],
ye = X + ie * R;
for (let _e = 0; _e < m.outWidth; ++_e) {
let ve = ne + _e * L,
Fe = _e * m.strideWidth - x;
for (let Pe = 0; Pe < f; ++Pe) {
let st = Fe + Pe * g;
if (st < 0 || st >= m.inWidth) continue;
let lt = le + Pe * _[1],
We = ye + st * D,
mt = lt;
for (let it = 0; it < m.inChannels; ++it) {
let ht = z[We + it * F];
for (let gt = 0; gt < m.outChannels; ++gt) j[ve + gt * B] += ht * U[mt + gt];
mt += m.outChannels;
}
}
}
}
}
}
return t10.makeTensorInfo(S.shape, S.dtype, j);
}
var K_ = {
kernelName: en,
backendName: "cpu",
kernelFunc: tI
};
function X8(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;
Y([n, s], "conv2dBackpropFilter");
let l = C.convertConv2DDataFormat(p),
m = C.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 tt(m.filterShape, "float32"),
w = m.padInfo.left,
S = m.padInfo.top,
k = t10.data.get(n.dataId).values,
_ = t10.data.get(s.dataId).values,
E = new tt(n.shape, n.dtype, k),
R = new tt(s.shape, s.dtype, _);
for (let D = 0; D < h; ++D) {
let F = Math.max(0, Math.ceil((S - D) / d)),
O = Math.min(m.outHeight, (m.inHeight + S - D) / d);
for (let M = 0; M < g; ++M) {
let L = Math.max(0, Math.ceil((w - M) / f)),
B = Math.min(m.outWidth, (m.inWidth + w - M) / f);
for (let z = 0; z < m.inChannels; ++z) for (let U = 0; U < m.outChannels; ++U) {
let j = 0;
for (let H = 0; H < m.batchSize; ++H) for (let X = F; X < O; ++X) {
let J = D + X * d - S;
for (let re = L; re < B; ++re) {
let ne = M + re * f - w;
x ? j += E.get(H, J, ne, z) * R.get(H, X, re, U) : j += E.get(H, z, J, ne) * R.get(H, U, X, re);
}
}
b.set(j, D, M, z, U);
}
}
}
return t10.makeTensorInfo(b.shape, b.dtype, b.values);
}
var q_ = {
kernelName: $i,
backendName: "cpu",
kernelFunc: X8
};
function Y8(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;
Y([n, s], "conv2dBackpropInput");
let l = y.computeStrides(s.shape),
m = y.computeStrides(n.shape),
d = C.convertConv2DDataFormat(u),
f = C.computeConv2DInfo(a, s.shape, i, 1, p, c, false, d),
h = new tt(f.inShape, "float32"),
g = h.values,
x = t10.data.get(n.dataId).values,
b = t10.data.get(s.dataId).values,
[w, S, k] = l,
{
batchSize: _,
filterHeight: E,
filterWidth: R,
inChannels: D,
inHeight: F,
inWidth: O,
outChannels: M,
outHeight: L,
outWidth: B,
strideHeight: z,
strideWidth: U
} = f;
d = f.dataFormat;
let j = E - 1 - f.padInfo.top,
H = R - 1 - f.padInfo.left,
X = d === "channelsLast",
J = h.strides[0],
re = X ? h.strides[1] : h.strides[2],
ne = X ? h.strides[2] : 1,
ee = X ? 1 : h.strides[1],
oe = m[0],
ie = X ? m[1] : m[2],
le = X ? m[2] : 1,
ye = X ? 1 : m[1];
for (let _e = 0; _e < _; ++_e) for (let ve = 0; ve < D; ++ve) for (let Fe = 0; Fe < F; ++Fe) {
let Pe = Fe - j,
st = Math.max(0, Math.ceil(Pe / z)),
lt = Math.min(L, (E + Pe) / z);
for (let We = 0; We < O; ++We) {
let mt = We - H,
it = Math.max(0, Math.ceil(mt / U)),
ht = Math.min(B, (R + mt) / U),
gt = 0;
for (let Mt = st; Mt < lt; ++Mt) {
let Qr = Mt * z - Pe;
for (let or = it; or < ht; ++or) {
let Tt = or * U - mt,
nr = oe * _e + ie * Mt + le * or,
sr = w * (E - 1 - Qr) + S * (R - 1 - Tt) + k * ve;
for (let Zr = 0; Zr < M; ++Zr) {
let Jr = x[nr + ye * Zr],
fr = b[sr + Zr];
gt += Jr * fr;
}
}
}
let Or = J * _e + re * Fe + ne * We + ee * ve;
g[Or] = gt;
}
}
return t10.makeTensorInfo(h.shape, h.dtype, h.values);
}
var j_ = {
kernelName: tn,
backendName: "cpu",
kernelFunc: Y8
};
function Q8(r) {
let {
inputs: e,
backend: t10,
attrs: o
} = r,
{
x: n,
filter: s
} = e,
{
strides: a,
pad: i,
dilations: p
} = o;
Y([n, s], "conv3d");
let u = C.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,
w = g.top,
S = new tt(u.outShape, n.dtype),
k = t10.data.get(n.dataId).values,
_ = t10.data.get(s.dataId).values,
E = S.values,
R = y.computeStrides(n.shape),
D = y.computeStrides(s.shape);
for (let F = 0; F < u.batchSize; ++F) {
let O = F * R[0],
M = F * S.strides[0];
for (let L = 0; L < u.outDepth; ++L) {
let B = M + L * S.strides[1],
z = L * u.strideDepth - x;
for (let U = 0; U < c; ++U) {
let j = z + U * d;
if (j < 0 || j >= u.inDepth) continue;
let H = U * D[0],
X = O + j * R[1];
for (let J = 0; J < u.outHeight; ++J) {
let re = B + J * S.strides[2],
ne = J * u.strideHeight - w;
for (let ee = 0; ee < l; ++ee) {
let oe = ne + ee * f;
if (oe < 0 || oe >= u.inHeight) continue;
let ie = H + ee * D[1],
le = X + oe * R[2];
for (let ye = 0; ye < u.outWidth; ++ye) {
let _e = re + ye * u.outChannels,
ve = ye * u.strideWidth - b;
for (let Fe = 0; Fe < m; ++Fe) {
let Pe = ve + Fe * h;
if (Pe < 0 || Pe >= u.inWidth) continue;
let st = ie + Fe * D[2],
lt = le + Pe * u.inChannels,
We = st;
for (let mt = 0; mt < u.inChannels; ++mt) {
let it = k[lt + mt];
for (let ht = 0; ht < u.outChannels; ++ht) E[_e + ht] += it * _[We + ht];
We += u.outChannels;
}
}
}
}
}
}
}
}
return t10.makeTensorInfo(S.shape, S.dtype, S.values);
}
var X_ = {
kernelName: rn,
backendName: "cpu",
kernelFunc: Q8
};
function Z8(r) {
let {
inputs: e,
backend: t10,
attrs: o
} = r,
{
x: n,
dy: s
} = e,
{
strides: a,
pad: i,
filterShape: p
} = o;
Y([n, s], "conv3dBackpropFilterV2");
let u = y.computeStrides(n.shape),
c = y.computeStrides(s.shape),
l = C.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 tt(l.filterShape, "float32"),
w = b.values,
[S, k, _, E] = b.strides,
R = t10.data.get(s.dataId).values,
[D, F, O, M] = c,
L = t10.data.get(n.dataId).values,
[B, z, U, j] = u,
H = l.padInfo.front,
X = l.padInfo.left,
J = l.padInfo.top;
for (let re = 0; re < h; ++re) {
let ne = Math.max(0, Math.ceil((H - re) / m)),
ee = Math.min(l.outDepth, (l.inDepth + H - re) / m),
oe = re * S;
for (let ie = 0; ie < g; ++ie) {
let le = Math.max(0, Math.ceil((J - ie) / d)),
ye = Math.min(l.outHeight, (l.inHeight + J - ie) / d),
_e = ie * k + oe;
for (let ve = 0; ve < x; ++ve) {
let Fe = Math.max(0, Math.ceil((X - ve) / f)),
Pe = Math.min(l.outWidth, (l.inWidth + X - ve) / f),
st = ve * _ + _e;
for (let lt = 0; lt < l.inChannels; ++lt) {
let We = lt * E + st;
for (let mt = 0; mt < l.outChannels; ++mt) {
let it = 0;
for (let ht = 0; ht < l.batchSize; ++ht) {
let gt = ht * B,
Or = ht * D;
for (let Mt = ne; Mt < ee; ++Mt) {
let or = (re + Mt * m - H) * z + gt,
Tt = Mt * F + Or;
for (let nr = le; nr < ye; ++nr) {
let Zr = (ie + nr * d - J) * U + or,
Jr = nr * O + Tt;
for (let fr = Fe; fr < Pe; ++fr) {
let Mo = (ve + fr * f - X) * j + Zr,
Vs = fr * M + Jr;
it += L[Mo + lt] * R[Vs + mt];
}
}
}
}
w[We + mt] = it;
}
}
}
}
}
return t10.makeTensorInfo(b.shape, b.dtype, b.values);
}
var Y_ = {
kernelName: za,
backendName: "cpu",
kernelFunc: Z8
};
function J8(r) {
let {
inputs: e,
backend: t10,
attrs: o
} = r,
{
dy: n,
filter: s
} = e,
{
pad: a,
strides: i,
inputShape: p
} = o;
Y([n], "conv3dBackpropInputV2");
let u = y.computeStrides(n.shape),
c = y.computeStrides(s.shape),
l = C.computeConv3DInfo(p, s.shape, i, 1, a),
m = new tt(l.inShape, "float32"),
d = m.values,
[f, h, g, x] = m.strides,
b = t10.data.get(n.dataId).values,
[w, S, k, _] = u,
E = t10.data.get(s.dataId).values,
[R, D, F, O] = c,
{
batchSize: M,
filterDepth: L,
filterHeight: B,
filterWidth: z,
inChannels: U,
inDepth: j,
inHeight: H,
inWidth: X,
outChannels: J,
outDepth: re,
outHeight: ne,
outWidth: ee,
strideDepth: oe,
strideHeight: ie,
strideWidth: le
} = l,
ye = L - 1 - l.padInfo.front,
_e = B - 1 - l.padInfo.top,
ve = z - 1 - l.padInfo.left;
for (let Fe = 0; Fe < M; ++Fe) for (let Pe = 0; Pe < U; ++Pe) for (let st = 0; st < j; ++st) {
let lt = st - ye,
We = Math.max(0, Math.ceil(lt / oe)),
mt = Math.min(re, (L + lt) / oe);
for (let it = 0; it < H; ++it) {
let ht = it - _e,
gt = Math.max(0, Math.ceil(ht / ie)),
Or = Math.min(ne, (B + ht) / ie);
for (let Mt = 0; Mt < X; ++Mt) {
let Qr = Mt - ve,
or = Math.max(0, Math.ceil(Qr / le)),
Tt = Math.min(ee, (z + Qr) / le),
nr = 0;
for (let sr = We; sr < mt; ++sr) {
let Zr = sr * oe - lt;
for (let Jr = gt; Jr < Or; ++Jr) {
let fr = Jr * ie - ht;
for (let Fa = or; Fa < Tt; ++Fa) {
let Mo = Fa * le - Qr,
Vs = w * Fe + S * sr + k * Jr + _ * Fa,
Xt = R * (L - 1 - Zr) + D * (B - 1 - fr) + F * (z - 1 - Mo) + O * Pe;
for (let Pa = 0; Pa < J; ++Pa) {
let el = b[Vs + Pa],
tl = E[Xt + Pa];
nr += el * tl;
}
}
}
}
d[f * Fe + h * st + g * it + x * Mt + Pe] = nr;
}
}
}
return t10.makeTensorInfo(m.shape, m.dtype, m.values);
}
var Q_ = {
kernelName: on,
backendName: "cpu",
kernelFunc: J8
};
var eY = Ie(nn, r => Math.cos(r));
var Z_ = {
kernelName: nn,
backendName: "cpu",
kernelFunc: eY
};
var tY = Ie(sn, r => Math.cosh(r));
var J_ = {
kernelName: sn,
backendName: "cpu",
kernelFunc: tY
};
function rY(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, d] = n.shape,
f = s.shape[0],
[h, g] = i,
x = me([f, h, g, d], "float32"),
b = t10.data.get(s.dataId).values,
w = t10.data.get(a.dataId).values,
S = t10.data.get(n.dataId).values,
k = y.computeStrides(n.shape),
_ = y.computeStrides(x.shape);
for (let E = 0; E < f; E++) {
let R = E * 4,
D = b[R],
F = b[R + 1],
O = b[R + 2],
M = b[R + 3],
L = w[E];
if (L >= c) continue;
let B = h > 1 ? (O - D) * (l - 1) / (h - 1) : 0,
z = g > 1 ? (M - F) * (m - 1) / (g - 1) : 0;
for (let U = 0; U < h; U++) {
let j = h > 1 ? D * (l - 1) + U * B : 0.5 * (D + O) * (l - 1);
if (j < 0 || j > l - 1) {
for (let H = 0; H < g; H++) for (let X = 0; X < d; X++) {
let J = X + H * _[2] + U * _[1] + E * _[0];
x.values[J] = u;
}
continue;
}
if (p === "bilinear") {
let H = Math.floor(j),
X = Math.ceil(j),
J = j - H;
for (let re = 0; re < g; re++) {
let ne = g > 1 ? F * (m - 1) + re * z : 0.5 * (F + M) * (m - 1);
if (ne < 0 || ne > m - 1) {
for (let le = 0; le < d; le++) {
let ye = le + re * _[2] + U * _[1] + E * _[0];
x.values[ye] = u;
}
continue;
}
let ee = Math.floor(ne),
oe = Math.ceil(ne),
ie = ne - ee;
for (let le = 0; le < d; le++) {
let ye = le + ee * k[2] + H * k[1] + L * k[0],
_e = S[ye];
ye = le + oe * k[2] + H * k[1] + L * k[0];
let ve = S[ye];
ye = le + ee * k[2] + X * k[1] + L * k[0];
let Fe = S[ye];
ye = le + oe * k[2] + X * k[1] + L * k[0];
let Pe = S[ye],
st = _e + (ve - _e) * ie,
lt = Fe + (Pe - Fe) * ie;
ye = le + re * _[2] + U * _[1] + E * _[0], x.values[ye] = st + (lt - st) * J;
}
}
} else for (let H = 0; H < g; ++H) {
let X = g > 1 ? F * (m - 1) + H * z : 0.5 * (F + M) * (m - 1);
if (X < 0 || X > m - 1) {
for (let ne = 0; ne < d; ne++) {
let ee = ne + H * _[2] + U * _[1] + E * _[0];
x.values[ee] = u;
}
continue;
}
let J = Math.round(X),
re = Math.round(j);
for (let ne = 0; ne < d; ne++) {
let ee = ne + J * k[2] + re * k[1] + L * k[0],
oe = ne + H * _[2] + U * _[1] + E * _[0];
x.values[oe] = S[ee];
}
}
}
}
return t10.makeTensorInfo(x.shape, x.dtype, x.values);
}
var e$ = {
kernelName: pn,
backendName: "cpu",
kernelFunc: rY
};
function oY(r) {
let {
inputs: e,
backend: t10,
attrs: o
} = r,
{
x: n
} = e,
{
axis: s,
exclusive: a,
reverse: i
} = o;
Y(n, "cumprod");
let p = C.getAxesPermutation([s], n.shape.length),
u = n;
p != null && (u = St({
inputs: {
x: n
},
backend: t10,
attrs: {
perm: p
}
}));
let c = C.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 = dt(u.dtype, "int32"),
m = y.makeOnesTypedArray(y.sizeFromShape(u.shape), l),
d = t10.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 w = h(x, b);
if (b === 0) m[w] = a ? 1 : d[w];else {
let S = h(x, b - 1);
m[w] = a ? d[S] * m[S] : d[w] * m[S];
}
}
let g = t10.makeTensorInfo(u.shape, l, m);
if (p != null) {
let x = C.getUndoAxesPermutation(p),
b = St({
inputs: {
x: g
},
backend: t10,
attrs: {
perm: x
}
});
return t10.disposeIntermediateTensorInfo(g), t10.disposeIntermediateTensorInfo(u), b;
}
return g;
}
var t$ = {
kernelName: an,
backendName: "cpu",
kernelFunc: oY
};
function nY(r) {
let {
inputs: e,
backend: t10,
attrs: o
} = r,
{
x: n
} = e,
{
axis: s,
exclusive: a,
reverse: i
} = o;
Y(n, "cumsum");
let p = C.getAxesPermutation([s], n.shape.length),
u = n;
p != null && (u = St({
inputs: {
x: n
},
backend: t10,
attrs: {
perm: p
}
}));
let c = C.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 = dt(u.dtype, "int32"),
m = y.makeZerosTypedArray(y.sizeFromShape(u.shape), l),
d = t10.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 w = h(x, b);
if (b === 0) m[w] = a ? 0 : d[w];else {
let S = h(x, b - 1);
m[w] = a ? d[S] + m[S] : d[w] + m[S];
}
}
let g = t10.makeTensorInfo(u.shape, l, m);
if (p != null) {
let x = C.getUndoAxesPermutation(p),
b = St({
inputs: {
x: g
},
backend: t10,
attrs: {
perm: x
}
});
return t10.disposeIntermediateTensorInfo(g), t10.disposeIntermediateTensorInfo(u), b;
}
return g;
}
var r$ = {
kernelName: un,
backendName: "cpu",
kernelFunc: nY
};
function sY(r) {
let {
inputs: e,
backend: t10,
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 = yc(p, u, s.dtype, s.shape, a);
return t10.makeTensorInfo([a], s.dtype, c);
} else if (n.shape.length === 2) {
let p = t10.bufferSync(n),
u = t10.bufferSync(s),
c = If(p, u, a, i);
return t10.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 o$ = {
kernelName: Qs,
backendName: "cpu",
kernelFunc: sY
};
function aY(r) {
let {
inputs: e,
backend: t10,
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 = t10.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 w = Math.floor(b / s),
S = b % s;
for (let k = 0; k < m; ++k) {
let _ = Math.floor(k / s),
E = k % s,
R = (S * s + E) * d;
for (let D = 0; D < d; ++D) {
let O = D + R + c * (_ + u * (w + p * x));
h[g++] = f[O];
}
}
}
return t10.makeTensorInfo([i, l, m, d], n.dtype, h);
}
var n$ = {
kernelName: cn,
backendName: "cpu",
kernelFunc: aY
};
function rI(r) {
let {
inputs: e,
backend: t10,
attrs: o
} = r,
{
x: n,
filter: s
} = e,
{
strides: a,
pad: i,
dilations: p,
dimRoundingMode: u
} = o;
Y([n, s], "depthwiseConv2DNative");
let c = y.computeStrides(n.shape),
l = y.computeStrides(s.shape),
m = p;
m == null && (m = [1, 1]), y.assert(C.eitherStridesOrDilationsAreOne(a, m), () => `Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${a} and dilations '${m}'`);
let d = C.computeConv2DInfo(n.shape, s.shape, a, m, i, u, true),
{
filterHeight: f,
filterWidth: h,
dilationHeight: g,
dilationWidth: x,
padInfo: b
} = d,
w = b.left,
S = b.top,
k = d.outChannels / d.inChannels,
_ = new tt(d.outShape, n.dtype),
E = t10.data.get(n.dataId).values,
R = t10.data.get(s.dataId).values,
D = _.values;
for (let F = 0; F < d.batchSize; ++F) {
let O = F * c[0],
M = F * _.strides[0];
for (let L = 0; L < d.outHeight; ++L) {
let B = M + L * _.strides[1],
z = L * d.strideHeight - S;
for (let U = 0; U < f; ++U) {
let j = z + U * g;
if (j < 0 || j >= d.inHeight) continue;
let H = U * l[0],
X = O + j * c[1];
for (let J = 0; J < d.outWidth; ++J) {
let re = B + J * _.strides[2],
ne = J * d.strideWidth - w;
for (let ee = 0; ee < h; ++ee) {
let oe = ne + ee * x;
if (oe < 0 || oe >= d.inWidth) continue;
let ie = H + ee * l[1],
le = X + oe * d.inChannels,
ye = re,
_e = ie;
for (let ve = 0; ve < d.inChannels; ++ve) {
let Fe = E[le + ve];
for (let Pe = 0; Pe < k; ++Pe) D[ye + Pe] += Fe * R[_e + Pe];
ye += k, _e += k;
}
}
}
}
}
}
return t10.makeTensorInfo(_.shape, _.dtype, _.values);
}
var s$ = {
kernelName: ln,
backendName: "cpu",
kernelFunc: rI
};
function iY(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;
Y([n, s], "depthwiseConv2dNativeBackpropFilter");
let l = C.computeConv2DInfo(n.shape, c, a, i, p, u, true),
{
strideHeight: m,
strideWidth: d,
filterHeight: f,
filterWidth: h
} = l,
g = new tt(l.filterShape, "float32"),
x = l.padInfo.left,
b = l.padInfo.top,
w = l.outChannels / l.inChannels,
S = t10.data.get(n.dataId).values,
k = new tt(n.shape, n.dtype, S),
_ = t10.data.get(s.dataId).values,
E = new tt(s.shape, s.dtype, _);
for (let R = 0; R < f; ++R) {
let D = Math.max(0, Math.ceil((b - R) / m)),
F = Math.min(l.outHeight, (l.inHeight + b - R) / m);
for (let O = 0; O < h; ++O) {
let M = Math.max(0, Math.ceil((x - O) / d)),
L = Math.min(l.outWidth, (l.inWidth + x - O) / d);
for (let B = 0; B < l.outChannels; ++B) {
let z = Math.trunc(B / w),
U = B % w,
j = 0;
for (let H = 0; H < l.batchSize; ++H) for (let X = D; X < F; ++X) {
let J = R + X * m - b;
for (let re = M; re < L; ++re) {
let ne = O + re * d - x;
j += k.get(H, J, ne, z) * E.get(H, X, re, B);
}
}
g.set(j, R, O, z, U);
}
}
}
return t10.makeTensorInfo(g.shape, g.dtype, g.values);
}
var a$ = {
kernelName: Ei,
backendName: "cpu",
kernelFunc: iY
};
function uY(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;
Y([n, s], "depthwiseConv2DNativeBackpropInput");
let l = y.computeStrides(n.shape),
m = y.computeStrides(s.shape),
d = C.computeConv2DInfo(c, s.shape, a, i, p, u, true),
f = new tt(d.inShape, "float32"),
h = f.values,
[g, x, b] = f.strides,
w = t10.data.get(n.dataId).values,
[S, k, _] = l,
E = t10.data.get(s.dataId).values,
[R, D, F] = m,
{
batchSize: O,
filterHeight: M,
filterWidth: L,
inChannels: B,
inHeight: z,
inWidth: U,
outChannels: j,
outHeight: H,
outWidth: X,
strideHeight: J,
strideWidth: re
} = d,
ne = M - 1 - d.padInfo.top,
ee = L - 1 - d.padInfo.left,
oe = j / B;
for (let ie = 0; ie < O; ++ie) for (let le = 0; le < B; ++le) for (let ye = 0; ye < z; ++ye) {
let _e = ye - ne,
ve = Math.max(0, Math.ceil(_e / J)),
Fe = Math.min(H, (M + _e) / J);
for (let Pe = 0; Pe < U; ++Pe) {
let st = Pe - ee,
lt = Math.max(0, Math.ceil(st / re)),
We = Math.min(X, (L + st) / re),
mt = 0;
for (let it = ve; it < Fe; ++it) {
let ht = it * J - _e;
for (let gt = lt; gt < We; ++gt) {
let Or = gt * re - st,
Mt = S * ie + k * it + _ * gt,
Qr = R * (M - 1 - ht) + D * (L - 1 - Or) + F * le;
for (let or = 0; or < oe; ++or) {
let Tt = le * oe + or,
nr = w[Mt + Tt],
sr = E[Qr + or];
mt += nr * sr;
}
}
}
h[g * ie + x * ye + b * Pe + le] = mt;
}
}
return t10.makeTensorInfo(f.shape, f.dtype, f.values);
}
var i$ = {
kernelName: Ri,
backendName: "cpu",
kernelFunc: uY
};
function pY(r) {
let {
inputs: e,
backend: t10
} = r,
{
x: o
} = e,
n = y.sizeFromShape(o.shape),
s = t10.data.get(o.dataId).values,
a = me([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);
}
var u$ = {
kernelName: Zs,
backendName: "cpu",
kernelFunc: pY
};
var p$ = {
kernelName: mn,
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: d,
inHeight: f,
inWidth: h,
inChannels: g,
outHeight: x,
outWidth: b,
padInfo: w,
strideHeight: S,
strideWidth: k,
filterHeight: _,
filterWidth: E,
dilationHeight: R,
dilationWidth: D,
outShape: F
} = C.computeDilation2DInfo(o.shape, n.shape, s, a, "NHWC", i),
O = y.sizeFromShape(F),
M = F.length,
L = y.getArrayFromDType(o.dtype, O);
for (let z = 0; z < d; ++z) for (let U = 0; U < x; ++U) {
let j = U * S - w.top;
for (let H = 0; H < b; ++H) {
let X = H * k - w.left;
for (let J = 0; J < g; ++J) {
let re = Number.MIN_SAFE_INTEGER;
for (let ee = 0; ee < _; ++ee) {
let oe = j + ee * R;
if (oe >= 0 && oe < f) for (let ie = 0; ie < E; ++ie) {
let le = X + ie * D;
if (le >= 0 && le < h) {
let ye = y.locToIndex([z, oe, le, J], c, y.computeStrides(o.shape)),
_e = y.locToIndex([ee, ie, J], m, y.computeStrides(n.shape)),
ve = u[ye] + l[_e];
ve > re && (re = ve);
}
}
}
let ne = y.locToIndex([z, U, H, J], M, y.computeStrides(F));
L[ne] = re;
}
}
}
return {
dataId: p.write(y.toTypedArray(L, o.dtype), F, o.dtype),
shape: F,
dtype: o.dtype
};
}
};
var c$ = {
kernelName: Ai,
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 = 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: w,
strideWidth: S,
filterHeight: k,
filterWidth: _,
dilationHeight: E,
dilationWidth: R,
outShape: D
} = C.computeDilation2DInfo(o.shape, n.shape, a, i, "NHWC", p);
y.assert(s.rank === D.length, () => `Error in ${Ai}, dy must have the same rank as output ${D.length}, but got ${s.rank}`);
let F = y.toNestedArray(D, u.data.get(s.dataId).values),
O = y.makeZerosNestedTypedArray(n.shape, n.dtype);
for (let L = 0; L < m; ++L) for (let B = 0; B < g; ++B) {
let z = B * w - b.top;
for (let U = 0; U < x; ++U) {
let j = U * S - b.left;
for (let H = 0; H < h; ++H) {
let X = Number.MIN_SAFE_INTEGER,
J = 0,
re = 0;
for (let ne = 0; ne < k; ++ne) {
let ee = z + ne * E;
if (ee >= 0 && ee < d) for (let oe = 0; oe < _; ++oe) {
let ie = j + oe * R;
if (ie >= 0 && ie < f) {
let le = c[L][ee][ie][H] + l[ne][oe][H];
le > X && (X = le, J = ne, re = oe);
}
}
}
O[J][re][H] += F[L][B][U][H];
}
}
}
return {
dataId: u.write(y.toTypedArray(O, o.dtype), n.shape, n.dtype),
shape: n.shape,
dtype: n.dtype
};
}
};
var l$ = {
kernelName: Di,
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 = 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: w,
strideWidth: S,
filterHeight: k,
filterWidth: _,
dilationHeight: E,
dilationWidth: R,
outShape: D
} = C.computeDilation2DInfo(o.shape, n.shape, a, i, "NHWC", p);
y.assert(s.rank === D.length, () => `Error in ${Di}, dy must have the same rank as output ${D.length}, but got ${s.rank}`);
let F = y.toNestedArray(D, u.data.get(s.dataId).values),
O = y.makeZerosNestedTypedArray(o.shape, o.dtype);
for (let L = 0; L < m; ++L) for (let B = 0; B < g; ++B) {
let z = B * w - b.top;
for (let U = 0; U < x; ++U) {
let j = U * S - b.left;
for (let H = 0; H < h; ++H) {
let X = Number.MIN_SAFE_INTEGER,
J = z < 0 ? 0 : z,
re = j < 0 ? 0 : j;
for (let ne = 0; ne < k; ++ne) {
let ee = z + ne * E;
if (ee >= 0 && ee < d) for (let oe = 0; oe < _; ++oe) {
let ie = j + oe * R;
if (ie >= 0 && ie < f) {
let le = c[L][ee][ie][H] + l[ne][oe][H];
le > X && (X = le, J = ee, re = ie);
}
}
}
O[L][J][re][H] += F[L][B][U][H];
}
}
}
return {
dataId: u.write(y.toTypedArray(O, o.dtype), o.shape, o.dtype),
shape: o.shape,
dtype: o.dtype
};
}
};
function li(r) {
let {
inputs: e,
backend: t10,
attrs: o
} = r,
{
x: n
} = e,
{
axis: s,
keepDims: a
} = o;
Y(n, "sum");
let i;
n.dtype === "bool" ? i = _o({
inputs: {
x: n
},
backend: t10,
attrs: {
dtype: "int32"
}
}) : i = lr({
inputs: {
x: n
},
backend: t10
});
let p = i.shape.length,
u = y.parseAxisParam(s, i.shape),
c = C.getAxesPermutation(u, p),
l = u,
m = i;
c != null && (m = St({
inputs: {
x: i
},
backend: t10,
attrs: {
perm: c
}
}), l = C.getInnerMostAxes(l.length, p)), C.assertAxesAreInnerMostDims("sum", l, m.shape.length);
let [d, f] = C.computeOutAndReduceShapes(m.shape, l),
h = C.upcastType(m.dtype, "int32"),
g = gc(t10, d, h),
x = y.sizeFromShape(f),
b = t10.data.get(g.dataId).values,
w = t10.data.get(m.dataId).values;
for (let S = 0; S < b.length; ++S) {
let k = S * x,
_ = 0;
for (let E = 0; E < x; ++E) _ += w[k + E];
b[S] = _;
}
if (a) {
let S = C.expandShapeToKeepDim(g.shape, u),
k = g;
g = Ve({
inputs: {
x: g
},
backend: t10,
attrs: {
shape: S
}
}), t10.disposeIntermediateTensorInfo(k);
}
return t10.disposeIntermediateTensorInfo(i), c != null && t10.disposeIntermediateTensorInfo(m), g;
}
var m$ = {
kernelName: ys,
backendName: "cpu",
kernelFunc: li
};
function cY(r) {
let {
inputs: e,
backend: t10,
attrs: o
} = r,
{
equation: n
} = o,
s = e,
{
allDims: a,
summedDims: i,
idDims: p
} = C.decodeEinsumEquation(n, s.length);
C.checkEinsumDimSizes(a.length, p, s);
let {
path: u,
steps: c
} = C.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: x,
expandDims: b
} = C.getEinsumPermutation(d, p[g]),
w;
C.isIdentityPermutation(x) ? w = s[g] : (w = St({
inputs: {
x: s[g]
},
backend: t10,
attrs: {
perm: x
}
}), f.push(w));
let S = w.shape.slice();
for (let k = 0; k < b.length; ++k) S.splice(b[k], 0, 1);
y.arraysEqual(w.shape, S) || (w = Ve({
inputs: {
x: w
},
backend: t10,
attrs: {
shape: S
}
}), f.push(w)), m === null ? m = w : (m = sp({
inputs: {
a: w,
b: m
},
backend: t10
}), f.push(m));
}
h < l - 1 && (u[h] >= 0 && (m = li({
inputs: {
x: m
},
backend: t10,
attrs: {
axis: u[h] - (a.length - d),
keepDims: false
}
}), f.push(m)), d--);
}
for (let h of f) h !== m && t10.disposeIntermediateTensorInfo(h);
return m;
}
var d$ = {
kernelName: Fi,
backendName: "cpu",
kernelFunc: cY
};
function lY(r) {
let {
inputs: e,
backend: t10
} = r,
{
dy: o,
y: n
} = e;
Y([o, n], "eluGrad");
let s = new Float32Array(y.sizeFromShape(n.shape)),
a = t10.data.get(n.dataId).values,
i = t10.data.get(o.dataId).values;
for (let p = 0; p < a.length; ++p) {
let u = a[p];
u >= 0 ? s[p] = i[p] : s[p] = i[p] * (u + 1);
}
return t10.makeTensorInfo(n.shape, "float32", s);
}
var f$ = {
kernelName: Va,
backendName: "cpu",
kernelFunc: lY
};
var mY = C.ERF_P;
var dY = C.ERF_A1;
var fY = C.ERF_A2;
var hY = C.ERF_A3;
var gY = C.ERF_A4;
var xY = C.ERF_A5;
var yY = Ie(Wa, r => {
let e = Math.sign(r),
t10 = Math.abs(r),
o = 1 / (1 + mY * t10);
return e * (1 - ((((xY * o + gY) * o + hY) * o + fY) * o + dY) * o * Math.exp(-t10 * t10));
});
var h$ = {
kernelName: Wa,
backendName: "cpu",
kernelFunc: yY
};
function vc(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 && (y.assert(-(a + 1) <= s, () => `Axis must be in the interval [${-(a + 1)}, ${a}]`), p = a + s + 1), i.splice(p, 0, 1), Ve({
inputs: {
x: n
},
backend: t10,
attrs: {
shape: i
}
});
}
var g$ = {
kernelName: Js,
backendName: "cpu",
kernelFunc: vc
};
var bY = ze((r, e) => r / e);
var zl = je(dn, bY);
var Vl = {
kernelName: dn,
backendName: "cpu",
kernelFunc: zl
};
function Lf(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 = y.sizeFromShape(u),
l = y.getTypedArrayFromDType("float32", c),
m = y.getTypedArrayFromDType("float32", c);
for (let g = 0; g < n; g++) {
let x = Eo({
inputs: {
x: i
},
backend: t10,
attrs: {
begin: [g, 0],
size: [1, s]
}
}),
b = Eo({
inputs: {
x: p
},
backend: t10,
attrs: {
begin: [g, 0],
size: [1, s]
}
}),
w = Kt({
inputs: {
real: x,
imag: b
},
backend: t10
}),
{
real: S,
imag: k
} = CY(w, e, t10),
_ = C.mergeRealAndImagArrays(S, k);
for (let E = 0; E < s; E++) {
let R = C.getComplexWithIndex(_, E);
l[g * s + E] = R.real, m[g * s + E] = R.imag;
}
t10.disposeIntermediateTensorInfo(x), t10.disposeIntermediateTensorInfo(b), t10.disposeIntermediateTensorInfo(w);
}
let d = t10.makeTensorInfo(u, "float32", l),
f = t10.makeTensorInfo(u, "float32", m),
h = Kt({
inputs: {
real: d,
imag: f
},
backend: t10
});
return t10.disposeIntermediateTensorInfo(d), t10.disposeIntermediateTensorInfo(f), h;
}
function CY(r, e, t10) {
let o = y.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 (wY(o)) {
let i = oI(s, a, o, e, t10),
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", y.createScalarValue(o, "float32")),
m = lr({
inputs: {
x: l
},
backend: t10
}),
d = Vl.kernelFunc({
inputs: {
a: u,
b: l
},
backend: t10
}),
f = Vl.kernelFunc({
inputs: {
a: c,
b: m
},
backend: t10
}),
h = t10.data.get(d.dataId).values,
g = t10.data.get(f.dataId).values;
return t10.disposeIntermediateTensorInfo(u), t10.disposeIntermediateTensorInfo(c), t10.disposeIntermediateTensorInfo(l), t10.disposeIntermediateTensorInfo(m), t10.disposeIntermediateTensorInfo(d), t10.disposeIntermediateTensorInfo(f), {
real: h,
imag: g
};
}
return i;
} else {
let i = C.mergeRealAndImagArrays(s, a),
p = SY(i, o, e);
return C.splitRealAndImagArrays(p);
}
}
function wY(r) {
return (r & r - 1) === 0;
}
function oI(r, e, t10, o, n) {
if (t10 === 1) return {
real: r,
imag: e
};
let s = C.mergeRealAndImagArrays(r, e),
a = t10 / 2,
i = C.complexWithEvenIndex(s),
p = i.real,
u = i.imag,
c = [p.length],
l = n.makeTensorInfo(c, "float32", p),
m = n.makeTensorInfo(c, "float32", u),
d = Kt({
inputs: {
real: l,
imag: m
},
backend: n
}),
f = C.complexWithOddIndex(s),
h = f.real,
g = f.imag,
x = [h.length],
b = n.makeTensorInfo(x, "float32", h),
w = n.makeTensorInfo(x, "float32", g),
S = Kt({
inputs: {
real: b,
imag: w
},
backend: n
}),
k = oI(p, u, a, o, n),
_ = k.real,
E = k.imag,
R = [_.length],
D = n.makeTensorInfo(R, "float32", _),
F = n.makeTensorInfo(R, "float32", E),
O = Kt({
inputs: {
real: D,
imag: F
},
backend: n
}),
M = oI(h, g, a, o, n),
L = M.real,
B = M.imag,
z = [L.length],
U = n.makeTensorInfo(z, "float32", L),
j = n.makeTensorInfo(z, "float32", B),
H = Kt({
inputs: {
real: U,
imag: j
},
backend: n
}),
X = C.exponents(t10, o),
J = [X.real.length],
re = n.makeTensorInfo(J, "float32", X.real),
ne = n.makeTensorInfo(J, "float32", X.imag),
ee = Kt({
inputs: {
real: re,
imag: ne
},
backend: n
}),
oe = sp({
inputs: {
a: ee,
b: H
},
backend: n
}),
ie = _a({
inputs: {
a: O,
b: oe
},
backend: n
}),
le = Ll({
inputs: {
a: O,
b: oe
},
backend: n
}),
ye = To({
inputs: {
input: ie
},
backend: n
}),
_e = To({
inputs: {
input: le
},
backend: n
}),
ve = $a({
inputs: {
input: ie
},
backend: n
}),
Fe = $a({
inputs: {
input: le
},
backend: n
}),
Pe = mu({
inputs: [ye, _e],
backend: n,
attrs: {
axis: 0
}
}),
st = mu({
inputs: [ve, Fe],
backend: n,
attrs: {
axis: 0
}
}),
lt = n.data.get(Pe.dataId).values,
We = n.data.get(st.dataId).values;
return n.disposeIntermediateTensorInfo(l), n.disposeIntermediateTensorInfo(m), n.disposeIntermediateTensorInfo(d), n.disposeIntermediateTensorInfo(b), n.disposeIntermediateTensorInfo(w), n.disposeIntermediateTensorInfo(S), n.disposeIntermediateTensorInfo(D), n.disposeIntermediateTensorInfo(F), n.disposeIntermediateTensorInfo(O), n.disposeIntermediateTensorInfo(U), n.disposeIntermediateTensorInfo(j), n.disposeIntermediateTensorInfo(H), n.disposeIntermediateTensorInfo(re), n.disposeIntermediateTensorInfo(ne), n.disposeIntermediateTensorInfo(ee), n.disposeIntermediateTensorInfo(oe), n.disposeIntermediateTensorInfo(ie), n.disposeIntermediateTensorInfo(le), n.disposeIntermediateTensorInfo(ye), n.disposeIntermediateTensorInfo(ve), n.disposeIntermediateTensorInfo(_e), n.disposeIntermediateTensorInfo(Fe), n.disposeIntermediateTensorInfo(Pe), n.disposeIntermediateTensorInfo(st), {
real: lt,
imag: We
};
}
function SY(r, e, t10) {
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 = C.exponent(n * i, e, t10),
u = C.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), C.assignToTypedArray(o, s, a, n);
}
return o;
}
function IY(r) {
let {
inputs: e,
backend: t10
} = r,
{
input: o
} = e,
n = y.sizeFromShape(o.shape),
s = o.shape[o.shape.length - 1],
a = n / s,
i = Ve({
inputs: {
x: o
},
backend: t10,
attrs: {
shape: [a, s]
}
}),
p = Lf(i, false, t10),
u = Ve({
inputs: {
x: p
},
backend: t10,
attrs: {
shape: o.shape
}
});
return t10.disposeIntermediateTensorInfo(i), t10.disposeIntermediateTensorInfo(p), u;
}
var x$ = {
kernelName: Pi,
backendName: "cpu",
kernelFunc: IY
};
function Wl(r) {
let {
backend: e,
attrs: t10
} = r,
{
shape: o,
value: n,
dtype: s
} = t10,
a = s || y.inferDtype(n),
i = y.getArrayFromDType(a, y.sizeFromShape(o));
return vY(i, n, a), e.makeTensorInfo(o, a, i);
}
var y$ = {
kernelName: ea,
backendName: "cpu",
kernelFunc: Wl
};
function vY(r, e, t10) {
r.fill(e);
}
var b$ = {
kernelName: yn,
backendName: "cpu",
kernelFunc: ({
inputs: r,
attrs: e,
backend: t10
}) => {
let {
image: o
} = r,
n = t10,
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 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 x = g * u;
for (let b = 0; b < u; b++) {
let w = Math.round(p - g - 1),
S = d + h + x + b,
k = c[S];
if (w >= 0 && w < p) {
let _ = w * u,
E = d + h + _ + b;
k = c[E];
}
s[S] = k;
}
}
}
}
return {
dataId: n.write(s, o.shape, o.dtype),
shape: o.shape,
dtype: o.dtype
};
}
};
function kY(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: d,
leakyreluAlpha: f
} = o,
h = tI({
inputs: {
x: n,
filter: s
},
backend: t10,
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 x = Ve({
inputs: {
x: a
},
backend: t10,
attrs: {
shape: [a.shape[0], 1, 1]
}
});
h = _a({
inputs: {
a: h,
b: x
},
backend: t10
}), t10.disposeIntermediateTensorInfo(x);
} else h = _a({
inputs: {
a: h,
b: a
},
backend: t10
});
t10.disposeIntermediateTensorInfo(g);
}
if (d) {
let g = h;
if (c === "NCHW" && d === "prelu" && i.shape.length === 1 && i.shape[0] !== 1) {
let x = Ve({
inputs: {
x: i
},
backend: t10,
attrs: {
shape: [i.shape[0], 1, 1]
}
});
h = mp(t10, h, d, x, f), t10.disposeIntermediateTensorInfo(x);
} else h = mp(t10, h, d, i, f);
t10.disposeIntermediateTensorInfo(g);
}
return h;
}
var C$ = {
kernelName: Co,
backendName: "cpu",
kernelFunc: kY
};
function NY(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: d,
leakyreluAlpha: f
} = o,
h = rI({
inputs: {
x: n,
filter: s
},
backend: t10,
attrs: {
strides: p,
pad: u,
dataFormat: c,
dilations: l,
dimRoundingMode: m
}
});
if (a) {
let g = h;
h = _a({
inputs: {
a: h,
b: a
},
backend: t10
}), t10.disposeIntermediateTensorInfo(g);
}
if (d) {
let g = h;
h = mp(t10, h, d, i, f), t10.disposeIntermediateTensorInfo(g);
}
return h;
}
var w$ = {
kernelName: wo,
backendName: "cpu",
kernelFunc: NY
};
function TY(r) {
let {
inputs: e,
backend: t10
} = r,
{
params: o,
indices: n
} = e,
s = y.sizeFromShape(o.shape),
a = n.shape,
i = a[a.length - 1],
[p, u, c, l] = C.prepareAndValidate(o, n);
if (u === 0) return t10.makeTensorInfo(p, o.dtype, []);
let m = t10.data.get(n.dataId).values,
d = t10.bufferSync(o),
f = vf(m, d, o.dtype, u, i, c, l, o.shape, s);
return t10.makeTensorInfo(p, o.dtype, f.values);
}
var S$ = {
kernelName: Sn,
backendName: "cpu",
kernelFunc: TY
};
function _Y(r) {
let {
inputs: e,
backend: t10,
attrs: o
} = r,
{
x: n,
indices: s
} = e,
{
axis: a,
batchDims: i
} = o;
Y([n, s], "gatherV2");
let p = y.parseAxisParam(a, n.shape)[0],
u = t10.data.get(s.dataId).values,
c = n.shape[p];
for (let S = 0; S < u.length; ++S) {
let k = u[S];
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 = y.sizeFromShape(s.shape),
d = C.segment_util.collectGatherOpShapeInfo(n, s, p, l),
f = Ve({
inputs: {
x: n
},
backend: t10,
attrs: {
shape: [d.batchSize, d.outerSize, d.dimSize, d.sliceSize]
}
}),
h = Ve({
inputs: {
x: s
},
backend: t10,
attrs: {
shape: [d.batchSize, m / d.batchSize]
}
}),
g = [d.batchSize, d.outerSize, m / d.batchSize, d.sliceSize],
x = t10.bufferSync(h),
b = t10.bufferSync(f),
w = kf(b, x, g);
return t10.disposeIntermediateTensorInfo(f), t10.disposeIntermediateTensorInfo(h), t10.makeTensorInfo(d.outputShape, w.dtype, w.values);
}
var I$ = {
kernelName: ta,
backendName: "cpu",
kernelFunc: _Y
};
function $Y(r) {
let {
inputs: e,
backend: t10
} = r,
{
input: o
} = e,
n = y.sizeFromShape(o.shape),
s = o.shape[o.shape.length - 1],
a = n / s,
i = Ve({
inputs: {
x: o
},
backend: t10,
attrs: {
shape: [a, s]
}
}),
p = Lf(i, true, t10),
u = Ve({
inputs: {
x: p
},
backend: t10,
attrs: {
shape: o.shape
}
});
return t10.disposeIntermediateTensorInfo(i), t10.disposeIntermediateTensorInfo(p), u;
}
var v$ = {
kernelName: Oi,
backendName: "cpu",
kernelFunc: $Y
};
var EY = Ie(kn, r => Number.isFinite(r) ? 1 : 0, "bool");
var k$ = {
kernelName: kn,
backendName: "cpu",
kernelFunc: EY
};
var RY = Ie(Nn, r => Math.abs(r) === 1 / 0 ? 1 : 0, "bool");
var N$ = {
kernelName: Nn,
backendName: "cpu",
kernelFunc: RY
};
var DY = Ie(Tn, r => Number.isNaN(r) ? 1 : 0, "bool");
var T$ = {
kernelName: Tn,
backendName: "cpu",
kernelFunc: DY
};
function AY(r) {
let {
backend: e,
attrs: t10
} = r,
{
start: o,
stop: n,
num: s
} = t10,
a = Nf(o, n, s);
return e.makeTensorInfo([a.length], "float32", a);
}
var _$ = {
kernelName: Rn,
backendName: "cpu",
kernelFunc: AY
};
var FY = Ie(An, r => Math.log1p(r));
var $$ = {
kernelName: An,
backendName: "cpu",
kernelFunc: FY
};
var PY = ze((r, e) => r && e);
var OY = je(Fn, PY, null, "bool");
var E$ = {
kernelName: Fn,
backendName: "cpu",
kernelFunc: OY
};
var MY = Ie(Pn, r => r ? 0 : 1, "bool");
var R$ = {
kernelName: Pn,
backendName: "cpu",
kernelFunc: MY
};
var LY = ze((r, e) => r || e);
var BY = je(On, LY, null, "bool");
var D$ = {
kernelName: On,
backendName: "cpu",
kernelFunc: BY
};
function zY(r) {
let {
inputs: e,
backend: t10,
attrs: o
} = r,
{
x: n
} = e,
{
depthRadius: s,
bias: a,
alpha: i,
beta: p
} = o;
Y(n, "LRN");
let u = n.shape[3],
c = u - 1,
l = t10.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),
w = 0;
for (; x <= b; x++) {
let S = l[x];
w += S * S;
}
return w;
}
for (let h = 0; h < m; h++) {
let g = f(h),
x = l[h] * Math.pow(a + i * g, -p);
d[h] = x;
}
return t10.makeTensorInfo(n.shape, n.dtype, d);
}
var A$ = {
kernelName: Mn,
backendName: "cpu",
kernelFunc: zY
};
function VY(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;
Y(a, "LRNGrad");
let l = y.sizeFromShape(a.shape),
m = a.shape[3],
d = t10.data.get(a.dataId).values,
f = t10.data.get(n.dataId).values,
h = t10.data.get(s.dataId).values,
g = new Float32Array(l),
x = l;
for (let b = 0; b < x; b++) {
let w = b % m,
S = b - w + Math.max(0, w - i),
k = b - w + Math.min(m, w + i + 1),
_ = 0;
for (let E = S; E < k; E++) _ += Math.pow(f[E], 2);
_ = u * _ + p;
for (let E = S; E < k; E++) {
let R = -2 * u * c * f[E] * h[b] / _;
b === E && (R += Math.pow(_, -c)), R *= d[b], g[E] += R;
}
}
return t10.makeTensorInfo(a.shape, n.dtype, g);
}
var F$ = {
kernelName: Ua,
backendName: "cpu",
kernelFunc: VY
};
function nI(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 = y.parseAxisParam(s, p),
l = c,
m = C.getAxesPermutation(l, u),
d = i.data.get(n.dataId).values;
if (m != null) {
let S = new Array(u);
for (let k = 0; k < S.length; k++) S[k] = p[m[k]];
d = bc(d, p, n.dtype, m, S), l = C.getInnerMostAxes(l.length, u), p = S;
}
Y(n, "max"), C.assertAxesAreInnerMostDims("max", l, u);
let [f, h] = C.computeOutAndReduceShapes(p, l),
g = y.sizeFromShape(h),
x = Tf(d, g, f, n.dtype),
b = i.write(x, f, n.dtype),
w = f;
return a && (w = C.expandShapeToKeepDim(f, c)), {
dataId: b,
shape: w,
dtype: n.dtype
};
}
var P$ = {
kernelName: Ln,
backendName: "cpu",
kernelFunc: nI
};
function WY(r) {
let {
inputs: e,
backend: t10,
attrs: o
} = r,
{
x: n
} = e;
Y(n, "maxPool");
let {
filterSize: s,
strides: a,
pad: i,
dimRoundingMode: p
} = o,
u = 1;
y.assert(C.eitherStridesOrDilationsAreOne(a, u), () => `Error in maxPool: Either strides or dilations must be 1. Got strides ${a} and dilations '${u}'`);
let c = C.computePool2DInfo(n.shape, s, a, u, i, p),
l;
if (c.filterWidth === 1 && c.filterHeight === 1 && y.arraysEqual(c.inShape, c.outShape)) l = lr({
inputs: {
x: n
},
backend: t10
});else {
let m = t10.data.get(n.dataId).values,
d = y.computeStrides(n.shape),
f = Ic(m, n.shape, n.dtype, d, c, "max");
l = t10.makeTensorInfo(c.outShape, n.dtype, f.values);
}
return l;
}
var O$ = {
kernelName: zn,
backendName: "cpu",
kernelFunc: WY
};
function UY(r) {
let {
inputs: e,
backend: t10,
attrs: o
} = r,
{
x: n
} = e,
{
filterSize: s,
strides: a,
pad: i,
dimRoundingMode: p,
dataFormat: u
} = o;
Y(n, "maxPool3d");
let c = C.computePool3DInfo(n.shape, s, a, 1, i, p, u),
l = t10.data.get(n.dataId).values,
m = Mf(l, n.shape, n.dtype, y.computeStrides(n.shape), c, "max");
return t10.makeTensorInfo(m.shape, "float32", m.values);
}
var M$ = {
kernelName: ra,
backendName: "cpu",
kernelFunc: UY
};
function GY(r) {
let {
inputs: e,
backend: t10,
attrs: o
} = r,
{
dy: n,
input: s
} = e,
{
filterSize: a,
strides: i,
pad: p,
dimRoundingMode: u
} = o;
Y([n, s], "maxPool3DGrad");
let c = C.computePool3DInfo(s.shape, a, i, 1, p, u),
l = t10.bufferSync(s),
m = A_(l, c),
d = c.strideDepth,
f = c.strideHeight,
h = c.strideWidth,
g = c.dilationDepth,
x = c.dilationHeight,
b = c.dilationWidth,
w = c.effectiveFilterDepth,
S = c.effectiveFilterHeight,
k = c.effectiveFilterWidth,
_ = w - 1 - c.padInfo.front,
E = k - 1 - c.padInfo.left,
R = S - 1 - c.padInfo.top,
D = me(s.shape, "float32"),
F = t10.bufferSync(n);
for (let O = 0; O < c.batchSize; ++O) for (let M = 0; M < c.inChannels; ++M) for (let L = 0; L < c.inDepth; ++L) for (let B = 0; B < c.inHeight; ++B) for (let z = 0; z < c.inWidth; ++z) {
let U = L - _,
j = B - R,
H = z - E,
X = 0;
for (let J = 0; J < w; J += g) {
let re = (U + J) / d;
if (!(re < 0 || re >= c.outDepth || Math.floor(re) !== re)) for (let ne = 0; ne < S; ne += x) {
let ee = (j + ne) / f;
if (!(ee < 0 || ee >= c.outHeight || Math.floor(ee) !== ee)) for (let oe = 0; oe < k; oe += b) {
let ie = (H + oe) / h;
if (ie < 0 || ie >= c.outWidth || Math.floor(ie) !== ie) continue;
let le = w * S * k - 1 - m.get(O, re, ee, ie, M),
ye = J * S * k + ne * k + oe,
_e = le === ye ? 1 : 0;
if (_e === 0) continue;
let ve = F.get(O, re, ee, ie, M);
X += ve * _e;
}
}
}
D.set(X, O, L, B, z, M);
}
return t10.makeTensorInfo(D.shape, D.dtype, D.values);
}
var L$ = {
kernelName: Li,
backendName: "cpu",
kernelFunc: GY
};
function HY(r) {
let {
inputs: e,
backend: t10,
attrs: o
} = r,
{
dy: n,
input: s,
output: a
} = e,
i = s;
Y([s, a], "maxPoolGrad");
let {
filterSize: p,
strides: u,
pad: c,
dimRoundingMode: l
} = o,
m = C.computePool2DInfo(i.shape, p, u, 1, c, l),
d = t10.data.get(i.dataId).values,
f = me(m.outShape, i.dtype, Of(d, i.shape, i.dtype, m).values),
h = m.strideHeight,
g = m.strideWidth,
x = m.dilationHeight,
b = m.dilationWidth,
w = m.effectiveFilterHeight,
S = m.effectiveFilterWidth,
k = S - 1 - m.padInfo.left,
_ = w - 1 - m.padInfo.top,
E = me(i.shape, "float32"),
R = t10.data.get(n.dataId).values,
D = me(n.shape, "float32", R);
for (let F = 0; F < m.batchSize; ++F) for (let O = 0; O < m.inChannels; ++O) for (let M = 0; M < m.inHeight; ++M) for (let L = 0; L < m.inWidth; ++L) {
let B = M - _,
z = L - k,
U = 0;
for (let j = 0; j < w; j += x) {
let H = (B + j) / h;
if (!(H < 0 || H >= m.outHeight || Math.floor(H) !== H)) for (let X = 0; X < S; X += b) {
let J = (z + X) / g;
if (J < 0 || J >= m.outWidth || Math.floor(J) !== J) continue;
let re = w * S - 1 - f.get(F, H, J, O),
ne = j * S + X,
ee = re === ne ? 1 : 0;
if (ee === 0) continue;
let oe = D.get(F, H, J, O);
U += oe * ee;
}
}
E.set(U, F, M, L, O);
}
return t10.makeTensorInfo(E.shape, E.dtype, E.values);
}
var B$ = {
kernelName: Hp,
backendName: "cpu",
kernelFunc: HY
};
function z$(r, e, t10, o, n) {
let s = y.computeStrides(e),
a = Ic(r, e, t10, s, n, "max"),
i = Of(r, e, t10, n, true, o);
return [a.values, i.values];
}
var V$ = {
kernelName: Bi,
backendName: "cpu",
kernelFunc: ({
inputs: r,
attrs: e,
backend: t10
}) => {
let {
x: o
} = r,
{
filterSize: n,
strides: s,
pad: a,
includeBatchInIndex: i
} = e,
p = t10;
Y(o, "MaxPoolWithArgmax");
let u = p.data.get(o.dataId).values,
c = C.computePool2DInfo(o.shape, n, s, [1, 1], a),
[l, m] = z$(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 KY(r) {
let {
inputs: e,
backend: t10,
attrs: o
} = r,
{
x: n
} = e,
{
axis: s,
keepDims: a
} = o,
i = y.parseAxisParam(s, n.shape),
u = C.computeOutAndReduceShapes(n.shape, i)[1],
c = y.sizeFromShape(u),
l = [],
m = t10.makeTensorInfo([], "float32", new Float32Array([c]));
l.push(m);
let d = _o({
inputs: {
x: n
},
backend: t10,
attrs: {
dtype: "float32"
}
});
l.push(d);
let f = zl({
inputs: {
a: d,
b: m
},
backend: t10
});
l.push(f);
let h = li({
inputs: {
x: f
},
backend: t10,
attrs: {
axis: s,
keepDims: a
}
});
return l.forEach(g => t10.disposeIntermediateTensorInfo(g)), h;
}
var W$ = {
kernelName: Vn,
backendName: "cpu",
kernelFunc: KY
};
function qY(r) {
let {
inputs: e,
backend: t10,
attrs: o
} = r,
{
x: n
} = e,
{
axis: s,
keepDims: a
} = o;
Y(n, "min");
let i = y.parseAxisParam(s, n.shape),
p = i,
u = C.getAxesPermutation(p, n.shape.length),
c = n;
u != null && (c = St({
inputs: {
x: n
},
backend: t10,
attrs: {
perm: u
}
}), p = C.getInnerMostAxes(p.length, n.shape.length)), C.assertAxesAreInnerMostDims("min", p, c.shape.length);
let [l, m] = C.computeOutAndReduceShapes(c.shape, p),
d = y.sizeFromShape(m),
f = y.makeZerosTypedArray(y.sizeFromShape(l), c.dtype),
h = t10.data.get(c.dataId).values;
for (let x = 0; x < f.length; ++x) {
let b = x * d,
w = h[b];
for (let S = 0; S < d; ++S) {
let k = h[b + S];
(Number.isNaN(k) || k < w) && (w = k);
}
f[x] = w;
}
u != null && t10.disposeIntermediateTensorInfo(c);
let g = t10.makeTensorInfo(l, c.dtype, f);
if (a) {
let x = C.expandShapeToKeepDim(l, i),
b = Ve({
inputs: {
x: g
},
backend: t10,
attrs: {
shape: x
}
});
return t10.disposeIntermediateTensorInfo(g), b;
}
return g;
}
var U$ = {
kernelName: Wn,
backendName: "cpu",
kernelFunc: qY
};
function jY(r) {
let {
inputs: e,
backend: t10,
attrs: o
} = r,
{
x: n
} = e,
{
paddings: s,
mode: a
} = o;
Y(n, "mirrorPad");
let i = s.map((w, S) => w[0] + n.shape[S] + w[1]),
p = s.map(w => w[0]),
u = s.map((w, S) => w[0] + n.shape[S]),
c = a === "reflect" ? 0 : 1,
l = t10.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 w = 0; w < f; w++) {
let S = y.indexToLoc(w, h, g);
for (let _ = 0; _ < h; _++) S[_] < p[_] ? S[_] = p[_] * 2 - S[_] - c : S[_] >= u[_] && (S[_] = (u[_] - 1) * 2 - S[_] + c);
S = S.map((_, E) => _ - p[E]);
let k = y.locToIndex(S, m, d);
x[w] = l[k];
}
return {
dataId: t10.write(x, i, n.dtype),
shape: i,
dtype: n.dtype
};
}
var G$ = {
kernelName: Gn,
backendName: "cpu",
kernelFunc: jY
};
var XY = ze((r, e) => {
let t10 = r % e;
return r < 0 && e < 0 || r >= 0 && e >= 0 ? t10 : (t10 + e) % e;
});
var YY = je(Ga, XY);
var H$ = {
kernelName: Ga,
backendName: "cpu",
kernelFunc: YY
};
var q$ = Bp(Rw());
function sI(r) {
let {
inputs: e,
backend: t10,
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 = y.parseAxisParam([i], n.shape),
u = nI({
inputs: {
x: n
},
backend: t10,
attrs: {
reductionIndices: p,
keepDims: false
}
}),
c = C.expandShapeToKeepDim(u.shape, p),
l = Ve({
inputs: {
x: u
},
backend: t10,
attrs: {
shape: c
}
}),
m = Ll({
inputs: {
a: n,
b: l
},
backend: t10
}),
d = $S({
inputs: {
x: m
},
backend: t10
}),
f = li({
inputs: {
x: d
},
backend: t10,
attrs: {
axis: p,
keepDims: false
}
}),
h = Ve({
inputs: {
x: f
},
backend: t10,
attrs: {
shape: c
}
}),
g = zl({
inputs: {
a: d,
b: h
},
backend: t10
});
return t10.disposeIntermediateTensorInfo(u), t10.disposeIntermediateTensorInfo(l), t10.disposeIntermediateTensorInfo(m), t10.disposeIntermediateTensorInfo(d), t10.disposeIntermediateTensorInfo(f), t10.disposeIntermediateTensorInfo(h), g;
}
var K$ = {
kernelName: bs,
backendName: "cpu",
kernelFunc: sI
};
function QY(r) {
let {
inputs: e,
backend: t10,
attrs: o
} = r,
{
logits: n
} = e,
{
numSamples: s,
seed: a,
normalized: i
} = o;
Y(n, "multinomial");
let p = i ? n : sI({
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],
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 w = 1; w < g.length; ++w) g[w] = g[w - 1] + l[h + w];
let x = q$.alea(a.toString()),
b = f * s;
for (let w = 0; w < s; ++w) {
let S = x();
d[b + w] = g.length;
for (let k = 0; k < g.length; k++) if (S < g[k]) {
d[b + w] = k;
break;
}
}
}
return i || t10.disposeIntermediateTensorInfo(p), t10.makeTensorInfo(m, "int32", d);
}
var j$ = {
kernelName: Hn,
backendName: "cpu",
kernelFunc: QY
};
var ZY = Wt.nonMaxSuppressionV3Impl;
function JY(r) {
let {
inputs: e,
backend: t10,
attrs: o
} = r,
{
boxes: n,
scores: s
} = e,
{
maxOutputSize: a,
iouThreshold: i,
scoreThreshold: p
} = o;
Y(n, "NonMaxSuppression");
let u = t10.data.get(n.dataId).values,
c = t10.data.get(s.dataId).values,
{
selectedIndices: l
} = ZY(u, c, a, i, p);
return t10.makeTensorInfo([l.length], "int32", new Int32Array(l));
}
var X$ = {
kernelName: jn,
backendName: "cpu",
kernelFunc: JY
};
var eQ = Wt.nonMaxSuppressionV4Impl;
function tQ(r) {
let {
inputs: e,
backend: t10,
attrs: o
} = r,
{
boxes: n,
scores: s
} = e,
{
maxOutputSize: a,
iouThreshold: i,
scoreThreshold: p,
padToMaxOutputSize: u
} = o;
Y(n, "NonMaxSuppressionPadded");
let c = t10.data.get(n.dataId).values,
l = t10.data.get(s.dataId).values,
{
selectedIndices: m,
validOutputs: d
} = eQ(c, l, a, i, p, u);
return [t10.makeTensorInfo([m.length], "int32", new Int32Array(m)), t10.makeTensorInfo([], "int32", new Int32Array([d]))];
}
var Y$ = {
kernelName: Ha,
backendName: "cpu",
kernelFunc: tQ
};
var rQ = Wt.nonMaxSuppressionV5Impl;
function oQ(r) {
let {
inputs: e,
backend: t10,
attrs: o
} = r,
{
boxes: n,
scores: s
} = e,
{
maxOutputSize: a,
iouThreshold: i,
scoreThreshold: p,
softNmsSigma: u
} = o;
Y(n, "NonMaxSuppressionWithScore");
let c = t10.data.get(n.dataId).values,
l = t10.data.get(s.dataId).values,
m = a,
d = i,
f = p,
h = u,
{
selectedIndices: g,
selectedScores: x
} = rQ(c, l, m, d, f, h);
return [t10.makeTensorInfo([g.length], "int32", new Int32Array(g)), t10.makeTensorInfo([x.length], "float32", new Float32Array(x))];
}
var Q$ = {
kernelName: Xn,
backendName: "cpu",
kernelFunc: oQ
};
function nQ(r) {
let {
inputs: e,
backend: t10,
attrs: o
} = r,
{
indices: n
} = e,
{
dtype: s,
depth: a,
onValue: i,
offValue: p
} = o;
Y(n, "oneHot");
let u = y.sizeFromShape(n.shape),
c = new Float32Array(u * a);
c.fill(p);
let l = t10.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);
}
var Z$ = {
kernelName: Yn,
backendName: "cpu",
kernelFunc: nQ
};
function Ul(r) {
let {
inputs: e,
backend: t10
} = r,
{
x: o
} = e;
if (o.dtype === "string") throw new Error("zerosLike is not supported for string tensors");
if (o.dtype === "complex64") {
let n = To({
inputs: {
input: o
},
backend: t10
}),
s = Ul({
inputs: {
x: n
},
backend: t10
}),
a = $a({
inputs: {
input: o
},
backend: t10
}),
i = Ul({
inputs: {
x: a
},
backend: t10
}),
p = Kt({
inputs: {
real: s,
imag: i
},
backend: t10
});
return t10.disposeIntermediateTensorInfo(n), t10.disposeIntermediateTensorInfo(s), t10.disposeIntermediateTensorInfo(a), t10.disposeIntermediateTensorInfo(i), p;
} else return Wl({
backend: t10,
attrs: {
shape: o.shape,
value: 0,
dtype: o.dtype
}
});
}
var J$ = {
kernelName: fa,
backendName: "cpu",
kernelFunc: Ul
};
function eE(r) {
let {
inputs: e,
backend: t10
} = r,
{
x: o
} = e;
if (o.dtype === "string") throw new Error("onesLike is not supported for string tensors");
if (o.dtype === "complex64") {
let n = To({
inputs: {
input: o
},
backend: t10
}),
s = eE({
inputs: {
x: n
},
backend: t10
}),
a = $a({
inputs: {
input: o
},
backend: t10
}),
i = Ul({
inputs: {
x: a
},
backend: t10
}),
p = Kt({
inputs: {
real: s,
imag: i
},
backend: t10
});
return t10.disposeIntermediateTensorInfo(n), t10.disposeIntermediateTensorInfo(s), t10.disposeIntermediateTensorInfo(a), t10.disposeIntermediateTensorInfo(i), p;
} else return Wl({
backend: t10,
attrs: {
shape: o.shape,
value: 1,
dtype: o.dtype
}
});
}
var tE = {
kernelName: na,
backendName: "cpu",
kernelFunc: eE
};
function aI(r) {
let {
inputs: e,
backend: t10,
attrs: o
} = r,
{
axis: n
} = o;
if (e.length === 1) return vc({
inputs: {
input: e[0]
},
backend: t10,
attrs: {
dim: n
}
});
let s = e[0].shape,
a = e[0].dtype;
e.forEach(c => {
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 = vc({
inputs: {
input: c
},
backend: t10,
attrs: {
dim: n
}
});
return i.push(l), l;
}),
u = mu({
inputs: p,
backend: t10,
attrs: {
axis: n
}
});
return i.forEach(c => t10.disposeIntermediateTensorInfo(c)), u;
}
var rE = {
kernelName: sa,
backendName: "cpu",
kernelFunc: aI
};
function sQ(r) {
let {
inputs: e,
backend: t10,
attrs: o
} = r,
{
x: n
} = e,
{
paddings: s,
constantValue: a
} = o;
Y(n, "pad");
let i = s.map((b, w) => b[0] + n.shape[w] + b[1]),
p = s.map(b => b[0]),
u = t10.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 S = y.indexToLoc(b, l, m).map((_, E) => _ + p[E]),
k = y.locToIndex(S, f, h);
g[k] = u[b];
}
return {
dataId: t10.write(g, i, n.dtype),
shape: i,
dtype: n.dtype
};
}
var Bf = {
kernelName: Qn,
backendName: "cpu",
kernelFunc: sQ
};
var aQ = ze((r, e) => Math.pow(r, e));
var iQ = je(Zn, aQ);
var oE = {
kernelName: Zn,
backendName: "cpu",
kernelFunc: iQ
};
function uQ(r) {
let {
inputs: e,
backend: t10,
attrs: o
} = r,
{
paramsNestedSplits: n,
paramsDenseValues: s,
indices: a
} = e,
{
outputRaggedRank: i
} = o,
p = n.map(x => t10.data.get(x.dataId).values),
u = n.map(x => x.shape),
c = t10.data.get(s.dataId).values,
l = t10.data.get(a.dataId).values,
[m, d, f] = _f(p, u, c, s.shape, s.dtype, l, a.shape, i),
h = m.map(x => t10.makeTensorInfo([x.length], "int32", x)),
g = t10.makeTensorInfo(f, s.dtype, d);
return h.concat([g]);
}
var nE = {
kernelName: Kp,
backendName: "cpu",
kernelFunc: uQ
};
function pQ(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] = $f(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);
return [l, m];
}
var sE = {
kernelName: qp,
backendName: "cpu",
kernelFunc: pQ
};
function cQ(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),
d = i.map(g => g.shape),
[f, h] = Ef(u, n.shape, c, s.shape, s.dtype, l, a.shape, m, d, p);
return t10.makeTensorInfo(f, s.dtype, h);
}
var aE = {
kernelName: jp,
backendName: "cpu",
kernelFunc: cQ
};
function lQ(r) {
let {
backend: e,
attrs: t10
} = r,
{
start: o,
stop: n,
dtype: s,
step: a
} = t10,
i = ap(o, n, a, s);
return e.makeTensorInfo([i.length], s, i);
}
var iE = {
kernelName: aa,
backendName: "cpu",
kernelFunc: lQ
};
var mQ = Ie(ts, r => 1 / r);
var uE = {
kernelName: ts,
backendName: "cpu",
kernelFunc: mQ
};
function dQ(r) {
let {
inputs: e,
backend: t10,
attrs: o
} = r,
{
images: n
} = e,
{
alignCorners: s,
halfPixelCenters: a,
size: i
} = o;
Y(n, "resizeBilinear");
let p = y.computeStrides(n.shape),
[u, c] = i,
[l, m, d, f] = n.shape,
h = t10.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],
w = 0,
S = x[0] / b[0],
k = x[1] / b[1];
for (let _ = 0; _ < l; _++) for (let E = 0; E < u; E++) {
let R;
a ? R = S * (E + 0.5) - 0.5 : R = S * E;
let D = Math.max(0, Math.floor(R)),
F = R - D,
O = Math.min(m - 1, Math.ceil(R)),
M = _ * p[0] + D * p[1],
L = _ * p[0] + O * p[1];
for (let B = 0; B < c; B++) {
let z;
a ? z = k * (B + 0.5) - 0.5 : z = k * B;
let U = Math.max(0, Math.floor(z)),
j = z - U,
H = Math.min(d - 1, Math.ceil(z)),
X = M + U * p[2],
J = L + U * p[2],
re = M + H * p[2],
ne = L + H * p[2];
for (let ee = 0; ee < f; ee++) {
let oe = h[X + ee],
ie = h[J + ee],
le = h[re + ee],
ye = h[ne + ee],
_e = oe + (le - oe) * j,
ve = ie + (ye - ie) * j,
Fe = _e + (ve - _e) * F;
g[w++] = Fe;
}
}
}
return t10.makeTensorInfo([l, u, c, f], "float32", g);
}
var pE = {
kernelName: ns,
backendName: "cpu",
kernelFunc: dQ
};
function fQ(r) {
let {
inputs: e,
backend: t10,
attrs: o
} = r,
{
images: n,
dy: s
} = e,
{
alignCorners: a
} = o;
Y([s, n], "resizeBilinearGrad");
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],
w = t10.data.get(s.dataId).values,
S = 0;
for (let k = 0; k < p; k++) {
let _ = k * i[0];
for (let E = 0; E < m; E++) {
let R = E * x,
D = Math.floor(R),
F = Math.min(Math.ceil(R), u - 1),
O = _ + D * i[1],
M = _ + F * i[1],
L = R - D,
B = 1 - L;
for (let z = 0; z < d; z++) {
let U = z * b,
j = Math.floor(U),
H = Math.min(Math.ceil(U), c - 1),
X = U - j,
J = 1 - X,
re = O + j * i[2],
ne = O + H * i[2],
ee = M + j * i[2],
oe = M + H * i[2],
ie = B * J,
le = B * X,
ye = L * J,
_e = L * X;
for (let ve = 0; ve < l; ve++) {
let Fe = w[S++];
f[re + ve] += Fe * ie, f[ne + ve] += Fe * le, f[ee + ve] += Fe * ye, f[oe + ve] += Fe * _e;
}
}
}
}
return t10.makeTensorInfo([p, c, u, l], "float32", f);
}
var cE = {
kernelName: qa,
backendName: "cpu",
kernelFunc: fQ
};
function hQ(r) {
let {
inputs: e,
backend: t10,
attrs: o
} = r,
{
images: n
} = e,
{
alignCorners: s,
halfPixelCenters: a,
size: i
} = o;
Y(n, "resizeNearestNeighbor");
let p = y.computeStrides(n.shape),
[u, c] = i,
[l, m, d, f] = n.shape,
h = t10.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],
w = x[0] / b[0],
S = x[1] / b[1],
k = 0;
for (let _ = 0; _ < l; _++) {
let E = _ * p[0];
for (let R = 0; R < u; R++) {
let D = a ? w * (R + 0.5) : w * R,
F = Math.min(m - 1, s ? Math.round(D) : Math.floor(D));
a && (F = Math.max(0, F));
let O = E + F * p[1];
for (let M = 0; M < c; M++) {
let L = a ? S * (M + 0.5) : S * M,
B = Math.min(d - 1, s ? Math.round(L) : Math.floor(L));
a && (B = Math.max(0, B));
let z = O + B * p[2];
for (let U = 0; U < f; U++) {
let j = h[z + U];
g[k++] = j;
}
}
}
}
return t10.makeTensorInfo([l, u, c, f], n.dtype, g);
}
var lE = {
kernelName: os,
backendName: "cpu",
kernelFunc: hQ
};
function gQ(r) {
let {
inputs: e,
backend: t10,
attrs: o
} = r,
{
images: n,
dy: s
} = e,
{
alignCorners: a
} = o;
Y([s, n], "resizeNearestNeighborGrad");
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 = t10.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],
w = x[0] / b[0],
S = x[1] / b[1],
k = 1 / w,
_ = 1 / S,
E = Math.ceil(k) * 2 + 2,
R = Math.ceil(_) * 2 + 2;
for (let D = 0; D < u; D++) {
let F = D * i[0];
for (let O = 0; O < c; O++) {
let M = F + O * i[1],
L = Math.floor(O * k),
B = Math.floor(L - E / 2);
for (let z = 0; z < l; z++) {
let U = M + z * i[2],
j = Math.floor(z * _),
H = Math.floor(j - R / 2);
for (let X = 0; X < m; X++) {
let J = 0;
for (let re = 0; re < E; re++) {
let ne = re + B;
if (ne < 0 || ne >= d) continue;
let ee = F + ne * p[1],
oe = ne * w,
ie = Math.min(c - 1, a ? Math.round(oe) : Math.floor(oe));
if (O === ie) for (let le = 0; le < R; le++) {
let ye = le + H;
if (ye < 0 || ye >= f) continue;
let _e = ee + ye * p[2],
ve = ye * S,
Fe = Math.min(l - 1, a ? Math.round(ve) : Math.floor(ve));
z === Fe && (J += g[_e + X]);
}
}
h[U + X] = J;
}
}
}
}
return t10.makeTensorInfo(n.shape, n.dtype, h);
}
var mE = {
kernelName: Ka,
backendName: "cpu",
kernelFunc: gQ
};
function xQ(r) {
let {
inputs: e,
backend: t10,
attrs: o
} = r,
{
x: n
} = e,
{
dims: s
} = o;
Y(n, "reverse");
let a = n.shape.length,
i = y.parseAxisParam(s, n.shape);
if (a === 0) return lr({
inputs: {
x: n
},
backend: t10
});
let p = new tt(n.shape, n.dtype),
u = t10.bufferSync(n);
for (let c = 0; c < p.size; c++) {
let l = p.indexToLoc(c),
m = l.slice();
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);
}
var dE = {
kernelName: as,
backendName: "cpu",
kernelFunc: xQ
};
var fE = {
kernelName: _s,
backendName: "cpu",
kernelFunc: ({
inputs: r,
attrs: e,
backend: t10
}) => {
let {
image: o
} = r,
{
radians: n,
fillValue: s,
center: a
} = e,
i = t10,
p = y.getTypedArrayFromDType(o.dtype, y.sizeFromShape(o.shape)),
[u, c, l, m] = o.shape,
[d, f] = C.getImageCenter(a, c, l),
h = 255,
g = Math.sin(n),
x = Math.cos(n),
b = i.data.get(o.dataId).values;
for (let S = 0; S < u; S++) {
let k = S * l * c * m;
for (let _ = 0; _ < c; _++) {
let E = _ * (l * m);
for (let R = 0; R < l; R++) {
let D = R * m;
for (let F = 0; F < m; F++) {
let O = [u, _, R, F],
M = O[2],
L = O[1],
B = (M - d) * x - (L - f) * g,
z = (M - d) * g + (L - f) * x;
B = Math.round(B + d), z = Math.round(z + f);
let U = s;
if (typeof s != "number" && (F === 3 ? U = h : U = s[F]), B >= 0 && B < l && z >= 0 && z < c) {
let H = z * (l * m),
X = B * m,
J = k + H + X + F;
U = b[J];
}
let j = k + E + D + F;
p[j] = U;
}
}
}
}
return {
dataId: i.write(p, o.shape, o.dtype),
shape: o.shape,
dtype: o.dtype
};
}
};
var yQ = Ie(is, 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 hE = {
kernelName: is,
backendName: "cpu",
kernelFunc: yQ
};
function bQ(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
} = C.calculateShapes(s, n, a),
m = true,
d = t10.bufferSync(n),
f = t10.bufferSync(s),
h = Fs(d, f, a, l, u, p, i, c, 0, m);
return t10.makeTensorInfo(a, h.dtype, h.values);
}
var gE = {
kernelName: ps,
backendName: "cpu",
kernelFunc: bQ
};
function CQ(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;
return o;
}
function wQ(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;
return o;
}
function xE(r, e, t10, o, n, s) {
let a = y.getArrayFromDType("int32", t10 * n);
for (let i = 0; i < t10; ++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" ? CQ(p, e[c + u]) : wQ(p, e[c + u]);
}
return a;
}
function SQ(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 = xE(i, p, n.shape[0], n.shape[1], s.shape[1], a);
return t10.makeTensorInfo(s.shape, "int32", u);
}
var yE = {
kernelName: ls,
backendName: "cpu",
kernelFunc: SQ
};
function IQ(r) {
let {
inputs: e,
backend: t10
} = r,
{
condition: o,
t: n,
e: s
} = e;
Y([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 = 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 t10.makeTensorInfo(n.shape, c, l);
}
var bE = {
kernelName: ua,
backendName: "cpu",
kernelFunc: IQ
};
var vQ = C.SELU_SCALEALPHA;
var kQ = C.SELU_SCALE;
var NQ = Ie(ms, r => r >= 0 ? kQ * r : vQ * (Math.exp(r) - 1));
var CE = {
kernelName: ms,
backendName: "cpu",
kernelFunc: NQ
};
var TQ = Ie(fs, r => r < 0 ? -1 : r > 0 ? 1 : 0);
var wE = {
kernelName: fs,
backendName: "cpu",
kernelFunc: TQ
};
var _Q = Ie(ds, r => Math.sin(r));
var SE = {
kernelName: ds,
backendName: "cpu",
kernelFunc: _Q
};
var $Q = Ie(ja, r => Math.sinh(r));
var IE = {
kernelName: ja,
backendName: "cpu",
kernelFunc: $Q
};
var EQ = 11920928955078125e-23;
var vE = Math.log(EQ) + 2;
var RQ = Ie(gs, r => {
let e = r > -vE,
t10 = r < vE,
o = Math.exp(r),
n;
return t10 ? n = o : e ? n = r : n = Math.log(1 + o), n;
});
var kE = {
kernelName: gs,
backendName: "cpu",
kernelFunc: RQ
};
function DQ(r) {
let {
inputs: e,
backend: t10,
attrs: o
} = r,
{
x: n
} = e,
{
blockShape: s,
paddings: a
} = o;
Y([n], "spaceToBatchND");
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 = Bf.kernelFunc({
inputs: {
x: n
},
backend: t10,
attrs: {
paddings: p,
constantValue: 0
}
}),
c = C.getReshaped(u.shape, s, i, false),
l = C.getPermuted(c.length, s.length, false),
m = C.getReshapedPermuted(u.shape, s, i, false),
h = Ve({
inputs: {
x: u
},
backend: t10,
attrs: {
shape: c
}
}),
b = St({
inputs: {
x: h
},
backend: t10,
attrs: {
perm: l
}
}),
k = Ve({
inputs: {
x: b
},
backend: t10,
attrs: {
shape: m
}
});
return t10.disposeIntermediateTensorInfo(u), t10.disposeIntermediateTensorInfo(h), t10.disposeIntermediateTensorInfo(b), k;
}
var NE = {
kernelName: ca,
backendName: "cpu",
kernelFunc: DQ
};
function AQ(r) {
let {
inputs: e,
backend: t10
} = 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}`);
if (o.shape.length !== 2) throw new Error(`Indices must be a matrix, saw:
${o.shape}`);
if (n.shape.length !== 1) throw new Error(`Values must be a vector, saw:
${n.shape}`);
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, d, f, h] = Rf(i, o.shape, o.dtype, p, n.dtype, u, c);
return [t10.makeTensorInfo(m, o.dtype, l), t10.makeTensorInfo([m[0]], n.dtype, d), t10.makeTensorInfo([f.length], "bool", new Uint8Array(f.map(g => Number(g)))), t10.makeTensorInfo([h.length], o.dtype, new Int32Array(h))];
}
var TE = {
kernelName: Vi,
backendName: "cpu",
kernelFunc: AQ
};
function FQ(r) {
let {
inputs: e,
backend: t10
} = 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.data.get(n.dataId).values),
i = t10.data.get(o.dataId).values,
p = Array.from(t10.data.get(s.dataId).values),
[u, c, l] = Df(i, o.shape, o.dtype, a, p);
return [t10.makeTensorInfo(c, o.dtype, u), t10.makeTensorInfo([l.length], s.dtype, new Int32Array(l))];
}
var _E = {
kernelName: Xa,
backendName: "cpu",
kernelFunc: FQ
};
function PQ(r) {
let {
inputs: e,
backend: t10
} = 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) throw new Error(`Indices should be a vector but received shape
${n.shape}`);
if (s.shape.length !== 1) throw new Error(`Segment ids should be a vector but received shape
${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] = wc(a, o.shape, o.dtype, i, p, true);
return t10.makeTensorInfo(c, o.dtype, u);
}
var $E = {
kernelName: Wi,
backendName: "cpu",
kernelFunc: PQ
};
function OQ(r) {
let {
inputs: e,
backend: t10
} = 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) throw new Error(`Indices should be a vector but received shape
${n.shape}`);
if (s.shape.length !== 1) throw new Error(`Segment ids should be a vector but received shape
${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] = wc(a, o.shape, o.dtype, i, p);
return t10.makeTensorInfo(c, o.dtype, u);
}
var EE = {
kernelName: Ui,
backendName: "cpu",
kernelFunc: OQ
};
function MQ(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
} = C.calculateShapes(s, n, i),
d = false,
f = t10.bufferSync(n),
h;
switch (s.dtype) {
case "bool":
{
let g = t10.bufferSync(s),
x = !!t10.data.get(a.dataId).values[0];
h = Fs(f, g, i, m, c, u, p, l, x, d);
break;
}
case "float32":
{
let g = t10.bufferSync(s),
x = t10.data.get(a.dataId).values[0];
h = Fs(f, g, i, m, c, u, p, l, x, d);
break;
}
case "int32":
{
let g = t10.bufferSync(s),
x = t10.data.get(a.dataId).values[0];
h = Fs(f, g, i, m, c, u, p, l, x, d);
break;
}
case "string":
{
let g = t10.bufferSync(s),
x = y.decodeString(t10.data.get(a.dataId).values[0]);
h = Fs(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);
}
var RE = {
kernelName: Cs,
backendName: "cpu",
kernelFunc: MQ
};
function LQ(r) {
let {
inputs: e,
backend: t10,
attrs: o
} = r,
{
x: n
} = e,
{
numOrSizeSplits: s,
axis: a
} = o,
i = y.parseAxisParam(a, n.shape)[0],
p = C.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 d = Eo({
inputs: {
x: n
},
backend: t10,
attrs: {
begin: u,
size: m
}
});
return u[i] += l, d;
});
}
var DE = {
kernelName: la,
backendName: "cpu",
kernelFunc: LQ
};
var AE = {
kernelName: Gi,
backendName: "cpu",
kernelFunc: ({
inputs: r,
backend: e
}) => {
let {
x: t10
} = r,
o = e;
Y(t10, "square");
let n = o.data.get(t10.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
};
}
};
var BQ = Ie(yo, (r, e) => {
let t10 = e;
return isNaN(r) ? NaN : r > 0 ? 1 : t10.alpha;
});
var FE = {
kernelName: yo,
backendName: "cpu",
kernelFunc: BQ
};
function zQ(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;
Y(n, "stridedSlice");
let {
finalShapeSparse: d,
finalShape: f,
isIdentity: h,
sliceDim0: g,
isSimpleSlice: x,
begin: b,
end: w,
strides: S
} = ct.sliceInfo(n.shape, s, a, i, p, u, c, l, m),
k;
if (h) k = Ve({
inputs: {
x: n
},
backend: t10,
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 _ = ct.computeOutShape(b, w, S),
E = Eo({
inputs: {
x: n
},
backend: t10,
attrs: {
begin: b,
size: _
}
});
k = Ve({
inputs: {
x: E
},
backend: t10,
attrs: {
shape: f
}
}), t10.disposeIntermediateTensorInfo(E);
} else {
let _ = t10.bufferSync(n),
E = Af(d, _, S, b);
k = t10.makeTensorInfo(f, E.dtype, E.values);
}
return k;
}
var PE = {
kernelName: Ss,
backendName: "cpu",
kernelFunc: zQ
};
function VQ(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,
d = t10.data.get(l.dataId).values,
[f, h] = up(m, d, n, s, a, i, p, u);
return [t10.makeTensorInfo([f.length], "string", f), t10.makeTensorInfo(l.shape, "int32", h)];
}
var OE = {
kernelName: ma,
backendName: "cpu",
kernelFunc: VQ
};
function WQ(r) {
let {
inputs: e,
backend: t10,
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] = pp(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))];
}
var ME = {
kernelName: Hi,
backendName: "cpu",
kernelFunc: WQ
};
function UQ(r) {
let {
inputs: e,
backend: t10,
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 = cp(a, n);
return t10.makeTensorInfo(s.shape, "int32", i);
}
var LE = {
kernelName: Ki,
backendName: "cpu",
kernelFunc: UQ
};
var GQ = Ie(vs, r => Math.tan(r));
var BE = {
kernelName: vs,
backendName: "cpu",
kernelFunc: GQ
};
var HQ = Ie(ks, r => Math.tanh(r));
var zE = {
kernelName: ks,
backendName: "cpu",
kernelFunc: HQ
};
function KQ(r) {
let {
inputs: e,
backend: t10
} = r,
{
tensor: o,
indices: n,
updates: s
} = e,
{
sliceRank: a,
numUpdates: i,
sliceSize: p,
strides: u,
outputSize: c
} = C.calculateShapes(s, n, o.shape),
l = false,
m = t10.bufferSync(n),
d = t10.bufferSync(s),
f = t10.bufferSync(o),
h = Fs(m, d, o.shape, c, p, i, a, u, f, l);
return t10.makeTensorInfo(o.shape, h.dtype, h.values);
}
var VE = {
kernelName: cs,
backendName: "cpu",
kernelFunc: KQ
};
function qQ(r) {
let {
inputs: e,
backend: t10,
attrs: o
} = r,
{
x: n
} = e,
{
reps: s
} = o;
Y(n, "tile");
let a = Ff(t10.bufferSync(n), s);
return t10.makeTensorInfo(a.shape, a.dtype, a.values);
}
var WE = {
kernelName: so,
backendName: "cpu",
kernelFunc: qQ
};
function jQ(r) {
let {
inputs: e,
backend: t10,
attrs: o
} = r,
{
x: n
} = e,
{
k: s,
sorted: a
} = o;
Y(n, "topk");
let i = t10.data.get(n.dataId).values,
[p, u] = Pf(i, n.shape, n.dtype, s, a);
return [t10.makeTensorInfo(p.shape, p.dtype, p.values), t10.makeTensorInfo(u.shape, u.dtype, u.values)];
}
var UE = {
kernelName: Ns,
backendName: "cpu",
kernelFunc: jQ
};
function XQ(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, d] = n.shape,
[f, h] = u != null ? u : [l, m],
g = [c, f, h, d],
x = y.computeStrides(n.shape),
b = x[0],
w = x[1],
S = x[2],
k = y.computeStrides(g),
_ = k[0],
E = k[1],
R = k[2],
D = y.getTypedArrayFromDType(n.dtype, y.sizeFromShape(g));
D.fill(p);
let F = o.data.get(n.dataId).values,
O = o.data.get(s.dataId).values;
for (let L = 0; L < c; ++L) {
let B = s.shape[0] === 1 ? O : O.subarray(L * 8, L * 8 + 8);
for (let z = 0; z < f; ++z) for (let U = 0; U < h; ++U) for (let j = 0; j < d; ++j) {
let H,
X = B[6] * U + B[7] * z + 1;
if (X === 0) continue;
let J = (B[0] * U + B[1] * z + B[2]) / X,
re = (B[3] * U + B[4] * z + B[5]) / X,
ne = GE(J, m, i),
ee = GE(re, l, i);
switch (a) {
case "nearest":
H = e7(F, l, m, b, w, S, L, ee, ne, j, p);
break;
case "bilinear":
H = t7(F, l, m, b, w, S, L, ee, ne, j, p);
break;
default:
throw new Error(`Error in Transform: Expect 'nearest' or 'bilinear', but got ${a}`);
}
let oe = L * _ + z * E + U * R + j;
D[oe] = H;
}
return o.makeTensorInfo(g, n.dtype, D);
}
return {
dataId: o.write(D, g, n.dtype),
shape: n.shape,
dtype: n.dtype
};
}
var HE = {
kernelName: Ts,
backendName: "cpu",
kernelFunc: XQ
};
function GE(r, e, t10) {
switch (t10) {
case "reflect":
return YQ(r, e);
case "wrap":
return QQ(r, e);
case "nearest":
return JQ(r, e);
case "constant":
default:
return ZQ(r, e);
}
}
function YQ(r, e) {
let t10 = r;
if (t10 < 0) {
if (e <= 1) t10 = 0;else {
let o = 2 * e;
t10 < o && (t10 = o * Math.trunc(-t10 / o) + t10), t10 = t10 < -e ? t10 + o : -t10 - 1;
}
} else if (t10 > e - 1) if (e <= 1) t10 = 0;else {
let o = 2 * e;
t10 -= o * Math.trunc(t10 / o), t10 >= e && (t10 = o - t10 - 1);
}
return y.clamp(0, t10, e - 1);
}
function QQ(r, e) {
let t10 = r;
if (t10 < 0) {
if (e <= 1) t10 = 0;else {
let o = e - 1;
t10 += e * (Math.trunc(-t10 / o) + 1);
}
} else if (t10 > e - 1) if (e <= 1) t10 = 0;else {
let o = e - 1;
t10 -= e * Math.trunc(t10 / o);
}
return y.clamp(0, t10, e - 1);
}
function ZQ(r, e) {
return r;
}
function JQ(r, e) {
return y.clamp(0, r, e - 1);
}
function Gl(r, e, t10, 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;
}
function e7(r, e, t10, o, n, s, a, i, p, u, c) {
let l = Math.round(i),
m = Math.round(p);
return Gl(r, e, t10, o, n, s, a, l, m, u, c);
}
function t7(r, e, t10, 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) * Gl(r, e, t10, o, n, s, a, l, m, u, c) + (p - m) * Gl(r, e, t10, o, n, s, a, l, f, u, c),
g = (f - p) * Gl(r, e, t10, o, n, s, a, d, m, u, c) + (p - m) * Gl(r, e, t10, o, n, s, a, d, f, u, c);
return (d - i) * h + (i - l) * g;
}
function r7(r) {
let {
inputs: e,
attrs: t10,
backend: o
} = r,
{
axis: n
} = t10,
{
x: s
} = e;
Y(s, "unique");
let a = o.data.get(s.dataId).values,
{
outputValues: i,
outputShape: p,
indices: u
} = lp(a, n, s.shape, s.dtype);
return [o.makeTensorInfo(p, s.dtype, i), o.makeTensorInfo([u.length], "int32", u)];
}
var KE = {
kernelName: qi,
backendName: "cpu",
kernelFunc: r7
};
function o7(r) {
let {
inputs: e,
backend: t10,
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 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 d = 0; d < m.length; d++) {
c[s] = d;
let f = Eo({
inputs: {
x: n
},
backend: t10,
attrs: {
begin: c,
size: l
}
});
m[d] = Ve({
inputs: {
x: f
},
backend: t10,
attrs: {
shape: p
}
}), t10.disposeIntermediateTensorInfo(f);
}
return m;
}
var qE = {
kernelName: da,
backendName: "cpu",
kernelFunc: o7
};
function n7(r) {
let {
inputs: e,
backend: t10,
attrs: o
} = r,
{
x: n,
segmentIds: s
} = e,
{
numSegments: a
} = o;
Y(n, "unsortedSegmentSum");
let i = n.shape.length,
p = s.shape.length,
u = [],
c = [],
l = i - p,
m = s;
for (let f = 0; f < l; ++f) {
let h = vc({
inputs: {
input: m
},
backend: t10,
attrs: {
dim: f + 1
}
});
m = h, c.push(h);
}
for (let f = 0; f < a; ++f) {
let h = y.createScalarValue(f, "int32"),
g = t10.makeTensorInfo([], "int32", h),
x = TS({
inputs: {
a: g,
b: m
},
backend: t10
}),
b = _o({
inputs: {
x
},
backend: t10,
attrs: {
dtype: "float32"
}
}),
w = sp({
inputs: {
a: b,
b: n
},
backend: t10
}),
S = li({
inputs: {
x: w
},
backend: t10,
attrs: {
axis: 0,
keepDims: false
}
});
u.push(S), c.push(g), c.push(x), c.push(b), c.push(w), c.push(S);
}
let d = aI({
inputs: u,
backend: t10,
attrs: {
axis: 0
}
});
return c.forEach(f => t10.disposeIntermediateTensorInfo(f)), d;
}
var jE = {
kernelName: ji,
backendName: "cpu",
kernelFunc: n7
};
var s7 = [C_, _T, w_, S_, AT, I_, v_, k_, N_, T_, __, $_, E_, R_, D_, F_, P_, O_, M_, b_, L_, B_, z_, FT, V_, DT, PT, W_, $T, U_, H_, K_, q_, j_, X_, Y_, Q_, Z_, J_, e$, t$, r$, o$, n$, s$, a$, i$, u$, p$, c$, l$, d$, d_, f$, OT, h$, MT, g$, LT, x$, y$, b$, BT, zT, C$, w$, S$, I$, VT, WT, ET, v$, G_, k$, N$, T$, f_, UT, GT, _$, HT, $$, E$, R$, D$, A$, F$, P$, KT, O$, M$, L$, B$, V$, W$, U$, qT, G$, H$, j$, jT, XT, X$, Y$, Q$, YT, Z$, tE, rE, Bf, oE, h_, ZT, nE, sE, aE, iE, RT, Vl, uE, g_, x_, y_, pE, cE, lE, mE, dE, fE, hE, o_, gE, yE, bE, CE, s_, wE, SE, IE, a_, K$, kE, NE, TE, _E, $E, EE, RE, DE, u_, AE, p_, c_, FE, PE, OE, ME, LE, l_, m$, BE, zE, VE, WE, UE, HE, QT, KE, qE, jE, J$];
for (let r of s7) Ya(r);
var _c = {};
He(_c, {
assertNotComplex: () => Ps,
bindCanvasToFramebuffer: () => f7,
bindColorTextureToFramebuffer: () => jl,
bindTextureToProgramUniformSampler: () => SI,
bindTextureUnit: () => ZE,
bindVertexBufferToProgramAttribute: () => Hf,
callAndCheck: () => ce,
canBeRepresented: () => cI,
createFragmentShader: () => mI,
createFramebuffer: () => bI,
createProgram: () => dI,
createStaticIndexBuffer: () => gI,
createStaticVertexBuffer: () => hI,
createTexture: () => xI,
createVertexShader: () => lI,
getBatchDim: () => di,
getExtensionOrThrow: () => kc,
getFramebufferErrorMessage: () => JE,
getMaxTexturesInShader: () => kI,
getNumChannels: () => m7,
getProgramUniformLocation: () => wI,
getProgramUniformLocationOrThrow: () => CI,
getRowsCols: () => fi,
getShapeAs3D: () => Tc,
getTextureShapeFromLogicalShape: () => II,
getWebGLDisjointQueryTimerVersion: () => NI,
getWebGLErrorMessage: () => QE,
getWebGLMaxTextureSize: () => vI,
hasExtension: () => Hr,
isCapableOfRenderingToFloatTexture: () => TI,
isDownloadFloatTextureEnabled: () => _I,
isReshapeFree: () => fu,
isWebGLFenceEnabled: () => $I,
isWebGLVersionEnabled: () => qf,
linkProgram: () => fI,
logShaderSourceAndInfoLog: () => Gf,
resetMaxTextureSize: () => h7,
resetMaxTexturesInShader: () => g7,
unbindColorTextureFromFramebuffer: () => Kf,
unbindTextureUnit: () => d7,
validateFramebuffer: () => Nc,
validateProgram: () => ql,
validateTextureSize: () => yI
});
var dp = {};
var zf = {
alpha: false,
antialias: false,
premultipliedAlpha: false,
preserveDrawingBuffer: false,
depth: false,
stencil: false,
failIfMajorPerformanceCaveat: true
};
function iI(r, e) {
dp[r] = e;
}
function Gr(r, e) {
if (!(r in dp) || e != null) {
let o = i7(r, e);
if (o !== null) dp[r] = o;else return console.log("Could not get context for WebGL version", r), null;
}
let t10 = dp[r];
return t10 == null || t10.isContextLost() ? (delete dp[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), dp[r]);
}
function a7(r) {
if (!P().getBool("IS_SAFARI") && 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 i7(r, e) {
if (r !== 1 && r !== 2) throw new Error("Cannot get WebGL rendering context, WebGL is disabled.");
let t10 = e == null ? a7(r) : e;
return t10.addEventListener("webglcontextlost", o => {
o.preventDefault(), delete dp[r];
}, false), P().getBool("SOFTWARE_WEBGL_ENABLED") && (zf.failIfMajorPerformanceCaveat = false), r === 1 ? t10.getContext("webgl", zf) || t10.getContext("experimental-webgl", zf) : t10.getContext("webgl2", zf);
}
var du;
(function (r) {
r[r.DENSE = 0] = "DENSE", r[r.SHARED_BATCH = 1] = "SHARED_BATCH";
})(du || (du = {}));
var mr;
(function (r) {
r[r.RENDER = 0] = "RENDER", r[r.UPLOAD = 1] = "UPLOAD", r[r.PIXELS = 2] = "PIXELS", r[r.DOWNLOAD = 3] = "DOWNLOAD";
})(mr || (mr = {}));
var er;
(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";
})(er || (er = {}));
function fp(r, e) {
return [e, r];
}
function XE(r, e) {
return r * e;
}
function Hl(r) {
let e = y.sizeFromShape(r),
t10 = Math.ceil(e / 4);
return y.sizeToSquarishShape(t10);
}
function Ea(r, e) {
return [Math.max(1, Math.ceil(e / 2)), Math.max(1, Math.ceil(r / 2))];
}
function YE(r, e) {
let [t10, o] = Ea(r, e);
return t10 * o * 4;
}
function Kl(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 ce(r, e) {
let t10 = e();
return P().getBool("DEBUG") && u7(r), t10;
}
function u7(r) {
let e = r.getError();
if (e !== r.NO_ERROR) throw new Error("WebGL Error: " + QE(r, e));
}
var p7 = 596e-10;
var c7 = 65504;
function cI(r) {
return !!(P().getBool("WEBGL_RENDER_FLOAT32_ENABLED") || r === 0 || p7 < Math.abs(r) && Math.abs(r) < c7);
}
function QE(r, e) {
switch (e) {
case r.NO_ERROR:
return "NO_ERROR";
case r.INVALID_ENUM:
return "INVALID_ENUM";
case r.INVALID_VALUE:
return "INVALID_VALUE";
case r.INVALID_OPERATION:
return "INVALID_OPERATION";
case r.INVALID_FRAMEBUFFER_OPERATION:
return "INVALID_FRAMEBUFFER_OPERATION";
case r.OUT_OF_MEMORY:
return "OUT_OF_MEMORY";
case r.CONTEXT_LOST_WEBGL:
return "CONTEXT_LOST_WEBGL";
default:
return `Unknown error code ${e}`;
}
}
function kc(r, e) {
return mi(r, () => r.getExtension(e), 'Extension "' + e + '" not supported on this browser.');
}
function lI(r, e) {
let t10 = mi(r, () => r.createShader(r.VERTEX_SHADER), "Unable to create vertex WebGLShader.");
if (ce(r, () => r.shaderSource(t10, e)), ce(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 mI(r, e) {
let t10 = mi(r, () => r.createShader(r.FRAGMENT_SHADER), "Unable to create fragment WebGLShader.");
if (ce(r, () => r.shaderSource(t10, e)), ce(r, () => r.compileShader(t10)), P().get("ENGINE_COMPILE_ONLY")) return t10;
if (r.getShaderParameter(t10, r.COMPILE_STATUS) === false) throw Gf(e, r.getShaderInfoLog(t10)), new Error("Failed to compile fragment shader.");
return t10;
}
var l7 = /ERROR: [0-9]+:([0-9]+):/g;
function Gf(r, e) {
let t10 = l7.exec(e);
if (t10 == 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) => 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 ${y.rightPad(u[0], i)}`, "border:1px solid red; background-color:#e3d2d2; color:#a61717"), console.log(c.join(`
`));
}
function dI(r) {
return mi(r, () => r.createProgram(), "Unable to create WebGLProgram.");
}
function fI(r, e) {
if (ce(r, () => r.linkProgram(e)), !P().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 ql(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 = mi(r, () => r.createBuffer(), "Unable to create WebGLBuffer");
return ce(r, () => r.bindBuffer(r.ARRAY_BUFFER, t10)), ce(r, () => r.bufferData(r.ARRAY_BUFFER, e, r.STATIC_DRAW)), t10;
}
function gI(r, e) {
let t10 = mi(r, () => r.createBuffer(), "Unable to create WebGLBuffer");
return ce(r, () => r.bindBuffer(r.ELEMENT_ARRAY_BUFFER, t10)), ce(r, () => r.bufferData(r.ELEMENT_ARRAY_BUFFER, e, r.STATIC_DRAW)), t10;
}
function m7() {
return P().getNumber("WEBGL_VERSION") === 2 ? 1 : 4;
}
function xI(r) {
return mi(r, () => r.createTexture(), "Unable to create WebGLTexture.");
}
function yI(r, e) {
let t10 = P().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}]`;
throw new Error("Requested texture size " + o + " greater than WebGL maximum on this browser / GPU " + n + ".");
}
}
function bI(r) {
return mi(r, () => r.createFramebuffer(), "Unable to create WebGLFramebuffer.");
}
function Hf(r, e, t10, o, n, s, a) {
let i = r.getAttribLocation(e, t10);
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 ZE(r, e, t10) {
eR(r, t10), ce(r, () => r.activeTexture(r.TEXTURE0 + t10)), ce(r, () => r.bindTexture(r.TEXTURE_2D, e));
}
function d7(r, e) {
eR(r, e), ce(r, () => r.activeTexture(r.TEXTURE0 + e)), ce(r, () => r.bindTexture(r.TEXTURE_2D, null));
}
function CI(r, e, t10) {
return mi(r, () => r.getUniformLocation(e, t10), 'uniform "' + t10 + '" not present in program.');
}
function wI(r, e, t10) {
return r.getUniformLocation(e, t10);
}
function SI(r, e, t10, o) {
ce(r, () => ZE(r, e, o)), ce(r, () => r.uniform1i(t10, o));
}
function f7(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 jl(r, e, t10) {
ce(r, () => r.bindFramebuffer(r.FRAMEBUFFER, t10)), ce(r, () => r.framebufferTexture2D(r.FRAMEBUFFER, r.COLOR_ATTACHMENT0, r.TEXTURE_2D, e, 0));
}
function Kf(r, e) {
ce(r, () => r.bindFramebuffer(r.FRAMEBUFFER, e)), ce(r, () => r.framebufferTexture2D(r.FRAMEBUFFER, r.COLOR_ATTACHMENT0, r.TEXTURE_2D, null, 0));
}
function Nc(r) {
let e = r.checkFramebufferStatus(r.FRAMEBUFFER);
if (e !== r.FRAMEBUFFER_COMPLETE) throw new Error("Error binding framebuffer: " + JE(r, e));
}
function JE(r, e) {
switch (e) {
case r.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
return "FRAMEBUFFER_INCOMPLETE_ATTACHMENT";
case r.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
return "FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT";
case r.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:
return "FRAMEBUFFER_INCOMPLETE_DIMENSIONS";
case r.FRAMEBUFFER_UNSUPPORTED:
return "FRAMEBUFFER_UNSUPPORTED";
default:
return `unknown error ${e}`;
}
}
function mi(r, e, t10) {
let o = ce(r, () => e());
if (o == null) throw new Error(t10);
return o;
}
function eR(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}]`;
throw new Error(`textureUnit must be in ${n}.`);
}
}
function di(r, e = 2) {
return y.sizeFromShape(r.slice(0, r.length - e));
}
function fi(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 Tc(r) {
let e = [1, 1, 1];
return r.length === 0 || r.length === 1 && r[0] === 1 || (e = [di(r), ...fi(r)]), e;
}
function II(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 ? 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 <= 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]]);
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 = di(r),
p = 2,
u = 2;
r.length && ([p, u] = fi(r)), n = i * (p / 2) * (u / 2), s = y.sizeToSquarishShape(n).map(c => c * 2);
} else s = y.sizeToSquarishShape(n);
return s;
}
function Vf(r) {
return r % 2 === 0;
}
function fu(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[r.length - 1],
o = e[e.length - 1];
if (t10 === o || Vf(t10) && Vf(o) && (r[0] === 1 || e[0] === 1)) return true;
}
return r[1] === e[1] && Vf(r[0]) && Vf(e[0]);
}
var Wf;
var Uf;
function vI(r) {
if (Wf == null) {
let e = Gr(r);
Wf = e.getParameter(e.MAX_TEXTURE_SIZE);
}
return Wf;
}
function h7() {
Wf = null;
}
function g7() {
Uf = null;
}
function kI(r) {
if (Uf == null) {
let e = Gr(r);
Uf = e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS);
}
return Math.min(16, Uf);
}
function NI(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;
}
function Hr(r, e) {
return r.getExtension(e) != null;
}
function qf(r) {
try {
if (Gr(r) != null) return true;
} catch (e) {
return console.log("Error when getting WebGL context: ", e), false;
}
return false;
}
function TI(r) {
if (r === 0) return false;
let e = Gr(r);
if (r === 1) {
if (!Hr(e, "OES_texture_float")) return false;
} else if (!Hr(e, "EXT_color_buffer_float")) return false;
return pI(e);
}
function _I(r) {
if (r === 0) return false;
let e = Gr(r);
if (r === 1) {
if (!Hr(e, "OES_texture_float") || !Hr(e, "WEBGL_color_buffer_float")) return false;
} else {
if (Hr(e, "EXT_color_buffer_float")) return pI(e);
let o = "EXT_color_buffer_half_float";
if (Hr(e, o)) {
let n = e.getExtension(o);
return x7(e, n);
}
return false;
}
return pI(e);
}
function pI(r) {
let e = Kl(r),
t10 = r.createTexture();
r.bindTexture(r.TEXTURE_2D, t10);
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);
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;
}
function x7(r, e) {
let t10 = Kl(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);
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 $I(r) {
return r !== 2 ? false : Gr(r).fenceSync != null;
}
function Ps(r, e) {
Array.isArray(r) || (r = [r]), r.forEach(t10 => {
t10 != null && y.assert(t10.dtype !== "complex64", () => `${e} does not support complex64 tensors in the WebGL backend.`);
});
}
var Se = P();
Se.registerFlag("HAS_WEBGL", () => Se.getNumber("WEBGL_VERSION") > 0);
Se.registerFlag("WEBGL_VERSION", () => qf(2) ? 2 : qf(1) ? 1 : 0);
Se.registerFlag("WEBGL_CHECK_NUMERICAL_PROBLEMS", () => false);
Se.registerFlag("WEBGL_BUFFER_SUPPORTED", () => Se.get("WEBGL_VERSION") === 2);
Se.registerFlag("WEBGL_CPU_FORWARD", () => true);
Se.registerFlag("WEBGL_FORCE_F16_TEXTURES", () => false);
Se.registerFlag("WEBGL_PACK", () => Se.getBool("HAS_WEBGL"));
Se.registerFlag("WEBGL_PACK_NORMALIZATION", () => Se.getBool("WEBGL_PACK"));
Se.registerFlag("WEBGL_PACK_CLIP", () => Se.getBool("WEBGL_PACK"));
Se.registerFlag("WEBGL_PACK_DEPTHWISECONV", () => Se.getBool("WEBGL_PACK"));
Se.registerFlag("WEBGL_PACK_BINARY_OPERATIONS", () => Se.getBool("WEBGL_PACK"));
Se.registerFlag("WEBGL_PACK_UNARY_OPERATIONS", () => Se.getBool("WEBGL_PACK"));
Se.registerFlag("WEBGL_PACK_ARRAY_OPERATIONS", () => Se.getBool("WEBGL_PACK"));
Se.registerFlag("WEBGL_PACK_IMAGE_OPERATIONS", () => Se.getBool("WEBGL_PACK"));
Se.registerFlag("WEBGL_PACK_REDUCE", () => Se.getBool("WEBGL_PACK"));
Se.registerFlag("WEBGL_LAZILY_UNPACK", () => Se.getBool("WEBGL_PACK"));
Se.registerFlag("WEBGL_CONV_IM2COL", () => Se.getBool("WEBGL_PACK"));
Se.registerFlag("WEBGL_MAX_TEXTURE_SIZE", () => vI(Se.getNumber("WEBGL_VERSION")));
Se.registerFlag("WEBGL_MAX_TEXTURES_IN_SHADER", () => kI(Se.getNumber("WEBGL_VERSION")));
Se.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION", () => {
let r = Se.getNumber("WEBGL_VERSION");
return r === 0 ? 0 : NI(r);
});
Se.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE", () => Se.getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION") > 0 && !Zi.isMobile());
Se.registerFlag("WEBGL_RENDER_FLOAT32_CAPABLE", () => TI(Se.getNumber("WEBGL_VERSION")));
Se.registerFlag("WEBGL_RENDER_FLOAT32_ENABLED", () => Se.getBool("WEBGL_FORCE_F16_TEXTURES") ? false : Se.getBool("WEBGL_RENDER_FLOAT32_CAPABLE"));
Se.registerFlag("WEBGL_DOWNLOAD_FLOAT_ENABLED", () => _I(Se.getNumber("WEBGL_VERSION")));
Se.registerFlag("WEBGL_FENCE_API_ENABLED", () => $I(Se.getNumber("WEBGL_VERSION")));
Se.registerFlag("WEBGL_SIZE_UPLOAD_UNIFORM", () => Se.getBool("WEBGL_RENDER_FLOAT32_ENABLED") ? 4 : 0);
Se.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}.`);
});
Se.registerFlag("WEBGL_FLUSH_THRESHOLD", () => Zi.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}.`);
});
Se.registerFlag("CPU_HANDOFF_SIZE_THRESHOLD", () => 128);
Se.registerFlag("WEBGL_USE_SHAPES_UNIFORMS", () => false);
Se.registerFlag("TOPK_LAST_DIM_CPU_HANDOFF_SIZE_THRESHOLD", () => 1e5);
Se.registerFlag("TOPK_K_CPU_HANDOFF_THRESHOLD", () => 128);
Se.registerFlag("WEBGL_EXP_CONV", () => false);
Se.registerFlag("SOFTWARE_WEBGL_ENABLED", () => Se.getBool("IS_TEST"));
Se.registerFlag("WEBGL_MAX_SIZE_FOR_NARROW_TEXTURE", () => 1 / 0);
Se.registerFlag("WEBGL_AUTO_SQUARIFY_NARROW_TEXTURE_SHAPE", () => false);
Se.registerFlag("WEBGL2_ISNAN_CUSTOM", () => false);
Se.registerFlag("ENGINE_COMPILE_ONLY", () => false);
function It() {
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") ? `
bool isnan_custom(float val) {
uint floatToUint = floatBitsToUint(val);
return (floatToUint & 0x7fffffffu) > 0x7f800000u;
}
bvec4 isnan_custom(vec4 val) {
return bvec4(isnan_custom(val.x),
isnan_custom(val.y), isnan_custom(val.z), isnan_custom(val.w));
}
#define isnan(value) isnan_custom(value)
` : "", p = "", u = `
#define round(value) newRound(value)
int newRound(float value) {
return int(floor(value + 0.5));
}
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 = `
#define isnan(value) isnan_custom(value)
bool isnan_custom(float val) {
return (val > 0. || val < 1. || val == 0.) ? false : true;
}
bvec4 isnan_custom(vec4 val) {
return bvec4(isnan(val.x), isnan(val.y), isnan(val.z), isnan(val.w));
}
`, p = `
uniform float INFINITY;
bool isinf(float val) {
return abs(val) == INFINITY;
}
bvec4 isinf(vec4 val) {
return equal(abs(val), vec4(INFINITY));
}
`, u = `
int round(float value) {
return int(floor(value + 0.5));
}
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
};
}
function Os(r, e, t10 = "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}`;
return `${a}; ${i};`;
}).join("");
}
function hp(r, e, t10 = "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}]`;
return `${a}; ${i};`;
}).join("");
}
function y7(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) n[s] = `(${n[s + 1]} * ${o[s + 1]})`;
return n;
}
function tR(r, e, t10 = "index") {
let o = r.map((s, a) => a),
n = y7(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]}`;
return `${i}; ${p};`;
}).join("");
}
function $c(r) {
let e = y.computeStrides(r).map(t10 => t10.toString());
return `
int getFlatIndex(ivec3 coords) {
return coords.x * ${e[0]} + coords.y * ${e[1]} + coords.z;
}
`;
}
function Ec() {
return `
int getFlatIndex(ivec3 coords) {
return coords.x * outShapeStrides[0] + coords.y * outShapeStrides[1] + coords.z;
}
`;
}
var jf = `
const float FLOAT_MAX = 1.70141184e38;
const float FLOAT_MIN = 1.17549435e-38;
lowp vec4 encode_float(highp float v) {
if (isnan(v)) {
return vec4(255, 255, 255, 255);
}
highp float av = abs(v);
if(av < FLOAT_MIN) {
return vec4(0.0, 0.0, 0.0, 0.0);
} else if(v > FLOAT_MAX) {
return vec4(0.0, 0.0, 128.0, 127.0) / 255.0;
} else if(v < -FLOAT_MAX) {
return vec4(0.0, 0.0, 128.0, 255.0) / 255.0;
}
highp vec4 c = vec4(0,0,0,0);
highp float e = floor(log2(av));
highp float m = exp2(fract(log2(av))) - 1.0;
c[2] = floor(128.0 * m);
m -= c[2] / 128.0;
c[1] = floor(32768.0 * m);
m -= c[1] / 32768.0;
c[0] = floor(8388608.0 * m);
highp float ebias = e + 127.0;
c[3] = floor(ebias / 2.0);
ebias -= c[3] * 2.0;
c[2] += floor(ebias) * 128.0;
c[3] += 128.0 * step(0.0, -v);
return c / 255.0;
}
`;
var {
getBroadcastDims: rR
} = C;
function oR(r, e, t10) {
let o = [];
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};`)), t10.enableShapeUniforms) {
let {
uniformShape: h
} = Xf(t10.packedInputs, d.shapeInfo.logicalShape, d.shapeInfo.texShape);
switch (h.length) {
case 1:
o.push(`uniform int ${d.name}Shape;`);
break;
case 2:
o.push(`uniform ivec2 ${d.name}Shape;`);
break;
case 3:
o.push(`uniform ivec3 ${d.name}Shape;`);
break;
case 4:
o.push(`uniform ivec4 ${d.name}Shape;`);
break;
default:
break;
}
o.push(`uniform ivec2 ${d.name}TexShape;`);
}
}), t10.enableShapeUniforms) {
switch (e.logicalShape.length) {
case 1:
o.push("uniform int outShape;");
break;
case 2:
o.push("uniform ivec2 outShape;"), o.push("uniform int outShapeStrides;");
break;
case 3:
o.push("uniform ivec3 outShape;"), o.push("uniform ivec2 outShapeStrides;");
break;
case 4:
o.push("uniform ivec4 outShape;"), o.push("uniform ivec3 outShapeStrides;");
break;
default:
break;
}
o.push("uniform ivec2 outTexShape;");
}
t10.customUniforms && t10.customUniforms.forEach(d => {
o.push(`uniform ${d.type} ${d.name}${d.arrayIndex ? `[${d.arrayIndex}]` : ""};`);
});
let n = o.join(`
`),
s = r.map(d => b7(d, e, t10.packedInputs, t10.enableShapeUniforms)).join(`
`),
a = e.texShape,
i = It(),
p = S7(i),
u,
c,
l = k7(i);
return e.isPacked ? (u = C7(e.logicalShape, a, t10.enableShapeUniforms), c = v7(i)) : (u = w7(e.logicalShape, a, t10.enableShapeUniforms), c = I7(i)), t10.packedInputs && (l += $7), [l, p, c, n, u, s, t10.userCode].join(`
`);
}
function Dc(r, e = false) {
let t10 = r.shapeInfo.logicalShape;
switch (t10.length) {
case 0:
return V7(r, e);
case 1:
return U7(r, e);
case 2:
return H7(r, e);
case 3:
return q7(r, e);
case 4:
return X7(r, e);
case 5:
return Y7(r);
case 6:
return Q7(r);
default:
throw new Error(`${t10.length}-D input sampling is not yet supported`);
}
}
function nR(r, e) {
switch (r.shapeInfo.logicalShape.length) {
case 0:
return z7(r);
case 1:
return W7(r, e);
case 2:
return G7(r, e);
case 3:
return K7(r, e);
default:
return j7(r, e);
}
}
function b7(r, e, t10 = false, o) {
let n = "";
t10 ? n += nR(r, o) : n += Dc(r, o);
let s = r.shapeInfo.logicalShape,
a = e.logicalShape;
return s.length <= a.length && (t10 ? n += Z7(r, e) : n += J7(r, e)), n;
}
function C7(r, e, t10) {
switch (r.length) {
case 0:
return sR();
case 1:
return E7(r, e, t10);
case 2:
return L7(r, e, t10);
case 3:
return D7(r, e, t10);
default:
return F7(r, e, t10);
}
}
function w7(r, e, t10) {
switch (r.length) {
case 0:
return sR();
case 1:
return R7(r, e, t10);
case 2:
return B7(r, e, t10);
case 3:
return A7(r, e, t10);
case 4:
return P7(r, e, t10);
case 5:
return O7(r, e);
case 6:
return M7(r, e);
default:
throw new Error(`${r.length}-D output sampling is not yet supported`);
}
}
function S7(r) {
return `
float sampleTexture(sampler2D textureSampler, vec2 uv) {
return ${r.texture2D}(textureSampler, uv).r;
}
`;
}
function I7(r) {
return `
void setOutput(float val) {
${r.output} = vec4(val, 0, 0, 0);
}
`;
}
function v7(r) {
return `
void setOutput(vec4 val) {
${r.output} = val;
}
`;
}
function k7(r) {
return `${r.version}
precision highp float;
precision highp int;
precision highp sampler2D;
${r.varyingFs} vec2 resultUV;
${r.defineOutput}
const vec2 halfCR = vec2(0.5, 0.5);
struct ivec5
{
int x;
int y;
int z;
int w;
int u;
};
struct ivec6
{
int x;
int y;
int z;
int w;
int u;
int v;
};
uniform float NAN;
${r.defineSpecialNaN}
${r.defineSpecialInf}
${r.defineRound}
int imod(int x, int y) {
return x - y * (x / y);
}
int idiv(int a, int b, float sign) {
int res = a / b;
int mod = imod(a, b);
if (sign < 0. && mod != 0) {
res -= 1;
}
return res;
}
//Based on the work of Dave Hoskins
//https://www.shadertoy.com/view/4djSRW
#define HASHSCALE1 443.8975
float random(float seed){
vec2 p = resultUV * seed;
vec3 p3 = fract(vec3(p.xyx) * HASHSCALE1);
p3 += dot(p3, p3.yzx + 19.19);
return fract((p3.x + p3.y) * p3.z);
}
${N7}
${T7}
${_7}
`;
}
var N7 = `
vec2 uvFromFlat(int texNumR, int texNumC, int index) {
int texR = index / texNumC;
int texC = index - texR * texNumC;
return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);
}
vec2 packedUVfrom1D(int texNumR, int texNumC, int index) {
int texelIndex = index / 2;
int texR = texelIndex / texNumC;
int texC = texelIndex - texR * texNumC;
return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);
}
`;
var T7 = `
vec2 packedUVfrom2D(int texelsInLogicalRow, int texNumR,
int texNumC, int row, int col) {
int texelIndex = (row / 2) * texelsInLogicalRow + (col / 2);
int texR = texelIndex / texNumC;
int texC = texelIndex - texR * texNumC;
return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);
}
`;
var _7 = `
vec2 packedUVfrom3D(int texNumR, int texNumC,
int texelsInBatch, int texelsInLogicalRow, int b,
int row, int col) {
int index = b * texelsInBatch + (row / 2) * texelsInLogicalRow + (col / 2);
int texR = index / texNumC;
int texC = index - texR * texNumC;
return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);
}
`;
var $7 = `
float getChannel(vec4 frag, vec2 innerDims) {
vec2 modCoord = mod(innerDims, 2.);
return modCoord.x == 0. ?
(modCoord.y == 0. ? frag.r : frag.g) :
(modCoord.y == 0. ? frag.b : frag.a);
}
float getChannel(vec4 frag, int dim) {
float modCoord = mod(float(dim), 2.);
return modCoord == 0. ? frag.r : frag.g;
}
`;
function sR() {
return `
int getOutputCoords() {
return 0;
}
`;
}
function E7(r, e, t10) {
let o = [Math.ceil(e[0] / 2), Math.ceil(e[1] / 2)];
return o[0] === 1 ? t10 ? `
int getOutputCoords() {
return 2 * int(resultUV.x * ceil(float(outTexShape[1]) / 2.0));
}
` : `
int getOutputCoords() {
return 2 * int(resultUV.x * ${o[1]}.0);
}
` : o[1] === 1 ? t10 ? `
int getOutputCoords() {
return 2 * int(resultUV.y * ceil(float(outTexShape[0]) / 2.0));
}
` : `
int getOutputCoords() {
return 2 * int(resultUV.y * ${o[0]}.0);
}
` : t10 ? `
int getOutputCoords() {
ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(packedTexShape[0], packedTexShape[1]));
return 2 * (resTexRC.x * packedTexShape[1] + resTexRC.y);
}
` : `
int getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(${o[0]}, ${o[1]}));
return 2 * (resTexRC.x * ${o[1]} + resTexRC.y);
}
`;
}
function R7(r, e, t10) {
return e[0] === 1 ? t10 ? `
int getOutputCoords() {
return int(resultUV.x * float(outTexShape[1]));
}
` : `
int getOutputCoords() {
return int(resultUV.x * ${e[1]}.0);
}
` : e[1] === 1 ? t10 ? `
int getOutputCoords() {
return int(resultUV.y * float(outTexShape[0]));
}
` : `
int getOutputCoords() {
return int(resultUV.y * ${e[0]}.0);
}
` : t10 ? `
int getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(outTexShape[0], outTexShape[1]));
return resTexRC.x * outTexShape[1] + resTexRC.y;
}
` : `
int getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(${e[0]}, ${e[1]}));
return resTexRC.x * ${e[1]} + resTexRC.y;
}
`;
}
function D7(r, e, t10) {
if (t10) return `
ivec3 getOutputCoords() {
ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));
int texelsInLogicalRow = int(ceil(float(outShape[2]) / 2.0));
int texelsInBatch = texelsInLogicalRow * int(ceil(float(outShape[1]) / 2.0));
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(packedTexShape[0], packedTexShape[1]));
int index = resTexRC.x * packedTexShape[1] + resTexRC.y;
int b = index / texelsInBatch;
index -= b * texelsInBatch;
int r = 2 * (index / texelsInLogicalRow);
int c = imod(index, texelsInLogicalRow) * 2;
return ivec3(b, r, c);
}
`;
let o = [Math.ceil(e[0] / 2), Math.ceil(e[1] / 2)],
n = Math.ceil(r[2] / 2),
s = n * Math.ceil(r[1] / 2);
return `
ivec3 getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(${o[0]}, ${o[1]}));
int index = resTexRC.x * ${o[1]} + resTexRC.y;
int b = index / ${s};
index -= b * ${s};
int r = 2 * (index / ${n});
int c = imod(index, ${n}) * 2;
return ivec3(b, r, c);
}
`;
}
function A7(r, e, t10) {
if (t10) return `
ivec3 getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(outTexShape[0], outTexShape[1]));
int index = resTexRC.x * outTexShape[1] + resTexRC.y;
${hp(["r", "c", "d"], r)}
return ivec3(r, c, d);
}
`;
let o = Os(["r", "c", "d"], r);
return `
ivec3 getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(${e[0]}, ${e[1]}));
int index = resTexRC.x * ${e[1]} + resTexRC.y;
${o}
return ivec3(r, c, d);
}
`;
}
function F7(r, e, t10) {
if (t10) return `
ivec4 getOutputCoords() {
ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(packedTexShape[0], packedTexShape[1]));
int index = resTexRC.x * packedTexShape[1] + resTexRC.y;
int texelsInLogicalRow = int(ceil(float(outShape[3]) / 2.0));
int texelsInBatch = texelsInLogicalRow * int(ceil(float(outShape[2]) / 2.0));
int texelsInBatchN = texelsInBatch * outShape[1];
int b2 = index / texelsInBatchN;
index -= b2 * texelsInBatchN;
int b = index / texelsInBatch;
index -= b * texelsInBatch;
int r = 2 * (index / texelsInLogicalRow);
int c = imod(index, texelsInLogicalRow) * 2;
return ivec4(b2, b, r, c);
}
`;
let o = [Math.ceil(e[0] / 2), Math.ceil(e[1] / 2)],
n = Math.ceil(r[r.length - 1] / 2),
s = n * Math.ceil(r[r.length - 2] / 2),
a = s,
i = "",
p = "b, r, c";
for (let u = 2; u < r.length - 1; u++) a *= r[r.length - u - 1], i = `
int b${u} = index / ${a};
index -= b${u} * ${a};
` + i, p = `b${u}, ` + p;
return `
ivec${r.length} getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(${o[0]}, ${o[1]}));
int index = resTexRC.x * ${o[1]} + resTexRC.y;
${i}
int b = index / ${s};
index -= b * ${s};
int r = 2 * (index / ${n});
int c = imod(index, ${n}) * 2;
return ivec${r.length}(${p});
}
`;
}
function P7(r, e, t10) {
if (t10) return `
ivec4 getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(outTexShape[0], outTexShape[1]));
int index = resTexRC.x * outTexShape[1] + resTexRC.y;
${hp(["r", "c", "d", "d2"], r)}
return ivec4(r, c, d, d2);
}
`;
let o = Os(["r", "c", "d", "d2"], r);
return `
ivec4 getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(${e[0]}, ${e[1]}));
int index = resTexRC.x * ${e[1]} + resTexRC.y;
${o}
return ivec4(r, c, d, d2);
}
`;
}
function O7(r, e) {
let t10 = Os(["r", "c", "d", "d2", "d3"], r);
return `
ivec5 getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx * vec2(${e[0]},
${e[1]}));
int index = resTexRC.x * ${e[1]} + resTexRC.y;
${t10}
ivec5 outShape = ivec5(r, c, d, d2, d3);
return outShape;
}
`;
}
function M7(r, e) {
let t10 = Os(["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}
ivec6 result = ivec6(r, c, d, d2, d3, d4);
return result;
}
`;
}
function L7(r, e, t10) {
let o = [Math.ceil(e[0] / 2), Math.ceil(e[1] / 2)];
if (y.arraysEqual(r, e)) return t10 ? `
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]));
}
` : `
ivec2 getOutputCoords() {
return 2 * ivec2(resultUV.yx * vec2(${o[0]}, ${o[1]}));
}
`;
let n = Math.ceil(r[1] / 2);
return t10 ? `
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));
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(packedTexShape[0], packedTexShape[1]));
int index = resTexRC.x * packedTexShape[1] + resTexRC.y;
int r = 2 * (index / texelsInLogicalRow);
int c = imod(index, texelsInLogicalRow) * 2;
return ivec2(r, c);
}
` : `
ivec2 getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(${o[0]}, ${o[1]}));
int index = resTexRC.x * ${o[1]} + resTexRC.y;
int r = 2 * (index / ${n});
int c = imod(index, ${n}) * 2;
return ivec2(r, c);
}
`;
}
function B7(r, e, t10) {
return y.arraysEqual(r, e) ? t10 ? `
ivec2 getOutputCoords() {
return ivec2(resultUV.yx * vec2(outTexShape[0], outTexShape[1]));
}
` : `
ivec2 getOutputCoords() {
return ivec2(resultUV.yx * vec2(${e[0]}, ${e[1]}));
}
` : r[1] === 1 ? t10 ? `
ivec2 getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(outTexShape[0], outTexShape[1]));
int index = resTexRC.x * outTexShape[1] + resTexRC.y;
return ivec2(index, 0);
}
` : `
ivec2 getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(${e[0]}, ${e[1]}));
int index = resTexRC.x * ${e[1]} + resTexRC.y;
return ivec2(index, 0);
}
` : r[0] === 1 ? t10 ? `
ivec2 getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(outTexShape[0], outTexShape[1]));
int index = resTexRC.x * outTexShape[1] + resTexRC.y;
return ivec2(0, index);
}
` : `
ivec2 getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(${e[0]}, ${e[1]}));
int index = resTexRC.x * ${e[1]} + resTexRC.y;
return ivec2(0, index);
}
` : t10 ? `
ivec2 getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(outTexShape[0], outTexShape[1]));
int index = resTexRC.x * outTexShape[1] + resTexRC.y;
int r = index / outShape[1];
int c = index - r * outShape[1];
return ivec2(r, c);
}
` : `
ivec2 getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(${e[0]}, ${e[1]}));
int index = resTexRC.x * ${e[1]} + resTexRC.y;
int r = index / ${r[1]};
int c = index - r * ${r[1]};
return ivec2(r, c);
}
`;
}
function gp(r) {
return `offset${r}`;
}
function z7(r) {
let e = r.name,
t10 = "get" + e.charAt(0).toUpperCase() + e.slice(1),
o = It();
return `
vec4 ${t10}() {
return ${o.texture2D}(${e}, halfCR);
}
`;
}
function V7(r, e) {
let t10 = r.name,
o = "get" + t10.charAt(0).toUpperCase() + t10.slice(1);
if (r.shapeInfo.isUniform) return `float ${o}() {return ${t10};}`;
let [n, s] = r.shapeInfo.texShape;
if (n === 1 && s === 1) return `
float ${o}() {
return sampleTexture(${t10}, halfCR);
}
`;
let a = gp(t10);
if (e) return `
float ${o}() {
vec2 uv = uvFromFlat(${t10}TexShape[0], ${t10}TexShape[1], ${a});
return sampleTexture(${t10}, uv);
}
`;
let [i, p] = r.shapeInfo.texShape;
return `
float ${o}() {
vec2 uv = uvFromFlat(${i}, ${p}, ${a});
return sampleTexture(${t10}, uv);
}
`;
}
function W7(r, e) {
let t10 = r.name,
o = "get" + t10.charAt(0).toUpperCase() + t10.slice(1),
n = r.shapeInfo.texShape,
s = It();
if (e) return `
vec4 ${o}(int index) {
ivec2 packedTexShape = ivec2(ceil(float(${t10}TexShape[0]) / 2.0), ceil(float(${t10}TexShape[1]) / 2.0));
vec2 uv = packedUVfrom1D(
packedTexShape[0], packedTexShape[1], index);
return ${s.texture2D}(${t10}, uv);
}
`;
let a = [Math.ceil(n[0] / 2), Math.ceil(n[1] / 2)];
return `
vec4 ${o}(int index) {
vec2 uv = packedUVfrom1D(
${a[0]}, ${a[1]}, index);
return ${s.texture2D}(${t10}, uv);
}
`;
}
function U7(r, e) {
let t10 = r.name,
o = "get" + t10.charAt(0).toUpperCase() + t10.slice(1);
if (r.shapeInfo.isUniform) return `
float ${o}(int index) {
${Ac(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);
}
`;
let i = gp(t10);
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);
}
` : `
float ${o}(int index) {
vec2 uv = vec2(0.5, (float(index + ${i}) + 0.5) / ${s}.0);
return sampleTexture(${t10}, 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);
}
` : `
float ${o}(int index) {
vec2 uv = vec2((float(index + ${i}) + 0.5) / ${a}.0, 0.5);
return sampleTexture(${t10}, uv);
}
` : e ? `
float ${o}(int index) {
vec2 uv = uvFromFlat(${t10}TexShape[0], ${t10}TexShape[1], index + ${i});
return sampleTexture(${t10}, uv);
}
` : `
float ${o}(int index) {
vec2 uv = uvFromFlat(${s}, ${a}, index + ${i});
return sampleTexture(${t10}, uv);
}
`;
}
function G7(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 = It();
if (s != null && y.arraysEqual(t10, s)) return e ? `
vec4 ${n}(int row, int col) {
vec2 uv = (vec2(col, row) + halfCR) / vec2(${o}TexShape[1], ${o}TexShape[0]);
return ${p.texture2D}(${o}, uv);
}
` : `
vec4 ${n}(int row, int col) {
vec2 uv = (vec2(col, row) + halfCR) / vec2(${i}.0, ${a}.0);
return ${p.texture2D}(${o}, uv);
}
`;
if (e) return `
vec4 ${n}(int row, int col) {
ivec2 packedTexShape = ivec2(ceil(float(${o}TexShape[0]) / 2.0), ceil(float(${o}TexShape[1]) / 2.0));
int valuesPerRow = int(ceil(float(${o}Shape[1]) / 2.0));
vec2 uv = packedUVfrom2D(valuesPerRow, packedTexShape[0], packedTexShape[1], row, col);
return ${p.texture2D}(${o}, uv);
}
`;
let u = [Math.ceil(s[0] / 2), Math.ceil(s[1] / 2)],
c = Math.ceil(t10[1] / 2);
return `
vec4 ${n}(int row, int col) {
vec2 uv = packedUVfrom2D(${c}, ${u[0]}, ${u[1]}, row, col);
return ${p.texture2D}(${o}, uv);
}
`;
}
function H7(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 && y.arraysEqual(t10, s)) {
if (e) return `
float ${n}(int row, int col) {
vec2 uv = (vec2(col, row) + halfCR) / vec2(${o}TexShape[1], ${o}TexShape[0]);
return sampleTexture(${o}, uv);
}
`;
let m = s[0],
d = s[1];
return `
float ${n}(int row, int col) {
vec2 uv = (vec2(col, row) + halfCR) / vec2(${d}.0, ${m}.0);
return sampleTexture(${o}, uv);
}
`;
}
let {
newShape: a,
keptDims: i
} = y.squeezeShape(t10),
p = a;
if (p.length < t10.length) {
let m = Fc(r, p),
d = ["row", "col"];
return `
${Dc(m, e)}
float ${n}(int row, int col) {
return ${n}(${Pc(d, i)});
}
`;
}
if (r.shapeInfo.isUniform) return `
float ${n}(int row, int col) {
int index = round(dot(vec2(row, col), vec2(${t10[1]}, 1)));
${Ac(r)}
}
`;
let u = s[0],
c = s[1],
l = gp(o);
return c === 1 ? e ? `
float ${n}(int row, int col) {
float index = dot(vec3(row, col, ${l}), vec3(${o}Shape[1], 1, 1));
vec2 uv = vec2(0.5, (index + 0.5) / float(${o}TexShape[0]));
return sampleTexture(${o}, uv);
}
` : `
float ${n}(int row, int col) {
float index = dot(vec3(row, col, ${l}), vec3(${t10[1]}, 1, 1));
vec2 uv = vec2(0.5, (index + 0.5) / ${u}.0);
return sampleTexture(${o}, uv);
}
` : u === 1 ? e ? `
float ${n}(int row, int col) {
float index = dot(vec3(row, col, ${l}), vec3(${o}Shape[1], 1, 1));
vec2 uv = vec2((index + 0.5) / float(${o}TexShape[1]), 0.5);
return sampleTexture(${o}, uv);
}
` : `
float ${n}(int row, int col) {
float index = dot(vec3(row, col, ${l}), vec3(${t10[1]}, 1, 1));
vec2 uv = vec2((index + 0.5) / ${c}.0, 0.5);
return sampleTexture(${o}, uv);
}
` : e ? `
float ${n}(int row, int col) {
// Explicitly use integer operations as dot() only works on floats.
int index = row * ${o}Shape[1] + col + ${l};
vec2 uv = uvFromFlat(${o}TexShape[0], ${o}TexShape[1], index);
return sampleTexture(${o}, uv);
}
` : `
float ${n}(int row, int col) {
// Explicitly use integer operations as dot() only works on floats.
int index = row * ${t10[1]} + col + ${l};
vec2 uv = uvFromFlat(${u}, ${c}, index);
return sampleTexture(${o}, uv);
}
`;
}
function K7(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),
d = [1, 2],
f = Fc(r, m),
h = ["b", "row", "col"];
return `
${nR(f, e)}
vec4 ${n}(int b, int row, int col) {
return ${n}(${Pc(h, d)});
}
`;
}
let i = It();
if (e) return `
vec4 ${n}(int b, int row, int col) {
ivec2 packedTexShape = ivec2(ceil(float(${o}TexShape[0]) / 2.0), ceil(float(${o}TexShape[1]) / 2.0));
int valuesPerRow = int(ceil(float(${o}Shape[2]) / 2.0));
int texelsInBatch = valuesPerRow * int(ceil(float(${o}Shape[1]) / 2.0));
vec2 uv = packedUVfrom3D(
packedTexShape[0], packedTexShape[1], texelsInBatch, valuesPerRow, b, row, col);
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);
return `
vec4 ${n}(int b, int row, int col) {
vec2 uv = packedUVfrom3D(
${p}, ${u}, ${l}, ${c}, b, row, col);
return ${i.texture2D}(${o}, uv);
}
`;
}
function q7(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
} = y.squeezeShape(t10),
u = i;
if (u.length < t10.length) {
let h = Fc(r, u),
g = ["row", "col", "depth"];
return `
${Dc(h, e)}
float ${n}(int row, int col, int depth) {
return ${n}(${Pc(g, p)});
}
`;
}
if (r.shapeInfo.isUniform) return `
float ${n}(int row, int col, int depth) {
int index = round(dot(vec3(row, col, depth),
vec3(${s}, ${a}, 1)));
${Ac(r)}
}
`;
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];
float texR = float(row);
float texC = dot(vec2(col, depth), vec2(stride1, 1));
vec2 uv = (vec2(texC, texR) + halfCR) /
vec2(${o}TexShape[1], ${o}TexShape[0]);
return sampleTexture(${o}, uv);
}
` : `
float ${n}(int row, int col, int depth) {
float texR = float(row);
float texC = dot(vec2(col, depth), vec2(${a}, 1));
vec2 uv = (vec2(texC, texR) + halfCR) /
vec2(${m}.0, ${l}.0);
return sampleTexture(${o}, uv);
}
`;
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));
float texC = float(depth);
vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${o}TexShape[1], ${o}TexShape[0]);
return sampleTexture(${o}, uv);
}
` : `
float ${n}(int row, int col, int depth) {
float texR = dot(vec2(row, col), vec2(${t10[1]}, 1));
float texC = float(depth);
vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${m}.0, ${l}.0);
return sampleTexture(${o}, uv);
}
`;
let f = gp(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 + ${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 + ${f};
vec2 uv = uvFromFlat(${l}, ${m}, index);
return sampleTexture(${o}, uv);
}
`;
}
function j7(r, e) {
let t10 = r.name,
o = "get" + t10.charAt(0).toUpperCase() + t10.slice(1),
n = It();
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 index = b * texelsInBatch + (row / 2) * valuesPerRow + (col / 2);
texelsInBatch *= ${t10}Shape[1];
index = b2 * texelsInBatch + index;
ivec2 packedTexShape = ivec2(ceil(float(${t10}TexShape[0]) / 2.0), ceil(float(${t10}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);
}
`;
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++) d = `int b${h}, ` + d, m *= s[a - h - 1], f = `b${h} * ${m} + ` + f;
return `
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);
}
`;
}
function X7(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
} = y.squeezeShape(t10);
if (p.length < t10.length) {
let b = Fc(r, p),
w = ["row", "col", "depth", "depth2"];
return `
${Dc(b, e)}
float ${n}(int row, int col, int depth, int depth2) {
return ${n}(${Pc(w, u)});
}
`;
}
if (r.shapeInfo.isUniform) return `
float ${n}(int row, int col, int depth, int depth2) {
int index = round(dot(vec4(row, col, depth, depth2),
vec4(${i}, ${a}, ${s}, 1)));
${Ac(r)}
}
`;
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) {
${f}
${h}
float texR = float(row);
float texC =
dot(vec3(col, depth, depth2),
vec3(stride1, stride2, 1));
vec2 uv = (vec2(texC, texR) + halfCR) /
vec2(${o}TexShape[1], ${o}TexShape[0]);
return sampleTexture(${o}, uv);
}
` : `
float ${n}(int row, int col, int depth, int depth2) {
float texR = float(row);
float texC =
dot(vec3(col, depth, depth2),
vec3(${a}, ${s}, 1));
vec2 uv = (vec2(texC, texR) + halfCR) /
vec2(${d}.0, ${m}.0);
return sampleTexture(${o}, uv);
}
`;
if (d === s && c == null) return e ? `
float ${n}(int row, int col, int depth, int depth2) {
float texR = dot(vec3(row, col, depth),
vec3(${o}Shape[1] * ${o}Shape[2], ${o}Shape[2], 1));
float texC = float(depth2);
vec2 uv = (vec2(texC, texR) + halfCR) /
vec2(${o}TexShape[1], ${o}TexShape[0]);
return sampleTexture(${o}, uv);
}
` : `
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));
float texC = float(depth2);
vec2 uv = (vec2(texC, texR) + halfCR) /
vec2(${d}.0, ${m}.0);
return sampleTexture(${o}, uv);
}
`;
let x = gp(o);
return e ? `
float ${n}(int row, int col, int depth, int depth2) {
// Explicitly use integer operations as dot() only works on floats.
${f}
${h}
${g}
int index = row * stride0 + col * stride1 +
depth * stride2 + depth2;
vec2 uv = uvFromFlat(${o}TexShape[0], ${o}TexShape[1], index + ${x});
return sampleTexture(${o}, uv);
}
` : `
float ${n}(int row, int col, int depth, int depth2) {
// Explicitly use integer operations as dot() only works on floats.
int index = row * ${i} + col * ${a} +
depth * ${s} + depth2;
vec2 uv = uvFromFlat(${m}, ${d}, index + ${x});
return sampleTexture(${o}, uv);
}
`;
}
function Y7(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
} = y.squeezeShape(e);
if (p.length < e.length) {
let h = Fc(r, p),
g = ["row", "col", "depth", "depth2", "depth3"];
return `
${Dc(h)}
float ${o}(int row, int col, int depth, int depth2, int depth3) {
return ${o}(${Pc(g, u)});
}
`;
}
if (r.shapeInfo.isUniform) return `
float ${o}(int row, int col, int depth, int depth2, int depth3) {
float index = dot(
vec4(row, col, depth, depth2),
vec4(${i}, ${a}, ${s}, ${n})) +
depth3;
${Ac(r)}
}
`;
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(${d}.0, ${m}.0);
return sampleTexture(${t10}, uv);
}
`;
if (d === n && c == null) return `
float ${o}(int row, int col, int depth, int depth2, int depth3) {
float texR = dot(
vec4(row, col, depth, depth2),
vec4(${e[1] * e[2] * e[3]},
${e[2] * e[3]}, ${e[3]}, 1));
int texC = depth3;
vec2 uv = (vec2(texC, texR) + halfCR) /
vec2(${d}.0, ${m}.0);
return sampleTexture(${t10}, uv);
}
`;
let f = gp(t10);
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 + ${f};
vec2 uv = uvFromFlat(${m}, ${d}, index);
return sampleTexture(${t10}, uv);
}
`;
}
function Q7(r) {
let e = r.shapeInfo.logicalShape,
t10 = r.name,
o = "get" + t10.charAt(0).toUpperCase() + t10.slice(1),
{
newShape: n,
keptDims: s
} = y.squeezeShape(e);
if (n.length < e.length) {
let g = Fc(r, n),
x = ["row", "col", "depth", "depth2", "depth3", "depth4"];
return `
${Dc(g)}
float ${o}(int row, int col, int depth,
int depth2, int depth3, int depth4) {
return ${o}(${Pc(x, s)});
}
`;
}
let a = e[5],
i = e[4] * a,
p = e[3] * i,
u = e[2] * p,
c = e[1] * u;
if (r.shapeInfo.isUniform) return `
float ${o}(int row, int col, int depth,
int depth2, int depth3, int depth4) {
int index = round(dot(
vec4(row, col, depth, depth2),
vec4(${c}, ${u}, ${p}, ${i})) +
dot(
vec2(depth3, depth4),
vec2(${a}, 1)));
${Ac(r)}
}
`;
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) {
int texR = row;
float texC = dot(vec4(col, depth, depth2, depth3),
vec4(${u}, ${p}, ${i}, ${a})) +
float(depth4);
vec2 uv = (vec2(texC, texR) + halfCR) /
vec2(${f}.0, ${d}.0);
return sampleTexture(${t10}, uv);
}
`;
if (f === a && l == null) return `
float ${o}(int row, int col, int depth,
int depth2, int depth3, int depth4) {
float texR = dot(vec4(row, col, depth, depth2),
vec4(${e[1] * e[2] * e[3] * e[4]},
${e[2] * e[3] * e[4]},
${e[3] * e[4]},
${e[4]})) + float(depth3);
int texC = depth4;
vec2 uv = (vec2(texC, texR) + halfCR) /
vec2(${f}.0, ${d}.0);
return sampleTexture(${t10}, uv);
}
`;
let h = gp(t10);
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(${d}, ${f}, index);
return sampleTexture(${t10}, uv);
}
`;
}
function Ac(r) {
let e = r.name,
t10 = y.sizeFromShape(r.shapeInfo.logicalShape);
return t10 < 2 ? `return ${e};` : `
for (int i = 0; i < ${t10}; i++) {
if (i == index) {
return ${e}[i];
}
}
`;
}
function Z7(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 = rR(r.shapeInfo.logicalShape, e.logicalShape),
p = Re(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, w) => `coords.${l[w + u]}`).join(", ");
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 && !x) a === 1 ? d = `
return vec4(outputValue.x, outputValue.x, 0., 0.);
` : d = `
return vec4(outputValue.x);
`;else if (i.length) {
let b = s - 2,
w = s - 1;
i.indexOf(b) > -1 && i.indexOf(w) > -1 ? d = "return vec4(outputValue.x);" : i.indexOf(b) > -1 ? d = "return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);" : i.indexOf(w) > -1 && (d = "return vec4(outputValue.xx, outputValue.zz);");
}
return `
vec4 ${n}() {
${p} coords = getOutputCoords();
${c}
vec4 outputValue = get${o}(${m});
${d}
}
`;
}
function J7(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 && y.arraysEqual(a, s)) return `
float ${n}() {
return sampleTexture(${t10}, resultUV);
}
`;
let u = Re(p),
c = rR(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 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}(${f});
}
`;
}
function Re(r) {
if (r <= 1) return "int";
if (r === 2) return "ivec2";
if (r === 3) return "ivec3";
if (r === 4) return "ivec4";
if (r === 5) return "ivec5";
if (r === 6) return "ivec6";
throw Error(`GPU for rank ${r} is not yet supported`);
}
function Xf(r, e, t10) {
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, t10) && 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) {
return e.map(t10 => r[t10]).join(", ");
}
function iR(r, e, t10, o) {
let n = t10.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 = oR(n, a, e),
p = mI(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,
variablesLocations: null,
customUniformLocations: null,
infLoc: null,
nanLoc: null,
outShapeLocation: null,
outShapeStridesLocation: null,
outTexShapeLocation: null
} : (r.buildVao(u), Object.assign({
program: e,
fragmentShader: p,
source: i,
webGLProgram: u,
inShapeInfos: s,
outShapeInfo: a
}, EI(r, e, u)));
}
function EI(r, e, t10) {
let o = [],
n = [],
s,
a,
i,
p = null,
u = null;
u = r.getUniformLocation(t10, "NAN", false), P().getNumber("WEBGL_VERSION") === 1 && (p = r.getUniformLocation(t10, "INFINITY", false));
let c = false;
for (let l of e.variableNames) {
let m = {
name: l,
uniform: r.getUniformLocation(t10, l, c),
offset: r.getUniformLocation(t10, `offset${l}`, c)
};
e.enableShapeUniforms && (m.shape = r.getUniformLocation(t10, `${l}Shape`, c), m.texShape = r.getUniformLocation(t10, `${l}TexShape`, c)), o.push(m);
}
if (e.enableShapeUniforms && (s = r.getUniformLocation(t10, "outShape", c), i = r.getUniformLocation(t10, "outShapeStrides", c), a = r.getUniformLocation(t10, "outTexShape", c)), e.customUniforms) for (let l of e.customUniforms) n.push(r.getUniformLocation(t10, l.name, c));
return {
variablesLocations: o,
customUniformLocations: n,
infLoc: p,
nanLoc: u,
outShapeLocation: s,
outShapeStridesLocation: i,
outTexShapeLocation: a
};
}
function aR(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 (!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) return;
let i = t10.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 uR(r, e, t10, o, n) {
e.program.enableShapeUniforms || (aR(e.inShapeInfos, t10), aR([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), r.bindVertexArray(e.webGLProgram.vao), P().getNumber("WEBGL_VERSION") === 1 && e.infLoc !== null && r.gl.uniform1f(e.infLoc, 1 / 0), e.nanLoc !== null && r.gl.uniform1f(e.nanLoc, NaN);
for (let p = 0; p < t10.length; ++p) {
let u = t10[p],
{
uniform: c,
offset: l,
shape: m,
texShape: d
} = e.variablesLocations[p];
if (m) {
let {
uniformShape: f
} = Xf(e.program.packedInputs, u.shape, u.texData.texShape);
switch (f.length) {
case 1:
r.gl.uniform1iv(m, new Int32Array(f));
break;
case 2:
r.gl.uniform2iv(m, new Int32Array(f));
break;
case 3:
r.gl.uniform3iv(m, new Int32Array(f));
break;
case 4:
r.gl.uniform4iv(m, new Int32Array(f));
break;
default:
break;
}
}
if (d && r.gl.uniform2i(d, u.texData.texShape[0], u.texData.texShape[1]), c != null) {
if (u.isUniform) {
if (y.sizeFromShape(u.shape) < 2) r.gl.uniform1f(c, u.uniformValues[0]);else {
let f = u.uniformValues;
f instanceof Float32Array || (f = new Float32Array(f)), r.gl.uniform1fv(c, f);
}
continue;
}
u.texData.slice != null && l != null && r.gl.uniform1i(l, u.texData.slice.flatOffset), r.setInputMatrixTexture(u.texData.texture.texture, c, p);
}
}
let i = e.outShapeLocation;
if (i) switch (o.shape.length) {
case 1:
r.gl.uniform1iv(i, new Int32Array(o.shape));
break;
case 2:
r.gl.uniform2iv(i, new Int32Array(o.shape));
break;
case 3:
r.gl.uniform3iv(i, new Int32Array(o.shape));
break;
case 4:
r.gl.uniform4iv(i, new Int32Array(o.shape));
break;
default:
break;
}
if (e.outShapeStridesLocation) {
let p = y.computeStrides(o.shape);
switch (o.shape.length) {
case 2:
r.gl.uniform1iv(e.outShapeStridesLocation, new Int32Array(p));
break;
case 3:
r.gl.uniform2iv(e.outShapeStridesLocation, new Int32Array(p));
break;
case 4:
r.gl.uniform3iv(e.outShapeStridesLocation, new Int32Array(p));
break;
default:
break;
}
}
if (e.outTexShapeLocation && r.gl.uniform2i(e.outTexShapeLocation, o.texData.texShape[0], o.texData.texShape[1]), e.program.customUniforms && n) for (let p = 0; p < e.program.customUniforms.length; ++p) {
let u = e.program.customUniforms[p],
c = e.customUniformLocations[p],
l = n[p];
if (u.type === "float") r.gl.uniform1fv(c, l);else if (u.type === "vec2") r.gl.uniform2fv(c, l);else if (u.type === "vec3") r.gl.uniform3fv(c, l);else if (u.type === "vec4") r.gl.uniform4fv(c, l);else if (u.type === "int") r.gl.uniform1iv(c, l);else if (u.type === "ivec2") r.gl.uniform2iv(c, l);else if (u.type === "ivec3") r.gl.uniform3iv(c, l);else if (u.type === "ivec4") r.gl.uniform4iv(c, l);else throw Error(`uniform type ${u.type} is not supported yet.`);
}
r.executeProgram();
}
function pR(r, e, t10) {
let o = "";
e.concat(t10).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
} = Xf(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) d = `${c[0] > 1}_${c[1] > 1}`;else if (c.length > 2 && !r.packedInputs) {
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 && y.arraysEqual(a.shape, p),
x = y.sizeFromShape(a.shape) === 1,
b = C.getBroadcastDims(a.shape, t10.shape),
w = !r.packedInputs && h === t10.shape.length && y.arraysEqual(p, t10.texData.texShape),
S = r.packedInputs || c.length > 2 ? "" : `${p[0] > 1}_${p[1] > 1}`;
o += `${h}_${w}_${u ? l : ""}_${c.length}_${x}_${b}_${g}_${m}_${d}_${f}_${S}_${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;
}
function ut(r) {
return P().getBool("WEBGL_USE_SHAPES_UNIFORMS") && r <= 4;
}
var Yf = class {
constructor(e) {
this.variableNames = ["A"], this.packedInputs = false, this.packedOutput = true, this.outPackingScheme = du.DENSE, this.customUniforms = [{
name: "texShape",
type: "ivec2"
}];
let t10 = It();
this.outputShape = e, this.enableShapeUniforms = ut(this.outputShape.length), this.userCode = `
ivec3 outCoordsFromFlatIndex(int index) {
${this.enableShapeUniforms ? hp(["r", "c", "d"], e) : Os(["r", "c", "d"], e)}
return ivec3(r, c, d);
}
void main() {
ivec2 resTexRC = ivec2(resultUV.yx * vec2(texShape[0], texShape[1]));
int index = 4 * (resTexRC.x * texShape[1] + resTexRC.y);
vec4 result = vec4(0.);
for (int i=0; i<4; i++) {
int flatIndex = index + i;
ivec3 rc = outCoordsFromFlatIndex(flatIndex);
result[i] = getA(rc.x, rc.y, rc.z);
}
${t10.output} = result;
}
`;
}
};
var Qf = class {
constructor(e) {
this.variableNames = ["A"], this.packedInputs = true, this.packedOutput = true, this.outPackingScheme = du.DENSE, this.customUniforms = [{
name: "texShape",
type: "ivec2"
}];
let t10 = It();
this.outputShape = e, this.enableShapeUniforms = ut(this.outputShape.length), this.userCode = `
ivec3 outCoordsFromFlatIndex(int index) {
${this.enableShapeUniforms ? hp(["r", "c", "d"], e) : Os(["r", "c", "d"], e)}
return ivec3(r, c, d);
}
void main() {
ivec2 resTexRC = ivec2(resultUV.yx * vec2(texShape[0], texShape[1]));
int index = 4 * (resTexRC.x * texShape[1] + resTexRC.y);
vec4 result = vec4(0.);
for (int i=0; i<4; i++) {
int flatIndex = index + i;
ivec3 rc = outCoordsFromFlatIndex(flatIndex);
result[i] = getChannel(getA(rc.x, rc.y, rc.z), vec2(rc.y, rc.z));
}
${t10.output} = result;
}
`;
}
};
var Zf = class {
constructor(e) {
this.variableNames = ["A"], this.outTexUsage = mr.DOWNLOAD;
let t10 = It();
this.outputShape = e, this.userCode = `
${jf}
void main() {
float x = getAAtOutCoords();
${t10.output} = encode_float(x);
}
`;
}
};
var Jf = class {
constructor(e) {
this.variableNames = ["A"], this.packedInputs = true, this.packedOutput = false, this.outTexUsage = mr.DOWNLOAD;
let t10 = It();
this.outputShape = e, this.userCode = `
${jf}
void main() {
ivec3 coords = getOutputCoords();
float x = getChannel(getAAtOutCoords(), vec2(coords.y, coords.z));
${t10.output} = encode_float(x);
}
`;
}
};
var rZ = {
R: 0,
G: 1,
B: 2,
A: 3
};
var Xl = class {
constructor(e, t10 = false, o = "RGBA") {
this.variableNames = ["A"], this.customUniforms = [{
name: "texShape",
type: "ivec2"
}];
let n = It();
this.outputShape = e, this.enableShapeUniforms = ut(this.outputShape.length);
let s = "result";
t10 && (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[${rZ[p]}];
}`;
}
this.userCode = `
${this.enableShapeUniforms ? Ec() : $c(e)}
void main() {
ivec3 coords = getOutputCoords();
int flatIndex = getFlatIndex(coords);
float result = 0.;
int offset = imod(flatIndex, ${o.length});
flatIndex = idiv(flatIndex, ${o.length}, 1.);
int r = flatIndex / texShape[1];
if (r < texShape[0]) {
int c = imod(flatIndex, texShape[1]);
vec2 uv = (vec2(c, r) + halfCR) / vec2(texShape[1], texShape[0]);
vec4 values = ${n.texture2D}(A, uv);
${a}
}
${n.output} = vec4(${s}, 0., 0., 0.);
}
`;
}
};
var eh = class {
constructor(e, t10 = false) {
this.variableNames = ["A"], this.packedInputs = false, this.packedOutput = true, this.customUniforms = [{
name: "texShape",
type: "ivec2"
}];
let o = It();
this.outputShape = e, this.enableShapeUniforms = ut(this.outputShape.length);
let n = "",
s = "result";
t10 && (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;
n += `
localCoords = coords;
if(localCoords[2] + ${i} < ${this.enableShapeUniforms ? "outShape[2]" : `${e[2]}`}) {
localCoords[2] += ${i};
if (localCoords[1] + ${a} < ${this.enableShapeUniforms ? "outShape[1]" : `${e[1]}`}) {
localCoords[1] += ${a};
flatIndex = getFlatIndex(localCoords);
offset = imod(flatIndex, 4);
flatIndex = idiv(flatIndex, 4, 1.);
int r = flatIndex / texShape[1];
int c = imod(flatIndex, texShape[1]);
vec2 uv = (vec2(c, r) + halfCR) / vec2(texShape[1], texShape[0]);
values = ${o.texture2D}(A, uv);
if (offset == 0) {
result[${p}] = values[0];
} else if (offset == 1) {
result[${p}] = values[1];
} else if (offset == 2) {
result[${p}] = values[2];
} else {
result[${p}] = values[3];
}
}
}
`;
}
this.userCode = `
${this.enableShapeUniforms ? Ec() : $c(e)}
void main() {
ivec3 coords = getOutputCoords();
vec4 result = vec4(0.);
int flatIndex, r, c, offset;
ivec3 localCoords;
vec2 uv;
vec4 values;
${n}
${o.output} = ${s};
}
`;
}
};
var qI = {};
He(qI, {
bindVertexProgramAttributeStreams: () => BI,
createBufferFromOutputTexture: () => WI,
createFloat16MatrixTexture: () => PI,
createFloat16PackedMatrixTexture: () => LI,
createFloat32MatrixTexture: () => FI,
createIndexBuffer: () => AI,
createPackedMatrixTexture: () => MI,
createUnsignedBytesMatrixTexture: () => OI,
createVertexBuffer: () => DI,
createVertexShader: () => RI,
downloadByteEncodedFloatMatrixFromOutputTexture: () => GI,
downloadFloat32MatrixFromBuffer: () => UI,
downloadMatrixFromPackedOutputTexture: () => KI,
downloadPackedMatrixFromBuffer: () => HI,
getInternalFormatForFloat16MatrixTexture: () => rh,
getInternalFormatForFloat16PackedMatrixTexture: () => sh,
getInternalFormatForFloat32MatrixTexture: () => th,
getInternalFormatForPackedMatrixTexture: () => nh,
getInternalFormatForUnsignedBytesMatrixTexture: () => oh,
uploadDenseMatrixToTexture: () => zI,
uploadPixelDataToTexture: () => VI
});
function RI(r) {
let e = It(),
t10 = `${e.version}
precision highp float;
${e.attribute} vec3 clipSpacePos;
${e.attribute} vec2 uv;
${e.varyingVs} vec2 resultUV;
void main() {
gl_Position = vec4(clipSpacePos, 1);
resultUV = uv;
}`;
return lI(r, t10);
}
function DI(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);
}
function AI(r) {
let e = new Uint16Array([0, 1, 2, 2, 1, 3]);
return gI(r, e);
}
function Yl(r, e, t10, o, n, s) {
yI(e, t10);
let a = xI(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)), P().getNumber("WEBGL_VERSION") === 1 ? ce(r, () => r.texImage2D(i, 0, o, e, t10, 0, n, s, null)) : ce(r, () => r.texStorage2D(i, 1, o, e, t10)), ce(r, () => r.bindTexture(r.TEXTURE_2D, null)), {
texture: a,
texShape: [t10, e]
};
}
function th(r) {
return r.internalFormatFloat;
}
function FI(r, e, t10, o) {
let [n, s] = fp(e, t10);
return Yl(r, n, s, th(o), o.textureFormatFloat, r.FLOAT);
}
function rh(r) {
return r.internalFormatHalfFloat;
}
function PI(r, e, t10, o) {
let [n, s] = fp(e, t10);
return Yl(r, n, s, rh(o), o.textureFormatFloat, o.textureTypeHalfFloat);
}
function oh(r) {
return r.downloadTextureFormat;
}
function OI(r, e, t10, o) {
let [n, s] = fp(e, t10);
return Yl(r, n, s, oh(o), r.RGBA, r.UNSIGNED_BYTE);
}
function nh(r) {
return r.internalFormatPackedFloat;
}
function MI(r, e, t10, o) {
let [n, s] = Ea(e, t10);
return Yl(r, n, s, nh(o), r.RGBA, r.FLOAT);
}
function sh(r) {
return r.internalFormatPackedHalfFloat;
}
function LI(r, e, t10, o) {
let [n, s] = Ea(e, t10);
return Yl(r, n, s, sh(o), r.RGBA, o.textureTypeHalfFloat);
}
function BI(r, e, t10) {
return ce(r, () => r.bindBuffer(r.ARRAY_BUFFER, t10)), Hf(r, e, "clipSpacePos", t10, 3, 20, 0) && Hf(r, e, "uv", t10, 2, 20, 12);
}
function zI(r, e, t10, 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 ? ce(r, () => r.texSubImage2D(r.TEXTURE_2D, 0, 0, 0, t10, o, r.RGBA, i, a)) : ce(r, () => r.texImage2D(r.TEXTURE_2D, 0, p, t10, o, 0, r.RGBA, i, a)), ce(r, () => r.bindTexture(r.TEXTURE_2D, null));
}
function VI(r, e, t10) {
ce(r, () => r.bindTexture(r.TEXTURE_2D, e)), t10.data instanceof Uint8Array ? P().getNumber("WEBGL_VERSION") === 2 ? ce(r, () => r.texSubImage2D(r.TEXTURE_2D, 0, 0, 0, t10.width, t10.height, r.RGBA, r.UNSIGNED_BYTE, t10.data)) : ce(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 ? ce(r, () => r.texSubImage2D(r.TEXTURE_2D, 0, 0, 0, r.RGBA, r.UNSIGNED_BYTE, t10)) : ce(r, () => r.texImage2D(r.TEXTURE_2D, 0, r.RGBA, r.RGBA, r.UNSIGNED_BYTE, t10)), ce(r, () => r.bindTexture(r.TEXTURE_2D, null));
}
function WI(r, e, t10, o) {
let n = r.createBuffer();
ce(r, () => r.bindBuffer(r.PIXEL_PACK_BUFFER, n));
let i = 4 * 4 * e * t10;
return ce(r, () => r.bufferData(r.PIXEL_PACK_BUFFER, i, r.STREAM_READ)), ce(r, () => r.readPixels(0, 0, t10, e, r.RGBA, r.FLOAT, 0)), ce(r, () => r.bindBuffer(r.PIXEL_PACK_BUFFER, null)), n;
}
function UI(r, e, t10) {
let o = r,
n = new Float32Array(t10);
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 GI(r, e, t10, o) {
let [n, s] = fp(e, t10),
a = 4,
i = new Uint8Array(XE(e * t10, a));
return ce(r, () => r.readPixels(0, 0, n, s, o.downloadTextureFormat, r.UNSIGNED_BYTE, i)), new Float32Array(i.buffer);
}
function HI(r, e, t10, o, n, s, a, i) {
let p = r,
u = new Float32Array(YE(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 KI(r, e, t10) {
let o = new Float32Array(e * t10 * 4);
return ce(r, () => r.readPixels(0, 0, t10, e, r.RGBA, r.FLOAT, o)), o;
}
var xp = class {
constructor(e) {
this.outputTexture = null, this.program = null, this.disposed = false, this.itemsToPoll = [];
let t10 = P().getNumber("WEBGL_VERSION");
if (e != null ? (this.gl = e, iI(t10, e)) : this.gl = Gr(t10), e = this.gl, P().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) {
let s = "OES_texture_float",
a = "OES_texture_half_float";
if (this.textureFloatExtension = kc(this.gl, s), Hr(this.gl, a)) this.textureHalfFloatExtension = kc(this.gl, a);else if (P().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 = kc(this.gl, n);else if (P().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)) this.colorBufferFloatExtension = this.gl.getExtension(o);else if (Hr(this.gl, n)) this.colorBufferHalfFloatExtension = this.gl.getExtension(n);else throw new Error("GL context does not support color renderable floats");
this.vertexBuffer = DI(this.gl), this.indexBuffer = AI(this.gl), this.framebuffer = bI(this.gl), this.textureConfig = Kl(this.gl, this.textureHalfFloatExtension);
}
get debug() {
return P().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;
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(), FI(this.gl, e, t10, this.textureConfig);
}
createFloat16MatrixTexture(e, t10) {
return this.throwIfDisposed(), PI(this.gl, e, t10, this.textureConfig);
}
createUnsignedBytesMatrixTexture(e, t10) {
return this.throwIfDisposed(), OI(this.gl, e, t10, this.textureConfig);
}
uploadPixelDataToTexture(e, t10) {
this.throwIfDisposed(), VI(this.gl, e, t10);
}
uploadDenseMatrixToTexture(e, t10, o, n) {
this.throwIfDisposed(), zI(this.gl, e, t10, o, n, this.textureConfig);
}
createFloat16PackedMatrixTexture(e, t10) {
return this.throwIfDisposed(), LI(this.gl, e, t10, this.textureConfig);
}
createPackedMatrixTexture(e, t10) {
return this.throwIfDisposed(), MI(this.gl, e, t10, this.textureConfig);
}
deleteMatrixTexture(e) {
this.throwIfDisposed(), this.outputTexture === e && (Kf(this.gl, this.framebuffer), this.outputTexture = null), ce(this.gl, () => this.gl.deleteTexture(e));
}
downloadByteEncodedFloatMatrixFromOutputTexture(e, t10, o) {
return this.downloadMatrixDriver(e, () => GI(this.gl, t10, o, this.textureConfig));
}
downloadPackedMatrixFromBuffer(e, t10, o, n, s, a) {
return HI(this.gl, e, t10, o, n, s, a, this.textureConfig);
}
downloadFloat32MatrixFromBuffer(e, t10) {
return UI(this.gl, e, t10);
}
createBufferFromTexture(e, t10, o) {
this.bindTextureToFrameBuffer(e);
let n = WI(this.gl, t10, o, this.textureConfig);
return this.unbindTextureToFrameBuffer(), n;
}
createAndWaitForFence() {
let e = this.createFence(this.gl);
return this.pollFence(e);
}
createFence(e) {
let t10, o;
if (P().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;
} 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
};
}
downloadMatrixFromPackedTexture(e, t10, o) {
return this.downloadMatrixDriver(e, () => KI(this.gl, t10, o));
}
createProgram(e) {
this.throwIfDisposed();
let t10 = this.gl;
this.vertexShader == null && (this.vertexShader = RI(t10));
let o = dI(t10);
ce(t10, () => t10.attachShader(o, this.vertexShader)), ce(t10, () => t10.attachShader(o, e)), fI(t10, o);
let n = Object.assign(o, {
vao: this.createVertexArray()
});
return this.debug && ql(t10, n), n;
}
buildVao(e) {
this.setProgram(e), this.bindVertexArray(e.vao);
let t10 = this.gl;
ce(t10, () => t10.bindBuffer(t10.ELEMENT_ARRAY_BUFFER, this.indexBuffer)), BI(t10, e, this.vertexBuffer);
}
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 && ql(this.gl, this.program), ce(this.gl, () => this.gl.useProgram(e));
}
getUniformLocation(e, t10, o = true) {
return this.throwIfDisposed(), o ? CI(this.gl, e, t10) : wI(this.gl, e, t10);
}
getAttributeLocation(e, t10) {
return this.throwIfDisposed(), ce(this.gl, () => this.gl.getAttribLocation(e, t10));
}
getUniformLocationNoThrow(e, t10) {
return this.throwIfDisposed(), this.gl.getUniformLocation(e, t10);
}
setInputMatrixTexture(e, t10, o) {
this.throwIfDisposed(), this.throwIfNoProgram(), SI(this.gl, e, t10, o);
}
setOutputMatrixTexture(e, t10, o) {
this.setOutputMatrixTextureDriver(e, o, t10);
}
setOutputPackedMatrixTexture(e, t10, o) {
this.throwIfDisposed();
let [n, s] = Ea(t10, o);
this.setOutputMatrixTextureDriver(e, n, s);
}
setOutputMatrixWriteRegion(e, t10, o, n) {
this.setOutputMatrixWriteRegionDriver(o, e, n, t10);
}
setOutputPackedMatrixWriteRegion(e, t10, o, n) {
throw new Error("setOutputPackedMatrixWriteRegion not implemented.");
}
debugValidate() {
this.program != null && ql(this.gl, this.program), Nc(this.gl);
}
executeProgram() {
this.throwIfDisposed(), this.throwIfNoProgram();
let e = this.gl;
if (this.debug) {
let t10 = this.getVertexArray();
console.assert(t10 === 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(), ce(this.gl, () => this.gl.finish());
}
getQueryTimerExtension() {
return this.disjointQueryTimerExtension == null && (this.disjointQueryTimerExtension = kc(this.gl, P().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION") === 2 ? "EXT_disjoint_timer_query_webgl2" : "EXT_disjoint_timer_query")), this.disjointQueryTimerExtension;
}
getQueryTimerExtensionWebGL2() {
return this.getQueryTimerExtension();
}
getQueryTimerExtensionWebGL1() {
return this.getQueryTimerExtension();
}
beginQuery() {
if (P().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;
}
endQuery() {
if (P().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION") === 2) {
let t10 = this.gl,
o = this.getQueryTimerExtensionWebGL2();
t10.endQuery(o.TIME_ELAPSED_EXT);
return;
}
let e = this.getQueryTimerExtensionWebGL1();
e.endQueryEXT(e.TIME_ELAPSED_EXT);
}
async waitForQueryAndGetTime(e) {
return await y.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"));
}
getQueryTime(e, t10) {
if (t10 === 0) return null;
if (t10 === 2) {
let o = this.gl;
return o.getQueryParameter(e, o.QUERY_RESULT) / 1e6;
} else {
let o = this.getQueryTimerExtensionWebGL1();
return o.getQueryObjectEXT(e, o.QUERY_RESULT_EXT) / 1e6;
}
}
isQueryAvailable(e, t10) {
if (t10 === 0) return true;
if (t10 === 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 {
let o = this.getQueryTimerExtensionWebGL1(),
n = o.getQueryObjectEXT(e, o.QUERY_RESULT_AVAILABLE_EXT);
return this.disjoint == null && (this.disjoint = this.gl.getParameter(o.GPU_DISJOINT_EXT)), n && !this.disjoint;
}
}
pollFence(e) {
return new Promise(t10 => {
this.addItemToPoll(() => e.isFencePassed(), () => t10());
});
}
pollItems() {
let e = oZ(this.itemsToPoll.map(t10 => t10.isDoneFn));
for (let t10 = 0; t10 <= e; ++t10) {
let {
resolveFn: o
} = this.itemsToPoll[t10];
o();
}
this.itemsToPoll = this.itemsToPoll.slice(e + 1);
}
addItemToPoll(e, t10) {
if (this.itemsToPoll.push({
isDoneFn: e,
resolveFn: t10
}), this.itemsToPoll.length > 1) return;
let o;
"setTimeoutCustom" in P().platform && (o = P().platform.setTimeoutCustom.bind(P().platform)), y.repeatedTry(() => (this.pollItems(), this.itemsToPoll.length === 0), () => 0, null, o);
}
bindTextureToFrameBuffer(e) {
this.throwIfDisposed(), jl(this.gl, e, this.framebuffer), this.debug && Nc(this.gl);
}
unbindTextureToFrameBuffer() {
this.outputTexture != null ? (jl(this.gl, this.outputTexture, this.framebuffer), this.debug && Nc(this.gl)) : Kf(this.gl, this.framebuffer);
}
downloadMatrixDriver(e, t10) {
this.bindTextureToFrameBuffer(e);
let o = t10();
return this.unbindTextureToFrameBuffer(), o;
}
setOutputMatrixTextureDriver(e, t10, o) {
this.throwIfDisposed();
let n = this.gl;
jl(n, e, this.framebuffer), this.debug && Nc(n), this.outputTexture = e, ce(n, () => n.viewport(0, 0, t10, o)), ce(n, () => n.scissor(0, 0, t10, o));
}
setOutputMatrixWriteRegionDriver(e, t10, o, n) {
this.throwIfDisposed(), ce(this.gl, () => this.gl.scissor(e, t10, o, n));
}
throwIfDisposed() {
if (this.disposed) throw new Error("Attempted to use disposed GPGPUContext.");
}
throwIfNoProgram() {
if (this.program == null) throw new Error("No GPU program is currently set.");
}
};
function oZ(r) {
let e = 0;
for (; e < r.length && r[e](); ++e);
return e - 1;
}
var {
addImpl: cR,
bincountImpl: ah,
bincountReduceImpl: lR,
castImpl: mR,
ceilImpl: dR,
concatImpl: fR,
equalImpl: hR,
expImpl: gR,
expm1Impl: xR,
floorImpl: yR,
gatherNdImpl: bR,
gatherV2Impl: CR,
greaterImpl: wR,
greaterEqualImpl: SR,
lessImpl: IR,
lessEqualImpl: vR,
linSpaceImpl: kR,
logImpl: NR,
maxImpl: TR,
maximumImpl: _R,
minimumImpl: $R,
multiplyImpl: ER,
negImpl: RR,
notEqualImpl: DR,
prodImpl: AR,
raggedGatherImpl: FR,
raggedRangeImpl: PR,
raggedTensorToTensorImpl: OR,
rangeImpl: MR,
rsqrtImpl: LR,
scatterImpl: BR,
sigmoidImpl: zR,
simpleAbsImpl: ih,
sliceImpl: VR,
sparseFillEmptyRowsImpl: WR,
sparseReshapeImpl: UR,
sparseSegmentReductionImpl: uh,
sqrtImpl: GR,
staticRegexReplaceImpl: HR,
stridedSliceImpl: KR,
stringNGramsImpl: qR,
stringSplitImpl: jR,
stringToHashBucketFastImpl: XR,
subImpl: YR,
tileImpl: QR,
topKImpl: ZR,
transposeImpl: yp,
uniqueImpl: JR
} = Sc;
function jI(r, e) {
return ["x", "y", "z", "w", "u", "v"].slice(0, e).map(t10 => `${r}.${t10}`);
}
function Rt(r, e) {
return e === 1 ? [r] : jI(r, e);
}
function eD(r, e) {
if (r === 1) return "rc";
let t10 = "";
for (let o = 0; o < r; o++) t10 += e[o], o < r - 1 && (t10 += ",");
return t10;
}
var ph = class {
constructor(e) {
if (this.variableNames = ["A"], this.packedInputs = false, this.packedOutput = true, this.outputShape = e, this.rank = e.length, this.enableShapeUniforms = ut(this.outputShape.length), this.rank === 0) this.userCode = `
void main() {
setOutput(vec4(getA(), 0., 0., 0.));
}
`;else {
let t10 = Rt("rc", this.rank),
o = Re(this.rank),
n = this.getOutOfBoundsCondition(t10),
s = this.getSetup(t10),
a = this.getOutput(t10);
this.userCode = `
void main() {
${o} rc = getOutputCoords();
if(${n}) {
setOutput(vec4(0));
} else {
${s}
setOutput(vec4(${a}));
}
}
`;
}
}
getSourceCoordsArr(e) {
let t10 = [];
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);
}
return t10;
}
getOutOfBoundsCondition(e) {
if (this.rank === 1) return `rc > ${this.enableShapeUniforms ? "outShape" : this.outputShape[0]}`;
let t10 = "";
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;
}
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];
return `
int r = ${t10[0]};
int c = ${t10[1]};
int rp1 = r + 1;
int cp1 = c + 1;
bool cEdge = cp1 >= ${o};
bool rEdge = rp1 >= ${n};
`;
}
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]})`;
}
};
var Oc = class {
constructor(e, t10) {
this.variableNames = ["A"], this.packedInputs = true, this.packedOutput = true, this.customUniforms = [{
name: "inputShape",
type: "ivec3"
}], this.outputShape = e, this.enableShapeUniforms = ut(this.outputShape.length);
let o = "";
for (let n = 0; n < 4; n++) {
let s = "thisRC = rc;";
n % 2 === 1 && (s += "thisRC.z += 1;"), n > 1 && (s += "thisRC.y += 1;"), o += `
${s}
${n > 0 ? "if(thisRC.y < rows && thisRC.z < cols){" : ""}
int flatIndex = getFlatIndex(thisRC);
ivec3 inputRC = inputCoordsFromReshapedOutCoords(flatIndex);
vec2 inputRCInnerDims = vec2(float(inputRC.y),float(inputRC.z));
result[${n}] =
getChannel(getA(inputRC.x, inputRC.y, inputRC.z), inputRCInnerDims);
${n > 0 ? "}" : ""}
`;
}
this.userCode = `
${nZ(t10, this.enableShapeUniforms)}
${this.enableShapeUniforms ? Ec() : $c(e)}
void main() {
ivec3 rc = getOutputCoords();
vec4 result = vec4(0.);
ivec3 thisRC;
int rows = ${this.enableShapeUniforms ? "outShape[1]" : e[1]};
int cols = ${this.enableShapeUniforms ? "outShape[2]" : e[2]};
${o}
setOutput(result);
}
`;
}
};
function nZ(r, e) {
return `
ivec3 inputCoordsFromReshapedOutCoords(int index) {
${e ? tR(["r", "c", "d"], "inputShape") : Os(["r", "c", "d"], r)}
return ivec3(r, c, d);
}
`;
}
var ch = class {
constructor(e) {
this.gpgpu = e, this.numUsedTextures = 0, this.numFreeTextures = 0, this._numBytesAllocated = 0, this._numBytesFree = 0, this.freeTextures = {}, this.usedTextures = {}, this.logEnabled = false;
}
acquireTexture(e, t10, o) {
let n = rD(t10, o),
s = oD(e, n, o);
s in this.freeTextures || (this.freeTextures[s] = []), s in this.usedTextures || (this.usedTextures[s] = []);
let a = tD(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].pop();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment