UNPKG

onnxruntime-web

Version:

A Javascript library for running ONNX models on browsers

7 lines 364 kB
/*! * ONNX Runtime Web v1.20.0-dev.20240924-cfa45df6b5 * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ var zn=Object.defineProperty;var cp=Object.getOwnPropertyDescriptor;var pp=Object.getOwnPropertyNames;var mp=Object.prototype.hasOwnProperty;var On=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var U=(e,t)=>()=>(e&&(t=e(e=0)),t);var Gt=(e,t)=>{for(var r in t)zn(e,r,{get:t[r],enumerable:!0})},fp=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of pp(t))!mp.call(e,o)&&o!==r&&zn(e,o,{get:()=>t[o],enumerable:!(n=cp(t,o))||n.enumerable});return e};var yr=e=>fp(zn({},"__esModule",{value:!0}),e);var br,_t,$t,hp,wr,vr=U(()=>{"use strict";br=new Map,_t=[],$t=(e,t,r)=>{if(t&&typeof t.init=="function"&&typeof t.createInferenceSessionHandler=="function"){let n=br.get(e);if(n===void 0)br.set(e,{backend:t,priority:r});else{if(n.priority>r)return;if(n.priority===r&&n.backend!==t)throw new Error(`cannot register backend "${e}" using priority ${r}`)}if(r>=0){let o=_t.indexOf(e);o!==-1&&_t.splice(o,1);for(let i=0;i<_t.length;i++)if(br.get(_t[i]).priority<=r){_t.splice(i,0,e);return}_t.push(e)}return}throw new TypeError("not a valid backend")},hp=async e=>{let t=br.get(e);if(!t)return"backend not found.";if(t.initialized)return t.backend;if(t.aborted)return t.error;{let r=!!t.initPromise;try{return r||(t.initPromise=t.backend.init(e)),await t.initPromise,t.initialized=!0,t.backend}catch(n){return r||(t.error=`${n}`,t.aborted=!0),t.error}finally{delete t.initPromise}}},wr=async e=>{let t=e.executionProviders||[],r=t.map(l=>typeof l=="string"?l:l.name),n=r.length===0?_t:r,o,i=[],a=new Set;for(let l of n){let c=await hp(l);typeof c=="string"?i.push({name:l,err:c}):(o||(o=c),o===c&&a.add(l))}if(!o)throw new Error(`no available backend found. ERR: ${i.map(l=>`[${l.name}] ${l.err}`).join(", ")}`);for(let{name:l,err:c}of i)r.includes(l)&&console.warn(`removing requested execution provider "${l}" from session options because it is not available: ${c}`);let d=t.filter(l=>a.has(typeof l=="string"?l:l.name));return[o,new Proxy(e,{get:(l,c)=>c==="executionProviders"?d:Reflect.get(l,c)})]}});var Li=U(()=>{"use strict";vr()});var Fi,qi=U(()=>{"use strict";Fi="1.20.0-dev.20240912-ae39c40e5b"});var ji,We,Dn=U(()=>{"use strict";qi();ji="warning",We={wasm:{},webgl:{},webgpu:{},versions:{common:Fi},set logLevel(e){if(e!==void 0){if(typeof e!="string"||["verbose","info","warning","error","fatal"].indexOf(e)===-1)throw new Error(`Unsupported logging level: ${e}`);ji=e}},get logLevel(){return ji}};Object.defineProperty(We,"logLevel",{enumerable:!0})});var ye,Ki=U(()=>{"use strict";Dn();ye=We});var Yi,Xi,Zi=U(()=>{"use strict";Yi=(e,t)=>{let r=typeof document<"u"?document.createElement("canvas"):new OffscreenCanvas(1,1);r.width=e.dims[3],r.height=e.dims[2];let n=r.getContext("2d");if(n!=null){let o,i;t?.tensorLayout!==void 0&&t.tensorLayout==="NHWC"?(o=e.dims[2],i=e.dims[3]):(o=e.dims[3],i=e.dims[2]);let a=t?.format!==void 0?t.format:"RGB",d=t?.norm,l,c;d===void 0||d.mean===void 0?l=[255,255,255,255]:typeof d.mean=="number"?l=[d.mean,d.mean,d.mean,d.mean]:(l=[d.mean[0],d.mean[1],d.mean[2],0],d.mean[3]!==void 0&&(l[3]=d.mean[3])),d===void 0||d.bias===void 0?c=[0,0,0,0]:typeof d.bias=="number"?c=[d.bias,d.bias,d.bias,d.bias]:(c=[d.bias[0],d.bias[1],d.bias[2],0],d.bias[3]!==void 0&&(c[3]=d.bias[3]));let m=i*o,u=0,h=m,w=m*2,y=-1;a==="RGBA"?(u=0,h=m,w=m*2,y=m*3):a==="RGB"?(u=0,h=m,w=m*2):a==="RBG"&&(u=0,w=m,h=m*2);for(let g=0;g<i;g++)for(let x=0;x<o;x++){let $=(e.data[u++]-c[0])*l[0],_=(e.data[h++]-c[1])*l[1],S=(e.data[w++]-c[2])*l[2],I=y===-1?255:(e.data[y++]-c[3])*l[3];n.fillStyle="rgba("+$+","+_+","+S+","+I+")",n.fillRect(x,g,1,1)}if("toDataURL"in r)return r.toDataURL();throw new Error("toDataURL is not supported")}else throw new Error("Can not access image data")},Xi=(e,t)=>{let r=typeof document<"u"?document.createElement("canvas").getContext("2d"):new OffscreenCanvas(1,1).getContext("2d"),n;if(r!=null){let o,i,a;t?.tensorLayout!==void 0&&t.tensorLayout==="NHWC"?(o=e.dims[2],i=e.dims[1],a=e.dims[3]):(o=e.dims[3],i=e.dims[2],a=e.dims[1]);let d=t!==void 0&&t.format!==void 0?t.format:"RGB",l=t?.norm,c,m;l===void 0||l.mean===void 0?c=[255,255,255,255]:typeof l.mean=="number"?c=[l.mean,l.mean,l.mean,l.mean]:(c=[l.mean[0],l.mean[1],l.mean[2],255],l.mean[3]!==void 0&&(c[3]=l.mean[3])),l===void 0||l.bias===void 0?m=[0,0,0,0]:typeof l.bias=="number"?m=[l.bias,l.bias,l.bias,l.bias]:(m=[l.bias[0],l.bias[1],l.bias[2],0],l.bias[3]!==void 0&&(m[3]=l.bias[3]));let u=i*o;if(t!==void 0&&(t.format!==void 0&&a===4&&t.format!=="RGBA"||a===3&&t.format!=="RGB"&&t.format!=="BGR"))throw new Error("Tensor format doesn't match input tensor dims");let h=4,w=0,y=1,g=2,x=3,$=0,_=u,S=u*2,I=-1;d==="RGBA"?($=0,_=u,S=u*2,I=u*3):d==="RGB"?($=0,_=u,S=u*2):d==="RBG"&&($=0,S=u,_=u*2),n=r.createImageData(o,i);for(let A=0;A<i*o;w+=h,y+=h,g+=h,x+=h,A++)n.data[w]=(e.data[$++]-m[0])*c[0],n.data[y]=(e.data[_++]-m[1])*c[1],n.data[g]=(e.data[S++]-m[2])*c[2],n.data[x]=I===-1?255:(e.data[I++]-m[3])*c[3]}else throw new Error("Can not access image data");return n}});var Bn,Qi,Ji,ea,ta,ra=U(()=>{"use strict";_r();Bn=(e,t)=>{if(e===void 0)throw new Error("Image buffer must be defined");if(t.height===void 0||t.width===void 0)throw new Error("Image height and width must be defined");if(t.tensorLayout==="NHWC")throw new Error("NHWC Tensor layout is not supported yet");let{height:r,width:n}=t,o=t.norm??{mean:255,bias:0},i,a;typeof o.mean=="number"?i=[o.mean,o.mean,o.mean,o.mean]:i=[o.mean[0],o.mean[1],o.mean[2],o.mean[3]??255],typeof o.bias=="number"?a=[o.bias,o.bias,o.bias,o.bias]:a=[o.bias[0],o.bias[1],o.bias[2],o.bias[3]??0];let d=t.format!==void 0?t.format:"RGBA",l=t.tensorFormat!==void 0&&t.tensorFormat!==void 0?t.tensorFormat:"RGB",c=r*n,m=l==="RGBA"?new Float32Array(c*4):new Float32Array(c*3),u=4,h=0,w=1,y=2,g=3,x=0,$=c,_=c*2,S=-1;d==="RGB"&&(u=3,h=0,w=1,y=2,g=-1),l==="RGBA"?S=c*3:l==="RBG"?(x=0,_=c,$=c*2):l==="BGR"&&(_=0,$=c,x=c*2);for(let A=0;A<c;A++,h+=u,y+=u,w+=u,g+=u)m[x++]=(e[h]+a[0])/i[0],m[$++]=(e[w]+a[1])/i[1],m[_++]=(e[y]+a[2])/i[2],S!==-1&&g!==-1&&(m[S++]=(e[g]+a[3])/i[3]);return l==="RGBA"?new Re("float32",m,[1,4,r,n]):new Re("float32",m,[1,3,r,n])},Qi=async(e,t)=>{let r=typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement,n=typeof ImageData<"u"&&e instanceof ImageData,o=typeof ImageBitmap<"u"&&e instanceof ImageBitmap,i=typeof e=="string",a,d=t??{},l=()=>{if(typeof document<"u")return document.createElement("canvas");if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(1,1);throw new Error("Canvas is not supported")},c=m=>m instanceof HTMLCanvasElement||m instanceof OffscreenCanvas?m.getContext("2d"):null;if(r){let m=l();m.width=e.width,m.height=e.height;let u=c(m);if(u!=null){let h=e.height,w=e.width;if(t!==void 0&&t.resizedHeight!==void 0&&t.resizedWidth!==void 0&&(h=t.resizedHeight,w=t.resizedWidth),t!==void 0){if(d=t,t.tensorFormat!==void 0)throw new Error("Image input config format must be RGBA for HTMLImageElement");d.tensorFormat="RGBA",d.height=h,d.width=w}else d.tensorFormat="RGBA",d.height=h,d.width=w;u.drawImage(e,0,0),a=u.getImageData(0,0,w,h).data}else throw new Error("Can not access image data")}else if(n){let m,u;if(t!==void 0&&t.resizedWidth!==void 0&&t.resizedHeight!==void 0?(m=t.resizedHeight,u=t.resizedWidth):(m=e.height,u=e.width),t!==void 0&&(d=t),d.format="RGBA",d.height=m,d.width=u,t!==void 0){let h=l();h.width=u,h.height=m;let w=c(h);if(w!=null)w.putImageData(e,0,0),a=w.getImageData(0,0,u,m).data;else throw new Error("Can not access image data")}else a=e.data}else if(o){if(t===void 0)throw new Error("Please provide image config with format for Imagebitmap");let m=l();m.width=e.width,m.height=e.height;let u=c(m);if(u!=null){let h=e.height,w=e.width;return u.drawImage(e,0,0,w,h),a=u.getImageData(0,0,w,h).data,d.height=h,d.width=w,Bn(a,d)}else throw new Error("Can not access image data")}else{if(i)return new Promise((m,u)=>{let h=l(),w=c(h);if(!e||!w)return u();let y=new Image;y.crossOrigin="Anonymous",y.src=e,y.onload=()=>{h.width=y.width,h.height=y.height,w.drawImage(y,0,0,h.width,h.height);let g=w.getImageData(0,0,h.width,h.height);d.height=h.height,d.width=h.width,m(Bn(g.data,d))}});throw new Error("Input data provided is not supported - aborted tensor creation")}if(a!==void 0)return Bn(a,d);throw new Error("Input data provided is not supported - aborted tensor creation")},Ji=(e,t)=>{let{width:r,height:n,download:o,dispose:i}=t,a=[1,n,r,4];return new Re({location:"texture",type:"float32",texture:e,dims:a,download:o,dispose:i})},ea=(e,t)=>{let{dataType:r,dims:n,download:o,dispose:i}=t;return new Re({location:"gpu-buffer",type:r??"float32",gpuBuffer:e,dims:n,download:o,dispose:i})},ta=(e,t,r)=>new Re({location:"cpu-pinned",type:e,data:t,dims:r??[t.length]})});var xt,Lt,na,oa,ia=U(()=>{"use strict";xt=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array],["int4",Uint8Array],["uint4",Uint8Array]]),Lt=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]),na=!1,oa=()=>{if(!na){na=!0;let e=typeof BigInt64Array<"u"&&BigInt64Array.from,t=typeof BigUint64Array<"u"&&BigUint64Array.from,r=typeof Float16Array<"u"&&Float16Array.from;e&&(xt.set("int64",BigInt64Array),Lt.set(BigInt64Array,"int64")),t&&(xt.set("uint64",BigUint64Array),Lt.set(BigUint64Array,"uint64")),r?(xt.set("float16",Float16Array),Lt.set(Float16Array,"float16")):xt.set("float16",Uint16Array)}}});var aa,sa,ua=U(()=>{"use strict";_r();aa=e=>{let t=1;for(let r=0;r<e.length;r++){let n=e[r];if(typeof n!="number"||!Number.isSafeInteger(n))throw new TypeError(`dims[${r}] must be an integer, got: ${n}`);if(n<0)throw new RangeError(`dims[${r}] must be a non-negative integer, got: ${n}`);t*=n}return t},sa=(e,t)=>{switch(e.location){case"cpu":return new Re(e.type,e.data,t);case"cpu-pinned":return new Re({location:"cpu-pinned",data:e.data,type:e.type,dims:t});case"texture":return new Re({location:"texture",texture:e.texture,type:e.type,dims:t});case"gpu-buffer":return new Re({location:"gpu-buffer",gpuBuffer:e.gpuBuffer,type:e.type,dims:t});default:throw new Error(`tensorReshape: tensor location ${e.location} is not supported`)}}});var Re,_r=U(()=>{"use strict";Zi();ra();ia();ua();Re=class{constructor(t,r,n){oa();let o,i;if(typeof t=="object"&&"location"in t)switch(this.dataLocation=t.location,o=t.type,i=t.dims,t.location){case"cpu-pinned":{let d=xt.get(o);if(!d)throw new TypeError(`unsupported type "${o}" to create tensor from pinned buffer`);if(!(t.data instanceof d))throw new TypeError(`buffer should be of type ${d.name}`);this.cpuData=t.data;break}case"texture":{if(o!=="float32")throw new TypeError(`unsupported type "${o}" to create tensor from texture`);this.gpuTextureData=t.texture,this.downloader=t.download,this.disposer=t.dispose;break}case"gpu-buffer":{if(o!=="float32"&&o!=="float16"&&o!=="int32"&&o!=="int64"&&o!=="uint32"&&o!=="uint8"&&o!=="bool"&&o!=="uint4"&&o!=="int4")throw new TypeError(`unsupported type "${o}" to create tensor from gpu buffer`);this.gpuBufferData=t.gpuBuffer,this.downloader=t.download,this.disposer=t.dispose;break}default:throw new Error(`Tensor constructor: unsupported location '${this.dataLocation}'`)}else{let d,l;if(typeof t=="string")if(o=t,l=n,t==="string"){if(!Array.isArray(r))throw new TypeError("A string tensor's data must be a string array.");d=r}else{let c=xt.get(t);if(c===void 0)throw new TypeError(`Unsupported tensor type: ${t}.`);if(Array.isArray(r)){if(t==="float16"&&c===Uint16Array||t==="uint4"||t==="int4")throw new TypeError(`Creating a ${t} tensor from number array is not supported. Please use ${c.name} as data.`);t==="uint64"||t==="int64"?d=c.from(r,BigInt):d=c.from(r)}else if(r instanceof c)d=r;else if(r instanceof Uint8ClampedArray)if(t==="uint8")d=Uint8Array.from(r);else throw new TypeError("A Uint8ClampedArray tensor's data must be type of uint8");else throw new TypeError(`A ${o} tensor's data must be type of ${c}`)}else if(l=r,Array.isArray(t)){if(t.length===0)throw new TypeError("Tensor type cannot be inferred from an empty array.");let c=typeof t[0];if(c==="string")o="string",d=t;else if(c==="boolean")o="bool",d=Uint8Array.from(t);else throw new TypeError(`Invalid element type of data array: ${c}.`)}else if(t instanceof Uint8ClampedArray)o="uint8",d=Uint8Array.from(t);else{let c=Lt.get(t.constructor);if(c===void 0)throw new TypeError(`Unsupported type for tensor data: ${t.constructor}.`);o=c,d=t}if(l===void 0)l=[d.length];else if(!Array.isArray(l))throw new TypeError("A tensor's dims must be a number array");i=l,this.cpuData=d,this.dataLocation="cpu"}let a=aa(i);if(this.cpuData&&a!==this.cpuData.length&&!((o==="uint4"||o==="int4")&&Math.ceil(a/2)===this.cpuData.length))throw new Error(`Tensor's size(${a}) does not match data length(${this.cpuData.length}).`);this.type=o,this.dims=i,this.size=a}static async fromImage(t,r){return Qi(t,r)}static fromTexture(t,r){return Ji(t,r)}static fromGpuBuffer(t,r){return ea(t,r)}static fromPinnedBuffer(t,r,n){return ta(t,r,n)}toDataURL(t){return Yi(this,t)}toImageData(t){return Xi(this,t)}get data(){if(this.ensureValid(),!this.cpuData)throw new Error("The data is not on CPU. Use `getData()` to download GPU data to CPU, or use `texture` or `gpuBuffer` property to access the GPU data directly.");return this.cpuData}get location(){return this.dataLocation}get texture(){if(this.ensureValid(),!this.gpuTextureData)throw new Error("The data is not stored as a WebGL texture.");return this.gpuTextureData}get gpuBuffer(){if(this.ensureValid(),!this.gpuBufferData)throw new Error("The data is not stored as a WebGPU buffer.");return this.gpuBufferData}async getData(t){switch(this.ensureValid(),this.dataLocation){case"cpu":case"cpu-pinned":return this.data;case"texture":case"gpu-buffer":{if(!this.downloader)throw new Error("The current tensor is not created with a specified data downloader.");if(this.isDownloading)throw new Error("The current tensor is being downloaded.");try{this.isDownloading=!0;let r=await this.downloader();return this.downloader=void 0,this.dataLocation="cpu",this.cpuData=r,t&&this.disposer&&(this.disposer(),this.disposer=void 0),r}finally{this.isDownloading=!1}}default:throw new Error(`cannot get data from location: ${this.dataLocation}`)}}dispose(){if(this.isDownloading)throw new Error("The current tensor is being downloaded.");this.disposer&&(this.disposer(),this.disposer=void 0),this.cpuData=void 0,this.gpuTextureData=void 0,this.gpuBufferData=void 0,this.downloader=void 0,this.isDownloading=void 0,this.dataLocation="none"}ensureValid(){if(this.dataLocation==="none")throw new Error("The tensor is disposed.")}reshape(t){if(this.ensureValid(),this.downloader||this.disposer)throw new Error("Cannot reshape a tensor that owns GPU resource.");return sa(this,t)}}});var Oe,$r=U(()=>{"use strict";_r();Oe=Re});var xr,da,Ne,Ue,Rn=U(()=>{"use strict";Dn();xr=(e,t)=>{(typeof We.trace>"u"?!We.wasm.trace:!We.trace)||console.timeStamp(`${e}::ORT::${t}`)},da=(e,t)=>{let r=new Error().stack?.split(/\r\n|\r|\n/g)||[],n=!1;for(let o=0;o<r.length;o++){if(n&&!r[o].includes("TRACE_FUNC")){let i=`FUNC_${e}::${r[o].trim().split(" ")[1]}`;t&&(i+=`::${t}`),xr("CPU",i);return}r[o].includes("TRACE_FUNC")&&(n=!0)}},Ne=e=>{(typeof We.trace>"u"?!We.wasm.trace:!We.trace)||da("BEGIN",e)},Ue=e=>{(typeof We.trace>"u"?!We.wasm.trace:!We.trace)||da("END",e)}});var Sr,la=U(()=>{"use strict";vr();$r();Rn();Sr=class e{constructor(t){this.handler=t}async run(t,r,n){Ne();let o={},i={};if(typeof t!="object"||t===null||t instanceof Oe||Array.isArray(t))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let a=!0;if(typeof r=="object"){if(r===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(r instanceof Oe)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(r)){if(r.length===0)throw new TypeError("'fetches' cannot be an empty array.");a=!1;for(let c of r){if(typeof c!="string")throw new TypeError("'fetches' must be a string array or an object.");if(this.outputNames.indexOf(c)===-1)throw new RangeError(`'fetches' contains invalid output name: ${c}.`);o[c]=null}if(typeof n=="object"&&n!==null)i=n;else if(typeof n<"u")throw new TypeError("'options' must be an object.")}else{let c=!1,m=Object.getOwnPropertyNames(r);for(let u of this.outputNames)if(m.indexOf(u)!==-1){let h=r[u];(h===null||h instanceof Oe)&&(c=!0,a=!1,o[u]=h)}if(c){if(typeof n=="object"&&n!==null)i=n;else if(typeof n<"u")throw new TypeError("'options' must be an object.")}else i=r}}else if(typeof r<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let c of this.inputNames)if(typeof t[c]>"u")throw new Error(`input '${c}' is missing in 'feeds'.`);if(a)for(let c of this.outputNames)o[c]=null;let d=await this.handler.run(t,o,i),l={};for(let c in d)if(Object.hasOwnProperty.call(d,c)){let m=d[c];m instanceof Oe?l[c]=m:l[c]=new Oe(m.type,m.data,m.dims)}return Ue(),l}async release(){return this.handler.dispose()}static async create(t,r,n,o){Ne();let i,a={};if(typeof t=="string"){if(i=t,typeof r=="object"&&r!==null)a=r;else if(typeof r<"u")throw new TypeError("'options' must be an object.")}else if(t instanceof Uint8Array){if(i=t,typeof r=="object"&&r!==null)a=r;else if(typeof r<"u")throw new TypeError("'options' must be an object.")}else if(t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer){let m=t,u=0,h=t.byteLength;if(typeof r=="object"&&r!==null)a=r;else if(typeof r=="number"){if(u=r,!Number.isSafeInteger(u))throw new RangeError("'byteOffset' must be an integer.");if(u<0||u>=m.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${m.byteLength}).`);if(h=t.byteLength-u,typeof n=="number"){if(h=n,!Number.isSafeInteger(h))throw new RangeError("'byteLength' must be an integer.");if(h<=0||u+h>m.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${m.byteLength-u}].`);if(typeof o=="object"&&o!==null)a=o;else if(typeof o<"u")throw new TypeError("'options' must be an object.")}else if(typeof n<"u")throw new TypeError("'byteLength' must be a number.")}else if(typeof r<"u")throw new TypeError("'options' must be an object.");i=new Uint8Array(m,u,h)}else throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");let[d,l]=await wr(a),c=await d.createInferenceSessionHandler(i,l);return Ue(),new e(c)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}}});var gp,ca=U(()=>{"use strict";la();gp=Sr});var pa=U(()=>{"use strict"});var ma=U(()=>{"use strict"});var fa=U(()=>{"use strict"});var ha=U(()=>{"use strict"});var yp,Ir,ga=U(()=>{"use strict";vr();$r();yp="Training backend could not be resolved. Make sure you're using the correct configuration & WebAssembly files.",Ir=class e{constructor(t,r,n){this.handler=t,this.hasOptimizerModel=r,this.hasEvalModel=n}get trainingInputNames(){return this.handler.inputNames}get trainingOutputNames(){return this.handler.outputNames}get evalInputNames(){if(this.hasEvalModel)return this.handler.evalInputNames;throw new Error("This training session has no evalModel loaded.")}get evalOutputNames(){if(this.hasEvalModel)return this.handler.evalOutputNames;throw new Error("This training session has no evalModel loaded.")}static async create(t,r){let n=t.evalModel||"",o=t.optimizerModel||"",i=r||{},[a,d]=await wr(i);if(a.createTrainingSessionHandler){let l=await a.createTrainingSessionHandler(t.checkpointState,t.trainModel,n,o,d);return new e(l,!!t.optimizerModel,!!t.evalModel)}else throw new Error(yp)}typeNarrowingForRunStep(t,r,n,o,i){let a={},d={};if(typeof n!="object"||n===null||n instanceof Oe||Array.isArray(n))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let l=!0;if(typeof o=="object"){if(o===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(o instanceof Oe)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(o)){if(o.length===0)throw new TypeError("'fetches' cannot be an empty array.");l=!1;for(let c of o){if(typeof c!="string")throw new TypeError("'fetches' must be a string array or an object.");if(r.indexOf(c)===-1)throw new RangeError(`'fetches' contains invalid output name: ${c}.`);a[c]=null}if(typeof i=="object"&&i!==null)d=i;else if(typeof i<"u")throw new TypeError("'options' must be an object.")}else{let c=!1,m=Object.getOwnPropertyNames(o);for(let u of r)if(m.indexOf(u)!==-1){let h=o[u];(h===null||h instanceof Oe)&&(c=!0,l=!1,a[u]=h)}if(c){if(typeof i=="object"&&i!==null)d=i;else if(typeof i<"u")throw new TypeError("'options' must be an object.")}else d=o}}else if(typeof o<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let c of t)if(typeof n[c]>"u")throw new Error(`input '${c}' is missing in 'feeds'.`);if(l)for(let c of r)a[c]=null;return[a,d]}convertHandlerReturnTypeToMapOfTensors(t){let r={};for(let n in t)if(Object.hasOwnProperty.call(t,n)){let o=t[n];o instanceof Oe?r[n]=o:r[n]=new Oe(o.type,o.data,o.dims)}return r}async lazyResetGrad(){await this.handler.lazyResetGrad()}async runTrainStep(t,r,n){let[o,i]=this.typeNarrowingForRunStep(this.trainingInputNames,this.trainingOutputNames,t,r,n),a=await this.handler.runTrainStep(t,o,i);return this.convertHandlerReturnTypeToMapOfTensors(a)}async runOptimizerStep(t){if(this.hasOptimizerModel)await this.handler.runOptimizerStep(t||{});else throw new Error("This TrainingSession has no OptimizerModel loaded.")}async runEvalStep(t,r,n){if(this.hasEvalModel){let[o,i]=this.typeNarrowingForRunStep(this.evalInputNames,this.evalOutputNames,t,r,n),a=await this.handler.runEvalStep(t,o,i);return this.convertHandlerReturnTypeToMapOfTensors(a)}else throw new Error("This TrainingSession has no EvalModel loaded.")}async getParametersSize(t=!0){return this.handler.getParametersSize(t)}async loadParametersBuffer(t,r=!0){let n=await this.getParametersSize(r);if(t.length!==4*n)throw new Error("Size of the buffer passed into loadParametersBuffer must match the number of parameters in the model. Please use getParametersSize method to check.");return this.handler.loadParametersBuffer(t,r)}async getContiguousParameters(t=!0){return this.handler.getContiguousParameters(t)}async release(){return this.handler.dispose()}}});var bp,ya=U(()=>{"use strict";ga();bp=Ir});var Mn={};Gt(Mn,{InferenceSession:()=>gp,TRACE:()=>xr,TRACE_FUNC_BEGIN:()=>Ne,TRACE_FUNC_END:()=>Ue,Tensor:()=>Oe,TrainingSession:()=>bp,env:()=>ye,registerBackend:()=>$t});var Ke=U(()=>{"use strict";Li();Ki();ca();$r();pa();ma();Rn();fa();ha();ya()});var Cr=U(()=>{"use strict"});var _a={};Gt(_a,{default:()=>wp});var wa,va,wp,$a=U(()=>{"use strict";Un();St();Ft();wa="ort-wasm-proxy-worker",va=globalThis.self?.name===wa;va&&(self.onmessage=e=>{let{type:t,in:r}=e.data;try{switch(t){case"init-wasm":Ar(r.wasm).then(()=>{Tr(r).then(()=>{postMessage({type:t})},n=>{postMessage({type:t,err:n})})},n=>{postMessage({type:t,err:n})});break;case"init-ep":{let{epName:n,env:o}=r;kr(o,n).then(()=>{postMessage({type:t})},i=>{postMessage({type:t,err:i})});break}case"copy-from":{let{buffer:n}=r,o=qt(n);postMessage({type:t,out:o});break}case"create":{let{model:n,options:o}=r;Er(n,o).then(i=>{postMessage({type:t,out:i})},i=>{postMessage({type:t,err:i})});break}case"release":Pr(r),postMessage({type:t});break;case"run":{let{sessionId:n,inputIndices:o,inputs:i,outputIndices:a,options:d}=r;zr(n,o,i,a,new Array(a.length).fill(null),d).then(l=>{l.some(c=>c[3]!=="cpu")?postMessage({type:t,err:"Proxy does not support non-cpu tensor location."}):postMessage({type:t,out:l},Dr([...i,...l]))},l=>{postMessage({type:t,err:l})});break}case"end-profiling":Or(r),postMessage({type:t});break;default:}}catch(n){postMessage({type:t,err:n})}});wp=va?null:e=>new Worker(e??Rt,{type:"module",name:wa})});var Sa={};Gt(Sa,{default:()=>vp});var Vn,xa,vp,Ia=U(()=>{"use strict";xa=(Vn=import.meta.url,async function(e={}){function t(){return le.buffer!=ce.buffer&&Ae(),ce}function r(){return le.buffer!=ce.buffer&&Ae(),Q}function n(){return le.buffer!=ce.buffer&&Ae(),be}function o(){return le.buffer!=ce.buffer&&Ae(),ae}function i(){return le.buffer!=ce.buffer&&Ae(),ie}function a(){return le.buffer!=ce.buffer&&Ae(),se}function d(){return le.buffer!=ce.buffer&&Ae(),M}function l(){return le.buffer!=ce.buffer&&Ae(),Me}var c,m,u=Object.assign({},e),h=new Promise((s,p)=>{c=s,m=p}),w=typeof window=="object",y=typeof importScripts=="function",g=y&&self.name=="em-pthread";u.mountExternalData=(s,p)=>{s.startsWith("./")&&(s=s.substring(2)),(u.Fb||(u.Fb=new Map)).set(s,p)},u.unmountExternalData=()=>{delete u.Fb};var x=globalThis.SharedArrayBuffer??new WebAssembly.Memory({initial:0,maximum:0,shared:!0}).buffer.constructor;let $=()=>{let s=(f,b,v)=>(...C)=>{let z=Je,D=b?.();C=f(...C);let N=b?.();return D!==N&&(f=N,v(D),b=v=null),Je!=z?new Promise((G,j)=>{Sn={resolve:G,reject:j}}):C},p=f=>async(...b)=>{try{if(u.Eb)throw Error("Session already started");let v=u.Eb={cc:b[0],errors:[]},C=await f(...b);if(u.Eb!==v)throw Error("Session mismatch");u.Mb?.flush();let z=v.errors;if(0<z.length){let D=await Promise.all(z);if(D=D.filter(N=>N),0<D.length)throw Error(D.join(` `))}return C}finally{u.Eb=null}};u._OrtCreateSession=s(u._OrtCreateSession,()=>u._OrtCreateSession,f=>u._OrtCreateSession=f),u._OrtRun=p(s(u._OrtRun,()=>u._OrtRun,f=>u._OrtRun=f)),u._OrtRunWithBinding=p(s(u._OrtRunWithBinding,()=>u._OrtRunWithBinding,f=>u._OrtRunWithBinding=f)),u._OrtBindInput=s(u._OrtBindInput,()=>u._OrtBindInput,f=>u._OrtBindInput=f),$=void 0};u.jsepInit=(s,p)=>{if($?.(),s==="webgpu"){[u.Mb,u.Tb,u.Xb,u.Nb,u.Wb,u.jb,u.Yb,u.$b,u.Ub,u.Vb,u.Zb]=p;let f=u.Mb;u.jsepRegisterBuffer=(b,v,C,z)=>f.registerBuffer(b,v,C,z),u.jsepGetBuffer=b=>f.getBuffer(b),u.jsepCreateDownloader=(b,v,C)=>f.createDownloader(b,v,C),u.jsepOnReleaseSession=b=>{f.onReleaseSession(b)},u.jsepOnRunStart=b=>f.onRunStart(b),u.ac=(b,v)=>{f.upload(b,v)}}};var _,S,I=Object.assign({},u),A="./this.program",T=(s,p)=>{throw p},O="";(w||y)&&(y?O=self.location.href:typeof document<"u"&&document.currentScript&&(O=document.currentScript.src),Vn&&(O=Vn),O=O.startsWith("blob:")?"":O.substr(0,O.replace(/[?#].*/,"").lastIndexOf("/")+1),y&&(S=s=>{var p=new XMLHttpRequest;return p.open("GET",s,!1),p.responseType="arraybuffer",p.send(null),new Uint8Array(p.response)}),_=(s,p,f)=>{var b=new XMLHttpRequest;b.open("GET",s,!0),b.responseType="arraybuffer",b.onload=()=>{b.status==200||b.status==0&&b.response?p(b.response):f()},b.onerror=f,b.send(null)});var B,W=console.log.bind(console),H=console.error.bind(console),K=W,X=H;if(Object.assign(u,I),I=null,g){let s=function(p){try{var f=p.data,b=f.cmd;if(b==="load"){let v=[];self.onmessage=C=>v.push(C),self.startWorker=()=>{postMessage({cmd:"loaded"});for(let C of v)s(C);self.onmessage=s};for(let C of f.handlers)u[C]&&!u[C].proxy||(u[C]=(...z)=>{postMessage({Lb:"callHandler",lc:C,args:z})},C=="print"&&(K=u[C]),C=="printErr"&&(X=u[C]));le=f.wasmMemory,Ae(),ne(f.wasmModule)}else if(b==="run"){Tn(f.pthread_ptr,0,0,1,0,0),_n(f.pthread_ptr),Yl(),Bo(),oe||(zi(),oe=!0);try{Xl(f.start_routine,f.arg)}catch(v){if(v!="unwind")throw v}}else b==="cancel"?Bt()&&hr(-1):f.target!=="setimmediate"&&(b==="checkMailbox"?oe&&ar():b&&(X(`worker: received unknown command ${b}`),X(f)))}catch(v){throw Oi(),v}};var Bh=s,ne,oe=!1;X=function(...p){p=p.join(" "),console.error(p)},self.alert=function(...p){postMessage({Lb:"alert",text:p.join(" "),nc:Bt()})},u.instantiateWasm=(p,f)=>new Promise(b=>{ne=v=>{v=new WebAssembly.Instance(v,Eo()),f(v),b()}}),self.onunhandledrejection=p=>{throw p.reason||p},self.onmessage=s}u.wasmBinary&&(B=u.wasmBinary);var le,Y,pe,ce,Q,be,ae,ie,se,M,F,fe,Me,Se=!1;function Ae(){var s=le.buffer;u.HEAP8=ce=new Int8Array(s),u.HEAP16=be=new Int16Array(s),u.HEAPU8=Q=new Uint8Array(s),u.HEAPU16=ae=new Uint16Array(s),u.HEAP32=ie=new Int32Array(s),u.HEAPU32=se=new Uint32Array(s),u.HEAPF32=M=new Float32Array(s),u.HEAPF64=Me=new Float64Array(s),u.HEAP64=F=new BigInt64Array(s),u.HEAPU64=fe=new BigUint64Array(s)}if(!g){if(!((le=new WebAssembly.Memory({initial:256,maximum:65536,shared:!0})).buffer instanceof x))throw X("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"),Error("bad memory");Ae()}var Ht=[],ze=[],Be=[],Fe=0,Et=null,yt=null;function Io(){if(--Fe==0&&(Et!==null&&(clearInterval(Et),Et=null),yt)){var s=yt;yt=null,s()}}function Pt(s){throw X(s="Aborted("+s+")"),Se=!0,pe=1,s=new WebAssembly.RuntimeError(s+". Build with -sASSERTIONS for more info."),m(s),s}var dn,Co=s=>s.startsWith("data:application/octet-stream;base64,"),Ao=s=>s.startsWith("file://");function To(s){if(s==dn&&B)return new Uint8Array(B);if(S)return S(s);throw"both async and sync fetching of the wasm failed"}function ko(s,p,f){return function(b){if(!B&&(w||y)){if(typeof fetch=="function"&&!Ao(b))return fetch(b,{credentials:"same-origin"}).then(v=>{if(!v.ok)throw`failed to load wasm binary file at '${b}'`;return v.arrayBuffer()}).catch(()=>To(b));if(_)return new Promise((v,C)=>{_(b,z=>v(new Uint8Array(z)),C)})}return Promise.resolve().then(()=>To(b))}(s).then(b=>WebAssembly.instantiate(b,p)).then(f,b=>{X(`failed to asynchronously prepare wasm: ${b}`),Pt(b)})}function Eo(){return{a:{M:Kl,za:jl,b:Ql,$:Vo,z:Ho,pa:Go,X:Fo,Z:qo,qa:jo,na:Ko,ga:Yo,ma:Xo,J:Zo,Y:Qo,V:Jo,oa:ei,W:ti,va:Jl,D:tc,P:rc,O:oc,C:ac,t:sc,q:uc,E:dc,y:gc,Q:yc,ta:bc,ja:wc,T:vc,aa:_c,F:$c,ia:_n,sa:xc,s:Sc,B:Ac,o:Tc,m:Ec,c:wn,n:Pc,k:Dc,Aa:Bc,p:Rc,g:Mc,v:Uc,l:Vc,f:Wc,j:Nc,i:Hc,h:Gc,d:Lc,da:Fc,ea:qc,fa:jc,ba:hi,ca:gi,S:Kc,e:Yc,N:Xc,G:Zc,K:Qc,w:Jc,ra:ep,U:tp,u:bi,x:rp,L:np,R:op,ya:ip,xa:ap,ka:_i,la:$i,_:fn,A:xi,I:Si,ha:Ii,H:Ci,a:le,wa:mn,ua:ki,r:dp}}}var ln={862036:(s,p,f,b,v)=>{if(u===void 0||!u.Fb)return 1;if((s=Ee(s>>>0)).startsWith("./")&&(s=s.substring(2)),!(s=u.Fb.get(s)))return 2;if(b>>>=0,(p>>>=0)+(f>>>=0)>s.byteLength)return 3;try{let C=s.subarray(p,p+f);switch(v){case 0:r().set(C,b>>>0);break;case 1:u.ac(b,C);break;default:return 4}return 0}catch{return 4}},862719:()=>{u.Ub()},862750:()=>{u.Vb()},862779:()=>{u.Zb()},862804:s=>u.Tb(s),862837:s=>u.Xb(s),862869:(s,p,f)=>{u.Nb(s,p,f,!0)},862908:(s,p,f)=>{u.Nb(s,p,f)},862941:()=>typeof wasmOffsetConverter<"u",862998:s=>{u.jb("Abs",s,void 0)},863049:s=>{u.jb("Neg",s,void 0)},863100:s=>{u.jb("Floor",s,void 0)},863153:s=>{u.jb("Ceil",s,void 0)},863205:s=>{u.jb("Reciprocal",s,void 0)},863263:s=>{u.jb("Sqrt",s,void 0)},863315:s=>{u.jb("Exp",s,void 0)},863366:s=>{u.jb("Erf",s,void 0)},863417:s=>{u.jb("Sigmoid",s,void 0)},863472:(s,p,f)=>{u.jb("HardSigmoid",s,{alpha:p,beta:f})},863551:s=>{u.jb("Log",s,void 0)},863602:s=>{u.jb("Sin",s,void 0)},863653:s=>{u.jb("Cos",s,void 0)},863704:s=>{u.jb("Tan",s,void 0)},863755:s=>{u.jb("Asin",s,void 0)},863807:s=>{u.jb("Acos",s,void 0)},863859:s=>{u.jb("Atan",s,void 0)},863911:s=>{u.jb("Sinh",s,void 0)},863963:s=>{u.jb("Cosh",s,void 0)},864015:s=>{u.jb("Asinh",s,void 0)},864068:s=>{u.jb("Acosh",s,void 0)},864121:s=>{u.jb("Atanh",s,void 0)},864174:s=>{u.jb("Tanh",s,void 0)},864226:s=>{u.jb("Not",s,void 0)},864277:(s,p,f)=>{u.jb("Clip",s,{min:p,max:f})},864346:s=>{u.jb("Clip",s,void 0)},864398:(s,p)=>{u.jb("Elu",s,{alpha:p})},864456:s=>{u.jb("Gelu",s,void 0)},864508:s=>{u.jb("Relu",s,void 0)},864560:(s,p)=>{u.jb("LeakyRelu",s,{alpha:p})},864624:(s,p)=>{u.jb("ThresholdedRelu",s,{alpha:p})},864694:(s,p)=>{u.jb("Cast",s,{to:p})},864752:s=>{u.jb("Add",s,void 0)},864803:s=>{u.jb("Sub",s,void 0)},864854:s=>{u.jb("Mul",s,void 0)},864905:s=>{u.jb("Div",s,void 0)},864956:s=>{u.jb("Pow",s,void 0)},865007:s=>{u.jb("Equal",s,void 0)},865060:s=>{u.jb("Greater",s,void 0)},865115:s=>{u.jb("GreaterOrEqual",s,void 0)},865177:s=>{u.jb("Less",s,void 0)},865229:s=>{u.jb("LessOrEqual",s,void 0)},865288:(s,p,f,b,v)=>{u.jb("ReduceMean",s,{keepDims:!!p,noopWithEmptyAxes:!!f,axes:b?Array.from(i().subarray(b>>>0,v>>>0)):[]})},865447:(s,p,f,b,v)=>{u.jb("ReduceMax",s,{keepDims:!!p,noopWithEmptyAxes:!!f,axes:b?Array.from(i().subarray(b>>>0,v>>>0)):[]})},865605:(s,p,f,b,v)=>{u.jb("ReduceMin",s,{keepDims:!!p,noopWithEmptyAxes:!!f,axes:b?Array.from(i().subarray(b>>>0,v>>>0)):[]})},865763:(s,p,f,b,v)=>{u.jb("ReduceProd",s,{keepDims:!!p,noopWithEmptyAxes:!!f,axes:b?Array.from(i().subarray(b>>>0,v>>>0)):[]})},865922:(s,p,f,b,v)=>{u.jb("ReduceSum",s,{keepDims:!!p,noopWithEmptyAxes:!!f,axes:b?Array.from(i().subarray(b>>>0,v>>>0)):[]})},866080:(s,p,f,b,v)=>{u.jb("ReduceL1",s,{keepDims:!!p,noopWithEmptyAxes:!!f,axes:b?Array.from(i().subarray(b>>>0,v>>>0)):[]})},866237:(s,p,f,b,v)=>{u.jb("ReduceL2",s,{keepDims:!!p,noopWithEmptyAxes:!!f,axes:b?Array.from(i().subarray(b>>>0,v>>>0)):[]})},866394:(s,p,f,b,v)=>{u.jb("ReduceLogSum",s,{keepDims:!!p,noopWithEmptyAxes:!!f,axes:b?Array.from(i().subarray(b>>>0,v>>>0)):[]})},866555:(s,p,f,b,v)=>{u.jb("ReduceSumSquare",s,{keepDims:!!p,noopWithEmptyAxes:!!f,axes:b?Array.from(i().subarray(b>>>0,v>>>0)):[]})},866719:(s,p,f,b,v)=>{u.jb("ReduceLogSumExp",s,{keepDims:!!p,noopWithEmptyAxes:!!f,axes:b?Array.from(i().subarray(b>>>0,v>>>0)):[]})},866883:s=>{u.jb("Where",s,void 0)},866936:(s,p,f)=>{u.jb("Transpose",s,{perm:p?Array.from(i().subarray(p>>>0,f>>>0)):[]})},867044:(s,p,f,b)=>{u.jb("DepthToSpace",s,{blocksize:p,mode:Ee(f),format:b?"NHWC":"NCHW"})},867177:(s,p,f,b)=>{u.jb("DepthToSpace",s,{blocksize:p,mode:Ee(f),format:b?"NHWC":"NCHW"})},867310:(s,p,f,b,v,C,z,D,N,G,j,de,he,P,ue)=>{u.jb("ConvTranspose",s,{format:N?"NHWC":"NCHW",autoPad:p,dilations:[f],group:b,kernelShape:[v],pads:[C,z],strides:[D],wIsConst:()=>!!t()[G>>>0],outputPadding:j?Array.from(i().subarray(j>>>0,de>>>0)):[],outputShape:he?Array.from(i().subarray(he>>>0,P>>>0)):[],activation:Ee(ue)})},867711:(s,p,f,b,v,C,z,D,N,G,j,de,he,P)=>{u.jb("ConvTranspose",s,{format:D?"NHWC":"NCHW",autoPad:p,dilations:Array.from(i().subarray(f>>>0,2+(f>>>0)>>>0)),group:b,kernelShape:Array.from(i().subarray(v>>>0,2+(v>>>0)>>>0)),pads:Array.from(i().subarray(C>>>0,4+(C>>>0)>>>0)),strides:Array.from(i().subarray(z>>>0,2+(z>>>0)>>>0)),wIsConst:()=>!!t()[N>>>0],outputPadding:G?Array.from(i().subarray(G>>>0,j>>>0)):[],outputShape:de?Array.from(i().subarray(de>>>0,he>>>0)):[],activation:Ee(P)})},868276:(s,p,f,b,v,C,z,D,N,G,j,de,he,P,ue)=>{u.jb("ConvTranspose",s,{format:N?"NHWC":"NCHW",autoPad:p,dilations:[f],group:b,kernelShape:[v],pads:[C,z],strides:[D],wIsConst:()=>!!t()[G>>>0],outputPadding:j?Array.from(i().subarray(j>>>0,de>>>0)):[],outputShape:he?Array.from(i().subarray(he>>>0,P>>>0)):[],activation:Ee(ue)})},868677:(s,p,f,b,v,C,z,D,N,G,j,de,he,P)=>{u.jb("ConvTranspose",s,{format:D?"NHWC":"NCHW",autoPad:p,dilations:Array.from(i().subarray(f>>>0,2+(f>>>0)>>>0)),group:b,kernelShape:Array.from(i().subarray(v>>>0,2+(v>>>0)>>>0)),pads:Array.from(i().subarray(C>>>0,4+(C>>>0)>>>0)),strides:Array.from(i().subarray(z>>>0,2+(z>>>0)>>>0)),wIsConst:()=>!!t()[N>>>0],outputPadding:G?Array.from(i().subarray(G>>>0,j>>>0)):[],outputShape:de?Array.from(i().subarray(de>>>0,he>>>0)):[],activation:Ee(P)})},869242:(s,p)=>{u.jb("GlobalAveragePool",s,{format:p?"NHWC":"NCHW"})},869333:(s,p,f,b,v,C,z,D,N,G,j,de,he,P)=>{u.jb("AveragePool",s,{format:P?"NHWC":"NCHW",auto_pad:p,ceil_mode:f,count_include_pad:b,storage_order:v,dilations:C?Array.from(i().subarray(C>>>0,z>>>0)):[],kernel_shape:D?Array.from(i().subarray(D>>>0,N>>>0)):[],pads:G?Array.from(i().subarray(G>>>0,j>>>0)):[],strides:de?Array.from(i().subarray(de>>>0,he>>>0)):[]})},869748:(s,p)=>{u.jb("GlobalAveragePool",s,{format:p?"NHWC":"NCHW"})},869839:(s,p,f,b,v,C,z,D,N,G,j,de,he,P)=>{u.jb("AveragePool",s,{format:P?"NHWC":"NCHW",auto_pad:p,ceil_mode:f,count_include_pad:b,storage_order:v,dilations:C?Array.from(i().subarray(C>>>0,z>>>0)):[],kernel_shape:D?Array.from(i().subarray(D>>>0,N>>>0)):[],pads:G?Array.from(i().subarray(G>>>0,j>>>0)):[],strides:de?Array.from(i().subarray(de>>>0,he>>>0)):[]})},870254:(s,p)=>{u.jb("GlobalMaxPool",s,{format:p?"NHWC":"NCHW"})},870341:(s,p,f,b,v,C,z,D,N,G,j,de,he,P)=>{u.jb("MaxPool",s,{format:P?"NHWC":"NCHW",auto_pad:p,ceil_mode:f,count_include_pad:b,storage_order:v,dilations:C?Array.from(i().subarray(C>>>0,z>>>0)):[],kernel_shape:D?Array.from(i().subarray(D>>>0,N>>>0)):[],pads:G?Array.from(i().subarray(G>>>0,j>>>0)):[],strides:de?Array.from(i().subarray(de>>>0,he>>>0)):[]})},870752:(s,p)=>{u.jb("GlobalMaxPool",s,{format:p?"NHWC":"NCHW"})},870839:(s,p,f,b,v,C,z,D,N,G,j,de,he,P)=>{u.jb("MaxPool",s,{format:P?"NHWC":"NCHW",auto_pad:p,ceil_mode:f,count_include_pad:b,storage_order:v,dilations:C?Array.from(i().subarray(C>>>0,z>>>0)):[],kernel_shape:D?Array.from(i().subarray(D>>>0,N>>>0)):[],pads:G?Array.from(i().subarray(G>>>0,j>>>0)):[],strides:de?Array.from(i().subarray(de>>>0,he>>>0)):[]})},871250:(s,p,f,b,v)=>{u.jb("Gemm",s,{alpha:p,beta:f,transA:b,transB:v})},871354:s=>{u.jb("MatMul",s,void 0)},871408:(s,p,f,b)=>{u.jb("ArgMax",s,{keepDims:!!p,selectLastIndex:!!f,axis:b})},871516:(s,p,f,b)=>{u.jb("ArgMin",s,{keepDims:!!p,selectLastIndex:!!f,axis:b})},871624:(s,p)=>{u.jb("Softmax",s,{axis:p})},871687:(s,p)=>{u.jb("Concat",s,{axis:p})},871747:(s,p,f,b,v)=>{u.jb("Split",s,{axis:p,numOutputs:f,splitSizes:b?Array.from(i().subarray(b>>>0,v>>>0)):[]})},871887:s=>{u.jb("Expand",s,void 0)},871941:(s,p)=>{u.jb("Gather",s,{axis:Number(p)})},872012:(s,p)=>{u.jb("GatherElements",s,{axis:Number(p)})},872091:(s,p,f,b,v,C,z,D,N,G,j)=>{u.jb("Resize",s,{antialias:p,axes:f?Array.from(i().subarray(f>>>0,b>>>0)):[],coordinateTransformMode:Ee(v),cubicCoeffA:C,excludeOutside:z,extrapolationValue:D,keepAspectRatioPolicy:Ee(N),mode:Ee(G),nearestMode:Ee(j)})},872437:(s,p,f,b,v,C,z)=>{u.jb("Slice",s,{starts:p?Array.from(i().subarray(p>>>0,f>>>0)):[],ends:b?Array.from(i().subarray(b>>>0,v>>>0)):[],axes:C?Array.from(i().subarray(C>>>0,z>>>0)):[]})},872653:s=>{u.jb("Tile",s,void 0)},872705:(s,p,f)=>{u.jb("InstanceNormalization",s,{epsilon:p,format:f?"NHWC":"NCHW"})},872819:(s,p,f)=>{u.jb("InstanceNormalization",s,{epsilon:p,format:f?"NHWC":"NCHW"})},872933:s=>{u.jb("Range",s,void 0)},872986:(s,p)=>{u.jb("Einsum",s,{equation:Ee(p)})},873067:(s,p,f,b,v)=>{u.jb("Pad",s,{mode:p,value:f,pads:b?Array.from(i().subarray(b>>>0,v>>>0)):[]})},873194:(s,p,f,b,v,C)=>{u.jb("BatchNormalization",s,{epsilon:p,momentum:f,spatial:!!v,trainingMode:!!b,format:C?"NHWC":"NCHW"})},873363:(s,p,f,b,v,C)=>{u.jb("BatchNormalization",s,{epsilon:p,momentum:f,spatial:!!v,trainingMode:!!b,format:C?"NHWC":"NCHW"})},873532:(s,p,f)=>{u.jb("CumSum",s,{exclusive:Number(p),reverse:Number(f)})},873629:(s,p,f)=>{u.jb("DequantizeLinear",s,{axis:p,blockSize:f})},873719:(s,p,f,b,v,C,z,D,N)=>{u.jb("Attention",s,{numHeads:p,isUnidirectional:f,maskFilterValue:b,scale:v,doRotary:C,qkvHiddenSizes:z?Array.from(i().subarray(Number(D)>>>0,Number(D)+z>>>0)):[],pastPresentShareBuffer:!!N})},873991:s=>{u.jb("BiasAdd",s,void 0)},874046:s=>{u.jb("BiasSplitGelu",s,void 0)},874107:s=>{u.jb("FastGelu",s,void 0)},874163:(s,p,f,b,v,C,z,D,N,G,j,de,he,P,ue,xe)=>{u.jb("Conv",s,{format:de?"NHWC":"NCHW",auto_pad:p,dilations:f?Array.from(i().subarray(f>>>0,b>>>0)):[],group:v,kernel_shape:C?Array.from(i().subarray(C>>>0,z>>>0)):[],pads:D?Array.from(i().subarray(D>>>0,N>>>0)):[],strides:G?Array.from(i().subarray(G>>>0,j>>>0)):[],w_is_const:()=>!!t()[he>>>0],activation:Ee(P),activation_params:ue?Array.from(d().subarray(ue>>>0,xe>>>0)):[]})},874659:s=>{u.jb("Gelu",s,void 0)},874711:(s,p,f,b)=>{u.jb("GroupQueryAttention",s,{numHeads:p,kvNumHeads:f,scale:b})},874824:(s,p,f,b)=>{u.jb("LayerNormalization",s,{axis:p,epsilon:f,simplified:!!b})},874935:(s,p,f,b)=>{u.jb("LayerNormalization",s,{axis:p,epsilon:f,simplified:!!b})},875046:(s,p,f,b,v,C)=>{u.jb("MatMulNBits",s,{k:p,n:f,accuracyLevel:b,bits:v,blockSize:C})},875173:(s,p,f,b,v,C)=>{u.jb("MultiHeadAttention",s,{numHeads:p,isUnidirectional:f,maskFilterValue:b,scale:v,doRotary:C})},875332:(s,p)=>{u.jb("QuickGelu",s,{alpha:p})},875396:(s,p,f,b,v)=>{u.jb("RotaryEmbedding",s,{interleaved:!!p,numHeads:f,rotaryEmbeddingDim:b,scale:v})},875535:(s,p,f)=>{u.jb("SkipLayerNormalization",s,{epsilon:p,simplified:!!f})},875637:(s,p,f)=>{u.jb("SkipLayerNormalization",s,{epsilon:p,simplified:!!f})},875739:(s,p,f,b)=>{u.jb("GatherBlockQuantized",s,{gatherAxis:p,quantizeAxis:f,blockSize:b})},875860:s=>{u.Yb(s)},875894:(s,p)=>u.$b(s,p,u.Eb.cc,u.Eb.errors)};function jl(s,p,f){return li(async()=>{await u.Wb(s,p,f)})}function Kl(){return typeof wasmOffsetConverter<"u"}function cn(s){this.name="ExitStatus",this.message=`Program terminated with exit(${s})`,this.status=s}var pn=s=>{s.terminate(),s.onmessage=()=>{}},Po=s=>{ct.length==0&&(Mo(),Ro(ct[0]));var p=ct.pop();if(!p)return 6;wt.push(p),Ze[s.Ab]=p,p.Ab=s.Ab;var f={cmd:"run",start_routine:s.dc,arg:s.Pb,pthread_ptr:s.Ab};return p.postMessage(f,s.jc),0},bt=0,$e=(s,p,...f)=>{for(var b=2*f.length,v=Pn(),C=En(8*b),z=C>>>3,D=0;D<f.length;D++){var N=f[D];typeof N=="bigint"?(F[z+2*D]=1n,F[z+2*D+1]=N):(F[z+2*D]=0n,l()[z+2*D+1>>>0]=N)}return s=Di(s,0,b,C,p),gr(v),s};function mn(s){if(g)return $e(0,1,s);if(pe=s,!(0<bt)){for(var p of wt)pn(p);for(p of ct)pn(p);ct=[],wt=[],Ze=[],Se=!0}T(s,new cn(s))}function zo(s){if(g)return $e(1,0,s);fn(s)}var fn=s=>{if(pe=s,g)throw zo(s),"unwind";mn(s)},ct=[],wt=[],Oo=[],Ze={},Do=s=>{var p=s.Ab;delete Ze[p],ct.push(s),wt.splice(wt.indexOf(s),1),s.Ab=0,kn(p)};function Bo(){Oo.forEach(s=>s())}var Ro=s=>new Promise(p=>{s.onmessage=v=>{var C=(v=v.data).cmd;if(v.targetThread&&v.targetThread!=Bt()){var z=Ze[v.targetThread];z?z.postMessage(v,v.transferList):X(`Internal error! Worker sent a message "${C}" to target pthread ${v.targetThread}, but that thread no longer exists!`)}else C==="checkMailbox"?ar():C==="spawnThread"?Po(v):C==="cleanupThread"?Do(Ze[v.thread]):C==="killThread"?(v=v.thread,C=Ze[v],delete Ze[v],pn(C),kn(v),wt.splice(wt.indexOf(C),1),C.Ab=0):C==="cancelThread"?Ze[v.thread].postMessage({cmd:"cancel"}):C==="loaded"?(s.loaded=!0,p(s)):C==="alert"?alert(`Thread ${v.threadId}: ${v.text}`):v.target==="setimmediate"?s.postMessage(v):C==="callHandler"?u[v.handler](...v.args):C&&X(`worker sent an unknown command ${C}`)},s.onerror=v=>{throw X(`worker sent an error! ${v.filename}:${v.lineno}: ${v.message}`),v};var f,b=[];for(f of[])u.hasOwnProperty(f)&&b.push(f);s.postMessage({cmd:"load",handlers:b,wasmMemory:le,wasmModule:Y})});function Mo(){var s=new Worker(new URL(import.meta.url),{type:"module",workerData:"em-pthread",name:"em-pthread"});ct.push(s)}var ir=s=>{for(;0<s.length;)s.shift()(u)},Yl=()=>{var s=Bt(),p=a()[s+52>>>2>>>0];s=a()[s+56>>>2>>>0],Ri(p,p-s),gr(p)},Xl=(s,p)=>{bt=0,s=Mi(s,p),0<bt?pe=s:hr(s)};class Zl{constructor(p){this.Ib=p-24}}function Ql(s,p,f){var b=new Zl(s>>>=0);throw p>>>=0,f>>>=0,a()[b.Ib+16>>>2>>>0]=0,a()[b.Ib+4>>>2>>>0]=p,a()[b.Ib+8>>>2>>>0]=f,s}function Uo(s,p,f,b){return g?$e(2,1,s,p,f,b):Vo(s,p,f,b)}function Vo(s,p,f,b){if(s>>>=0,p>>>=0,f>>>=0,b>>>=0,x===void 0)return X("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var v=[];return g&&v.length===0?Uo(s,p,f,b):(s={dc:f,Ab:s,Pb:b,jc:v},g?(s.Lb="spawnThread",postMessage(s,v),0):Po(s))}var Wo=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,No=(s,p,f)=>{var b=(p>>>=0)+f;for(f=p;s[f]&&!(f>=b);)++f;if(16<f-p&&s.buffer&&Wo)return Wo.decode(s.buffer instanceof x?s.slice(p,f):s.subarray(p,f));for(b="";p<f;){var v=s[p++];if(128&v){var C=63&s[p++];if((224&v)==192)b+=String.fromCharCode((31&v)<<6|C);else{var z=63&s[p++];65536>(v=(240&v)==224?(15&v)<<12|C<<6|z:(7&v)<<18|C<<12|z<<6|63&s[p++])?b+=String.fromCharCode(v):(v-=65536,b+=String.fromCharCode(55296|v>>10,56320|1023&v))}}else b+=String.fromCharCode(v)}return b},Ee=(s,p)=>(s>>>=0)?No(r(),s,p):"";function Ho(s,p,f){return g?$e(3,1,s,p,f):0}function Go(s,p){if(g)return $e(4,1,s,p)}var hn=s=>{for(var p=0,f=0;f<s.length;++f){var b=s.charCodeAt(f);127>=b?p++:2047>=b?p+=2:55296<=b&&57343>=b?(p+=4,++f):p+=3}return p},Lo=(s,p,f,b)=>{if(!(0<b))return 0;var v=f>>>=0;b=f+b-1;for(var C=0;C<s.length;++C){var z=s.charCodeAt(C);if(55296<=z&&57343>=z&&(z=65536+((1023&z)<<10)|1023&s.charCodeAt(++C)),127>=z){if(f>=b)break;p[f++>>>0]=z}else{if(2047>=z){if(f+1>=b)break;p[f++>>>0]=192|z>>6}else{if(65535>=z){if(f+2>=b)break;p[f++>>>0]=224|z>>12}else{if(f+3>=b)break;p[f++>>>0]=240|z>>18,p[f++>>>0]=128|z>>12&63}p[f++>>>0]=128|z>>6&63}p[f++>>>0]=128|63&z}}return p[f>>>0]=0,f-v},zt=(s,p,f)=>Lo(s,r(),p,f);function Fo(s,p){if(g)return $e(5,1,s,p)}function qo(s,p,f){if(g)return $e(6,1,s,p,f)}function jo(s,p,f){return g?$e(7,1,s,p,f):0}function Ko(s,p){if(g)return $e(8,1,s,p)}function Yo(s,p,f){if(g)return $e(9,1,s,p,f)}function Xo(s,p,f,b){if(g)return $e(10,1,s,p,f,b)}function Zo(s,p,f,b){if(g)return $e(11,1,s,p,f,b)}function Qo(s,p,f,b){if(g)return $e(12,1,s,p,f,b)}function Jo(s){if(g)return $e(13,1,s)}function ei(s,p){if(g)return $e(14,1,s,p)}function ti(s,p,f){if(g)return $e(15,1,s,p,f)}var ri,pt,Jl=()=>{Pt("")},Qe=s=>{for(var p="";r()[s>>>0];)p+=ri[r()[s++>>>0]];return p},gn={},yn={},ec={};function st(s,p,f={}){if(!("argPackAdvance"in p))throw new TypeError("registerType registeredInstance requires argPackAdvance");return function(b,v,C={}){var z=v.name;if(!b)throw new pt(`type "${z}" must have a positive integer typeid pointer`);if(yn.hasOwnProperty(b)){if(C.Rb)return;throw new pt(`Cannot register type '${z}' twice`)}yn[b]=v,delete ec[b],gn.hasOwnProperty(b)&&(v=gn[b],delete gn[b],v.forEach(D=>D()))}(s,p,f)}var ni=(s,p,f)=>{switch(p){case 1:return f?b=>t()[b>>>0]:b=>r()[b>>>0];case 2:return f?b=>n()[b>>>1>>>0]:b=>o()[b>>>1>>>0];case 4:return f?b=>i()[b>>>2>>>0]:b=>a()[b>>>2>>>0];case 8:return f?b=>F[b>>>3]:b=>fe[b>>>3];default:throw new TypeError(`invalid integer width (${p}): ${s}`)}};function tc(s,p,f){f>>>=0,st(s>>>=0,{name:p=Qe(p>>>0),fromWireType:b=>b,toWireType:function(b,v){if(typeof v!="bigint"&&typeof v!="number")throw v=v===null?"null":(b=typeof v)=="object"||b==="array"||b==="function"?v.toString():""+v,new TypeError(`Cannot convert "${v}" to ${this.name}`);return typeof v=="number"&&(v=BigInt(v)),v},argPackAdvance:mt,readValueFromPointer:ni(p,f,p.indexOf("u")==-1),Db:null})}var mt=8;function rc(s,p,f,b){st(s>>>=0,{name:p=Qe(p>>>0),fromWireType:function(v){return!!v},toWireType:function(v,C){return C?f:b},argPackAdvance:mt,readValueFromPointer:function(v){return this.fromWireType(r()[v>>>0])},Db:null})}var bn=[],ut=[];function wn(s){9<(s>>>=0)&&--ut[s+1]==0&&(ut[s]=void 0,bn.push(s))}var qe=s=>{if(!s)throw new pt("Cannot use deleted val. handle = "+s);return ut[s]},je=s=>{switch(s){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:let p=bn.pop()||ut.length;return ut[p]=s,ut[p+1]=1,p}};function vn(s){return this.fromWireType(a()[s>>>2>>>0])}var nc={name:"emscripten::val",fromWireType:s=>{var p=qe(s);return wn(s),p},toWireType:(s,p)=>je(p),argPackAdvance:mt,readValueFromPointer:vn,Db:null};function oc(s){return st(s>>>0,nc)}var ic=(s,p)=>{switch(p){case 4:return function(f){return this.fromWireType(d()[f>>>2>>>0])};case 8:return function(f){return this.fromWireType(l()[f>>>3>>>0])};default:throw new TypeError(`invalid float width (${p}): ${s}`)}};function ac(s,p,f){f>>>=0,st(s>>>=0,{name:p=Qe(p>>>0),fromWireType:b=>b,toWireType:(b,v)=>v,argPackAdvance:mt,readValueFromPointer:ic(p,f),Db:null})}function sc(s,p,f,b,v){if(s>>>=0,f>>>=0,p=Qe(p>>>0),v===-1&&(v=4294967295),v=D=>D,b===0){var C=32-8*f;v=D=>D<<C>>>C}var z=p.includes("unsigned")?function(D,N){return N>>>0}:function(D,N){return N};st(s,{name:p,fromWireType:v,toWireType:z,argPackAdvance:mt,readValueFromPointer:ni(p,f,b!==0),Db:null})}function uc(s,p,f){function b(C){var z=a()[C>>>2>>>0];return C=a()[C+4>>>2>>>0],new v(t().buffer,C,z)}var v=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array][p];st(s>>>=0,{name:f=Qe(f>>>0),fromWireType:b,argPackAdvance:mt,readValueFromPointer:b},{Rb:!0})}function dc(s,p){s>>>=0;var f=(p=Qe(p>>>0))==="std::string";st(s,{name:p,fromWireType:function(b){var v=a()[b>>>2>>>0],C=b+4;if(f)for(var z=C,D=0;D<=v;++D){var N=C+D;if(D==v||r()[N>>>0]==0){if(z=Ee(z,N-z),G===void 0)var G=z;else G+=String.fromCharCode(0),G+=z;z=N+1}}else{for(G=Array(v),D=0;D<v;++D)G[D]=String.fromCharCode(r()[C+D>>>0]);G=G.join("")}return et(b),G},toWireType:function(b,v){v instanceof ArrayBuffer&&(v=new Uint8Array(v));var C=typeof v=="string";if(!(C||v instanceof Uint8Array||v instanceof Uint8ClampedArray||v instanceof Int8Array))throw new pt("Cannot pass non-string to std::string");var z=f&&C?hn(v):v.length,D=fr(4+z+1),N=D+4;if(a()[D>>>2>>>0]=z,f&&C)zt(v,N,z+1);else if(C)for(C=0;C<z;++C){var G=v.charCodeAt(C);if(255<G)throw et(N),new pt("String has UTF-16 code units that do not fit in 8 bits");r()[N+C>>>0]=G}else for(C=0;C<z;++C)r()[N+C>>>0]=v[C];return b!==null&&b.push(et,D),D},argPackAdvance:mt,readValueFromPointer:vn,Db(b){et(b)}})}var oi=typeof TextDecoder<"u"?new TextDecoder("utf-16le"):void 0,lc=(s,p)=>{for(var f=s>>1,b=f+p/2;!(f>=b)&&o()[f>>>0];)++f;if(32<(f<<=1)-s&&oi)return oi.decode(r().slice(s,f));for(f="",b=0;!(b>=p/2);++b){var v=n()[s+2*b>>>1>>>0];if(v==0)break;f+=String.fromCharCode(v)}return f},cc=(s,p,f)=>{if(f??=2147483647,2>f)return 0;var b=p;f=(f-=2)<2*s.length?f/2:s.length;for(var v=0;v<f;++v){var C=s.charCodeAt(v);n()[p>>>1>>>0]=C,p+=2}return n()[p>>>1>>>0]=0,p-b},pc=s=>2*s.length,