/*! * ONNX Runtime Web v1.18.0 * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */var vd=Object.create,Pn=Object.defineProperty,_d=Object.getOwnPropertyDescriptor,Od=Object.getOwnPropertyNames,Id=Object.getPrototypeOf,Sd=Object.prototype.hasOwnProperty,L=(e,r)=>()=>(e&&(r=e(e=0)),r),me=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),Sr=(e,r)=>{for(var a in r)Pn(e,a,{get:r[a],enumerable:!0})},Va=(e,r,a,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let l of Od(r))!Sd.call(e,l)&&l!==a&&Pn(e,l,{get:()=>r[l],enumerable:!(i=_d(r,l))||i.enumerable});return e},Ar=(e,r,a)=>(a=e!=null?vd(Id(e)):{},Va(!e||!e.__esModule?Pn(a,"default",{value:e,enumerable:!0}):a,e)),ar=e=>Va(Pn({},"__esModule",{value:!0}),e),En,sr,Pr,Ad,Dn,Ln=L(()=>{En=new Map,sr=[],Pr=(e,r,a)=>{if(r&&typeof r.init=="function"&&typeof r.createInferenceSessionHandler=="function"){let i=En.get(e);if(i===void 0)En.set(e,{backend:r,priority:a});else{if(i.priority>a)return;if(i.priority===a&&i.backend!==r)throw new Error(`cannot register backend "${e}" using priority ${a}`)}if(a>=0){let l=sr.indexOf(e);l!==-1&&sr.splice(l,1);for(let n=0;n{let r=En.get(e);if(!r)return"backend not found.";if(r.initialized)return r.backend;if(r.aborted)return r.error;{let a=!!r.initPromise;try{return a||(r.initPromise=r.backend.init(e)),await r.initPromise,r.initialized=!0,r.backend}catch(i){return a||(r.error=`${i}`,r.aborted=!0),r.error}finally{delete r.initPromise}}},Dn=async e=>{let r=e.executionProviders||[],a=r.map(c=>typeof c=="string"?c:c.name),i=a.length===0?sr:a,l,n=[],o=new Set;for(let c of i){let t=await Ad(c);typeof t=="string"?n.push({name:c,err:t}):(l||(l=t),l===t&&o.add(c))}if(!l)throw new Error(`no available backend found. ERR: ${n.map(c=>`[${c.name}] ${c.err}`).join(", ")}`);for(let{name:c,err:t}of n)a.includes(c)&&console.warn(`removing requested execution provider "${c}" from session options because it is not available: ${t}`);let p=r.filter(c=>o.has(typeof c=="string"?c:c.name));return[l,new Proxy(e,{get:(c,t)=>t==="executionProviders"?p:Reflect.get(c,t)})]}}),Wa=L(()=>{Ln()}),Ha,qa=L(()=>{Ha="1.18.0"}),ja,ut,Vo=L(()=>{qa(),ja="warning",ut={wasm:{},webgl:{},webgpu:{},versions:{common:Ha},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}`);ja=e}},get logLevel(){return ja}},Object.defineProperty(ut,"logLevel",{enumerable:!0})}),Z,Ya=L(()=>{Vo(),Z=ut}),Xa,Ka,Ja=L(()=>{Xa=(e,r)=>{let a=typeof document<"u"?document.createElement("canvas"):new OffscreenCanvas(1,1);a.width=e.dims[3],a.height=e.dims[2];let i=a.getContext("2d");if(i!=null){let l,n;(r==null?void 0:r.tensorLayout)!==void 0&&r.tensorLayout==="NHWC"?(l=e.dims[2],n=e.dims[3]):(l=e.dims[3],n=e.dims[2]);let o=(r==null?void 0:r.format)!==void 0?r.format:"RGB",p=r==null?void 0:r.norm,c,t;p===void 0||p.mean===void 0?c=[255,255,255,255]:typeof p.mean=="number"?c=[p.mean,p.mean,p.mean,p.mean]:(c=[p.mean[0],p.mean[1],p.mean[2],0],p.mean[3]!==void 0&&(c[3]=p.mean[3])),p===void 0||p.bias===void 0?t=[0,0,0,0]:typeof p.bias=="number"?t=[p.bias,p.bias,p.bias,p.bias]:(t=[p.bias[0],p.bias[1],p.bias[2],0],p.bias[3]!==void 0&&(t[3]=p.bias[3]));let u=n*l,s=0,d=u,f=u*2,b=-1;o==="RGBA"?(s=0,d=u,f=u*2,b=u*3):o==="RGB"?(s=0,d=u,f=u*2):o==="RBG"&&(s=0,f=u,d=u*2);for(let y=0;y{let a=typeof document<"u"?document.createElement("canvas").getContext("2d"):new OffscreenCanvas(1,1).getContext("2d"),i;if(a!=null){let l,n,o;(r==null?void 0:r.tensorLayout)!==void 0&&r.tensorLayout==="NHWC"?(l=e.dims[2],n=e.dims[1],o=e.dims[3]):(l=e.dims[3],n=e.dims[2],o=e.dims[1]);let p=r!==void 0&&r.format!==void 0?r.format:"RGB",c=r==null?void 0:r.norm,t,u;c===void 0||c.mean===void 0?t=[255,255,255,255]:typeof c.mean=="number"?t=[c.mean,c.mean,c.mean,c.mean]:(t=[c.mean[0],c.mean[1],c.mean[2],255],c.mean[3]!==void 0&&(t[3]=c.mean[3])),c===void 0||c.bias===void 0?u=[0,0,0,0]:typeof c.bias=="number"?u=[c.bias,c.bias,c.bias,c.bias]:(u=[c.bias[0],c.bias[1],c.bias[2],0],c.bias[3]!==void 0&&(u[3]=c.bias[3]));let s=n*l;if(r!==void 0&&(r.format!==void 0&&o===4&&r.format!=="RGBA"||o===3&&r.format!=="RGB"&&r.format!=="BGR"))throw new Error("Tensor format doesn't match input tensor dims");let d=4,f=0,b=1,y=2,v=3,E=0,T=s,$=s*2,F=-1;p==="RGBA"?(E=0,T=s,$=s*2,F=s*3):p==="RGB"?(E=0,T=s,$=s*2):p==="RBG"&&(E=0,$=s,T=s*2),i=a.createImageData(l,n);for(let C=0;C{Cn(),Wo=(e,r)=>{if(e===void 0)throw new Error("Image buffer must be defined");if(r.height===void 0||r.width===void 0)throw new Error("Image height and width must be defined");if(r.tensorLayout==="NHWC")throw new Error("NHWC Tensor layout is not supported yet");let{height:a,width:i}=r,l=r.norm??{mean:255,bias:0},n,o;typeof l.mean=="number"?n=[l.mean,l.mean,l.mean,l.mean]:n=[l.mean[0],l.mean[1],l.mean[2],l.mean[3]??255],typeof l.bias=="number"?o=[l.bias,l.bias,l.bias,l.bias]:o=[l.bias[0],l.bias[1],l.bias[2],l.bias[3]??0];let p=r.format!==void 0?r.format:"RGBA",c=r.tensorFormat!==void 0&&r.tensorFormat!==void 0?r.tensorFormat:"RGB",t=a*i,u=c==="RGBA"?new Float32Array(t*4):new Float32Array(t*3),s=4,d=0,f=1,b=2,y=3,v=0,E=t,T=t*2,$=-1;p==="RGB"&&(s=3,d=0,f=1,b=2,y=-1),c==="RGBA"?$=t*3:c==="RBG"?(v=0,T=t,E=t*2):c==="BGR"&&(T=0,E=t,v=t*2);for(let F=0;F{let a=typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement,i=typeof ImageData<"u"&&e instanceof ImageData,l=typeof ImageBitmap<"u"&&e instanceof ImageBitmap,n=typeof e=="string",o,p=r??{},c=()=>{if(typeof document<"u")return document.createElement("canvas");if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(1,1);throw new Error("Canvas is not supported")},t=u=>u instanceof HTMLCanvasElement||u instanceof OffscreenCanvas?u.getContext("2d"):null;if(a){let u=c();u.width=e.width,u.height=e.height;let s=t(u);if(s!=null){let d=e.height,f=e.width;if(r!==void 0&&r.resizedHeight!==void 0&&r.resizedWidth!==void 0&&(d=r.resizedHeight,f=r.resizedWidth),r!==void 0){if(p=r,r.tensorFormat!==void 0)throw new Error("Image input config format must be RGBA for HTMLImageElement");p.tensorFormat="RGBA",p.height=d,p.width=f}else p.tensorFormat="RGBA",p.height=d,p.width=f;s.drawImage(e,0,0),o=s.getImageData(0,0,f,d).data}else throw new Error("Can not access image data")}else if(i){let u,s;if(r!==void 0&&r.resizedWidth!==void 0&&r.resizedHeight!==void 0?(u=r.resizedHeight,s=r.resizedWidth):(u=e.height,s=e.width),r!==void 0&&(p=r),p.format="RGBA",p.height=u,p.width=s,r!==void 0){let d=c();d.width=s,d.height=u;let f=t(d);if(f!=null)f.putImageData(e,0,0),o=f.getImageData(0,0,s,u).data;else throw new Error("Can not access image data")}else o=e.data}else if(l){if(r===void 0)throw new Error("Please provide image config with format for Imagebitmap");let u=c();u.width=e.width,u.height=e.height;let s=t(u);if(s!=null){let d=e.height,f=e.width;return s.drawImage(e,0,0,f,d),o=s.getImageData(0,0,f,d).data,p.height=d,p.width=f,Wo(o,p)}else throw new Error("Can not access image data")}else{if(n)return new Promise((u,s)=>{let d=c(),f=t(d);if(!e||!f)return s();let b=new Image;b.crossOrigin="Anonymous",b.src=e,b.onload=()=>{d.width=b.width,d.height=b.height,f.drawImage(b,0,0,d.width,d.height);let y=f.getImageData(0,0,d.width,d.height);p.height=d.height,p.width=d.width,u(Wo(y.data,p))}});throw new Error("Input data provided is not supported - aborted tensor creation")}if(o!==void 0)return Wo(o,p);throw new Error("Input data provided is not supported - aborted tensor creation")},Qa=(e,r)=>{let{width:a,height:i,download:l,dispose:n}=r,o=[1,i,a,4];return new Je({location:"texture",type:"float32",texture:e,dims:o,download:l,dispose:n})},es=(e,r)=>{let{dataType:a,dims:i,download:l,dispose:n}=r;return new Je({location:"gpu-buffer",type:a??"float32",gpuBuffer:e,dims:i,download:l,dispose:n})},ts=(e,r,a)=>new Je({location:"cpu-pinned",type:e,data:r,dims:a??[r.length]})}),ur,Qr,ns,os,is=L(()=>{ur=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array]]),Qr=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]),ns=!1,os=()=>{if(!ns){ns=!0;let e=typeof BigInt64Array<"u"&&BigInt64Array.from,r=typeof BigUint64Array<"u"&&BigUint64Array.from,a=typeof Float16Array<"u"&&Float16Array.from;e&&(ur.set("int64",BigInt64Array),Qr.set(BigInt64Array,"int64")),r&&(ur.set("uint64",BigUint64Array),Qr.set(BigUint64Array,"uint64")),a?(ur.set("float16",Float16Array),Qr.set(Float16Array,"float16")):ur.set("float16",Uint16Array)}}}),as,ss,us=L(()=>{Cn(),as=e=>{let r=1;for(let a=0;a{switch(e.location){case"cpu":return new Je(e.type,e.data,r);case"cpu-pinned":return new Je({location:"cpu-pinned",data:e.data,type:e.type,dims:r});case"texture":return new Je({location:"texture",texture:e.texture,type:e.type,dims:r});case"gpu-buffer":return new Je({location:"gpu-buffer",gpuBuffer:e.gpuBuffer,type:e.type,dims:r});default:throw new Error(`tensorReshape: tensor location ${e.location} is not supported`)}}}),Je,Cn=L(()=>{Ja(),rs(),is(),us(),Je=class{constructor(e,r,a){os();let i,l;if(typeof e=="object"&&"location"in e)switch(this.dataLocation=e.location,i=e.type,l=e.dims,e.location){case"cpu-pinned":{let o=ur.get(i);if(!o)throw new TypeError(`unsupported type "${i}" to create tensor from pinned buffer`);if(!(e.data instanceof o))throw new TypeError(`buffer should be of type ${o.name}`);this.cpuData=e.data;break}case"texture":{if(i!=="float32")throw new TypeError(`unsupported type "${i}" to create tensor from texture`);this.gpuTextureData=e.texture,this.downloader=e.download,this.disposer=e.dispose;break}case"gpu-buffer":{if(i!=="float32"&&i!=="float16"&&i!=="int32"&&i!=="int64"&&i!=="uint32"&&i!=="uint8"&&i!=="bool")throw new TypeError(`unsupported type "${i}" to create tensor from gpu buffer`);this.gpuBufferData=e.gpuBuffer,this.downloader=e.download,this.disposer=e.dispose;break}default:throw new Error(`Tensor constructor: unsupported location '${this.dataLocation}'`)}else{let o,p;if(typeof e=="string")if(i=e,p=a,e==="string"){if(!Array.isArray(r))throw new TypeError("A string tensor's data must be a string array.");o=r}else{let c=ur.get(e);if(c===void 0)throw new TypeError(`Unsupported tensor type: ${e}.`);if(Array.isArray(r)){if(e==="float16"&&c===Uint16Array)throw new TypeError("Creating a float16 tensor from number array is not supported. Please use Uint16Array as data.");e==="uint64"||e==="int64"?o=c.from(r,BigInt):o=c.from(r)}else if(r instanceof c)o=r;else throw new TypeError(`A ${i} tensor's data must be type of ${c}`)}else if(p=r,Array.isArray(e)){if(e.length===0)throw new TypeError("Tensor type cannot be inferred from an empty array.");let c=typeof e[0];if(c==="string")i="string",o=e;else if(c==="boolean")i="bool",o=Uint8Array.from(e);else throw new TypeError(`Invalid element type of data array: ${c}.`)}else{let c=Qr.get(e.constructor);if(c===void 0)throw new TypeError(`Unsupported type for tensor data: ${e.constructor}.`);i=c,o=e}if(p===void 0)p=[o.length];else if(!Array.isArray(p))throw new TypeError("A tensor's dims must be a number array");l=p,this.cpuData=o,this.dataLocation="cpu"}let n=as(l);if(this.cpuData&&n!==this.cpuData.length)throw new Error(`Tensor's size(${n}) does not match data length(${this.cpuData.length}).`);this.type=i,this.dims=l,this.size=n}static async fromImage(e,r){return Za(e,r)}static fromTexture(e,r){return Qa(e,r)}static fromGpuBuffer(e,r){return es(e,r)}static fromPinnedBuffer(e,r,a){return ts(e,r,a)}toDataURL(e){return Xa(this,e)}toImageData(e){return Ka(this,e)}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(e){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,e&&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(e){if(this.ensureValid(),this.downloader||this.disposer)throw new Error("Cannot reshape a tensor that owns GPU resource.");return ss(this,e)}}}),Me,Fn=L(()=>{Cn(),Me=Je}),ls,fs,lr,fr,Ho=L(()=>{Vo(),ls=(e,r)=>{(typeof ut.trace>"u"?!ut.wasm.trace:!ut.trace)||console.timeStamp(`${e}::ORT::${r}`)},fs=(e,r)=>{var l;let a=((l=new Error().stack)==null?void 0:l.split(/\r\n|\r|\n/g))||[],i=!1;for(let n=0;n{(typeof ut.trace>"u"?!ut.wasm.trace:!ut.trace)||fs("BEGIN",e)},fr=e=>{(typeof ut.trace>"u"?!ut.wasm.trace:!ut.trace)||fs("END",e)}}),$n,cs=L(()=>{Ln(),Fn(),Ho(),$n=class ci{constructor(r){this.handler=r}async run(r,a,i){lr();let l={},n={};if(typeof r!="object"||r===null||r instanceof Me||Array.isArray(r))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let o=!0;if(typeof a=="object"){if(a===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(a instanceof Me)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(a)){if(a.length===0)throw new TypeError("'fetches' cannot be an empty array.");o=!1;for(let t of a){if(typeof t!="string")throw new TypeError("'fetches' must be a string array or an object.");if(this.outputNames.indexOf(t)===-1)throw new RangeError(`'fetches' contains invalid output name: ${t}.`);l[t]=null}if(typeof i=="object"&&i!==null)n=i;else if(typeof i<"u")throw new TypeError("'options' must be an object.")}else{let t=!1,u=Object.getOwnPropertyNames(a);for(let s of this.outputNames)if(u.indexOf(s)!==-1){let d=a[s];(d===null||d instanceof Me)&&(t=!0,o=!1,l[s]=d)}if(t){if(typeof i=="object"&&i!==null)n=i;else if(typeof i<"u")throw new TypeError("'options' must be an object.")}else n=a}}else if(typeof a<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let t of this.inputNames)if(typeof r[t]>"u")throw new Error(`input '${t}' is missing in 'feeds'.`);if(o)for(let t of this.outputNames)l[t]=null;let p=await this.handler.run(r,l,n),c={};for(let t in p)if(Object.hasOwnProperty.call(p,t)){let u=p[t];u instanceof Me?c[t]=u:c[t]=new Me(u.type,u.data,u.dims)}return fr(),c}async release(){return this.handler.dispose()}static async create(r,a,i,l){lr();let n,o={};if(typeof r=="string"){if(n=r,typeof a=="object"&&a!==null)o=a;else if(typeof a<"u")throw new TypeError("'options' must be an object.")}else if(r instanceof Uint8Array){if(n=r,typeof a=="object"&&a!==null)o=a;else if(typeof a<"u")throw new TypeError("'options' must be an object.")}else if(r instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&r instanceof SharedArrayBuffer){let u=r,s=0,d=r.byteLength;if(typeof a=="object"&&a!==null)o=a;else if(typeof a=="number"){if(s=a,!Number.isSafeInteger(s))throw new RangeError("'byteOffset' must be an integer.");if(s<0||s>=u.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${u.byteLength}).`);if(d=r.byteLength-s,typeof i=="number"){if(d=i,!Number.isSafeInteger(d))throw new RangeError("'byteLength' must be an integer.");if(d<=0||s+d>u.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${u.byteLength-s}].`);if(typeof l=="object"&&l!==null)o=l;else if(typeof l<"u")throw new TypeError("'options' must be an object.")}else if(typeof i<"u")throw new TypeError("'byteLength' must be a number.")}else if(typeof a<"u")throw new TypeError("'options' must be an object.");n=new Uint8Array(u,s,d)}else throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");let[p,c]=await Dn(o),t=await p.createInferenceSessionHandler(n,c);return fr(),new ci(t)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}}}),Pd,ps=L(()=>{cs(),Pd=$n}),ds=L(()=>{}),hs=L(()=>{}),ms=L(()=>{}),bs=L(()=>{}),Ed,kn,gs=L(()=>{Ln(),Fn(),Ed="Training backend could not be resolved. Make sure you're using the correct configuration & WebAssembly files.",kn=class ra{constructor(r,a,i){this.handler=r,this.hasOptimizerModel=a,this.hasEvalModel=i}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(r,a){let i=r.evalModel||"",l=r.optimizerModel||"",n=a||{},[o,p]=await Dn(n);if(o.createTrainingSessionHandler){let c=await o.createTrainingSessionHandler(r.checkpointState,r.trainModel,i,l,p);return new ra(c,!!r.optimizerModel,!!r.evalModel)}else throw new Error(Ed)}typeNarrowingForRunStep(r,a,i,l,n){let o={},p={};if(typeof i!="object"||i===null||i instanceof Me||Array.isArray(i))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let c=!0;if(typeof l=="object"){if(l===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(l instanceof Me)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(l)){if(l.length===0)throw new TypeError("'fetches' cannot be an empty array.");c=!1;for(let t of l){if(typeof t!="string")throw new TypeError("'fetches' must be a string array or an object.");if(a.indexOf(t)===-1)throw new RangeError(`'fetches' contains invalid output name: ${t}.`);o[t]=null}if(typeof n=="object"&&n!==null)p=n;else if(typeof n<"u")throw new TypeError("'options' must be an object.")}else{let t=!1,u=Object.getOwnPropertyNames(l);for(let s of a)if(u.indexOf(s)!==-1){let d=l[s];(d===null||d instanceof Me)&&(t=!0,c=!1,o[s]=d)}if(t){if(typeof n=="object"&&n!==null)p=n;else if(typeof n<"u")throw new TypeError("'options' must be an object.")}else p=l}}else if(typeof l<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let t of r)if(typeof i[t]>"u")throw new Error(`input '${t}' is missing in 'feeds'.`);if(c)for(let t of a)o[t]=null;return[o,p]}convertHandlerReturnTypeToMapOfTensors(r){let a={};for(let i in r)if(Object.hasOwnProperty.call(r,i)){let l=r[i];l instanceof Me?a[i]=l:a[i]=new Me(l.type,l.data,l.dims)}return a}async lazyResetGrad(){await this.handler.lazyResetGrad()}async runTrainStep(r,a,i){let[l,n]=this.typeNarrowingForRunStep(this.trainingInputNames,this.trainingOutputNames,r,a,i),o=await this.handler.runTrainStep(r,l,n);return this.convertHandlerReturnTypeToMapOfTensors(o)}async runOptimizerStep(r){if(this.hasOptimizerModel)await this.handler.runOptimizerStep(r||{});else throw new Error("This TrainingSession has no OptimizerModel loaded.")}async runEvalStep(r,a,i){if(this.hasEvalModel){let[l,n]=this.typeNarrowingForRunStep(this.evalInputNames,this.evalOutputNames,r,a,i),o=await this.handler.runEvalStep(r,l,n);return this.convertHandlerReturnTypeToMapOfTensors(o)}else throw new Error("This TrainingSession has no EvalModel loaded.")}async getParametersSize(r=!0){return this.handler.getParametersSize(r)}async loadParametersBuffer(r,a=!0){let i=await this.getParametersSize(a);if(r.length!==4*i)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(r,a)}async getContiguousParameters(r=!0){return this.handler.getContiguousParameters(r)}async release(){return this.handler.dispose()}}}),Dd,ys=L(()=>{gs(),Dd=kn}),qo={};Sr(qo,{InferenceSession:()=>Pd,TRACE:()=>ls,TRACE_FUNC_BEGIN:()=>lr,TRACE_FUNC_END:()=>fr,Tensor:()=>Me,TrainingSession:()=>Dd,env:()=>Z,registerBackend:()=>Pr});var Ot=L(()=>{Wa(),Ya(),ps(),Fn(),ds(),hs(),Ho(),ms(),bs(),ys()});function Xt(e,r,a,i){if(r===void 0)return Cd(e);if(a===void 0)Bn(e,r);else if(typeof a=="number"&&i===void 0)Bn(e,r);else if(typeof a=="string"&&i===void 0)Bn(e,a,1,r);else if(typeof a=="string"&&typeof i=="number")Bn(e,a,i,r);else throw new TypeError("input is valid")}function Cd(e){return{verbose:Xt.verbose.bind(null,e),info:Xt.info.bind(null,e),warning:Xt.warning.bind(null,e),error:Xt.error.bind(null,e),fatal:Xt.fatal.bind(null,e)}}function Bn(e,r,a,i){let l=en[i||""]||en[""];xs[e]{jo=class{log(e,r,a){}},Yo=class{log(e,r,a){console.log(`${this.color(e)} ${a?"\x1B[35m"+a+"\x1B[0m ":""}${r}`)}color(e){switch(e){case"verbose":return"\x1B[34;40mv\x1B[0m";case"info":return"\x1B[32mi\x1B[0m";case"warning":return"\x1B[30;43mw\x1B[0m";case"error":return"\x1B[31;40me\x1B[0m";case"fatal":return"\x1B[101mf\x1B[0m";default:throw new Error(`unsupported severity: ${e}`)}}},xs={verbose:1e3,info:2e3,warning:4e3,error:5e3,fatal:6e3},Ld={none:new jo,console:new Yo},ws={provider:"console",minimalSeverity:"warning",logDateTime:!0,logSourceLocation:!1},en={"":ws},(e=>{function r(t,u){e("verbose",t,u)}e.verbose=r;function a(t,u){e("info",t,u)}e.info=a;function i(t,u){e("warning",t,u)}e.warning=i;function l(t,u){e("error",t,u)}e.error=l;function n(t,u){e("fatal",t,u)}e.fatal=n;function o(t){en={},p("",t||{})}e.reset=o;function p(t,u){if(t==="*")o(u);else{let s=en[t]||ws;en[t]={provider:u.provider||s.provider,minimalSeverity:u.minimalSeverity||s.minimalSeverity,logDateTime:u.logDateTime===void 0?s.logDateTime:u.logDateTime,logSourceLocation:u.logSourceLocation===void 0?s.logSourceLocation:u.logSourceLocation}}}e.set=p;function c(t){let u={};t.logLevel&&(u.minimalSeverity=t.logLevel),p("",u)}e.setWithEnv=c})(Xt||(Xt={})),ce=Xt,Rn=class{constructor(e,r,a,i,l,n){this.category=e,this.name=r,this.startTime=a,this.endCallback=i,this.timer=l,this.ctx=n}async end(){return this.endCallback(this)}async checkTimer(){if(this.ctx===void 0||this.timer===void 0)throw new Error("No webgl timer found");return this.ctx.endTimer(),this.ctx.waitForQueryAndGetTime(this.timer)}},Mn=class{constructor(e,r,a,i){this.category=e,this.name=r,this.startTime=a,this.endTime=i}},Gn=class{constructor(e,r,a){this._started=!1,this._flushPointer=0,this._started=!1,this._maxNumberEvents=e===void 0?1e4:e,this._flushBatchSize=r===void 0?10:r,this._flushIntervalInMilliseconds=a===void 0?5e3:a}static create(e){return e===void 0?new this:new this(e.maxNumberEvents,e.flushBatchSize,e.flushIntervalInMilliseconds)}start(){this._started=!0,this._timingEvents=[],this._flushTime=Nn(),this._flushPointer=0}stop(){for(this._started=!1;this._flushPointer{o.then(async t=>{l&&await l.end(),p(t)},async t=>{l&&await l.end(),c(t)})});if(!n&&l){let p=l.end();if(p&&typeof p.then=="function")return new Promise((c,t)=>{p.then(()=>{c(o)},u=>{t(u)})})}return o}begin(e,r,a){if(!this._started)throw new Error("profiler is not started yet");if(a===void 0){let i=Nn();return this.flush(i),new Rn(e,r,i,l=>this.endSync(l))}else{let i=a.beginTimer();return new Rn(e,r,0,async l=>this.end(l),i,a)}}async end(e){let r=await e.checkTimer();this._timingEvents.length=this._flushBatchSize||e-this._flushTime>=this._flushIntervalInMilliseconds){for(let r=this._flushPointer;this._flushPointerperformance.now():Date.now});function vs(e,r,a){for(let i of a){let l=i[0],n=i[1],o=i[2],p=i[3],c=i[4];if(e.opType===l){for(let t of r)if((t.domain===n||t.domain==="ai.onnx"&&n==="")&&Fd(t.version,o))return{opImpl:p,opInit:c}}}throw new TypeError(`cannot resolve operator '${e.opType}' with opsets: ${r.map(i=>`${i.domain||"ai.onnx"} v${i.version}`).join(", ")}`)}function Fd(e,r){if(r.endsWith("+")){let a=Number.parseInt(r.substring(0,r.length-1),10);return!isNaN(a)&&a<=e}else if(r.split("-").length===2){let a=r.split("-"),i=Number.parseInt(a[0],10),l=Number.parseInt(a[1],10);return!isNaN(i)&&!isNaN(l)&&i<=e&&e<=l}else return Number.parseInt(r,10)===e}var _s=L(()=>{}),Os=me(e=>{e.__esModule=!0;var r=function(){function a(i){if(!i)throw new TypeError("Invalid argument; `value` has no value.");this.value=a.EMPTY,i&&a.isGuid(i)&&(this.value=i)}return a.isGuid=function(i){var l=i.toString();return i&&(i instanceof a||a.validator.test(l))},a.create=function(){return new a([a.gen(2),a.gen(1),a.gen(1),a.gen(1),a.gen(3)].join("-"))},a.createEmpty=function(){return new a("emptyguid")},a.parse=function(i){return new a(i)},a.raw=function(){return[a.gen(2),a.gen(1),a.gen(1),a.gen(1),a.gen(3)].join("-")},a.gen=function(i){for(var l="",n=0;n>>=0,(l=0<=e&&e<256)&&(i=As[e],i)?i:(a=le(e,0,!0),l&&(As[e]=a),a)):(e|=0,(l=-128<=e&&e<128)&&(i=Ss[e],i)?i:(a=le(e,e<0?-1:0,!1),l&&(Ss[e]=a),a))}function ct(e,r){if(isNaN(e))return r?zt:It;if(r){if(e<0)return zt;if(e>=Ls)return $s}else{if(e<=-Es)return nt;if(e+1>=Es)return Fs}return e<0?ct(-e,r).neg():le(e%Dr|0,e/Dr|0,r)}function le(e,r,a){return new be(e,r,a)}function Jo(e,r,a){if(e.length===0)throw Error("empty string");if(typeof r=="number"?(a=r,r=!1):r=!!r,e==="NaN"||e==="Infinity"||e==="+Infinity"||e==="-Infinity")return r?zt:It;if(a=a||10,a<2||360)throw Error("interior hyphen");if(i===0)return Jo(e.substring(1),r,a).neg();for(var l=ct(Un(a,8)),n=It,o=0;o{ft=null;try{ft=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{}be.prototype.__isLong__,Object.defineProperty(be.prototype,"__isLong__",{value:!0}),be.isLong=Xe,Ss={},As={},be.fromInt=cr,be.fromNumber=ct,be.fromBits=le,Un=Math.pow,be.fromString=Jo,be.fromValue=St,Ps=65536,kd=1<<24,Dr=Ps*Ps,Ls=Dr*Dr,Es=Ls/2,Ds=cr(kd),It=cr(0),be.ZERO=It,zt=cr(0,!0),be.UZERO=zt,Er=cr(1),be.ONE=Er,Cs=cr(1,!0),be.UONE=Cs,Ko=cr(-1),be.NEG_ONE=Ko,Fs=le(-1,2147483647,!1),be.MAX_VALUE=Fs,$s=le(-1,-1,!0),be.MAX_UNSIGNED_VALUE=$s,nt=le(0,-2147483648,!1),be.MIN_VALUE=nt,B=be.prototype,B.toInt=function(){return this.unsigned?this.low>>>0:this.low},B.toNumber=function(){return this.unsigned?(this.high>>>0)*Dr+(this.low>>>0):this.high*Dr+(this.low>>>0)},B.toString=function(e){if(e=e||10,e<2||36>>0,t=c.toString(e);if(n=p,n.isZero())return t+o;for(;t.length<6;)t="0"+t;o=""+t+o}},B.getHighBits=function(){return this.high},B.getHighBitsUnsigned=function(){return this.high>>>0},B.getLowBits=function(){return this.low},B.getLowBitsUnsigned=function(){return this.low>>>0},B.getNumBitsAbs=function(){if(this.isNegative())return this.eq(nt)?64:this.neg().getNumBitsAbs();for(var e=this.high!=0?this.high:this.low,r=31;r>0&&!(e&1<=0},B.isOdd=function(){return(this.low&1)===1},B.isEven=function(){return(this.low&1)===0},B.equals=function(e){return Xe(e)||(e=St(e)),this.unsigned!==e.unsigned&&this.high>>>31===1&&e.high>>>31===1?!1:this.high===e.high&&this.low===e.low},B.eq=B.equals,B.notEquals=function(e){return!this.eq(e)},B.neq=B.notEquals,B.ne=B.notEquals,B.lessThan=function(e){return this.comp(e)<0},B.lt=B.lessThan,B.lessThanOrEqual=function(e){return this.comp(e)<=0},B.lte=B.lessThanOrEqual,B.le=B.lessThanOrEqual,B.greaterThan=function(e){return this.comp(e)>0},B.gt=B.greaterThan,B.greaterThanOrEqual=function(e){return this.comp(e)>=0},B.gte=B.greaterThanOrEqual,B.ge=B.greaterThanOrEqual,B.compare=function(e){if(Xe(e)||(e=St(e)),this.eq(e))return 0;var r=this.isNegative(),a=e.isNegative();return r&&!a?-1:!r&&a?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},B.comp=B.compare,B.negate=function(){return!this.unsigned&&this.eq(nt)?nt:this.not().add(Er)},B.neg=B.negate,B.add=function(e){Xe(e)||(e=St(e));var r=this.high>>>16,a=this.high&65535,i=this.low>>>16,l=this.low&65535,n=e.high>>>16,o=e.high&65535,p=e.low>>>16,c=e.low&65535,t=0,u=0,s=0,d=0;return d+=l+c,s+=d>>>16,d&=65535,s+=i+p,u+=s>>>16,s&=65535,u+=a+o,t+=u>>>16,u&=65535,t+=r+n,t&=65535,le(s<<16|d,t<<16|u,this.unsigned)},B.subtract=function(e){return Xe(e)||(e=St(e)),this.add(e.neg())},B.sub=B.subtract,B.multiply=function(e){if(this.isZero())return this;if(Xe(e)||(e=St(e)),ft){var r=ft.mul(this.low,this.high,e.low,e.high);return le(r,ft.get_high(),this.unsigned)}if(e.isZero())return this.unsigned?zt:It;if(this.eq(nt))return e.isOdd()?nt:It;if(e.eq(nt))return this.isOdd()?nt:It;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(Ds)&&e.lt(Ds))return ct(this.toNumber()*e.toNumber(),this.unsigned);var a=this.high>>>16,i=this.high&65535,l=this.low>>>16,n=this.low&65535,o=e.high>>>16,p=e.high&65535,c=e.low>>>16,t=e.low&65535,u=0,s=0,d=0,f=0;return f+=n*t,d+=f>>>16,f&=65535,d+=l*t,s+=d>>>16,d&=65535,d+=n*c,s+=d>>>16,d&=65535,s+=i*t,u+=s>>>16,s&=65535,s+=l*c,u+=s>>>16,s&=65535,s+=n*p,u+=s>>>16,s&=65535,u+=a*t+i*c+l*p+n*o,u&=65535,le(d<<16|f,u<<16|s,this.unsigned)},B.mul=B.multiply,B.divide=function(e){if(Xe(e)||(e=St(e)),e.isZero())throw Error("division by zero");if(ft){if(!this.unsigned&&this.high===-2147483648&&e.low===-1&&e.high===-1)return this;var r=(this.unsigned?ft.div_u:ft.div_s)(this.low,this.high,e.low,e.high);return le(r,ft.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?zt:It;var a,i,l;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return zt;if(e.gt(this.shru(1)))return Cs;l=zt}else{if(this.eq(nt)){if(e.eq(Er)||e.eq(Ko))return nt;if(e.eq(nt))return Er;var n=this.shr(1);return a=n.div(e).shl(1),a.eq(It)?e.isNegative()?Er:Ko:(i=this.sub(e.mul(a)),l=a.add(i.div(e)),l)}else if(e.eq(nt))return this.unsigned?zt:It;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();l=It}for(i=this;i.gte(e);){a=Math.max(1,Math.floor(i.toNumber()/e.toNumber()));for(var o=Math.ceil(Math.log(a)/Math.LN2),p=o<=48?1:Un(2,o-48),c=ct(a),t=c.mul(e);t.isNegative()||t.gt(i);)a-=p,c=ct(a,this.unsigned),t=c.mul(e);c.isZero()&&(c=Er),l=l.add(c),i=i.sub(t)}return l},B.div=B.divide,B.modulo=function(e){if(Xe(e)||(e=St(e)),ft){var r=(this.unsigned?ft.rem_u:ft.rem_s)(this.low,this.high,e.low,e.high);return le(r,ft.get_high(),this.unsigned)}return this.sub(this.div(e).mul(e))},B.mod=B.modulo,B.rem=B.modulo,B.not=function(){return le(~this.low,~this.high,this.unsigned)},B.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32},B.clz=B.countLeadingZeros,B.countTrailingZeros=function(){return this.low?Is(this.low):Is(this.high)+32},B.ctz=B.countTrailingZeros,B.and=function(e){return Xe(e)||(e=St(e)),le(this.low&e.low,this.high&e.high,this.unsigned)},B.or=function(e){return Xe(e)||(e=St(e)),le(this.low|e.low,this.high|e.high,this.unsigned)},B.xor=function(e){return Xe(e)||(e=St(e)),le(this.low^e.low,this.high^e.high,this.unsigned)},B.shiftLeft=function(e){return Xe(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?le(this.low<>>32-e,this.unsigned):le(0,this.low<>>e|this.high<<32-e,this.high>>e,this.unsigned):le(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},B.shr=B.shiftRight,B.shiftRightUnsigned=function(e){return Xe(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?le(this.low>>>e|this.high<<32-e,this.high>>>e,this.unsigned):e===32?le(this.high,0,this.unsigned):le(this.high>>>e-32,0,this.unsigned)},B.shru=B.shiftRightUnsigned,B.shr_u=B.shiftRightUnsigned,B.rotateLeft=function(e){var r;return Xe(e)&&(e=e.toInt()),(e&=63)===0?this:e===32?le(this.high,this.low,this.unsigned):e<32?(r=32-e,le(this.low<>>r,this.high<>>r,this.unsigned)):(e-=32,r=32-e,le(this.high<>>r,this.low<>>r,this.unsigned))},B.rotl=B.rotateLeft,B.rotateRight=function(e){var r;return Xe(e)&&(e=e.toInt()),(e&=63)===0?this:e===32?le(this.high,this.low,this.unsigned):e<32?(r=32-e,le(this.high<>>e,this.low<>>e,this.unsigned)):(e-=32,r=32-e,le(this.low<>>e,this.high<>>e,this.unsigned))},B.rotr=B.rotateRight,B.toSigned=function(){return this.unsigned?le(this.low,this.high,!1):this},B.toUnsigned=function(){return this.unsigned?this:le(this.low,this.high,!0)},B.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},B.toBytesLE=function(){var e=this.high,r=this.low;return[r&255,r>>>8&255,r>>>16&255,r>>>24,e&255,e>>>8&255,e>>>16&255,e>>>24]},B.toBytesBE=function(){var e=this.high,r=this.low;return[e>>>24,e>>>16&255,e>>>8&255,e&255,r>>>24,r>>>16&255,r>>>8&255,r&255]},be.fromBytes=function(e,r,a){return a?be.fromBytesLE(e,r):be.fromBytesBE(e,r)},be.fromBytesLE=function(e,r){return new be(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,r)},be.fromBytesBE=function(e,r){return new be(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],r)},Vt=be}),_,zn=L(()=>{_={},_.Offset,_.Table,_.SIZEOF_SHORT=2,_.SIZEOF_INT=4,_.FILE_IDENTIFIER_LENGTH=4,_.SIZE_PREFIX_LENGTH=4,_.Encoding={UTF8_BYTES:1,UTF16_STRING:2},_.int32=new Int32Array(2),_.float32=new Float32Array(_.int32.buffer),_.float64=new Float64Array(_.int32.buffer),_.isLittleEndian=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1,_.Long=function(e,r){this.low=e|0,this.high=r|0},_.Long.create=function(e,r){return e==0&&r==0?_.Long.ZERO:new _.Long(e,r)},_.Long.prototype.toFloat64=function(){return(this.low>>>0)+this.high*4294967296},_.Long.prototype.equals=function(e){return this.low==e.low&&this.high==e.high},_.Long.ZERO=new _.Long(0,0),_.Builder=function(e){if(e)var r=e;else var r=1024;this.bb=_.ByteBuffer.allocate(r),this.space=r,this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1},_.Builder.prototype.clear=function(){this.bb.clear(),this.space=this.bb.capacity(),this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1},_.Builder.prototype.forceDefaults=function(e){this.force_defaults=e},_.Builder.prototype.dataBuffer=function(){return this.bb},_.Builder.prototype.asUint8Array=function(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())},_.Builder.prototype.prep=function(e,r){e>this.minalign&&(this.minalign=e);for(var a=~(this.bb.capacity()-this.space+r)+1&e-1;this.space=0&&this.vtable[r]==0;r--);for(var a=r+1;r>=0;r--)this.addInt16(this.vtable[r]!=0?e-this.vtable[r]:0);var i=2;this.addInt16(e-this.object_start);var l=(a+i)*_.SIZEOF_SHORT;this.addInt16(l);var n=0,o=this.space;e:for(r=0;r=0;n--)this.writeInt8(l.charCodeAt(n))}this.prep(this.minalign,_.SIZEOF_INT+i),this.addOffset(e),i&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)},_.Builder.prototype.finishSizePrefixed=function(e,r){this.finish(e,r,!0)},_.Builder.prototype.requiredField=function(e,r){var a=this.bb.capacity()-e,i=a-this.bb.readInt32(a),l=this.bb.readInt16(i+r)!=0;if(!l)throw new Error("FlatBuffers: field "+r+" must be set")},_.Builder.prototype.startVector=function(e,r,a){this.notNested(),this.vector_num_elems=r,this.prep(_.SIZEOF_INT,e*r),this.prep(a,e*r)},_.Builder.prototype.endVector=function(){return this.writeInt32(this.vector_num_elems),this.offset()},_.Builder.prototype.createString=function(e){if(e instanceof Uint8Array)var r=e;else for(var r=[],a=0;a=56320)i=l;else{var n=e.charCodeAt(a++);i=(l<<10)+n+-56613888}i<128?r.push(i):(i<2048?r.push(i>>6&31|192):(i<65536?r.push(i>>12&15|224):r.push(i>>18&7|240,i>>12&63|128),r.push(i>>6&63|128)),r.push(i&63|128))}this.addInt8(0),this.startVector(1,r.length,1),this.bb.setPosition(this.space-=r.length);for(var a=0,o=this.space,p=this.bb.bytes();a>24},_.ByteBuffer.prototype.readUint8=function(e){return this.bytes_[e]},_.ByteBuffer.prototype.readInt16=function(e){return this.readUint16(e)<<16>>16},_.ByteBuffer.prototype.readUint16=function(e){return this.bytes_[e]|this.bytes_[e+1]<<8},_.ByteBuffer.prototype.readInt32=function(e){return this.bytes_[e]|this.bytes_[e+1]<<8|this.bytes_[e+2]<<16|this.bytes_[e+3]<<24},_.ByteBuffer.prototype.readUint32=function(e){return this.readInt32(e)>>>0},_.ByteBuffer.prototype.readInt64=function(e){return new _.Long(this.readInt32(e),this.readInt32(e+4))},_.ByteBuffer.prototype.readUint64=function(e){return new _.Long(this.readUint32(e),this.readUint32(e+4))},_.ByteBuffer.prototype.readFloat32=function(e){return _.int32[0]=this.readInt32(e),_.float32[0]},_.ByteBuffer.prototype.readFloat64=function(e){return _.int32[_.isLittleEndian?0:1]=this.readInt32(e),_.int32[_.isLittleEndian?1:0]=this.readInt32(e+4),_.float64[0]},_.ByteBuffer.prototype.writeInt8=function(e,r){this.bytes_[e]=r},_.ByteBuffer.prototype.writeUint8=function(e,r){this.bytes_[e]=r},_.ByteBuffer.prototype.writeInt16=function(e,r){this.bytes_[e]=r,this.bytes_[e+1]=r>>8},_.ByteBuffer.prototype.writeUint16=function(e,r){this.bytes_[e]=r,this.bytes_[e+1]=r>>8},_.ByteBuffer.prototype.writeInt32=function(e,r){this.bytes_[e]=r,this.bytes_[e+1]=r>>8,this.bytes_[e+2]=r>>16,this.bytes_[e+3]=r>>24},_.ByteBuffer.prototype.writeUint32=function(e,r){this.bytes_[e]=r,this.bytes_[e+1]=r>>8,this.bytes_[e+2]=r>>16,this.bytes_[e+3]=r>>24},_.ByteBuffer.prototype.writeInt64=function(e,r){this.writeInt32(e,r.low),this.writeInt32(e+4,r.high)},_.ByteBuffer.prototype.writeUint64=function(e,r){this.writeUint32(e,r.low),this.writeUint32(e+4,r.high)},_.ByteBuffer.prototype.writeFloat32=function(e,r){_.float32[0]=r,this.writeInt32(e,_.int32[0])},_.ByteBuffer.prototype.writeFloat64=function(e,r){_.float64[0]=r,this.writeInt32(e,_.int32[_.isLittleEndian?0:1]),this.writeInt32(e+4,_.int32[_.isLittleEndian?1:0])},_.ByteBuffer.prototype.getBufferIdentifier=function(){if(this.bytes_.length>10)+55296,(n&1023)+56320))}return i},_.ByteBuffer.prototype.__indirect=function(e){return e+this.readInt32(e)},_.ByteBuffer.prototype.__vector=function(e){return e+this.readInt32(e)+_.SIZEOF_INT},_.ByteBuffer.prototype.__vector_len=function(e){return this.readInt32(e+this.readInt32(e))},_.ByteBuffer.prototype.__has_identifier=function(e){if(e.length!=_.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+_.FILE_IDENTIFIER_LENGTH);for(var r=0;r<_.FILE_IDENTIFIER_LENGTH;r++)if(e.charCodeAt(r)!=this.readInt8(this.position_+_.SIZEOF_INT+r))return!1;return!0},_.ByteBuffer.prototype.createLong=function(e,r){return _.Long.create(e,r)}}),V,tn=L(()=>{zn(),(e=>{(r=>{(a=>{(i=>(i[i.UNDEFINED=0]="UNDEFINED",i[i.FLOAT=1]="FLOAT",i[i.INT=2]="INT",i[i.STRING=3]="STRING",i[i.TENSOR=4]="TENSOR",i[i.GRAPH=5]="GRAPH",i[i.FLOATS=6]="FLOATS",i[i.INTS=7]="INTS",i[i.STRINGS=8]="STRINGS",i[i.TENSORS=9]="TENSORS",i[i.GRAPHS=10]="GRAPHS",i[i.SPARSE_TENSOR=11]="SPARSE_TENSOR",i[i.SPARSE_TENSORS=12]="SPARSE_TENSORS"))(a.AttributeType||(a.AttributeType={}))})(r.fbs||(r.fbs={}))})(e.experimental||(e.experimental={}))})(V||(V={})),(e=>{(r=>{(a=>{(i=>(i[i.UNKNOWN=0]="UNKNOWN",i[i.VALUE=1]="VALUE",i[i.PARAM=2]="PARAM"))(a.DimensionValueType||(a.DimensionValueType={}))})(r.fbs||(r.fbs={}))})(e.experimental||(e.experimental={}))})(V||(V={})),(e=>{(r=>{(a=>{(i=>(i[i.UNDEFINED=0]="UNDEFINED",i[i.FLOAT=1]="FLOAT",i[i.UINT8=2]="UINT8",i[i.INT8=3]="INT8",i[i.UINT16=4]="UINT16",i[i.INT16=5]="INT16",i[i.INT32=6]="INT32",i[i.INT64=7]="INT64",i[i.STRING=8]="STRING",i[i.BOOL=9]="BOOL",i[i.FLOAT16=10]="FLOAT16",i[i.DOUBLE=11]="DOUBLE",i[i.UINT32=12]="UINT32",i[i.UINT64=13]="UINT64",i[i.COMPLEX64=14]="COMPLEX64",i[i.COMPLEX128=15]="COMPLEX128",i[i.BFLOAT16=16]="BFLOAT16",i[i.FLOAT8E4M3FN=17]="FLOAT8E4M3FN",i[i.FLOAT8E4M3FNUZ=18]="FLOAT8E4M3FNUZ",i[i.FLOAT8E5M2=19]="FLOAT8E5M2",i[i.FLOAT8E5M2FNUZ=20]="FLOAT8E5M2FNUZ"))(a.TensorDataType||(a.TensorDataType={}))})(r.fbs||(r.fbs={}))})(e.experimental||(e.experimental={}))})(V||(V={})),(e=>{(r=>{(a=>{(i=>(i[i.Primitive=0]="Primitive",i[i.Fused=1]="Fused"))(a.NodeType||(a.NodeType={}))})(r.fbs||(r.fbs={}))})(e.experimental||(e.experimental={}))})(V||(V={})),(e=>{(r=>{(a=>{(i=>(i[i.NONE=0]="NONE",i[i.tensor_type=1]="tensor_type",i[i.sequence_type=2]="sequence_type",i[i.map_type=3]="map_type"))(a.TypeInfoValue||(a.TypeInfoValue={}))})(r.fbs||(r.fbs={}))})(e.experimental||(e.experimental={}))})(V||(V={})),(e=>{(r=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(n,o){return this.bb_pos=n,this.bb=o,this}static getRootAsShape(n,o){return(o||new i).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsShape(n,o){return n.setPosition(n.position()+_.SIZE_PREFIX_LENGTH),(o||new i).__init(n.readInt32(n.position())+n.position(),n)}dim(n,o){let p=this.bb.__offset(this.bb_pos,4);return p?(o||new e.experimental.fbs.Dimension).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+p)+n*4),this.bb):null}dimLength(){let n=this.bb.__offset(this.bb_pos,4);return n?this.bb.__vector_len(this.bb_pos+n):0}static startShape(n){n.startObject(1)}static addDim(n,o){n.addFieldOffset(0,o,0)}static createDimVector(n,o){n.startVector(4,o.length,4);for(let p=o.length-1;p>=0;p--)n.addOffset(o[p]);return n.endVector()}static startDimVector(n,o){n.startVector(4,o,4)}static endShape(n){return n.endObject()}static createShape(n,o){return i.startShape(n),i.addDim(n,o),i.endShape(n)}}a.Shape=i})(r.fbs||(r.fbs={}))})(e.experimental||(e.experimental={}))})(V||(V={})),(e=>{(r=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(n,o){return this.bb_pos=n,this.bb=o,this}static getRootAsDimension(n,o){return(o||new i).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsDimension(n,o){return n.setPosition(n.position()+_.SIZE_PREFIX_LENGTH),(o||new i).__init(n.readInt32(n.position())+n.position(),n)}value(n){let o=this.bb.__offset(this.bb_pos,4);return o?(n||new e.experimental.fbs.DimensionValue).__init(this.bb.__indirect(this.bb_pos+o),this.bb):null}denotation(n){let o=this.bb.__offset(this.bb_pos,6);return o?this.bb.__string(this.bb_pos+o,n):null}static startDimension(n){n.startObject(2)}static addValue(n,o){n.addFieldOffset(0,o,0)}static addDenotation(n,o){n.addFieldOffset(1,o,0)}static endDimension(n){return n.endObject()}static createDimension(n,o,p){return i.startDimension(n),i.addValue(n,o),i.addDenotation(n,p),i.endDimension(n)}}a.Dimension=i})(r.fbs||(r.fbs={}))})(e.experimental||(e.experimental={}))})(V||(V={})),(e=>{(r=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(n,o){return this.bb_pos=n,this.bb=o,this}static getRootAsDimensionValue(n,o){return(o||new i).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsDimensionValue(n,o){return n.setPosition(n.position()+_.SIZE_PREFIX_LENGTH),(o||new i).__init(n.readInt32(n.position())+n.position(),n)}dimType(){let n=this.bb.__offset(this.bb_pos,4);return n?this.bb.readInt8(this.bb_pos+n):0}dimValue(){let n=this.bb.__offset(this.bb_pos,6);return n?this.bb.readInt64(this.bb_pos+n):this.bb.createLong(0,0)}dimParam(n){let o=this.bb.__offset(this.bb_pos,8);return o?this.bb.__string(this.bb_pos+o,n):null}static startDimensionValue(n){n.startObject(3)}static addDimType(n,o){n.addFieldInt8(0,o,0)}static addDimValue(n,o){n.addFieldInt64(1,o,n.createLong(0,0))}static addDimParam(n,o){n.addFieldOffset(2,o,0)}static endDimensionValue(n){return n.endObject()}static createDimensionValue(n,o,p,c){return i.startDimensionValue(n),i.addDimType(n,o),i.addDimValue(n,p),i.addDimParam(n,c),i.endDimensionValue(n)}}a.DimensionValue=i})(r.fbs||(r.fbs={}))})(e.experimental||(e.experimental={}))})(V||(V={})),(e=>{(r=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(n,o){return this.bb_pos=n,this.bb=o,this}static getRootAsTensorTypeAndShape(n,o){return(o||new i).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsTensorTypeAndShape(n,o){return n.setPosition(n.position()+_.SIZE_PREFIX_LENGTH),(o||new i).__init(n.readInt32(n.position())+n.position(),n)}elemType(){let n=this.bb.__offset(this.bb_pos,4);return n?this.bb.readInt32(this.bb_pos+n):0}shape(n){let o=this.bb.__offset(this.bb_pos,6);return o?(n||new e.experimental.fbs.Shape).__init(this.bb.__indirect(this.bb_pos+o),this.bb):null}static startTensorTypeAndShape(n){n.startObject(2)}static addElemType(n,o){n.addFieldInt32(0,o,0)}static addShape(n,o){n.addFieldOffset(1,o,0)}static endTensorTypeAndShape(n){return n.endObject()}static createTensorTypeAndShape(n,o,p){return i.startTensorTypeAndShape(n),i.addElemType(n,o),i.addShape(n,p),i.endTensorTypeAndShape(n)}}a.TensorTypeAndShape=i})(r.fbs||(r.fbs={}))})(e.experimental||(e.experimental={}))})(V||(V={})),(e=>{(r=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(n,o){return this.bb_pos=n,this.bb=o,this}static getRootAsMapType(n,o){return(o||new i).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsMapType(n,o){return n.setPosition(n.position()+_.SIZE_PREFIX_LENGTH),(o||new i).__init(n.readInt32(n.position())+n.position(),n)}keyType(){let n=this.bb.__offset(this.bb_pos,4);return n?this.bb.readInt32(this.bb_pos+n):0}valueType(n){let o=this.bb.__offset(this.bb_pos,6);return o?(n||new e.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+o),this.bb):null}static startMapType(n){n.startObject(2)}static addKeyType(n,o){n.addFieldInt32(0,o,0)}static addValueType(n,o){n.addFieldOffset(1,o,0)}static endMapType(n){return n.endObject()}static createMapType(n,o,p){return i.startMapType(n),i.addKeyType(n,o),i.addValueType(n,p),i.endMapType(n)}}a.MapType=i})(r.fbs||(r.fbs={}))})(e.experimental||(e.experimental={}))})(V||(V={})),(e=>{(r=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(n,o){return this.bb_pos=n,this.bb=o,this}static getRootAsSequenceType(n,o){return(o||new i).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsSequenceType(n,o){return n.setPosition(n.position()+_.SIZE_PREFIX_LENGTH),(o||new i).__init(n.readInt32(n.position())+n.position(),n)}elemType(n){let o=this.bb.__offset(this.bb_pos,4);return o?(n||new e.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+o),this.bb):null}static startSequenceType(n){n.startObject(1)}static addElemType(n,o){n.addFieldOffset(0,o,0)}static endSequenceType(n){return n.endObject()}static createSequenceType(n,o){return i.startSequenceType(n),i.addElemType(n,o),i.endSequenceType(n)}}a.SequenceType=i})(r.fbs||(r.fbs={}))})(e.experimental||(e.experimental={}))})(V||(V={})),(e=>{(r=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(n,o){return this.bb_pos=n,this.bb=o,this}nodeIndex(){return this.bb.readUint32(this.bb_pos)}srcArgIndex(){return this.bb.readInt32(this.bb_pos+4)}dstArgIndex(){return this.bb.readInt32(this.bb_pos+8)}static createEdgeEnd(n,o,p,c){return n.prep(4,12),n.writeInt32(c),n.writeInt32(p),n.writeInt32(o),n.offset()}}a.EdgeEnd=i})(r.fbs||(r.fbs={}))})(e.experimental||(e.experimental={}))})(V||(V={})),(e=>{(r=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(n,o){return this.bb_pos=n,this.bb=o,this}static getRootAsNodeEdge(n,o){return(o||new i).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsNodeEdge(n,o){return n.setPosition(n.position()+_.SIZE_PREFIX_LENGTH),(o||new i).__init(n.readInt32(n.position())+n.position(),n)}nodeIndex(){let n=this.bb.__offset(this.bb_pos,4);return n?this.bb.readUint32(this.bb_pos+n):0}inputEdges(n,o){let p=this.bb.__offset(this.bb_pos,6);return p?(o||new e.experimental.fbs.EdgeEnd).__init(this.bb.__vector(this.bb_pos+p)+n*12,this.bb):null}inputEdgesLength(){let n=this.bb.__offset(this.bb_pos,6);return n?this.bb.__vector_len(this.bb_pos+n):0}outputEdges(n,o){let p=this.bb.__offset(this.bb_pos,8);return p?(o||new e.experimental.fbs.EdgeEnd).__init(this.bb.__vector(this.bb_pos+p)+n*12,this.bb):null}outputEdgesLength(){let n=this.bb.__offset(this.bb_pos,8);return n?this.bb.__vector_len(this.bb_pos+n):0}static startNodeEdge(n){n.startObject(3)}static addNodeIndex(n,o){n.addFieldInt32(0,o,0)}static addInputEdges(n,o){n.addFieldOffset(1,o,0)}static startInputEdgesVector(n,o){n.startVector(12,o,4)}static addOutputEdges(n,o){n.addFieldOffset(2,o,0)}static startOutputEdgesVector(n,o){n.startVector(12,o,4)}static endNodeEdge(n){return n.endObject()}static createNodeEdge(n,o,p,c){return i.startNodeEdge(n),i.addNodeIndex(n,o),i.addInputEdges(n,p),i.addOutputEdges(n,c),i.endNodeEdge(n)}}a.NodeEdge=i})(r.fbs||(r.fbs={}))})(e.experimental||(e.experimental={}))})(V||(V={})),(e=>{(r=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(n,o){return this.bb_pos=n,this.bb=o,this}static getRootAsNode(n,o){return(o||new i).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsNode(n,o){return n.setPosition(n.position()+_.SIZE_PREFIX_LENGTH),(o||new i).__init(n.readInt32(n.position())+n.position(),n)}name(n){let o=this.bb.__offset(this.bb_pos,4);return o?this.bb.__string(this.bb_pos+o,n):null}docString(n){let o=this.bb.__offset(this.bb_pos,6);return o?this.bb.__string(this.bb_pos+o,n):null}domain(n){let o=this.bb.__offset(this.bb_pos,8);return o?this.bb.__string(this.bb_pos+o,n):null}sinceVersion(){let n=this.bb.__offset(this.bb_pos,10);return n?this.bb.readInt32(this.bb_pos+n):0}index(){let n=this.bb.__offset(this.bb_pos,12);return n?this.bb.readUint32(this.bb_pos+n):0}opType(n){let o=this.bb.__offset(this.bb_pos,14);return o?this.bb.__string(this.bb_pos+o,n):null}type(){let n=this.bb.__offset(this.bb_pos,16);return n?this.bb.readInt32(this.bb_pos+n):0}executionProviderType(n){let o=this.bb.__offset(this.bb_pos,18);return o?this.bb.__string(this.bb_pos+o,n):null}inputs(n,o){let p=this.bb.__offset(this.bb_pos,20);return p?this.bb.__string(this.bb.__vector(this.bb_pos+p)+n*4,o):null}inputsLength(){let n=this.bb.__offset(this.bb_pos,20);return n?this.bb.__vector_len(this.bb_pos+n):0}outputs(n,o){let p=this.bb.__offset(this.bb_pos,22);return p?this.bb.__string(this.bb.__vector(this.bb_pos+p)+n*4,o):null}outputsLength(){let n=this.bb.__offset(this.bb_pos,22);return n?this.bb.__vector_len(this.bb_pos+n):0}attributes(n,o){let p=this.bb.__offset(this.bb_pos,24);return p?(o||new e.experimental.fbs.Attribute).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+p)+n*4),this.bb):null}attributesLength(){let n=this.bb.__offset(this.bb_pos,24);return n?this.bb.__vector_len(this.bb_pos+n):0}inputArgCounts(n){let o=this.bb.__offset(this.bb_pos,26);return o?this.bb.readInt32(this.bb.__vector(this.bb_pos+o)+n*4):0}inputArgCountsLength(){let n=this.bb.__offset(this.bb_pos,26);return n?this.bb.__vector_len(this.bb_pos+n):0}inputArgCountsArray(){let n=this.bb.__offset(this.bb_pos,26);return n?new Int32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+n),this.bb.__vector_len(this.bb_pos+n)):null}implicitInputs(n,o){let p=this.bb.__offset(this.bb_pos,28);return p?this.bb.__string(this.bb.__vector(this.bb_pos+p)+n*4,o):null}implicitInputsLength(){let n=this.bb.__offset(this.bb_pos,28);return n?this.bb.__vector_len(this.bb_pos+n):0}static startNode(n){n.startObject(13)}static addName(n,o){n.addFieldOffset(0,o,0)}static addDocString(n,o){n.addFieldOffset(1,o,0)}static addDomain(n,o){n.addFieldOffset(2,o,0)}static addSinceVersion(n,o){n.addFieldInt32(3,o,0)}static addIndex(n,o){n.addFieldInt32(4,o,0)}static addOpType(n,o){n.addFieldOffset(5,o,0)}static addType(n,o){n.addFieldInt32(6,o,0)}static addExecutionProviderType(n,o){n.addFieldOffset(7,o,0)}static addInputs(n,o){n.addFieldOffset(8,o,0)}static createInputsVector(n,o){n.startVector(4,o.length,4);for(let p=o.length-1;p>=0;p--)n.addOffset(o[p]);return n.endVector()}static startInputsVector(n,o){n.startVector(4,o,4)}static addOutputs(n,o){n.addFieldOffset(9,o,0)}static createOutputsVector(n,o){n.startVector(4,o.length,4);for(let p=o.length-1;p>=0;p--)n.addOffset(o[p]);return n.endVector()}static startOutputsVector(n,o){n.startVector(4,o,4)}static addAttributes(n,o){n.addFieldOffset(10,o,0)}static createAttributesVector(n,o){n.startVector(4,o.length,4);for(let p=o.length-1;p>=0;p--)n.addOffset(o[p]);return n.endVector()}static startAttributesVector(n,o){n.startVector(4,o,4)}static addInputArgCounts(n,o){n.addFieldOffset(11,o,0)}static createInputArgCountsVector(n,o){n.startVector(4,o.length,4);for(let p=o.length-1;p>=0;p--)n.addInt32(o[p]);return n.endVector()}static startInputArgCountsVector(n,o){n.startVector(4,o,4)}static addImplicitInputs(n,o){n.addFieldOffset(12,o,0)}static createImplicitInputsVector(n,o){n.startVector(4,o.length,4);for(let p=o.length-1;p>=0;p--)n.addOffset(o[p]);return n.endVector()}static startImplicitInputsVector(n,o){n.startVector(4,o,4)}static endNode(n){return n.endObject()}static createNode(n,o,p,c,t,u,s,d,f,b,y,v,E,T){return i.startNode(n),i.addName(n,o),i.addDocString(n,p),i.addDomain(n,c),i.addSinceVersion(n,t),i.addIndex(n,u),i.addOpType(n,s),i.addType(n,d),i.addExecutionProviderType(n,f),i.addInputs(n,b),i.addOutputs(n,y),i.addAttributes(n,v),i.addInputArgCounts(n,E),i.addImplicitInputs(n,T),i.endNode(n)}}a.Node=i})(r.fbs||(r.fbs={}))})(e.experimental||(e.experimental={}))})(V||(V={})),(e=>{(r=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(n,o){return this.bb_pos=n,this.bb=o,this}static getRootAsValueInfo(n,o){return(o||new i).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsValueInfo(n,o){return n.setPosition(n.position()+_.SIZE_PREFIX_LENGTH),(o||new i).__init(n.readInt32(n.position())+n.position(),n)}name(n){let o=this.bb.__offset(this.bb_pos,4);return o?this.bb.__string(this.bb_pos+o,n):null}docString(n){let o=this.bb.__offset(this.bb_pos,6);return o?this.bb.__string(this.bb_pos+o,n):null}type(n){let o=this.bb.__offset(this.bb_pos,8);return o?(n||new e.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+o),this.bb):null}static startValueInfo(n){n.startObject(3)}static addName(n,o){n.addFieldOffset(0,o,0)}static addDocString(n,o){n.addFieldOffset(1,o,0)}static addType(n,o){n.addFieldOffset(2,o,0)}static endValueInfo(n){return n.endObject()}static createValueInfo(n,o,p,c){return i.startValueInfo(n),i.addName(n,o),i.addDocString(n,p),i.addType(n,c),i.endValueInfo(n)}}a.ValueInfo=i})(r.fbs||(r.fbs={}))})(e.experimental||(e.experimental={}))})(V||(V={})),(e=>{(r=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(n,o){return this.bb_pos=n,this.bb=o,this}static getRootAsTypeInfo(n,o){return(o||new i).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsTypeInfo(n,o){return n.setPosition(n.position()+_.SIZE_PREFIX_LENGTH),(o||new i).__init(n.readInt32(n.position())+n.position(),n)}denotation(n){let o=this.bb.__offset(this.bb_pos,4);return o?this.bb.__string(this.bb_pos+o,n):null}valueType(){let n=this.bb.__offset(this.bb_pos,6);return n?this.bb.readUint8(this.bb_pos+n):0}value(n){let o=this.bb.__offset(this.bb_pos,8);return o?this.bb.__union(n,this.bb_pos+o):null}static startTypeInfo(n){n.startObject(3)}static addDenotation(n,o){n.addFieldOffset(0,o,0)}static addValueType(n,o){n.addFieldInt8(1,o,0)}static addValue(n,o){n.addFieldOffset(2,o,0)}static endTypeInfo(n){return n.endObject()}static createTypeInfo(n,o,p,c){return i.startTypeInfo(n),i.addDenotation(n,o),i.addValueType(n,p),i.addValue(n,c),i.endTypeInfo(n)}}a.TypeInfo=i})(r.fbs||(r.fbs={}))})(e.experimental||(e.experimental={}))})(V||(V={})),(e=>{(r=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(n,o){return this.bb_pos=n,this.bb=o,this}static getRootAsOperatorSetId(n,o){return(o||new i).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsOperatorSetId(n,o){return n.setPosition(n.position()+_.SIZE_PREFIX_LENGTH),(o||new i).__init(n.readInt32(n.position())+n.position(),n)}domain(n){let o=this.bb.__offset(this.bb_pos,4);return o?this.bb.__string(this.bb_pos+o,n):null}version(){let n=this.bb.__offset(this.bb_pos,6);return n?this.bb.readInt64(this.bb_pos+n):this.bb.createLong(0,0)}static startOperatorSetId(n){n.startObject(2)}static addDomain(n,o){n.addFieldOffset(0,o,0)}static addVersion(n,o){n.addFieldInt64(1,o,n.createLong(0,0))}static endOperatorSetId(n){return n.endObject()}static createOperatorSetId(n,o,p){return i.startOperatorSetId(n),i.addDomain(n,o),i.addVersion(n,p),i.endOperatorSetId(n)}}a.OperatorSetId=i})(r.fbs||(r.fbs={}))})(e.experimental||(e.experimental={}))})(V||(V={})),(e=>{(r=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(n,o){return this.bb_pos=n,this.bb=o,this}static getRootAsTensor(n,o){return(o||new i).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsTensor(n,o){return n.setPosition(n.position()+_.SIZE_PREFIX_LENGTH),(o||new i).__init(n.readInt32(n.position())+n.position(),n)}name(n){let o=this.bb.__offset(this.bb_pos,4);return o?this.bb.__string(this.bb_pos+o,n):null}docString(n){let o=this.bb.__offset(this.bb_pos,6);return o?this.bb.__string(this.bb_pos+o,n):null}dims(n){let o=this.bb.__offset(this.bb_pos,8);return o?this.bb.readInt64(this.bb.__vector(this.bb_pos+o)+n*8):this.bb.createLong(0,0)}dimsLength(){let n=this.bb.__offset(this.bb_pos,8);return n?this.bb.__vector_len(this.bb_pos+n):0}dataType(){let n=this.bb.__offset(this.bb_pos,10);return n?this.bb.readInt32(this.bb_pos+n):0}rawData(n){let o=this.bb.__offset(this.bb_pos,12);return o?this.bb.readUint8(this.bb.__vector(this.bb_pos+o)+n):0}rawDataLength(){let n=this.bb.__offset(this.bb_pos,12);return n?this.bb.__vector_len(this.bb_pos+n):0}rawDataArray(){let n=this.bb.__offset(this.bb_pos,12);return n?new Uint8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+n),this.bb.__vector_len(this.bb_pos+n)):null}stringData(n,o){let p=this.bb.__offset(this.bb_pos,14);return p?this.bb.__string(this.bb.__vector(this.bb_pos+p)+n*4,o):null}stringDataLength(){let n=this.bb.__offset(this.bb_pos,14);return n?this.bb.__vector_len(this.bb_pos+n):0}static startTensor(n){n.startObject(6)}static addName(n,o){n.addFieldOffset(0,o,0)}static addDocString(n,o){n.addFieldOffset(1,o,0)}static addDims(n,o){n.addFieldOffset(2,o,0)}static createDimsVector(n,o){n.startVector(8,o.length,8);for(let p=o.length-1;p>=0;p--)n.addInt64(o[p]);return n.endVector()}static startDimsVector(n,o){n.startVector(8,o,8)}static addDataType(n,o){n.addFieldInt32(3,o,0)}static addRawData(n,o){n.addFieldOffset(4,o,0)}static createRawDataVector(n,o){n.startVector(1,o.length,1);for(let p=o.length-1;p>=0;p--)n.addInt8(o[p]);return n.endVector()}static startRawDataVector(n,o){n.startVector(1,o,1)}static addStringData(n,o){n.addFieldOffset(5,o,0)}static createStringDataVector(n,o){n.startVector(4,o.length,4);for(let p=o.length-1;p>=0;p--)n.addOffset(o[p]);return n.endVector()}static startStringDataVector(n,o){n.startVector(4,o,4)}static endTensor(n){return n.endObject()}static createTensor(n,o,p,c,t,u,s){return i.startTensor(n),i.addName(n,o),i.addDocString(n,p),i.addDims(n,c),i.addDataType(n,t),i.addRawData(n,u),i.addStringData(n,s),i.endTensor(n)}}a.Tensor=i})(r.fbs||(r.fbs={}))})(e.experimental||(e.experimental={}))})(V||(V={})),(e=>{(r=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(n,o){return this.bb_pos=n,this.bb=o,this}static getRootAsSparseTensor(n,o){return(o||new i).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsSparseTensor(n,o){return n.setPosition(n.position()+_.SIZE_PREFIX_LENGTH),(o||new i).__init(n.readInt32(n.position())+n.position(),n)}values(n){let o=this.bb.__offset(this.bb_pos,4);return o?(n||new e.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+o),this.bb):null}indices(n){let o=this.bb.__offset(this.bb_pos,6);return o?(n||new e.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+o),this.bb):null}dims(n){let o=this.bb.__offset(this.bb_pos,8);return o?this.bb.readInt64(this.bb.__vector(this.bb_pos+o)+n*8):this.bb.createLong(0,0)}dimsLength(){let n=this.bb.__offset(this.bb_pos,8);return n?this.bb.__vector_len(this.bb_pos+n):0}static startSparseTensor(n){n.startObject(3)}static addValues(n,o){n.addFieldOffset(0,o,0)}static addIndices(n,o){n.addFieldOffset(1,o,0)}static addDims(n,o){n.addFieldOffset(2,o,0)}static createDimsVector(n,o){n.startVector(8,o.length,8);for(let p=o.length-1;p>=0;p--)n.addInt64(o[p]);return n.endVector()}static startDimsVector(n,o){n.startVector(8,o,8)}static endSparseTensor(n){return n.endObject()}static createSparseTensor(n,o,p,c){return i.startSparseTensor(n),i.addValues(n,o),i.addIndices(n,p),i.addDims(n,c),i.endSparseTensor(n)}}a.SparseTensor=i})(r.fbs||(r.fbs={}))})(e.experimental||(e.experimental={}))})(V||(V={})),(e=>{(r=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(n,o){return this.bb_pos=n,this.bb=o,this}static getRootAsAttribute(n,o){return(o||new i).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsAttribute(n,o){return n.setPosition(n.position()+_.SIZE_PREFIX_LENGTH),(o||new i).__init(n.readInt32(n.position())+n.position(),n)}name(n){let o=this.bb.__offset(this.bb_pos,4);return o?this.bb.__string(this.bb_pos+o,n):null}docString(n){let o=this.bb.__offset(this.bb_pos,6);return o?this.bb.__string(this.bb_pos+o,n):null}type(){let n=this.bb.__offset(this.bb_pos,8);return n?this.bb.readInt32(this.bb_pos+n):0}f(){let n=this.bb.__offset(this.bb_pos,10);return n?this.bb.readFloat32(this.bb_pos+n):0}i(){let n=this.bb.__offset(this.bb_pos,12);return n?this.bb.readInt64(this.bb_pos+n):this.bb.createLong(0,0)}s(n){let o=this.bb.__offset(this.bb_pos,14);return o?this.bb.__string(this.bb_pos+o,n):null}t(n){let o=this.bb.__offset(this.bb_pos,16);return o?(n||new e.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+o),this.bb):null}g(n){let o=this.bb.__offset(this.bb_pos,18);return o?(n||new e.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb_pos+o),this.bb):null}floats(n){let o=this.bb.__offset(this.bb_pos,20);return o?this.bb.readFloat32(this.bb.__vector(this.bb_pos+o)+n*4):0}floatsLength(){let n=this.bb.__offset(this.bb_pos,20);return n?this.bb.__vector_len(this.bb_pos+n):0}floatsArray(){let n=this.bb.__offset(this.bb_pos,20);return n?new Float32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+n),this.bb.__vector_len(this.bb_pos+n)):null}ints(n){let o=this.bb.__offset(this.bb_pos,22);return o?this.bb.readInt64(this.bb.__vector(this.bb_pos+o)+n*8):this.bb.createLong(0,0)}intsLength(){let n=this.bb.__offset(this.bb_pos,22);return n?this.bb.__vector_len(this.bb_pos+n):0}strings(n,o){let p=this.bb.__offset(this.bb_pos,24);return p?this.bb.__string(this.bb.__vector(this.bb_pos+p)+n*4,o):null}stringsLength(){let n=this.bb.__offset(this.bb_pos,24);return n?this.bb.__vector_len(this.bb_pos+n):0}tensors(n,o){let p=this.bb.__offset(this.bb_pos,26);return p?(o||new e.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+p)+n*4),this.bb):null}tensorsLength(){let n=this.bb.__offset(this.bb_pos,26);return n?this.bb.__vector_len(this.bb_pos+n):0}graphs(n,o){let p=this.bb.__offset(this.bb_pos,28);return p?(o||new e.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+p)+n*4),this.bb):null}graphsLength(){let n=this.bb.__offset(this.bb_pos,28);return n?this.bb.__vector_len(this.bb_pos+n):0}static startAttribute(n){n.startObject(13)}static addName(n,o){n.addFieldOffset(0,o,0)}static addDocString(n,o){n.addFieldOffset(1,o,0)}static addType(n,o){n.addFieldInt32(2,o,0)}static addF(n,o){n.addFieldFloat32(3,o,0)}static addI(n,o){n.addFieldInt64(4,o,n.createLong(0,0))}static addS(n,o){n.addFieldOffset(5,o,0)}static addT(n,o){n.addFieldOffset(6,o,0)}static addG(n,o){n.addFieldOffset(7,o,0)}static addFloats(n,o){n.addFieldOffset(8,o,0)}static createFloatsVector(n,o){n.startVector(4,o.length,4);for(let p=o.length-1;p>=0;p--)n.addFloat32(o[p]);return n.endVector()}static startFloatsVector(n,o){n.startVector(4,o,4)}static addInts(n,o){n.addFieldOffset(9,o,0)}static createIntsVector(n,o){n.startVector(8,o.length,8);for(let p=o.length-1;p>=0;p--)n.addInt64(o[p]);return n.endVector()}static startIntsVector(n,o){n.startVector(8,o,8)}static addStrings(n,o){n.addFieldOffset(10,o,0)}static createStringsVector(n,o){n.startVector(4,o.length,4);for(let p=o.length-1;p>=0;p--)n.addOffset(o[p]);return n.endVector()}static startStringsVector(n,o){n.startVector(4,o,4)}static addTensors(n,o){n.addFieldOffset(11,o,0)}static createTensorsVector(n,o){n.startVector(4,o.length,4);for(let p=o.length-1;p>=0;p--)n.addOffset(o[p]);return n.endVector()}static startTensorsVector(n,o){n.startVector(4,o,4)}static addGraphs(n,o){n.addFieldOffset(12,o,0)}static createGraphsVector(n,o){n.startVector(4,o.length,4);for(let p=o.length-1;p>=0;p--)n.addOffset(o[p]);return n.endVector()}static startGraphsVector(n,o){n.startVector(4,o,4)}static endAttribute(n){return n.endObject()}static createAttribute(n,o,p,c,t,u,s,d,f,b,y,v,E,T){return i.startAttribute(n),i.addName(n,o),i.addDocString(n,p),i.addType(n,c),i.addF(n,t),i.addI(n,u),i.addS(n,s),i.addT(n,d),i.addG(n,f),i.addFloats(n,b),i.addInts(n,y),i.addStrings(n,v),i.addTensors(n,E),i.addGraphs(n,T),i.endAttribute(n)}}a.Attribute=i})(r.fbs||(r.fbs={}))})(e.experimental||(e.experimental={}))})(V||(V={})),(e=>{(r=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(n,o){return this.bb_pos=n,this.bb=o,this}static getRootAsGraph(n,o){return(o||new i).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsGraph(n,o){return n.setPosition(n.position()+_.SIZE_PREFIX_LENGTH),(o||new i).__init(n.readInt32(n.position())+n.position(),n)}initializers(n,o){let p=this.bb.__offset(this.bb_pos,4);return p?(o||new e.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+p)+n*4),this.bb):null}initializersLength(){let n=this.bb.__offset(this.bb_pos,4);return n?this.bb.__vector_len(this.bb_pos+n):0}nodeArgs(n,o){let p=this.bb.__offset(this.bb_pos,6);return p?(o||new e.experimental.fbs.ValueInfo).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+p)+n*4),this.bb):null}nodeArgsLength(){let n=this.bb.__offset(this.bb_pos,6);return n?this.bb.__vector_len(this.bb_pos+n):0}nodes(n,o){let p=this.bb.__offset(this.bb_pos,8);return p?(o||new e.experimental.fbs.Node).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+p)+n*4),this.bb):null}nodesLength(){let n=this.bb.__offset(this.bb_pos,8);return n?this.bb.__vector_len(this.bb_pos+n):0}maxNodeIndex(){let n=this.bb.__offset(this.bb_pos,10);return n?this.bb.readUint32(this.bb_pos+n):0}nodeEdges(n,o){let p=this.bb.__offset(this.bb_pos,12);return p?(o||new e.experimental.fbs.NodeEdge).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+p)+n*4),this.bb):null}nodeEdgesLength(){let n=this.bb.__offset(this.bb_pos,12);return n?this.bb.__vector_len(this.bb_pos+n):0}inputs(n,o){let p=this.bb.__offset(this.bb_pos,14);return p?this.bb.__string(this.bb.__vector(this.bb_pos+p)+n*4,o):null}inputsLength(){let n=this.bb.__offset(this.bb_pos,14);return n?this.bb.__vector_len(this.bb_pos+n):0}outputs(n,o){let p=this.bb.__offset(this.bb_pos,16);return p?this.bb.__string(this.bb.__vector(this.bb_pos+p)+n*4,o):null}outputsLength(){let n=this.bb.__offset(this.bb_pos,16);return n?this.bb.__vector_len(this.bb_pos+n):0}sparseInitializers(n,o){let p=this.bb.__offset(this.bb_pos,18);return p?(o||new e.experimental.fbs.SparseTensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+p)+n*4),this.bb):null}sparseInitializersLength(){let n=this.bb.__offset(this.bb_pos,18);return n?this.bb.__vector_len(this.bb_pos+n):0}static startGraph(n){n.startObject(8)}static addInitializers(n,o){n.addFieldOffset(0,o,0)}static createInitializersVector(n,o){n.startVector(4,o.length,4);for(let p=o.length-1;p>=0;p--)n.addOffset(o[p]);return n.endVector()}static startInitializersVector(n,o){n.startVector(4,o,4)}static addNodeArgs(n,o){n.addFieldOffset(1,o,0)}static createNodeArgsVector(n,o){n.startVector(4,o.length,4);for(let p=o.length-1;p>=0;p--)n.addOffset(o[p]);return n.endVector()}static startNodeArgsVector(n,o){n.startVector(4,o,4)}static addNodes(n,o){n.addFieldOffset(2,o,0)}static createNodesVector(n,o){n.startVector(4,o.length,4);for(let p=o.length-1;p>=0;p--)n.addOffset(o[p]);return n.endVector()}static startNodesVector(n,o){n.startVector(4,o,4)}static addMaxNodeIndex(n,o){n.addFieldInt32(3,o,0)}static addNodeEdges(n,o){n.addFieldOffset(4,o,0)}static createNodeEdgesVector(n,o){n.startVector(4,o.length,4);for(let p=o.length-1;p>=0;p--)n.addOffset(o[p]);return n.endVector()}static startNodeEdgesVector(n,o){n.startVector(4,o,4)}static addInputs(n,o){n.addFieldOffset(5,o,0)}static createInputsVector(n,o){n.startVector(4,o.length,4);for(let p=o.length-1;p>=0;p--)n.addOffset(o[p]);return n.endVector()}static startInputsVector(n,o){n.startVector(4,o,4)}static addOutputs(n,o){n.addFieldOffset(6,o,0)}static createOutputsVector(n,o){n.startVector(4,o.length,4);for(let p=o.length-1;p>=0;p--)n.addOffset(o[p]);return n.endVector()}static startOutputsVector(n,o){n.startVector(4,o,4)}static addSparseInitializers(n,o){n.addFieldOffset(7,o,0)}static createSparseInitializersVector(n,o){n.startVector(4,o.length,4);for(let p=o.length-1;p>=0;p--)n.addOffset(o[p]);return n.endVector()}static startSparseInitializersVector(n,o){n.startVector(4,o,4)}static endGraph(n){return n.endObject()}static createGraph(n,o,p,c,t,u,s,d,f){return i.startGraph(n),i.addInitializers(n,o),i.addNodeArgs(n,p),i.addNodes(n,c),i.addMaxNodeIndex(n,t),i.addNodeEdges(n,u),i.addInputs(n,s),i.addOutputs(n,d),i.addSparseInitializers(n,f),i.endGraph(n)}}a.Graph=i})(r.fbs||(r.fbs={}))})(e.experimental||(e.experimental={}))})(V||(V={})),(e=>{(r=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(n,o){return this.bb_pos=n,this.bb=o,this}static getRootAsModel(n,o){return(o||new i).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsModel(n,o){return n.setPosition(n.position()+_.SIZE_PREFIX_LENGTH),(o||new i).__init(n.readInt32(n.position())+n.position(),n)}irVersion(){let n=this.bb.__offset(this.bb_pos,4);return n?this.bb.readInt64(this.bb_pos+n):this.bb.createLong(0,0)}opsetImport(n,o){let p=this.bb.__offset(this.bb_pos,6);return p?(o||new e.experimental.fbs.OperatorSetId).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+p)+n*4),this.bb):null}opsetImportLength(){let n=this.bb.__offset(this.bb_pos,6);return n?this.bb.__vector_len(this.bb_pos+n):0}producerName(n){let o=this.bb.__offset(this.bb_pos,8);return o?this.bb.__string(this.bb_pos+o,n):null}producerVersion(n){let o=this.bb.__offset(this.bb_pos,10);return o?this.bb.__string(this.bb_pos+o,n):null}domain(n){let o=this.bb.__offset(this.bb_pos,12);return o?this.bb.__string(this.bb_pos+o,n):null}modelVersion(){let n=this.bb.__offset(this.bb_pos,14);return n?this.bb.readInt64(this.bb_pos+n):this.bb.createLong(0,0)}docString(n){let o=this.bb.__offset(this.bb_pos,16);return o?this.bb.__string(this.bb_pos+o,n):null}graph(n){let o=this.bb.__offset(this.bb_pos,18);return o?(n||new e.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb_pos+o),this.bb):null}graphDocString(n){let o=this.bb.__offset(this.bb_pos,20);return o?this.bb.__string(this.bb_pos+o,n):null}static startModel(n){n.startObject(9)}static addIrVersion(n,o){n.addFieldInt64(0,o,n.createLong(0,0))}static addOpsetImport(n,o){n.addFieldOffset(1,o,0)}static createOpsetImportVector(n,o){n.startVector(4,o.length,4);for(let p=o.length-1;p>=0;p--)n.addOffset(o[p]);return n.endVector()}static startOpsetImportVector(n,o){n.startVector(4,o,4)}static addProducerName(n,o){n.addFieldOffset(2,o,0)}static addProducerVersion(n,o){n.addFieldOffset(3,o,0)}static addDomain(n,o){n.addFieldOffset(4,o,0)}static addModelVersion(n,o){n.addFieldInt64(5,o,n.createLong(0,0))}static addDocString(n,o){n.addFieldOffset(6,o,0)}static addGraph(n,o){n.addFieldOffset(7,o,0)}static addGraphDocString(n,o){n.addFieldOffset(8,o,0)}static endModel(n){return n.endObject()}static createModel(n,o,p,c,t,u,s,d,f,b){return i.startModel(n),i.addIrVersion(n,o),i.addOpsetImport(n,p),i.addProducerName(n,c),i.addProducerVersion(n,t),i.addDomain(n,u),i.addModelVersion(n,s),i.addDocString(n,d),i.addGraph(n,f),i.addGraphDocString(n,b),i.endModel(n)}}a.Model=i})(r.fbs||(r.fbs={}))})(e.experimental||(e.experimental={}))})(V||(V={})),(e=>{(r=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(n,o){return this.bb_pos=n,this.bb=o,this}static getRootAsKernelCreateInfos(n,o){return(o||new i).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsKernelCreateInfos(n,o){return n.setPosition(n.position()+_.SIZE_PREFIX_LENGTH),(o||new i).__init(n.readInt32(n.position())+n.position(),n)}nodeIndices(n){let o=this.bb.__offset(this.bb_pos,4);return o?this.bb.readUint32(this.bb.__vector(this.bb_pos+o)+n*4):0}nodeIndicesLength(){let n=this.bb.__offset(this.bb_pos,4);return n?this.bb.__vector_len(this.bb_pos+n):0}nodeIndicesArray(){let n=this.bb.__offset(this.bb_pos,4);return n?new Uint32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+n),this.bb.__vector_len(this.bb_pos+n)):null}kernelDefHashes(n){let o=this.bb.__offset(this.bb_pos,6);return o?this.bb.readUint64(this.bb.__vector(this.bb_pos+o)+n*8):this.bb.createLong(0,0)}kernelDefHashesLength(){let n=this.bb.__offset(this.bb_pos,6);return n?this.bb.__vector_len(this.bb_pos+n):0}static startKernelCreateInfos(n){n.startObject(2)}static addNodeIndices(n,o){n.addFieldOffset(0,o,0)}static createNodeIndicesVector(n,o){n.startVector(4,o.length,4);for(let p=o.length-1;p>=0;p--)n.addInt32(o[p]);return n.endVector()}static startNodeIndicesVector(n,o){n.startVector(4,o,4)}static addKernelDefHashes(n,o){n.addFieldOffset(1,o,0)}static createKernelDefHashesVector(n,o){n.startVector(8,o.length,8);for(let p=o.length-1;p>=0;p--)n.addInt64(o[p]);return n.endVector()}static startKernelDefHashesVector(n,o){n.startVector(8,o,8)}static endKernelCreateInfos(n){return n.endObject()}static createKernelCreateInfos(n,o,p){return i.startKernelCreateInfos(n),i.addNodeIndices(n,o),i.addKernelDefHashes(n,p),i.endKernelCreateInfos(n)}}a.KernelCreateInfos=i})(r.fbs||(r.fbs={}))})(e.experimental||(e.experimental={}))})(V||(V={})),(e=>{(r=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(n,o){return this.bb_pos=n,this.bb=o,this}static getRootAsSubGraphSessionState(n,o){return(o||new i).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsSubGraphSessionState(n,o){return n.setPosition(n.position()+_.SIZE_PREFIX_LENGTH),(o||new i).__init(n.readInt32(n.position())+n.position(),n)}graphId(n){let o=this.bb.__offset(this.bb_pos,4);return o?this.bb.__string(this.bb_pos+o,n):null}sessionState(n){let o=this.bb.__offset(this.bb_pos,6);return o?(n||new e.experimental.fbs.SessionState).__init(this.bb.__indirect(this.bb_pos+o),this.bb):null}static startSubGraphSessionState(n){n.startObject(2)}static addGraphId(n,o){n.addFieldOffset(0,o,0)}static addSessionState(n,o){n.addFieldOffset(1,o,0)}static endSubGraphSessionState(n){let o=n.endObject();return n.requiredField(o,4),o}static createSubGraphSessionState(n,o,p){return i.startSubGraphSessionState(n),i.addGraphId(n,o),i.addSessionState(n,p),i.endSubGraphSessionState(n)}}a.SubGraphSessionState=i})(r.fbs||(r.fbs={}))})(e.experimental||(e.experimental={}))})(V||(V={})),(e=>{(r=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(n,o){return this.bb_pos=n,this.bb=o,this}static getRootAsSessionState(n,o){return(o||new i).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsSessionState(n,o){return n.setPosition(n.position()+_.SIZE_PREFIX_LENGTH),(o||new i).__init(n.readInt32(n.position())+n.position(),n)}kernels(n){let o=this.bb.__offset(this.bb_pos,4);return o?(n||new e.experimental.fbs.KernelCreateInfos).__init(this.bb.__indirect(this.bb_pos+o),this.bb):null}subGraphSessionStates(n,o){let p=this.bb.__offset(this.bb_pos,6);return p?(o||new e.experimental.fbs.SubGraphSessionState).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+p)+n*4),this.bb):null}subGraphSessionStatesLength(){let n=this.bb.__offset(this.bb_pos,6);return n?this.bb.__vector_len(this.bb_pos+n):0}static startSessionState(n){n.startObject(2)}static addKernels(n,o){n.addFieldOffset(0,o,0)}static addSubGraphSessionStates(n,o){n.addFieldOffset(1,o,0)}static createSubGraphSessionStatesVector(n,o){n.startVector(4,o.length,4);for(let p=o.length-1;p>=0;p--)n.addOffset(o[p]);return n.endVector()}static startSubGraphSessionStatesVector(n,o){n.startVector(4,o,4)}static endSessionState(n){return n.endObject()}static createSessionState(n,o,p){return i.startSessionState(n),i.addKernels(n,o),i.addSubGraphSessionStates(n,p),i.endSessionState(n)}}a.SessionState=i})(r.fbs||(r.fbs={}))})(e.experimental||(e.experimental={}))})(V||(V={})),(e=>{(r=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(n,o){return this.bb_pos=n,this.bb=o,this}static getRootAsInferenceSession(n,o){return(o||new i).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsInferenceSession(n,o){return n.setPosition(n.position()+_.SIZE_PREFIX_LENGTH),(o||new i).__init(n.readInt32(n.position())+n.position(),n)}static bufferHasIdentifier(n){return n.__has_identifier("ORTM")}ortVersion(n){let o=this.bb.__offset(this.bb_pos,4);return o?this.bb.__string(this.bb_pos+o,n):null}model(n){let o=this.bb.__offset(this.bb_pos,6);return o?(n||new e.experimental.fbs.Model).__init(this.bb.__indirect(this.bb_pos+o),this.bb):null}sessionState(n){let o=this.bb.__offset(this.bb_pos,8);return o?(n||new e.experimental.fbs.SessionState).__init(this.bb.__indirect(this.bb_pos+o),this.bb):null}static startInferenceSession(n){n.startObject(3)}static addOrtVersion(n,o){n.addFieldOffset(0,o,0)}static addModel(n,o){n.addFieldOffset(1,o,0)}static addSessionState(n,o){n.addFieldOffset(2,o,0)}static endInferenceSession(n){return n.endObject()}static finishInferenceSessionBuffer(n,o){n.finish(o,"ORTM")}static finishSizePrefixedInferenceSessionBuffer(n,o){n.finish(o,"ORTM",!0)}static createInferenceSession(n,o,p,c){return i.startInferenceSession(n),i.addOrtVersion(n,o),i.addModel(n,p),i.addSessionState(n,c),i.endInferenceSession(n)}}a.InferenceSession=i})(r.fbs||(r.fbs={}))})(e.experimental||(e.experimental={}))})(V||(V={}))}),Bs=me((e,r)=>{r.exports=a;function a(i,l){for(var n=new Array(arguments.length-1),o=0,p=2,c=!0;p{var r=e;r.length=function(o){var p=o.length;if(!p)return 0;for(var c=0;--p%4>1&&o.charAt(p)==="=";)++c;return Math.ceil(o.length*3)/4-c};var a=new Array(64),i=new Array(123);for(l=0;l<64;)i[a[l]=l<26?l+65:l<52?l+71:l<62?l-4:l-59|43]=l++;var l;r.encode=function(o,p,c){for(var t=null,u=[],s=0,d=0,f;p>2],f=(b&3)<<4,d=1;break;case 1:u[s++]=a[f|b>>4],f=(b&15)<<2,d=2;break;case 2:u[s++]=a[f|b>>6],u[s++]=a[b&63],d=0;break}s>8191&&((t||(t=[])).push(String.fromCharCode.apply(String,u)),s=0)}return d&&(u[s++]=a[f],u[s++]=61,d===1&&(u[s++]=61)),t?(s&&t.push(String.fromCharCode.apply(String,u.slice(0,s))),t.join("")):String.fromCharCode.apply(String,u.slice(0,s))};var n="invalid encoding";r.decode=function(o,p,c){for(var t=c,u=0,s,d=0;d1)break;if((f=i[f])===void 0)throw Error(n);switch(u){case 0:s=f,u=1;break;case 1:p[c++]=s<<2|(f&48)>>4,s=f,u=2;break;case 2:p[c++]=(s&15)<<4|(f&60)>>2,s=f,u=3;break;case 3:p[c++]=(s&3)<<6|f,u=0;break}}if(u===1)throw Error(n);return c-t},r.test=function(o){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(o)}}),zs=me((e,r)=>{r.exports=a;function a(){this._listeners={}}a.prototype.on=function(i,l,n){return(this._listeners[i]||(this._listeners[i]=[])).push({fn:l,ctx:n||this}),this},a.prototype.off=function(i,l){if(i===void 0)this._listeners={};else if(l===void 0)this._listeners[i]=[];else for(var n=this._listeners[i],o=0;o{r.exports=a(a);function a(p){return typeof Float32Array<"u"?function(){var c=new Float32Array([-0]),t=new Uint8Array(c.buffer),u=t[3]===128;function s(y,v,E){c[0]=y,v[E]=t[0],v[E+1]=t[1],v[E+2]=t[2],v[E+3]=t[3]}function d(y,v,E){c[0]=y,v[E]=t[3],v[E+1]=t[2],v[E+2]=t[1],v[E+3]=t[0]}p.writeFloatLE=u?s:d,p.writeFloatBE=u?d:s;function f(y,v){return t[0]=y[v],t[1]=y[v+1],t[2]=y[v+2],t[3]=y[v+3],c[0]}function b(y,v){return t[3]=y[v],t[2]=y[v+1],t[1]=y[v+2],t[0]=y[v+3],c[0]}p.readFloatLE=u?f:b,p.readFloatBE=u?b:f}():function(){function c(u,s,d,f){var b=s<0?1:0;if(b&&(s=-s),s===0)u(1/s>0?0:2147483648,d,f);else if(isNaN(s))u(2143289344,d,f);else if(s>34028234663852886e22)u((b<<31|2139095040)>>>0,d,f);else if(s<11754943508222875e-54)u((b<<31|Math.round(s/1401298464324817e-60))>>>0,d,f);else{var y=Math.floor(Math.log(s)/Math.LN2),v=Math.round(s*Math.pow(2,-y)*8388608)&8388607;u((b<<31|y+127<<23|v)>>>0,d,f)}}p.writeFloatLE=c.bind(null,i),p.writeFloatBE=c.bind(null,l);function t(u,s,d){var f=u(s,d),b=(f>>31)*2+1,y=f>>>23&255,v=f&8388607;return y===255?v?NaN:b*(1/0):y===0?b*1401298464324817e-60*v:b*Math.pow(2,y-150)*(v+8388608)}p.readFloatLE=t.bind(null,n),p.readFloatBE=t.bind(null,o)}(),typeof Float64Array<"u"?function(){var c=new Float64Array([-0]),t=new Uint8Array(c.buffer),u=t[7]===128;function s(y,v,E){c[0]=y,v[E]=t[0],v[E+1]=t[1],v[E+2]=t[2],v[E+3]=t[3],v[E+4]=t[4],v[E+5]=t[5],v[E+6]=t[6],v[E+7]=t[7]}function d(y,v,E){c[0]=y,v[E]=t[7],v[E+1]=t[6],v[E+2]=t[5],v[E+3]=t[4],v[E+4]=t[3],v[E+5]=t[2],v[E+6]=t[1],v[E+7]=t[0]}p.writeDoubleLE=u?s:d,p.writeDoubleBE=u?d:s;function f(y,v){return t[0]=y[v],t[1]=y[v+1],t[2]=y[v+2],t[3]=y[v+3],t[4]=y[v+4],t[5]=y[v+5],t[6]=y[v+6],t[7]=y[v+7],c[0]}function b(y,v){return t[7]=y[v],t[6]=y[v+1],t[5]=y[v+2],t[4]=y[v+3],t[3]=y[v+4],t[2]=y[v+5],t[1]=y[v+6],t[0]=y[v+7],c[0]}p.readDoubleLE=u?f:b,p.readDoubleBE=u?b:f}():function(){function c(u,s,d,f,b,y){var v=f<0?1:0;if(v&&(f=-f),f===0)u(0,b,y+s),u(1/f>0?0:2147483648,b,y+d);else if(isNaN(f))u(0,b,y+s),u(2146959360,b,y+d);else if(f>17976931348623157e292)u(0,b,y+s),u((v<<31|2146435072)>>>0,b,y+d);else{var E;if(f<22250738585072014e-324)E=f/5e-324,u(E>>>0,b,y+s),u((v<<31|E/4294967296)>>>0,b,y+d);else{var T=Math.floor(Math.log(f)/Math.LN2);T===1024&&(T=1023),E=f*Math.pow(2,-T),u(E*4503599627370496>>>0,b,y+s),u((v<<31|T+1023<<20|E*1048576&1048575)>>>0,b,y+d)}}}p.writeDoubleLE=c.bind(null,i,0,4),p.writeDoubleBE=c.bind(null,l,4,0);function t(u,s,d,f,b){var y=u(f,b+s),v=u(f,b+d),E=(v>>31)*2+1,T=v>>>20&2047,$=4294967296*(v&1048575)+y;return T===2047?$?NaN:E*(1/0):T===0?E*5e-324*$:E*Math.pow(2,T-1075)*($+4503599627370496)}p.readDoubleLE=t.bind(null,n,0,4),p.readDoubleBE=t.bind(null,o,4,0)}(),p}function i(p,c,t){c[t]=p&255,c[t+1]=p>>>8&255,c[t+2]=p>>>16&255,c[t+3]=p>>>24}function l(p,c,t){c[t]=p>>>24,c[t+1]=p>>>16&255,c[t+2]=p>>>8&255,c[t+3]=p&255}function n(p,c){return(p[c]|p[c+1]<<8|p[c+2]<<16|p[c+3]<<24)>>>0}function o(p,c){return(p[c]<<24|p[c+1]<<16|p[c+2]<<8|p[c+3])>>>0}}),Ks=me((exports,module)=>{module.exports=inquire;function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(e){}return null}}),Zs=me(e=>{var r=e;r.length=function(a){for(var i=0,l=0,n=0;n191&&t<224?p[c++]=(t&31)<<6|a[i++]&63:t>239&&t<365?(t=((t&7)<<18|(a[i++]&63)<<12|(a[i++]&63)<<6|a[i++]&63)-65536,p[c++]=55296+(t>>10),p[c++]=56320+(t&1023)):p[c++]=(t&15)<<12|(a[i++]&63)<<6|a[i++]&63,c>8191&&((o||(o=[])).push(String.fromCharCode.apply(String,p)),c=0);return o?(c&&o.push(String.fromCharCode.apply(String,p.slice(0,c))),o.join("")):String.fromCharCode.apply(String,p.slice(0,c))},r.write=function(a,i,l){for(var n=l,o,p,c=0;c>6|192,i[l++]=o&63|128):(o&64512)===55296&&((p=a.charCodeAt(c+1))&64512)===56320?(o=65536+((o&1023)<<10)+(p&1023),++c,i[l++]=o>>18|240,i[l++]=o>>12&63|128,i[l++]=o>>6&63|128,i[l++]=o&63|128):(i[l++]=o>>12|224,i[l++]=o>>6&63|128,i[l++]=o&63|128);return l-n}}),eu=me((e,r)=>{r.exports=a;function a(i,l,n){var o=n||8192,p=o>>>1,c=null,t=o;return function(u){if(u<1||u>p)return i(u);t+u>o&&(c=i(o),t=0);var s=l.call(c,t,t+=u);return t&7&&(t=(t|7)+1),s}}}),ru=me((e,r)=>{r.exports=i;var a=Jt();function i(p,c){this.lo=p>>>0,this.hi=c>>>0}var l=i.zero=new i(0,0);l.toNumber=function(){return 0},l.zzEncode=l.zzDecode=function(){return this},l.length=function(){return 1};var n=i.zeroHash="\0\0\0\0\0\0\0\0";i.fromNumber=function(p){if(p===0)return l;var c=p<0;c&&(p=-p);var t=p>>>0,u=(p-t)/4294967296>>>0;return c&&(u=~u>>>0,t=~t>>>0,++t>4294967295&&(t=0,++u>4294967295&&(u=0))),new i(t,u)},i.from=function(p){if(typeof p=="number")return i.fromNumber(p);if(a.isString(p))if(a.Long)p=a.Long.fromString(p);else return i.fromNumber(parseInt(p,10));return p.low||p.high?new i(p.low>>>0,p.high>>>0):l},i.prototype.toNumber=function(p){if(!p&&this.hi>>>31){var c=~this.lo+1>>>0,t=~this.hi>>>0;return c||(t=t+1>>>0),-(c+t*4294967296)}return this.lo+this.hi*4294967296},i.prototype.toLong=function(p){return a.Long?new a.Long(this.lo|0,this.hi|0,!!p):{low:this.lo|0,high:this.hi|0,unsigned:!!p}};var o=String.prototype.charCodeAt;i.fromHash=function(p){return p===n?l:new i((o.call(p,0)|o.call(p,1)<<8|o.call(p,2)<<16|o.call(p,3)<<24)>>>0,(o.call(p,4)|o.call(p,5)<<8|o.call(p,6)<<16|o.call(p,7)<<24)>>>0)},i.prototype.toHash=function(){return String.fromCharCode(this.lo&255,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,this.hi&255,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},i.prototype.zzEncode=function(){var p=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^p)>>>0,this.lo=(this.lo<<1^p)>>>0,this},i.prototype.zzDecode=function(){var p=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^p)>>>0,this.hi=(this.hi>>>1^p)>>>0,this},i.prototype.length=function(){var p=this.lo,c=(this.lo>>>28|this.hi<<4)>>>0,t=this.hi>>>24;return t===0?c===0?p<16384?p<128?1:2:p<2097152?3:4:c<16384?c<128?5:6:c<2097152?7:8:t<128?9:10}}),Jt=me(e=>{var r=e;r.asPromise=Bs(),r.base64=Gs(),r.EventEmitter=zs(),r.float=Xs(),r.inquire=Ks(),r.utf8=Zs(),r.pool=eu(),r.LongBits=ru(),r.isNode=!!(typeof global<"u"&&global&&global.process&&global.process.versions&&global.process.versions.node),r.global=r.isNode&&global||typeof window<"u"&&window||typeof self<"u"&&self||e,r.emptyArray=Object.freeze?Object.freeze([]):[],r.emptyObject=Object.freeze?Object.freeze({}):{},r.isInteger=Number.isInteger||function(l){return typeof l=="number"&&isFinite(l)&&Math.floor(l)===l},r.isString=function(l){return typeof l=="string"||l instanceof String},r.isObject=function(l){return l&&typeof l=="object"},r.isset=r.isSet=function(l,n){var o=l[n];return o!=null&&l.hasOwnProperty(n)?typeof o!="object"||(Array.isArray(o)?o.length:Object.keys(o).length)>0:!1},r.Buffer=function(){try{var l=r.inquire("buffer").Buffer;return l.prototype.utf8Write?l:null}catch{return null}}(),r._Buffer_from=null,r._Buffer_allocUnsafe=null,r.newBuffer=function(l){return typeof l=="number"?r.Buffer?r._Buffer_allocUnsafe(l):new r.Array(l):r.Buffer?r._Buffer_from(l):typeof Uint8Array>"u"?l:new Uint8Array(l)},r.Array=typeof Uint8Array<"u"?Uint8Array:Array,r.Long=r.global.dcodeIO&&r.global.dcodeIO.Long||r.global.Long||r.inquire("long"),r.key2Re=/^true|false|0|1$/,r.key32Re=/^-?(?:0|[1-9][0-9]*)$/,r.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,r.longToHash=function(l){return l?r.LongBits.from(l).toHash():r.LongBits.zeroHash},r.longFromHash=function(l,n){var o=r.LongBits.fromHash(l);return r.Long?r.Long.fromBits(o.lo,o.hi,n):o.toNumber(!!n)};function a(l,n,o){for(var p=Object.keys(n),c=0;c-1;--c)if(n[p[c]]===1&&this[p[c]]!==void 0&&this[p[c]]!==null)return p[c]}},r.oneOfSetter=function(l){return function(n){for(var o=0;o{r.exports=u;var a=Jt(),i,l=a.LongBits,n=a.base64,o=a.utf8;function p(T,$,F){this.fn=T,this.len=$,this.next=void 0,this.val=F}function c(){}function t(T){this.head=T.head,this.tail=T.tail,this.len=T.len,this.next=T.states}function u(){this.len=0,this.head=new p(c,0,0),this.tail=this.head,this.states=null}var s=function(){return a.Buffer?function(){return(u.create=function(){return new i})()}:function(){return new u}};u.create=s(),u.alloc=function(T){return new a.Array(T)},a.Array!==Array&&(u.alloc=a.pool(u.alloc,a.Array.prototype.subarray)),u.prototype._push=function(T,$,F){return this.tail=this.tail.next=new p(T,$,F),this.len+=$,this};function d(T,$,F){$[F]=T&255}function f(T,$,F){for(;T>127;)$[F++]=T&127|128,T>>>=7;$[F]=T}function b(T,$){this.len=T,this.next=void 0,this.val=$}b.prototype=Object.create(p.prototype),b.prototype.fn=f,u.prototype.uint32=function(T){return this.len+=(this.tail=this.tail.next=new b((T=T>>>0)<128?1:T<16384?2:T<2097152?3:T<268435456?4:5,T)).len,this},u.prototype.int32=function(T){return T<0?this._push(y,10,l.fromNumber(T)):this.uint32(T)},u.prototype.sint32=function(T){return this.uint32((T<<1^T>>31)>>>0)};function y(T,$,F){for(;T.hi;)$[F++]=T.lo&127|128,T.lo=(T.lo>>>7|T.hi<<25)>>>0,T.hi>>>=7;for(;T.lo>127;)$[F++]=T.lo&127|128,T.lo=T.lo>>>7;$[F++]=T.lo}u.prototype.uint64=function(T){var $=l.from(T);return this._push(y,$.length(),$)},u.prototype.int64=u.prototype.uint64,u.prototype.sint64=function(T){var $=l.from(T).zzEncode();return this._push(y,$.length(),$)},u.prototype.bool=function(T){return this._push(d,1,T?1:0)};function v(T,$,F){$[F]=T&255,$[F+1]=T>>>8&255,$[F+2]=T>>>16&255,$[F+3]=T>>>24}u.prototype.fixed32=function(T){return this._push(v,4,T>>>0)},u.prototype.sfixed32=u.prototype.fixed32,u.prototype.fixed64=function(T){var $=l.from(T);return this._push(v,4,$.lo)._push(v,4,$.hi)},u.prototype.sfixed64=u.prototype.fixed64,u.prototype.float=function(T){return this._push(a.float.writeFloatLE,4,T)},u.prototype.double=function(T){return this._push(a.float.writeDoubleLE,8,T)};var E=a.Array.prototype.set?function(T,$,F){$.set(T,F)}:function(T,$,F){for(var C=0;C>>0;if(!$)return this._push(d,1,0);if(a.isString(T)){var F=u.alloc($=n.length(T));n.decode(T,F,0),T=F}return this.uint32($)._push(E,$,T)},u.prototype.string=function(T){var $=o.length(T);return $?this.uint32($)._push(o.write,$,T):this._push(d,1,0)},u.prototype.fork=function(){return this.states=new t(this),this.head=this.tail=new p(c,0,0),this.len=0,this},u.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new p(c,0,0),this.len=0),this},u.prototype.ldelim=function(){var T=this.head,$=this.tail,F=this.len;return this.reset().uint32(F),F&&(this.tail.next=T.next,this.tail=$,this.len+=F),this},u.prototype.finish=function(){for(var T=this.head.next,$=this.constructor.alloc(this.len),F=0;T;)T.fn(T.val,$,F),F+=T.len,T=T.next;return $},u._configure=function(T){i=T,u.create=s(),i._configure()}}),cu=me((e,r)=>{r.exports=l;var a=si();(l.prototype=Object.create(a.prototype)).constructor=l;var i=Jt();function l(){a.call(this)}l._configure=function(){l.alloc=i._Buffer_allocUnsafe,l.writeBytesBuffer=i.Buffer&&i.Buffer.prototype instanceof Uint8Array&&i.Buffer.prototype.set.name==="set"?function(o,p,c){p.set(o,c)}:function(o,p,c){if(o.copy)o.copy(p,c,0,o.length);else for(var t=0;t>>0;return this.uint32(p),p&&this._push(l.writeBytesBuffer,p,o),this};function n(o,p,c){o.length<40?i.utf8.write(o,p,c):p.utf8Write?p.utf8Write(o,c):p.write(o,c)}l.prototype.string=function(o){var p=i.Buffer.byteLength(o);return this.uint32(p),p&&this._push(n,p,o),this},l._configure()}),fi=me((e,r)=>{r.exports=p;var a=Jt(),i,l=a.LongBits,n=a.utf8;function o(f,b){return RangeError("index out of range: "+f.pos+" + "+(b||1)+" > "+f.len)}function p(f){this.buf=f,this.pos=0,this.len=f.length}var c=typeof Uint8Array<"u"?function(f){if(f instanceof Uint8Array||Array.isArray(f))return new p(f);throw Error("illegal buffer")}:function(f){if(Array.isArray(f))return new p(f);throw Error("illegal buffer")},t=function(){return a.Buffer?function(f){return(p.create=function(b){return a.Buffer.isBuffer(b)?new i(b):c(b)})(f)}:c};p.create=t(),p.prototype._slice=a.Array.prototype.subarray||a.Array.prototype.slice,p.prototype.uint32=function(){var f=4294967295;return function(){if(f=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(f=(f|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(f=(f|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(f=(f|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(f=(f|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return f;if((this.pos+=5)>this.len)throw this.pos=this.len,o(this,10);return f}}(),p.prototype.int32=function(){return this.uint32()|0},p.prototype.sint32=function(){var f=this.uint32();return f>>>1^-(f&1)|0};function u(){var f=new l(0,0),b=0;if(this.len-this.pos>4){for(;b<4;++b)if(f.lo=(f.lo|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return f;if(f.lo=(f.lo|(this.buf[this.pos]&127)<<28)>>>0,f.hi=(f.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return f;b=0}else{for(;b<3;++b){if(this.pos>=this.len)throw o(this);if(f.lo=(f.lo|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return f}return f.lo=(f.lo|(this.buf[this.pos++]&127)<>>0,f}if(this.len-this.pos>4){for(;b<5;++b)if(f.hi=(f.hi|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return f}else for(;b<5;++b){if(this.pos>=this.len)throw o(this);if(f.hi=(f.hi|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return f}throw Error("invalid varint encoding")}p.prototype.bool=function(){return this.uint32()!==0};function s(f,b){return(f[b-4]|f[b-3]<<8|f[b-2]<<16|f[b-1]<<24)>>>0}p.prototype.fixed32=function(){if(this.pos+4>this.len)throw o(this,4);return s(this.buf,this.pos+=4)},p.prototype.sfixed32=function(){if(this.pos+4>this.len)throw o(this,4);return s(this.buf,this.pos+=4)|0};function d(){if(this.pos+8>this.len)throw o(this,8);return new l(s(this.buf,this.pos+=4),s(this.buf,this.pos+=4))}p.prototype.float=function(){if(this.pos+4>this.len)throw o(this,4);var f=a.float.readFloatLE(this.buf,this.pos);return this.pos+=4,f},p.prototype.double=function(){if(this.pos+8>this.len)throw o(this,4);var f=a.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,f},p.prototype.bytes=function(){var f=this.uint32(),b=this.pos,y=this.pos+f;if(y>this.len)throw o(this,f);if(this.pos+=f,Array.isArray(this.buf))return this.buf.slice(b,y);if(b===y){var v=a.Buffer;return v?v.alloc(0):new this.buf.constructor(0)}return this._slice.call(this.buf,b,y)},p.prototype.string=function(){var f=this.bytes();return n.read(f,0,f.length)},p.prototype.skip=function(f){if(typeof f=="number"){if(this.pos+f>this.len)throw o(this,f);this.pos+=f}else do if(this.pos>=this.len)throw o(this);while(this.buf[this.pos++]&128);return this},p.prototype.skipType=function(f){switch(f){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(f=this.uint32()&7)!==4;)this.skipType(f);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+f+" at offset "+this.pos)}return this},p._configure=function(f){i=f,p.create=t(),i._configure();var b=a.Long?"toLong":"toNumber";a.merge(p.prototype,{int64:function(){return u.call(this)[b](!1)},uint64:function(){return u.call(this)[b](!0)},sint64:function(){return u.call(this).zzDecode()[b](!1)},fixed64:function(){return d.call(this)[b](!0)},sfixed64:function(){return d.call(this)[b](!1)}})}}),xu=me((e,r)=>{r.exports=l;var a=fi();(l.prototype=Object.create(a.prototype)).constructor=l;var i=Jt();function l(n){a.call(this,n)}l._configure=function(){i.Buffer&&(l.prototype._slice=i.Buffer.prototype.slice)},l.prototype.string=function(){var n=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+n,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+n,this.len))},l._configure()}),vu=me((e,r)=>{r.exports=i;var a=Jt();(i.prototype=Object.create(a.EventEmitter.prototype)).constructor=i;function i(l,n,o){if(typeof l!="function")throw TypeError("rpcImpl must be a function");a.EventEmitter.call(this),this.rpcImpl=l,this.requestDelimited=!!n,this.responseDelimited=!!o}i.prototype.rpcCall=function l(n,o,p,c,t){if(!c)throw TypeError("request must be specified");var u=this;if(!t)return a.asPromise(l,u,n,o,p,c);if(!u.rpcImpl){setTimeout(function(){t(Error("already ended"))},0);return}try{return u.rpcImpl(n,o[u.requestDelimited?"encodeDelimited":"encode"](c).finish(),function(s,d){if(s)return u.emit("error",s,n),t(s);if(d===null){u.end(!0);return}if(!(d instanceof p))try{d=p[u.responseDelimited?"decodeDelimited":"decode"](d)}catch(f){return u.emit("error",f,n),t(f)}return u.emit("data",d,n),t(null,d)})}catch(s){u.emit("error",s,n),setTimeout(function(){t(s)},0);return}},i.prototype.end=function(l){return this.rpcImpl&&(l||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}}),Ou=me(e=>{var r=e;r.Service=vu()}),Su=me((e,r)=>{r.exports={}}),Eu=me(e=>{var r=e;r.build="minimal",r.Writer=si(),r.BufferWriter=cu(),r.Reader=fi(),r.BufferReader=xu(),r.util=Jt(),r.rpc=Ou(),r.roots=Su(),r.configure=a;function a(){r.util._configure(),r.Writer._configure(r.BufferWriter),r.Reader._configure(r.BufferReader)}a()}),Lu=me((e,r)=>{r.exports=Eu()}),Cr=me((e,r)=>{var a=Lu(),i=a.Reader,l=a.Writer,n=a.util,o=a.roots.default||(a.roots.default={});o.onnx=function(){var p={};return p.Version=function(){var c={},t=Object.create(c);return t[c[0]="_START_VERSION"]=0,t[c[1]="IR_VERSION_2017_10_10"]=1,t[c[2]="IR_VERSION_2017_10_30"]=2,t[c[3]="IR_VERSION_2017_11_3"]=3,t[c[4]="IR_VERSION_2019_1_22"]=4,t[c[5]="IR_VERSION_2019_3_18"]=5,t[c[6]="IR_VERSION_2019_9_19"]=6,t[c[7]="IR_VERSION_2020_5_8"]=7,t[c[8]="IR_VERSION_2021_7_30"]=8,t[c[9]="IR_VERSION"]=9,t}(),p.AttributeProto=function(){function c(t){if(this.floats=[],this.ints=[],this.strings=[],this.tensors=[],this.graphs=[],this.sparseTensors=[],this.typeProtos=[],t)for(var u=Object.keys(t),s=0;s>>3){case 1:{d.name=t.string();break}case 21:{d.refAttrName=t.string();break}case 13:{d.docString=t.string();break}case 20:{d.type=t.int32();break}case 2:{d.f=t.float();break}case 3:{d.i=t.int64();break}case 4:{d.s=t.bytes();break}case 5:{d.t=o.onnx.TensorProto.decode(t,t.uint32());break}case 6:{d.g=o.onnx.GraphProto.decode(t,t.uint32());break}case 22:{d.sparseTensor=o.onnx.SparseTensorProto.decode(t,t.uint32());break}case 14:{d.tp=o.onnx.TypeProto.decode(t,t.uint32());break}case 7:{if(d.floats&&d.floats.length||(d.floats=[]),(f&7)===2)for(var b=t.uint32()+t.pos;t.pos>>0,t.i.high>>>0).toNumber())),t.s!=null&&(typeof t.s=="string"?n.base64.decode(t.s,u.s=n.newBuffer(n.base64.length(t.s)),0):t.s.length>=0&&(u.s=t.s)),t.t!=null){if(typeof t.t!="object")throw TypeError(".onnx.AttributeProto.t: object expected");u.t=o.onnx.TensorProto.fromObject(t.t)}if(t.g!=null){if(typeof t.g!="object")throw TypeError(".onnx.AttributeProto.g: object expected");u.g=o.onnx.GraphProto.fromObject(t.g)}if(t.sparseTensor!=null){if(typeof t.sparseTensor!="object")throw TypeError(".onnx.AttributeProto.sparseTensor: object expected");u.sparseTensor=o.onnx.SparseTensorProto.fromObject(t.sparseTensor)}if(t.tp!=null){if(typeof t.tp!="object")throw TypeError(".onnx.AttributeProto.tp: object expected");u.tp=o.onnx.TypeProto.fromObject(t.tp)}if(t.floats){if(!Array.isArray(t.floats))throw TypeError(".onnx.AttributeProto.floats: array expected");u.floats=[];for(var s=0;s>>0,t.ints[s].high>>>0).toNumber())}if(t.strings){if(!Array.isArray(t.strings))throw TypeError(".onnx.AttributeProto.strings: array expected");u.strings=[];for(var s=0;s=0&&(u.strings[s]=t.strings[s])}if(t.tensors){if(!Array.isArray(t.tensors))throw TypeError(".onnx.AttributeProto.tensors: array expected");u.tensors=[];for(var s=0;s>>0,t.i.high>>>0).toNumber():t.i),t.s!=null&&t.hasOwnProperty("s")&&(s.s=u.bytes===String?n.base64.encode(t.s,0,t.s.length):u.bytes===Array?Array.prototype.slice.call(t.s):t.s),t.t!=null&&t.hasOwnProperty("t")&&(s.t=o.onnx.TensorProto.toObject(t.t,u)),t.g!=null&&t.hasOwnProperty("g")&&(s.g=o.onnx.GraphProto.toObject(t.g,u)),t.floats&&t.floats.length){s.floats=[];for(var f=0;f>>0,t.ints[f].high>>>0).toNumber():t.ints[f]}if(t.strings&&t.strings.length){s.strings=[];for(var f=0;f>>3){case 1:{d.name=t.string();break}case 2:{d.type=o.onnx.TypeProto.decode(t,t.uint32());break}case 3:{d.docString=t.string();break}default:t.skipType(f&7);break}}return d},c.decodeDelimited=function(t){return t instanceof i||(t=new i(t)),this.decode(t,t.uint32())},c.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.name!=null&&t.hasOwnProperty("name")&&!n.isString(t.name))return"name: string expected";if(t.type!=null&&t.hasOwnProperty("type")){var u=o.onnx.TypeProto.verify(t.type);if(u)return"type."+u}return t.docString!=null&&t.hasOwnProperty("docString")&&!n.isString(t.docString)?"docString: string expected":null},c.fromObject=function(t){if(t instanceof o.onnx.ValueInfoProto)return t;var u=new o.onnx.ValueInfoProto;if(t.name!=null&&(u.name=String(t.name)),t.type!=null){if(typeof t.type!="object")throw TypeError(".onnx.ValueInfoProto.type: object expected");u.type=o.onnx.TypeProto.fromObject(t.type)}return t.docString!=null&&(u.docString=String(t.docString)),u},c.toObject=function(t,u){u||(u={});var s={};return u.defaults&&(s.name="",s.type=null,s.docString=""),t.name!=null&&t.hasOwnProperty("name")&&(s.name=t.name),t.type!=null&&t.hasOwnProperty("type")&&(s.type=o.onnx.TypeProto.toObject(t.type,u)),t.docString!=null&&t.hasOwnProperty("docString")&&(s.docString=t.docString),s},c.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},c.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/onnx.ValueInfoProto"},c}(),p.NodeProto=function(){function c(t){if(this.input=[],this.output=[],this.attribute=[],t)for(var u=Object.keys(t),s=0;s>>3){case 1:{d.input&&d.input.length||(d.input=[]),d.input.push(t.string());break}case 2:{d.output&&d.output.length||(d.output=[]),d.output.push(t.string());break}case 3:{d.name=t.string();break}case 4:{d.opType=t.string();break}case 7:{d.domain=t.string();break}case 5:{d.attribute&&d.attribute.length||(d.attribute=[]),d.attribute.push(o.onnx.AttributeProto.decode(t,t.uint32()));break}case 6:{d.docString=t.string();break}default:t.skipType(f&7);break}}return d},c.decodeDelimited=function(t){return t instanceof i||(t=new i(t)),this.decode(t,t.uint32())},c.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.input!=null&&t.hasOwnProperty("input")){if(!Array.isArray(t.input))return"input: array expected";for(var u=0;u>>3){case 1:{d.initialization=o.onnx.GraphProto.decode(t,t.uint32());break}case 2:{d.algorithm=o.onnx.GraphProto.decode(t,t.uint32());break}case 3:{d.initializationBinding&&d.initializationBinding.length||(d.initializationBinding=[]),d.initializationBinding.push(o.onnx.StringStringEntryProto.decode(t,t.uint32()));break}case 4:{d.updateBinding&&d.updateBinding.length||(d.updateBinding=[]),d.updateBinding.push(o.onnx.StringStringEntryProto.decode(t,t.uint32()));break}default:t.skipType(f&7);break}}return d},c.decodeDelimited=function(t){return t instanceof i||(t=new i(t)),this.decode(t,t.uint32())},c.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.initialization!=null&&t.hasOwnProperty("initialization")){var u=o.onnx.GraphProto.verify(t.initialization);if(u)return"initialization."+u}if(t.algorithm!=null&&t.hasOwnProperty("algorithm")){var u=o.onnx.GraphProto.verify(t.algorithm);if(u)return"algorithm."+u}if(t.initializationBinding!=null&&t.hasOwnProperty("initializationBinding")){if(!Array.isArray(t.initializationBinding))return"initializationBinding: array expected";for(var s=0;s>>3){case 1:{d.irVersion=t.int64();break}case 8:{d.opsetImport&&d.opsetImport.length||(d.opsetImport=[]),d.opsetImport.push(o.onnx.OperatorSetIdProto.decode(t,t.uint32()));break}case 2:{d.producerName=t.string();break}case 3:{d.producerVersion=t.string();break}case 4:{d.domain=t.string();break}case 5:{d.modelVersion=t.int64();break}case 6:{d.docString=t.string();break}case 7:{d.graph=o.onnx.GraphProto.decode(t,t.uint32());break}case 14:{d.metadataProps&&d.metadataProps.length||(d.metadataProps=[]),d.metadataProps.push(o.onnx.StringStringEntryProto.decode(t,t.uint32()));break}case 20:{d.trainingInfo&&d.trainingInfo.length||(d.trainingInfo=[]),d.trainingInfo.push(o.onnx.TrainingInfoProto.decode(t,t.uint32()));break}case 25:{d.functions&&d.functions.length||(d.functions=[]),d.functions.push(o.onnx.FunctionProto.decode(t,t.uint32()));break}default:t.skipType(f&7);break}}return d},c.decodeDelimited=function(t){return t instanceof i||(t=new i(t)),this.decode(t,t.uint32())},c.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.irVersion!=null&&t.hasOwnProperty("irVersion")&&!n.isInteger(t.irVersion)&&!(t.irVersion&&n.isInteger(t.irVersion.low)&&n.isInteger(t.irVersion.high)))return"irVersion: integer|Long expected";if(t.opsetImport!=null&&t.hasOwnProperty("opsetImport")){if(!Array.isArray(t.opsetImport))return"opsetImport: array expected";for(var u=0;u>>0,t.irVersion.high>>>0).toNumber())),t.opsetImport){if(!Array.isArray(t.opsetImport))throw TypeError(".onnx.ModelProto.opsetImport: array expected");u.opsetImport=[];for(var s=0;s>>0,t.modelVersion.high>>>0).toNumber())),t.docString!=null&&(u.docString=String(t.docString)),t.graph!=null){if(typeof t.graph!="object")throw TypeError(".onnx.ModelProto.graph: object expected");u.graph=o.onnx.GraphProto.fromObject(t.graph)}if(t.metadataProps){if(!Array.isArray(t.metadataProps))throw TypeError(".onnx.ModelProto.metadataProps: array expected");u.metadataProps=[];for(var s=0;s>>0,t.irVersion.high>>>0).toNumber():t.irVersion),t.producerName!=null&&t.hasOwnProperty("producerName")&&(s.producerName=t.producerName),t.producerVersion!=null&&t.hasOwnProperty("producerVersion")&&(s.producerVersion=t.producerVersion),t.domain!=null&&t.hasOwnProperty("domain")&&(s.domain=t.domain),t.modelVersion!=null&&t.hasOwnProperty("modelVersion")&&(typeof t.modelVersion=="number"?s.modelVersion=u.longs===String?String(t.modelVersion):t.modelVersion:s.modelVersion=u.longs===String?n.Long.prototype.toString.call(t.modelVersion):u.longs===Number?new n.LongBits(t.modelVersion.low>>>0,t.modelVersion.high>>>0).toNumber():t.modelVersion),t.docString!=null&&t.hasOwnProperty("docString")&&(s.docString=t.docString),t.graph!=null&&t.hasOwnProperty("graph")&&(s.graph=o.onnx.GraphProto.toObject(t.graph,u)),t.opsetImport&&t.opsetImport.length){s.opsetImport=[];for(var f=0;f>>3){case 1:{d.key=t.string();break}case 2:{d.value=t.string();break}default:t.skipType(f&7);break}}return d},c.decodeDelimited=function(t){return t instanceof i||(t=new i(t)),this.decode(t,t.uint32())},c.verify=function(t){return typeof t!="object"||t===null?"object expected":t.key!=null&&t.hasOwnProperty("key")&&!n.isString(t.key)?"key: string expected":t.value!=null&&t.hasOwnProperty("value")&&!n.isString(t.value)?"value: string expected":null},c.fromObject=function(t){if(t instanceof o.onnx.StringStringEntryProto)return t;var u=new o.onnx.StringStringEntryProto;return t.key!=null&&(u.key=String(t.key)),t.value!=null&&(u.value=String(t.value)),u},c.toObject=function(t,u){u||(u={});var s={};return u.defaults&&(s.key="",s.value=""),t.key!=null&&t.hasOwnProperty("key")&&(s.key=t.key),t.value!=null&&t.hasOwnProperty("value")&&(s.value=t.value),s},c.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},c.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/onnx.StringStringEntryProto"},c}(),p.TensorAnnotation=function(){function c(t){if(this.quantParameterTensorNames=[],t)for(var u=Object.keys(t),s=0;s>>3){case 1:{d.tensorName=t.string();break}case 2:{d.quantParameterTensorNames&&d.quantParameterTensorNames.length||(d.quantParameterTensorNames=[]),d.quantParameterTensorNames.push(o.onnx.StringStringEntryProto.decode(t,t.uint32()));break}default:t.skipType(f&7);break}}return d},c.decodeDelimited=function(t){return t instanceof i||(t=new i(t)),this.decode(t,t.uint32())},c.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.tensorName!=null&&t.hasOwnProperty("tensorName")&&!n.isString(t.tensorName))return"tensorName: string expected";if(t.quantParameterTensorNames!=null&&t.hasOwnProperty("quantParameterTensorNames")){if(!Array.isArray(t.quantParameterTensorNames))return"quantParameterTensorNames: array expected";for(var u=0;u>>3){case 1:{d.node&&d.node.length||(d.node=[]),d.node.push(o.onnx.NodeProto.decode(t,t.uint32()));break}case 2:{d.name=t.string();break}case 5:{d.initializer&&d.initializer.length||(d.initializer=[]),d.initializer.push(o.onnx.TensorProto.decode(t,t.uint32()));break}case 15:{d.sparseInitializer&&d.sparseInitializer.length||(d.sparseInitializer=[]),d.sparseInitializer.push(o.onnx.SparseTensorProto.decode(t,t.uint32()));break}case 10:{d.docString=t.string();break}case 11:{d.input&&d.input.length||(d.input=[]),d.input.push(o.onnx.ValueInfoProto.decode(t,t.uint32()));break}case 12:{d.output&&d.output.length||(d.output=[]),d.output.push(o.onnx.ValueInfoProto.decode(t,t.uint32()));break}case 13:{d.valueInfo&&d.valueInfo.length||(d.valueInfo=[]),d.valueInfo.push(o.onnx.ValueInfoProto.decode(t,t.uint32()));break}case 14:{d.quantizationAnnotation&&d.quantizationAnnotation.length||(d.quantizationAnnotation=[]),d.quantizationAnnotation.push(o.onnx.TensorAnnotation.decode(t,t.uint32()));break}default:t.skipType(f&7);break}}return d},c.decodeDelimited=function(t){return t instanceof i||(t=new i(t)),this.decode(t,t.uint32())},c.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.node!=null&&t.hasOwnProperty("node")){if(!Array.isArray(t.node))return"node: array expected";for(var u=0;u>>3){case 1:{if(d.dims&&d.dims.length||(d.dims=[]),(f&7)===2)for(var b=t.uint32()+t.pos;t.pos>>0,t.dims[s].high>>>0).toNumber())}if(t.dataType!=null&&(u.dataType=t.dataType|0),t.segment!=null){if(typeof t.segment!="object")throw TypeError(".onnx.TensorProto.segment: object expected");u.segment=o.onnx.TensorProto.Segment.fromObject(t.segment)}if(t.floatData){if(!Array.isArray(t.floatData))throw TypeError(".onnx.TensorProto.floatData: array expected");u.floatData=[];for(var s=0;s=0&&(u.stringData[s]=t.stringData[s])}if(t.int64Data){if(!Array.isArray(t.int64Data))throw TypeError(".onnx.TensorProto.int64Data: array expected");u.int64Data=[];for(var s=0;s>>0,t.int64Data[s].high>>>0).toNumber())}if(t.name!=null&&(u.name=String(t.name)),t.docString!=null&&(u.docString=String(t.docString)),t.rawData!=null&&(typeof t.rawData=="string"?n.base64.decode(t.rawData,u.rawData=n.newBuffer(n.base64.length(t.rawData)),0):t.rawData.length>=0&&(u.rawData=t.rawData)),t.externalData){if(!Array.isArray(t.externalData))throw TypeError(".onnx.TensorProto.externalData: array expected");u.externalData=[];for(var s=0;s>>0,t.uint64Data[s].high>>>0).toNumber(!0))}return u},c.toObject=function(t,u){u||(u={});var s={};if((u.arrays||u.defaults)&&(s.dims=[],s.floatData=[],s.int32Data=[],s.stringData=[],s.int64Data=[],s.doubleData=[],s.uint64Data=[],s.externalData=[]),u.defaults&&(s.dataType=0,s.segment=null,s.name="",u.bytes===String?s.rawData="":(s.rawData=[],u.bytes!==Array&&(s.rawData=n.newBuffer(s.rawData))),s.docString="",s.dataLocation=u.enums===String?"DEFAULT":0),t.dims&&t.dims.length){s.dims=[];for(var d=0;d>>0,t.dims[d].high>>>0).toNumber():t.dims[d]}if(t.dataType!=null&&t.hasOwnProperty("dataType")&&(s.dataType=t.dataType),t.segment!=null&&t.hasOwnProperty("segment")&&(s.segment=o.onnx.TensorProto.Segment.toObject(t.segment,u)),t.floatData&&t.floatData.length){s.floatData=[];for(var d=0;d>>0,t.int64Data[d].high>>>0).toNumber():t.int64Data[d]}if(t.name!=null&&t.hasOwnProperty("name")&&(s.name=t.name),t.rawData!=null&&t.hasOwnProperty("rawData")&&(s.rawData=u.bytes===String?n.base64.encode(t.rawData,0,t.rawData.length):u.bytes===Array?Array.prototype.slice.call(t.rawData):t.rawData),t.doubleData&&t.doubleData.length){s.doubleData=[];for(var d=0;d>>0,t.uint64Data[d].high>>>0).toNumber(!0):t.uint64Data[d]}if(t.docString!=null&&t.hasOwnProperty("docString")&&(s.docString=t.docString),t.externalData&&t.externalData.length){s.externalData=[];for(var d=0;d>>3){case 1:{f.begin=u.int64();break}case 2:{f.end=u.int64();break}default:u.skipType(b&7);break}}return f},t.decodeDelimited=function(u){return u instanceof i||(u=new i(u)),this.decode(u,u.uint32())},t.verify=function(u){return typeof u!="object"||u===null?"object expected":u.begin!=null&&u.hasOwnProperty("begin")&&!n.isInteger(u.begin)&&!(u.begin&&n.isInteger(u.begin.low)&&n.isInteger(u.begin.high))?"begin: integer|Long expected":u.end!=null&&u.hasOwnProperty("end")&&!n.isInteger(u.end)&&!(u.end&&n.isInteger(u.end.low)&&n.isInteger(u.end.high))?"end: integer|Long expected":null},t.fromObject=function(u){if(u instanceof o.onnx.TensorProto.Segment)return u;var s=new o.onnx.TensorProto.Segment;return u.begin!=null&&(n.Long?(s.begin=n.Long.fromValue(u.begin)).unsigned=!1:typeof u.begin=="string"?s.begin=parseInt(u.begin,10):typeof u.begin=="number"?s.begin=u.begin:typeof u.begin=="object"&&(s.begin=new n.LongBits(u.begin.low>>>0,u.begin.high>>>0).toNumber())),u.end!=null&&(n.Long?(s.end=n.Long.fromValue(u.end)).unsigned=!1:typeof u.end=="string"?s.end=parseInt(u.end,10):typeof u.end=="number"?s.end=u.end:typeof u.end=="object"&&(s.end=new n.LongBits(u.end.low>>>0,u.end.high>>>0).toNumber())),s},t.toObject=function(u,s){s||(s={});var d={};if(s.defaults){if(n.Long){var f=new n.Long(0,0,!1);d.begin=s.longs===String?f.toString():s.longs===Number?f.toNumber():f}else d.begin=s.longs===String?"0":0;if(n.Long){var f=new n.Long(0,0,!1);d.end=s.longs===String?f.toString():s.longs===Number?f.toNumber():f}else d.end=s.longs===String?"0":0}return u.begin!=null&&u.hasOwnProperty("begin")&&(typeof u.begin=="number"?d.begin=s.longs===String?String(u.begin):u.begin:d.begin=s.longs===String?n.Long.prototype.toString.call(u.begin):s.longs===Number?new n.LongBits(u.begin.low>>>0,u.begin.high>>>0).toNumber():u.begin),u.end!=null&&u.hasOwnProperty("end")&&(typeof u.end=="number"?d.end=s.longs===String?String(u.end):u.end:d.end=s.longs===String?n.Long.prototype.toString.call(u.end):s.longs===Number?new n.LongBits(u.end.low>>>0,u.end.high>>>0).toNumber():u.end),d},t.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},t.getTypeUrl=function(u){return u===void 0&&(u="type.googleapis.com"),u+"/onnx.TensorProto.Segment"},t}(),c.DataLocation=function(){var t={},u=Object.create(t);return u[t[0]="DEFAULT"]=0,u[t[1]="EXTERNAL"]=1,u}(),c}(),p.SparseTensorProto=function(){function c(t){if(this.dims=[],t)for(var u=Object.keys(t),s=0;s>>3){case 1:{d.values=o.onnx.TensorProto.decode(t,t.uint32());break}case 2:{d.indices=o.onnx.TensorProto.decode(t,t.uint32());break}case 3:{if(d.dims&&d.dims.length||(d.dims=[]),(f&7)===2)for(var b=t.uint32()+t.pos;t.pos>>0,t.dims[s].high>>>0).toNumber())}return u},c.toObject=function(t,u){u||(u={});var s={};if((u.arrays||u.defaults)&&(s.dims=[]),u.defaults&&(s.values=null,s.indices=null),t.values!=null&&t.hasOwnProperty("values")&&(s.values=o.onnx.TensorProto.toObject(t.values,u)),t.indices!=null&&t.hasOwnProperty("indices")&&(s.indices=o.onnx.TensorProto.toObject(t.indices,u)),t.dims&&t.dims.length){s.dims=[];for(var d=0;d>>0,t.dims[d].high>>>0).toNumber():t.dims[d]}return s},c.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},c.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/onnx.SparseTensorProto"},c}(),p.TensorShapeProto=function(){function c(t){if(this.dim=[],t)for(var u=Object.keys(t),s=0;s>>3){case 1:{d.dim&&d.dim.length||(d.dim=[]),d.dim.push(o.onnx.TensorShapeProto.Dimension.decode(t,t.uint32()));break}default:t.skipType(f&7);break}}return d},c.decodeDelimited=function(t){return t instanceof i||(t=new i(t)),this.decode(t,t.uint32())},c.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.dim!=null&&t.hasOwnProperty("dim")){if(!Array.isArray(t.dim))return"dim: array expected";for(var u=0;u>>3){case 1:{b.dimValue=s.int64();break}case 2:{b.dimParam=s.string();break}case 3:{b.denotation=s.string();break}default:s.skipType(y&7);break}}return b},t.decodeDelimited=function(s){return s instanceof i||(s=new i(s)),this.decode(s,s.uint32())},t.verify=function(s){if(typeof s!="object"||s===null)return"object expected";var d={};if(s.dimValue!=null&&s.hasOwnProperty("dimValue")&&(d.value=1,!n.isInteger(s.dimValue)&&!(s.dimValue&&n.isInteger(s.dimValue.low)&&n.isInteger(s.dimValue.high))))return"dimValue: integer|Long expected";if(s.dimParam!=null&&s.hasOwnProperty("dimParam")){if(d.value===1)return"value: multiple values";if(d.value=1,!n.isString(s.dimParam))return"dimParam: string expected"}return s.denotation!=null&&s.hasOwnProperty("denotation")&&!n.isString(s.denotation)?"denotation: string expected":null},t.fromObject=function(s){if(s instanceof o.onnx.TensorShapeProto.Dimension)return s;var d=new o.onnx.TensorShapeProto.Dimension;return s.dimValue!=null&&(n.Long?(d.dimValue=n.Long.fromValue(s.dimValue)).unsigned=!1:typeof s.dimValue=="string"?d.dimValue=parseInt(s.dimValue,10):typeof s.dimValue=="number"?d.dimValue=s.dimValue:typeof s.dimValue=="object"&&(d.dimValue=new n.LongBits(s.dimValue.low>>>0,s.dimValue.high>>>0).toNumber())),s.dimParam!=null&&(d.dimParam=String(s.dimParam)),s.denotation!=null&&(d.denotation=String(s.denotation)),d},t.toObject=function(s,d){d||(d={});var f={};return d.defaults&&(f.denotation=""),s.dimValue!=null&&s.hasOwnProperty("dimValue")&&(typeof s.dimValue=="number"?f.dimValue=d.longs===String?String(s.dimValue):s.dimValue:f.dimValue=d.longs===String?n.Long.prototype.toString.call(s.dimValue):d.longs===Number?new n.LongBits(s.dimValue.low>>>0,s.dimValue.high>>>0).toNumber():s.dimValue,d.oneofs&&(f.value="dimValue")),s.dimParam!=null&&s.hasOwnProperty("dimParam")&&(f.dimParam=s.dimParam,d.oneofs&&(f.value="dimParam")),s.denotation!=null&&s.hasOwnProperty("denotation")&&(f.denotation=s.denotation),f},t.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},t.getTypeUrl=function(s){return s===void 0&&(s="type.googleapis.com"),s+"/onnx.TensorShapeProto.Dimension"},t}(),c}(),p.TypeProto=function(){function c(u){if(u)for(var s=Object.keys(u),d=0;d>>3){case 1:{f.tensorType=o.onnx.TypeProto.Tensor.decode(u,u.uint32());break}case 4:{f.sequenceType=o.onnx.TypeProto.Sequence.decode(u,u.uint32());break}case 5:{f.mapType=o.onnx.TypeProto.Map.decode(u,u.uint32());break}case 9:{f.optionalType=o.onnx.TypeProto.Optional.decode(u,u.uint32());break}case 8:{f.sparseTensorType=o.onnx.TypeProto.SparseTensor.decode(u,u.uint32());break}case 6:{f.denotation=u.string();break}default:u.skipType(b&7);break}}return f},c.decodeDelimited=function(u){return u instanceof i||(u=new i(u)),this.decode(u,u.uint32())},c.verify=function(u){if(typeof u!="object"||u===null)return"object expected";var s={};if(u.tensorType!=null&&u.hasOwnProperty("tensorType")){s.value=1;{var d=o.onnx.TypeProto.Tensor.verify(u.tensorType);if(d)return"tensorType."+d}}if(u.sequenceType!=null&&u.hasOwnProperty("sequenceType")){if(s.value===1)return"value: multiple values";s.value=1;{var d=o.onnx.TypeProto.Sequence.verify(u.sequenceType);if(d)return"sequenceType."+d}}if(u.mapType!=null&&u.hasOwnProperty("mapType")){if(s.value===1)return"value: multiple values";s.value=1;{var d=o.onnx.TypeProto.Map.verify(u.mapType);if(d)return"mapType."+d}}if(u.optionalType!=null&&u.hasOwnProperty("optionalType")){if(s.value===1)return"value: multiple values";s.value=1;{var d=o.onnx.TypeProto.Optional.verify(u.optionalType);if(d)return"optionalType."+d}}if(u.sparseTensorType!=null&&u.hasOwnProperty("sparseTensorType")){if(s.value===1)return"value: multiple values";s.value=1;{var d=o.onnx.TypeProto.SparseTensor.verify(u.sparseTensorType);if(d)return"sparseTensorType."+d}}return u.denotation!=null&&u.hasOwnProperty("denotation")&&!n.isString(u.denotation)?"denotation: string expected":null},c.fromObject=function(u){if(u instanceof o.onnx.TypeProto)return u;var s=new o.onnx.TypeProto;if(u.tensorType!=null){if(typeof u.tensorType!="object")throw TypeError(".onnx.TypeProto.tensorType: object expected");s.tensorType=o.onnx.TypeProto.Tensor.fromObject(u.tensorType)}if(u.sequenceType!=null){if(typeof u.sequenceType!="object")throw TypeError(".onnx.TypeProto.sequenceType: object expected");s.sequenceType=o.onnx.TypeProto.Sequence.fromObject(u.sequenceType)}if(u.mapType!=null){if(typeof u.mapType!="object")throw TypeError(".onnx.TypeProto.mapType: object expected");s.mapType=o.onnx.TypeProto.Map.fromObject(u.mapType)}if(u.optionalType!=null){if(typeof u.optionalType!="object")throw TypeError(".onnx.TypeProto.optionalType: object expected");s.optionalType=o.onnx.TypeProto.Optional.fromObject(u.optionalType)}if(u.sparseTensorType!=null){if(typeof u.sparseTensorType!="object")throw TypeError(".onnx.TypeProto.sparseTensorType: object expected");s.sparseTensorType=o.onnx.TypeProto.SparseTensor.fromObject(u.sparseTensorType)}return u.denotation!=null&&(s.denotation=String(u.denotation)),s},c.toObject=function(u,s){s||(s={});var d={};return s.defaults&&(d.denotation=""),u.tensorType!=null&&u.hasOwnProperty("tensorType")&&(d.tensorType=o.onnx.TypeProto.Tensor.toObject(u.tensorType,s),s.oneofs&&(d.value="tensorType")),u.sequenceType!=null&&u.hasOwnProperty("sequenceType")&&(d.sequenceType=o.onnx.TypeProto.Sequence.toObject(u.sequenceType,s),s.oneofs&&(d.value="sequenceType")),u.mapType!=null&&u.hasOwnProperty("mapType")&&(d.mapType=o.onnx.TypeProto.Map.toObject(u.mapType,s),s.oneofs&&(d.value="mapType")),u.denotation!=null&&u.hasOwnProperty("denotation")&&(d.denotation=u.denotation),u.sparseTensorType!=null&&u.hasOwnProperty("sparseTensorType")&&(d.sparseTensorType=o.onnx.TypeProto.SparseTensor.toObject(u.sparseTensorType,s),s.oneofs&&(d.value="sparseTensorType")),u.optionalType!=null&&u.hasOwnProperty("optionalType")&&(d.optionalType=o.onnx.TypeProto.Optional.toObject(u.optionalType,s),s.oneofs&&(d.value="optionalType")),d},c.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},c.getTypeUrl=function(u){return u===void 0&&(u="type.googleapis.com"),u+"/onnx.TypeProto"},c.Tensor=function(){function u(s){if(s)for(var d=Object.keys(s),f=0;f>>3){case 1:{b.elemType=s.int32();break}case 2:{b.shape=o.onnx.TensorShapeProto.decode(s,s.uint32());break}default:s.skipType(y&7);break}}return b},u.decodeDelimited=function(s){return s instanceof i||(s=new i(s)),this.decode(s,s.uint32())},u.verify=function(s){if(typeof s!="object"||s===null)return"object expected";if(s.elemType!=null&&s.hasOwnProperty("elemType")&&!n.isInteger(s.elemType))return"elemType: integer expected";if(s.shape!=null&&s.hasOwnProperty("shape")){var d=o.onnx.TensorShapeProto.verify(s.shape);if(d)return"shape."+d}return null},u.fromObject=function(s){if(s instanceof o.onnx.TypeProto.Tensor)return s;var d=new o.onnx.TypeProto.Tensor;if(s.elemType!=null&&(d.elemType=s.elemType|0),s.shape!=null){if(typeof s.shape!="object")throw TypeError(".onnx.TypeProto.Tensor.shape: object expected");d.shape=o.onnx.TensorShapeProto.fromObject(s.shape)}return d},u.toObject=function(s,d){d||(d={});var f={};return d.defaults&&(f.elemType=0,f.shape=null),s.elemType!=null&&s.hasOwnProperty("elemType")&&(f.elemType=s.elemType),s.shape!=null&&s.hasOwnProperty("shape")&&(f.shape=o.onnx.TensorShapeProto.toObject(s.shape,d)),f},u.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},u.getTypeUrl=function(s){return s===void 0&&(s="type.googleapis.com"),s+"/onnx.TypeProto.Tensor"},u}(),c.Sequence=function(){function u(s){if(s)for(var d=Object.keys(s),f=0;f>>3){case 1:{b.elemType=o.onnx.TypeProto.decode(s,s.uint32());break}default:s.skipType(y&7);break}}return b},u.decodeDelimited=function(s){return s instanceof i||(s=new i(s)),this.decode(s,s.uint32())},u.verify=function(s){if(typeof s!="object"||s===null)return"object expected";if(s.elemType!=null&&s.hasOwnProperty("elemType")){var d=o.onnx.TypeProto.verify(s.elemType);if(d)return"elemType."+d}return null},u.fromObject=function(s){if(s instanceof o.onnx.TypeProto.Sequence)return s;var d=new o.onnx.TypeProto.Sequence;if(s.elemType!=null){if(typeof s.elemType!="object")throw TypeError(".onnx.TypeProto.Sequence.elemType: object expected");d.elemType=o.onnx.TypeProto.fromObject(s.elemType)}return d},u.toObject=function(s,d){d||(d={});var f={};return d.defaults&&(f.elemType=null),s.elemType!=null&&s.hasOwnProperty("elemType")&&(f.elemType=o.onnx.TypeProto.toObject(s.elemType,d)),f},u.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},u.getTypeUrl=function(s){return s===void 0&&(s="type.googleapis.com"),s+"/onnx.TypeProto.Sequence"},u}(),c.Map=function(){function u(s){if(s)for(var d=Object.keys(s),f=0;f>>3){case 1:{b.keyType=s.int32();break}case 2:{b.valueType=o.onnx.TypeProto.decode(s,s.uint32());break}default:s.skipType(y&7);break}}return b},u.decodeDelimited=function(s){return s instanceof i||(s=new i(s)),this.decode(s,s.uint32())},u.verify=function(s){if(typeof s!="object"||s===null)return"object expected";if(s.keyType!=null&&s.hasOwnProperty("keyType")&&!n.isInteger(s.keyType))return"keyType: integer expected";if(s.valueType!=null&&s.hasOwnProperty("valueType")){var d=o.onnx.TypeProto.verify(s.valueType);if(d)return"valueType."+d}return null},u.fromObject=function(s){if(s instanceof o.onnx.TypeProto.Map)return s;var d=new o.onnx.TypeProto.Map;if(s.keyType!=null&&(d.keyType=s.keyType|0),s.valueType!=null){if(typeof s.valueType!="object")throw TypeError(".onnx.TypeProto.Map.valueType: object expected");d.valueType=o.onnx.TypeProto.fromObject(s.valueType)}return d},u.toObject=function(s,d){d||(d={});var f={};return d.defaults&&(f.keyType=0,f.valueType=null),s.keyType!=null&&s.hasOwnProperty("keyType")&&(f.keyType=s.keyType),s.valueType!=null&&s.hasOwnProperty("valueType")&&(f.valueType=o.onnx.TypeProto.toObject(s.valueType,d)),f},u.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},u.getTypeUrl=function(s){return s===void 0&&(s="type.googleapis.com"),s+"/onnx.TypeProto.Map"},u}(),c.Optional=function(){function u(s){if(s)for(var d=Object.keys(s),f=0;f>>3){case 1:{b.elemType=o.onnx.TypeProto.decode(s,s.uint32());break}default:s.skipType(y&7);break}}return b},u.decodeDelimited=function(s){return s instanceof i||(s=new i(s)),this.decode(s,s.uint32())},u.verify=function(s){if(typeof s!="object"||s===null)return"object expected";if(s.elemType!=null&&s.hasOwnProperty("elemType")){var d=o.onnx.TypeProto.verify(s.elemType);if(d)return"elemType."+d}return null},u.fromObject=function(s){if(s instanceof o.onnx.TypeProto.Optional)return s;var d=new o.onnx.TypeProto.Optional;if(s.elemType!=null){if(typeof s.elemType!="object")throw TypeError(".onnx.TypeProto.Optional.elemType: object expected");d.elemType=o.onnx.TypeProto.fromObject(s.elemType)}return d},u.toObject=function(s,d){d||(d={});var f={};return d.defaults&&(f.elemType=null),s.elemType!=null&&s.hasOwnProperty("elemType")&&(f.elemType=o.onnx.TypeProto.toObject(s.elemType,d)),f},u.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},u.getTypeUrl=function(s){return s===void 0&&(s="type.googleapis.com"),s+"/onnx.TypeProto.Optional"},u}(),c.SparseTensor=function(){function u(s){if(s)for(var d=Object.keys(s),f=0;f>>3){case 1:{b.elemType=s.int32();break}case 2:{b.shape=o.onnx.TensorShapeProto.decode(s,s.uint32());break}default:s.skipType(y&7);break}}return b},u.decodeDelimited=function(s){return s instanceof i||(s=new i(s)),this.decode(s,s.uint32())},u.verify=function(s){if(typeof s!="object"||s===null)return"object expected";if(s.elemType!=null&&s.hasOwnProperty("elemType")&&!n.isInteger(s.elemType))return"elemType: integer expected";if(s.shape!=null&&s.hasOwnProperty("shape")){var d=o.onnx.TensorShapeProto.verify(s.shape);if(d)return"shape."+d}return null},u.fromObject=function(s){if(s instanceof o.onnx.TypeProto.SparseTensor)return s;var d=new o.onnx.TypeProto.SparseTensor;if(s.elemType!=null&&(d.elemType=s.elemType|0),s.shape!=null){if(typeof s.shape!="object")throw TypeError(".onnx.TypeProto.SparseTensor.shape: object expected");d.shape=o.onnx.TensorShapeProto.fromObject(s.shape)}return d},u.toObject=function(s,d){d||(d={});var f={};return d.defaults&&(f.elemType=0,f.shape=null),s.elemType!=null&&s.hasOwnProperty("elemType")&&(f.elemType=s.elemType),s.shape!=null&&s.hasOwnProperty("shape")&&(f.shape=o.onnx.TensorShapeProto.toObject(s.shape,d)),f},u.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},u.getTypeUrl=function(s){return s===void 0&&(s="type.googleapis.com"),s+"/onnx.TypeProto.SparseTensor"},u}(),c}(),p.OperatorSetIdProto=function(){function c(t){if(t)for(var u=Object.keys(t),s=0;s>>3){case 1:{d.domain=t.string();break}case 2:{d.version=t.int64();break}default:t.skipType(f&7);break}}return d},c.decodeDelimited=function(t){return t instanceof i||(t=new i(t)),this.decode(t,t.uint32())},c.verify=function(t){return typeof t!="object"||t===null?"object expected":t.domain!=null&&t.hasOwnProperty("domain")&&!n.isString(t.domain)?"domain: string expected":t.version!=null&&t.hasOwnProperty("version")&&!n.isInteger(t.version)&&!(t.version&&n.isInteger(t.version.low)&&n.isInteger(t.version.high))?"version: integer|Long expected":null},c.fromObject=function(t){if(t instanceof o.onnx.OperatorSetIdProto)return t;var u=new o.onnx.OperatorSetIdProto;return t.domain!=null&&(u.domain=String(t.domain)),t.version!=null&&(n.Long?(u.version=n.Long.fromValue(t.version)).unsigned=!1:typeof t.version=="string"?u.version=parseInt(t.version,10):typeof t.version=="number"?u.version=t.version:typeof t.version=="object"&&(u.version=new n.LongBits(t.version.low>>>0,t.version.high>>>0).toNumber())),u},c.toObject=function(t,u){u||(u={});var s={};if(u.defaults)if(s.domain="",n.Long){var d=new n.Long(0,0,!1);s.version=u.longs===String?d.toString():u.longs===Number?d.toNumber():d}else s.version=u.longs===String?"0":0;return t.domain!=null&&t.hasOwnProperty("domain")&&(s.domain=t.domain),t.version!=null&&t.hasOwnProperty("version")&&(typeof t.version=="number"?s.version=u.longs===String?String(t.version):t.version:s.version=u.longs===String?n.Long.prototype.toString.call(t.version):u.longs===Number?new n.LongBits(t.version.low>>>0,t.version.high>>>0).toNumber():t.version),s},c.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},c.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/onnx.OperatorSetIdProto"},c}(),p.OperatorStatus=function(){var c={},t=Object.create(c);return t[c[0]="EXPERIMENTAL"]=0,t[c[1]="STABLE"]=1,t}(),p.FunctionProto=function(){function c(t){if(this.input=[],this.output=[],this.attribute=[],this.attributeProto=[],this.node=[],this.opsetImport=[],t)for(var u=Object.keys(t),s=0;s>>3){case 1:{d.name=t.string();break}case 4:{d.input&&d.input.length||(d.input=[]),d.input.push(t.string());break}case 5:{d.output&&d.output.length||(d.output=[]),d.output.push(t.string());break}case 6:{d.attribute&&d.attribute.length||(d.attribute=[]),d.attribute.push(t.string());break}case 11:{d.attributeProto&&d.attributeProto.length||(d.attributeProto=[]),d.attributeProto.push(o.onnx.AttributeProto.decode(t,t.uint32()));break}case 7:{d.node&&d.node.length||(d.node=[]),d.node.push(o.onnx.NodeProto.decode(t,t.uint32()));break}case 8:{d.docString=t.string();break}case 9:{d.opsetImport&&d.opsetImport.length||(d.opsetImport=[]),d.opsetImport.push(o.onnx.OperatorSetIdProto.decode(t,t.uint32()));break}case 10:{d.domain=t.string();break}default:t.skipType(f&7);break}}return d},c.decodeDelimited=function(t){return t instanceof i||(t=new i(t)),this.decode(t,t.uint32())},c.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.name!=null&&t.hasOwnProperty("name")&&!n.isString(t.name))return"name: string expected";if(t.input!=null&&t.hasOwnProperty("input")){if(!Array.isArray(t.input))return"input: array expected";for(var u=0;u{zn(),Zo(),ye=Ar(Cr()),yr(),hr=class{static arraysEqual(e,r){if(e.length!==r.length)return!1;for(let a=0;a1&&u>1)return;p[o-c]=Math.max(t,u)}return p}static index(r,a){let i=new Array(a.length);return tr.fillIndex(r,a,i),i}static fillIndex(r,a,i){let l=r.length-a.length;for(let n=0;n=0;T--)t[T]=v%o[T],v=Math.floor(v/o[T]);b||(tr.fillIndex(t,r.dims,u),d=r.get(u)),y||(tr.fillIndex(t,a.dims,s),f=a.get(s)),c.set(t,i(d,f))}}return c}}static isValidBroadcast(r,a){let i=r.length,l=a.length;if(i>l)return!1;for(let n=1;n<=i;n++)if(r[i-n]!==1&&r[i-n]!==a[l-n])return!1;return!0}static getBroadcastDims(r,a){let i=r.length,l=[];for(let n=0;n1&&p===1&&l.unshift(o)}return l}},jn=class{static getShapeOfGemmResult(e,r,a,i,l){if(e.length!==2||a.length!==2)throw new Error("shape need to be of size 2");let n,o,p;r?(n=e[1],o=e[0]):(n=e[0],o=e[1]);let c=-1;if(i?(p=a[0],c=1):(p=a[1],c=0),a[c]!==o)throw new Error("dimension mismatch");if(n<=0||p<=0||o<=0)throw new Error("invalid shape specified");if(l&&!Ze.isValidBroadcast(l,[n,p]))throw new Error("gemm: invalid bias shape for broadcast");return[n,p,o]}},We=class _n{static tensorDataTypeFromProto(r){switch(r){case ye.onnx.TensorProto.DataType.INT8:return"int8";case ye.onnx.TensorProto.DataType.UINT8:return"uint8";case ye.onnx.TensorProto.DataType.BOOL:return"bool";case ye.onnx.TensorProto.DataType.INT16:return"int16";case ye.onnx.TensorProto.DataType.UINT16:return"uint16";case ye.onnx.TensorProto.DataType.INT32:return"int32";case ye.onnx.TensorProto.DataType.UINT32:return"uint32";case ye.onnx.TensorProto.DataType.FLOAT:return"float32";case ye.onnx.TensorProto.DataType.DOUBLE:return"float64";case ye.onnx.TensorProto.DataType.STRING:return"string";case ye.onnx.TensorProto.DataType.INT64:return"int32";case ye.onnx.TensorProto.DataType.UINT64:return"uint32";default:throw new Error(`unsupported data type: ${ye.onnx.TensorProto.DataType[r]}`)}}static tensorDataTypeStringToEnum(r){switch(r){case"int8":return ye.onnx.TensorProto.DataType.INT8;case"uint8":return ye.onnx.TensorProto.DataType.UINT8;case"bool":return ye.onnx.TensorProto.DataType.BOOL;case"int16":return ye.onnx.TensorProto.DataType.INT16;case"uint16":return ye.onnx.TensorProto.DataType.UINT16;case"int32":return ye.onnx.TensorProto.DataType.INT32;case"uint32":return ye.onnx.TensorProto.DataType.UINT32;case"float32":return ye.onnx.TensorProto.DataType.FLOAT;case"float64":return ye.onnx.TensorProto.DataType.DOUBLE;case"string":return ye.onnx.TensorProto.DataType.STRING;case"int64":return ye.onnx.TensorProto.DataType.INT64;case"uint64":return ye.onnx.TensorProto.DataType.UINT64;default:throw new Error(`unsupported data type: ${r}`)}}static tensorDimsFromProto(r){return r.map(a=>Vt.isLong(a)?a.toNumber():a)}static tensorValueTypeFromProto(r){return{tensorType:_n.tensorDataTypeFromProto(r.elemType),shape:{dims:_n.tensorDimsFromProto(r.shape.dim.map(a=>a.dimValue))}}}static tensorDimsFromORTFormat(r){let a=[];for(let i=0;ir.length)throw new Error(`invalid dimension of ${a} for sizeFromDimension as Tensor has ${r.length} dimensions.`);return Tt.getSizeFromDimensionRange(r,a,r.length)}static sizeToDimension(r,a){if(a<0||a>r.length)throw new Error(`invalid dimension of ${a} for sizeToDimension as Tensor has ${r.length} dimensions.`);return Tt.getSizeFromDimensionRange(r,0,a)}static getSizeFromDimensionRange(r,a,i){let l=1;for(let n=a;n=0;--l)i[l]=i[l+1]*r[l+1];return i}static transpose(r){return r.slice().reverse()}static indicesToOffset(r,a,i){i===void 0&&(i=r.length);let l=0;for(let n=0;n=a)throw new Error("unsupported axis for this operation.");return r<0?r+a:r}static normalizeAxes(r,a){return r.map(i=>this.normalizeAxis(i,a))}static incrementIndex(r,a,i){if(a.length===0||r.length===0)throw new Error("Index incrementing unsupported for scalar Tensor");if(i===void 0)i=a.length;else if(i<=0||i>a.length)throw new Error("Incorrect axis to increment on");for(let l=i-1;l>=0&&(r[l]++,!(r[l]=r.length)throw new Error("the dimension with value zero exceeds the dimension size of the input tensor");l[c]=r[c]}else l[c]=a[c];o*=l[c]}}let p=Tt.size(r);if(n!==-1){if(p%o!==0)throw new Error(`the input tensor cannot be reshaped to the requested shape. Input shape: [${r}] Output shape: [${a}]`);l[n]=p/o}else if(o!==p)throw new Error("reshapedDims and originalDims don't have matching sizes");return l}static sortBasedOnPerm(r,a){return a?a.map(i=>r[i]):r.slice().reverse()}static padShape(r,a){let i=r.length;return r.map((l,n)=>l+a[n]+a[n+i])}static areEqual(r,a){return r.length!==a.length?!1:r.every((i,l)=>i===a[l])}static validateDimsAndCalcSize(r){if(r.length>6)throw new TypeError("Only rank 0 to 6 is supported for tensor shape.");let a=1;for(let i of r){if(!Number.isInteger(i))throw new TypeError(`Invalid shape: ${i} is not an integer`);if(i<0||i>2147483647)throw new TypeError(`Invalid shape: length ${i} is not allowed`);a*=i}return a}static flattenShape(r,a){a<0&&(a+=r.length);let i=r.reduce((n,o)=>n*o,1),l=r.slice(a).reduce((n,o)=>n*o,1);return[i/l,l]}static squeezeShape(r,a){let i=new Array;a=Tt.normalizeAxes(a,r.length);for(let l=0;l=0;if(n&&r[l]!==1)throw new Error("squeeze an axis of size different than 1");(a.length===0&&r[l]>1||a.length>0&&!n)&&i.push(r[l])}return i}static unsqueezeShape(r,a){let i=new Array(r.length+a.length);i.fill(0);for(let n=0;n=i.length)throw new Error("'axes' has an out of range axis");if(i[o]!==0)throw new Error("'axes' has a duplicate axis");i[o]=1}let l=0;for(let n=0;n=i.length?i.push(a[p+2]):i[p]=a[p+2];for(let p=0;p=i[p]||o[p+i.length]>=i[p])throw new Error("pads should be smaller than kernel")}}static adjustPadsBasedOnAutoPad(r,a,i,l,n,o){if(o){if(n.length!==2*(r.length-2))throw new Error("length of pads should be twice the length of data dimensions");if(a.length!==r.length-2)throw new Error("length of strides should be the length of data dimensions");if(l.length!==r.length-2)throw new Error("length of kernel shapes should be the length of data dimensions");for(let p=0;p{ku=Ar(Os()),Zo(),tn(),ne=Ar(Cr()),fe(),di=V.experimental.fbs,$e=class qr{constructor(r,a,i,l,n,o=ku.Guid.create()){this.dims=r,this.type=a,this.dataProvider=i,this.asyncDataProvider=l,this.cache=n,this.dataId=o,this.size=U.validateDimsAndCalcSize(r);let p=this.size,c=i===void 0&&l===void 0&&n===void 0;if(n!==void 0&&n.length!==p)throw new RangeError("Input dims doesn't match data length.");if(a==="string"){if(n!==void 0&&(!Array.isArray(n)||!n.every(t=>typeof t=="string")))throw new TypeError("cache should be a string array");c&&(this.cache=new Array(p))}else{if(n!==void 0){let t=Bu(a);if(!(n instanceof t))throw new TypeError(`cache should be type ${t.name}`)}if(c){let t=new ArrayBuffer(p*Hd(a));this.cache=qd(t,a)}}}get data(){if(this.cache===void 0){let r=this.dataProvider(this.dataId);if(r.length!==this.size)throw new Error("Length of data provided by the Data Provider is inconsistent with the dims of this Tensor.");this.cache=r}return this.cache}get stringData(){if(this.type!=="string")throw new TypeError("data type is not string");return this.data}get integerData(){switch(this.type){case"uint8":case"int8":case"uint16":case"int16":case"int32":case"uint32":case"bool":return this.data;default:throw new TypeError("data type is not integer (uint8, int8, uint16, int16, int32, uint32, bool)")}}get floatData(){switch(this.type){case"float32":case"float64":return this.data;default:throw new TypeError("data type is not float (float32, float64)")}}get numberData(){if(this.type!=="string")return this.data;throw new TypeError("type cannot be non-number (string)")}get(r){return this.data[U.indicesToOffset(r,this.strides)]}set(r,a){this.data[U.indicesToOffset(r,this.strides)]=a}async getData(){return this.cache===void 0&&(this.cache=await this.asyncDataProvider(this.dataId)),this.cache}get strides(){return this._strides||(this._strides=U.computeStrides(this.dims)),this._strides}static fromProto(r){if(!r)throw new Error("cannot construct Value from an empty tensor");let a=We.tensorDataTypeFromProto(r.dataType),i=We.tensorDimsFromProto(r.dims),l=new qr(i,a);if(a==="string")r.stringData.forEach((n,o)=>{l.data[o]=sn(n)});else if(r.rawData&&typeof r.rawData.byteLength=="number"&&r.rawData.byteLength>0){let n=l.data,o=new DataView(r.rawData.buffer,r.rawData.byteOffset,r.rawData.byteLength),p=Fu(r.dataType),c=r.rawData.byteLength/p;if(r.rawData.byteLength%p!==0)throw new Error("invalid buffer length");if(n.length!==c)throw new Error("buffer length mismatch");for(let t=0;t0){let n=l.data,o=new DataView(r.rawDataArray().buffer,r.rawDataArray().byteOffset,r.rawDataLength()),p=Fu(r.dataType()),c=r.rawDataLength()/p;if(r.rawDataLength()%p!==0)throw new Error("invalid buffer length");if(n.length!==c)throw new Error("buffer length mismatch");for(let t=0;t{jd={version:"",attribute:"attribute",varyingVertex:"varying",varyingFrag:"varying",texture2D:"texture2D",output:"gl_FragColor",outputDeclaration:""},Yd={version:"#version 300 es",attribute:"in",varyingVertex:"out",varyingFrag:"in",texture2D:"texture",output:"outputColor",outputDeclaration:"out vec4 outputColor;"}}),ae=L(()=>{});async function mi(e,r=i=>0,a){return new Promise((i,l)=>{let n=0,o=()=>{if(e()){i();return}n++;let p=r(n);setTimeout(o,p)};o()})}function Yn(e){return Fr(typeof e<"u"&&e.length!==0,()=>"empty string found for sampler name"),"get"+e.charAt(0).toUpperCase()+e.slice(1)}function Gu(e){return Fr(typeof e<"u"&&e.length!==0,()=>"empty string found for sampler name"),"get"+e.charAt(0).toUpperCase()+e.slice(1)+"AtOutCoords"}function $r(e,r){let a=JSON.parse(JSON.stringify(e));return a=r,a}function kr(e,r){return r.map(a=>e[a]).join(", ")}function Qe(e){if(e<=1)return"int";if(e===2)return"ivec2";if(e===3)return"ivec3";if(e===4)return"ivec4";if(e===5)return"ivec5";if(e===6)return"ivec6";throw Error(`GPU for rank ${e} is not yet supported`)}function Dt(e=6){return["x","y","z","w","u","v"].slice(0,e)}var Bt=L(()=>{fe()});function Xd(e,r){return Dt(r).map(a=>`${e}.${a}`)}function Br(e,r){return r===1?[e]:Xd(e,r)}function Nt(){return` float getChannel(vec4 frag, int dim) { int modCoord = imod(dim, 2); return modCoord == 0 ? frag.r : frag.g; } 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); } `}var Tr=L(()=>{Bt()});function Jd(e,r,a){if(e===0)return"false";if(e===1)return`rc > ${r[0]}`;let i="";for(let l=e-2;l= ${r[l-e+2]}`,l= ${e[0]} ? 0. : getA(rc + 1), 0, 0`;let i="r, c",l="r, cp1",n="rp1, c",o="rp1, cp1",p="";if(a>2)for(let c=0;c= ${i}; bool cEdge = cp1 >= ${a}; `}var Uu,Kd,zu,Vu=L(()=>{we(),ae(),Bt(),Tr(),Uu={name:"pack",inputNames:["A"],inputTypes:[1]},Kd=(e,r)=>{let a=H(e.session.backend.glContext.version),i=r.dims,l=i.length,n=r.dims.length,o=Qe(n),p=Br("rc",n),c=Qd(n,p,i[i.length-2],i[i.length-1]),t;l===0?t=[1,1]:l===1?t=[i[0],1]:t=[i[n-1],i[n-2]];let u=Jd(n,t,p),s=Zd(i,p),d=` void main() { ${o} rc = getOutputCoords(); if(${u}) { ${a.output} = vec4(0); } else { ${c} ${a.output} = vec4(${s}); } } `;return{...Uu,hasMain:!0,output:{dims:r.dims,type:r.type,textureType:2},shaderSource:d}},zu=(e,r)=>({...Uu,get:()=>Kd(e,r)})});function bi(e){if(e.length===0)return[1,1,1];let r=1;for(let a=0;a1?e[e.length-2]:1,e[e.length-1]]}function Hu(e,r){let a=!1;return e.length===0||r.length===0?a=!0:e.length<2||r.length<2?a=e[e.length-1]===r[r.length-1]:a=e[e.length-1]===r[r.length-1]&&e[e.length-2]===r[r.length-2],a}function rh(e){let r=U.computeStrides(e),a=["b","r","c"],i="index";return` ivec3 inputCoordsFromReshapedOutCoords(int index) { ${r.map((l,n)=>{let o=`int ${a[n]} = ${i} / ${l}`,p=n===r.length-1?`int ${a[n+1]} = ${i} - ${a[n]} * ${l}`:`index -= ${a[n]} * ${l}`;return`${o}; ${p};`}).join("")} return ivec3(b, r, c); } `}function nh(e){let r=U.computeStrides(e);return` int getFlattenedIndex(ivec3 coords) { // reverse y, z order return coords.x * ${r[0]} + coords.z * ${r[1]} + coords.y; } `}var eh,th,Wu,qu=L(()=>{fe(),we(),ae(),Tr(),eh=e=>({name:"Reshape (packed)",inputTypes:[2],inputNames:["A"],cacheHint:`${e}`}),th=(e,r,a,i)=>{let l=r.dims,n=i,o="";for(let t=0;t<4;t++){let u="";switch(t){case 0:u="outputCoords = rc;";break;case 1:u="outputCoords = ivec3(rc.x, rc.y+1, rc.z);";break;case 2:u="outputCoords = ivec3(rc.x, rc.y, rc.z+1);";break;case 3:u="outputCoords = ivec3(rc.x, rc.y+1, rc.z+1);";break;default:throw new Error}o+=` ${u} ${t>0?"if(outputCoords.y < rows && outputCoords.z < cols){":""} int flattenedIndex = getFlattenedIndex(outputCoords); ivec3 inputRC = inputCoordsFromReshapedOutCoords(flattenedIndex); vec2 innerDims = vec2(float(inputRC.y),float(inputRC.z)); result[${t}] = getChannel(getA(inputRC.x, inputRC.y, inputRC.z), innerDims); ${t>0?"}":""} `}let p=H(e.session.backend.glContext.version),c=` ${rh(l)} ${nh(n)} ${Nt()} void main() { ivec3 rc = getOutputCoords(); vec4 result = vec4(0.0); ivec3 outputCoords; int rows = ${n[2]}; int cols = ${n[1]}; ${o} ${p.output} = result; } `;return{...a,output:{dims:n,type:r.type,textureType:2},shaderSource:c,hasMain:!0}},Wu=(e,r,a)=>{let i=eh(a);return{...i,get:()=>th(e,r,i,a)}}}),gi,ju=L(()=>{we(),ae(),gi=(e,r)=>{let a=r.shape,i=H(e.session.backend.glContext.version),l=` const float FLOAT_MAX = 1.70141184e38; const float FLOAT_MIN = 1.17549435e-38; bool isNaN(float val) { return (val < 1.0 || 0.0 < val || val == 0.0) ? false : true; } highp vec4 encodeAsUint8(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; } void main() { float value = ${i.texture2D}(X,TexCoords).r; ${i.output} = encodeAsUint8(value); }`,n={name:"Uint8Encode",inputTypes:[0],inputNames:["X"],output:{dims:a,type:r.tensor.type,textureType:3},shaderSource:l,hasMain:!0};return e.executeProgram(n,[r.tensor])}});function ih(e,r){if(e===1)return"rc";let a="";for(let i=0;i{we(),ae(),Bt(),Tr(),Yu={name:"unpack",inputNames:["A"],inputTypes:[2]},oh=(e,r)=>{let a=r.dims.length,i=Br("rc",a),l=i.slice(-2),n=Qe(a),o=Nt(),p=r.dims.length===0?"":ih(a,i),c=a<=1?"rc":`vec2(${l.join(",")})`,t=H(e.session.backend.glContext.version),u=` ${o} void main() { ${n} rc = getOutputCoords(); // Sample the texture with the coords to get the rgba channel value. vec4 packedInput = getA(${p}); ${t.output} = vec4(getChannel(packedInput, ${c}), 0, 0, 0); } `;return{...Yu,hasMain:!0,output:{dims:r.dims,type:r.type,textureType:0},shaderSource:u}},Xu=(e,r)=>({...Yu,get:()=>oh(e,r)})}),Xn,un,Kn,ln=L(()=>{lt(),Xn=class{constructor(e,r=1){if(r===1)this.internalFormat=e.R32F,this.format=e.RED,this.textureType=e.FLOAT,this.channelSize=r;else if(r===4)this.internalFormat=e.RGBA32F,this.format=e.RGBA,this.textureType=e.FLOAT,this.channelSize=r;else throw new Error(`Invalid number of channels: ${r}`)}encode(e,r){let a,i;return e.constructor!==Float32Array&&(ce.warning("Encoder","data was not of type Float32; creating new Float32Array"),i=new Float32Array(e)),r*this.channelSize>e.length?(ce.warning("Encoder","Source data too small. Allocating larger array"),i=e,a=this.allocate(r*this.channelSize),i.forEach((l,n)=>a[n]=l)):(i=e,a=i),a}allocate(e){return new Float32Array(e*4)}decode(e,r){return this.channelSize===1?e.filter((a,i)=>i%4===0).subarray(0,r):e.subarray(0,r)}},un=class{constructor(e,r=1,a){if(r!==1&&r!==4)throw new Error(`Invalid number of channels: ${r}`);this.internalFormat=e.RGBA,this.format=e.RGBA,this.channelSize=r,this.textureType=a||e.FLOAT}encode(e,r){let a=e;return this.channelSize===1&&(ce.verbose("Encoder","Exploding into a larger array"),a=this.allocate(r),e.forEach((i,l)=>a[l*4]=i)),a}allocate(e){return new Float32Array(e*4)}decode(e,r){return this.channelSize===1?e.filter((a,i)=>i%4===0).subarray(0,r):e.subarray(0,r)}},Kn=class{constructor(e,r=1){if(this.channelSize=4,r===1)this.internalFormat=e.ALPHA,this.format=e.ALPHA,this.textureType=e.UNSIGNED_BYTE,this.channelSize=r;else if(r===4)this.internalFormat=e.RGBA,this.format=e.RGBA,this.textureType=e.UNSIGNED_BYTE,this.channelSize=r;else throw new Error(`Invalid number of channels: ${r}`)}encode(e,r){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}allocate(e){return new Uint8Array(e*this.channelSize)}decode(e,r){if(e instanceof Uint8Array)return e.subarray(0,r);throw new Error(`Invalid array type: ${e.constructor}`)}}}),fn,Ju,yi,Zu=L(()=>{fe(),ae(),fn=(e,r,a)=>{let i=a===0||a===1?1:4,l=a===2,n=a===1||a===2,o=a===4?r.length-1:void 0,p=a===4?r.map((c,t)=>t===r.length-1?c*4:c):void 0;return yi(e,r,i,p,{isPacked:l,reverseWH:n,breakAxis:o})},Ju=(e,r,a)=>{let i=fn(e,r,a);return[i.width,i.height]},yi=(e,r,a=1,i,l)=>{let n=!!(l&&l.isPacked),[o,p]=e.computeTextureWH(n&&i||r,l),c=r.length,t=r.slice(0);if(c===0&&(t=[1]),a===1)i=r;else if(n){if(a!==4)throw new Error("a packed texture must be 4-channel");i=r,c>0&&(t[c-1]=Math.ceil(t[c-1]/2)),c>1&&(t[c-2]=Math.ceil(t[c-2]/2))}else if(!i)throw new Error("Unpacked shape is needed when using channels > 1");return{width:o,height:p,channels:a,isPacked:n,shape:t,strides:U.computeStrides(t),unpackedShape:i,reversedWH:l&&l.reverseWH}}}),sh,Jn,el=L(()=>{lt(),yr(),fe(),Vu(),qu(),ju(),Ku(),ln(),Zu(),ae(),sh=(e,r)=>{let a=r.map(l=>`${l.unpackedShape.join(",")};${l.width}x${l.height}`).join("_"),i=e.name;return e.cacheHint&&(i+="["+e.cacheHint+"]"),i+=":"+a,i},Jn=class{constructor(e){this.session=e,this.packedTextureDataCache=new Map,this.unpackedTextureDataCache=new Map}calculateTextureWidthAndHeight(e,r){return Ju(this.session.layoutStrategy,e,r)}executeProgram(e,r){if(r.lengththis.readTexture(n),async o=>this.readTextureAsync(n),void 0,l),texture:a};return this.setTextureData(n.tensor.dataId,n,e.isPacked),n}getTextureData(e,r=!1){return this.session.isInitializer(e)?this.session.getTextureData(e,r):r?this.packedTextureDataCache.get(e):this.unpackedTextureDataCache.get(e)}setTextureData(e,r,a=!1){this.session.isInitializer(e)?this.session.setTextureData(e,r,a):(a?this.packedTextureDataCache:this.unpackedTextureDataCache).set(e,r)}isTextureLayoutCached(e,r=!1){return!!this.getTextureData(e.dataId,r)}dispose(){this.session.textureManager.clearActiveTextures(),this.packedTextureDataCache.forEach(e=>this.session.textureManager.releaseTexture(e)),this.packedTextureDataCache=new Map,this.unpackedTextureDataCache.forEach(e=>this.session.textureManager.releaseTexture(e)),this.unpackedTextureDataCache=new Map}readTexture(e){return e.isPacked?this.readTexture(this.unpack(e)):this.session.backend.glContext.isFloat32DownloadSupported?this.session.textureManager.readTexture(e,e.tensor.type,e.channels):this.session.textureManager.readUint8TextureAsFloat(gi(this,e))}async readTextureAsync(e){return e.isPacked?this.readTextureAsync(this.unpack(e)):this.session.backend.glContext.isFloat32DownloadSupported?this.session.textureManager.readTextureAsync(e,e.tensor.type,e.channels):this.session.textureManager.readUint8TextureAsFloat(gi(this,e))}pack(e){return this.executeProgram(zu(this,e.tensor),[e.tensor])}unpack(e){return this.executeProgram(Xu(this,e.tensor),[e.tensor])}}}),Ti,Q,Ue=L(()=>{Ti=class{constructor(e){Object.assign(this,e)}get cacheKey(){return this.key||(this.key=Object.getOwnPropertyNames(this).sort().map(e=>`${this[e]}`).join(";")),this.key}},Q=e=>new Ti(e)}),tl,rl,nl,uh,lh,ol=L(()=>{Ue(),we(),ae(),tl={name:"BatchNormalization",inputNames:["A","Scale","B","Mean","Variance"],inputTypes:[0,0,0,0,0]},rl=(e,r,a)=>(lh(r),[e.run({...tl,cacheHint:a.cacheKey,get:()=>uh(e,r,a)},r)]),nl=e=>{let r=e.attributes.getFloat("epsilon",1e-5),a=e.attributes.getFloat("momentum",.9),i=e.attributes.getInt("spatial",1);return Q({epsilon:r,momentum:a,spatial:i})},uh=(e,r,a)=>{let i=H(e.session.backend.glContext.version),l=r[0].dims.length,[n,o]=e.calculateTextureWidthAndHeight(r[1].dims,0),p=` float process(int[${l}] indices) { vec2 position = offsetToCoords(indices[1], ${n}, ${o}); float scale = getColorAsFloat(${i.texture2D}(Scale, position)); float mean = getColorAsFloat(${i.texture2D}(Mean, position)); float variance = getColorAsFloat(${i.texture2D}(Variance, position)); float b = getColorAsFloat(${i.texture2D}(B, position)); return scale * ( (_A(indices) - mean) / sqrt(variance + float(${a.epsilon})) ) + b; }`;return{...tl,output:{dims:r[0].dims,type:r[0].type,textureType:0},shaderSource:p}},lh=e=>{if(!e||e.length!==5)throw new Error("BatchNormalization requires 5 inputs.");let r=e[0],a=e[1],i=e[2],l=e[3],n=e[4];if(r.dims.length<3||a.dims.length!==1||i.dims.length!==1||l.dims.length!==1||n.dims.length!==1)throw new Error("invalid input shape.");if(a.dims[0]!==r.dims[1]||i.dims[0]!==r.dims[1]||l.dims[0]!==r.dims[1]||n.dims[0]!==r.dims[1])throw new Error("invalid input shape.");if(r.type!=="float32"&&r.type!=="float64"||a.type!=="float32"&&a.type!=="float64"||i.type!=="float32"&&i.type!=="float64"||l.type!=="float32"&&l.type!=="float64"||n.type!=="float32"&&n.type!=="float64")throw new Error("invalid input tensor types.")}}),Zn,dt,R,cn,Qn,Wt=L(()=>{Zn=class{constructor(e,r,a,i){this.glContext=e,this.programInfo=r,this.inputTextureLayouts=a,this.outputTextureLayout=i}},dt=class{constructor(e){this.context=e}},R=class{constructor(e,r){this.routineBody=e,this.dependencies=r}},cn=class{constructor(e,r,a){this.name=e,a?this.dependencies=a:this.dependencies=[],r&&(this.routineBody=r)}addDependency(e){e&&this.dependencies.push(e)}},Qn=class{static returnOrderedNodes(e){if(!e||e.length===0)return[];if(e.length===1)return e;let r=new Set,a=new Set,i=new Array;return this.createOrderedNodes(e,r,a,i),i}static createOrderedNodes(e,r,a,i){for(let l=0;l0)for(let n=0;n b); } vec4 ${e}(vec4 v1, vec4 v2) { return vec4( v1.r > v2.r , v1.g > v2.g, v1.b > v2.b, v1.a > v2.a ); } `,name:e,type:0}}function gh(){let e="less_";return{body:` float ${e}(float a, float b) { return float(a < b); } vec4 ${e}(vec4 v1, vec4 v2) { return vec4( v1.r < v2.r , v1.g < v2.g, v1.b < v2.b, v1.a < v2.a ); } `,name:e,type:0}}function yh(){let e="and_";return{body:` float ${e}(float a, float b) { return float( bool(a) && bool(b) ); } vec4 ${e}(vec4 v1, vec4 v2) { bvec4 b1 = bvec4(v1); bvec4 b2 = bvec4(v2); return vec4( b1.r && b2.r , b1.g && b2.g, b1.b && b2.b, b1.a && b2.a ); } `,name:e,type:0}}function Th(){let e="or_";return{body:` float ${e}(float a, float b) { return float( bool(a) || bool(b) ); } vec4 ${e}(vec4 v1, vec4 v2) { bvec4 b1 = bvec4(v1); bvec4 b2 = bvec4(v2); return vec4( b1.r || b2.r , b1.g || b2.g, b1.b || b2.b, b1.a || b2.a ); } `,name:e,type:0}}function xh(){let e="xor_";return{body:` float ${e}(float a, float b) { return float( bool(a) ^^ bool(b) ); } vec4 ${e}(vec4 v1, vec4 v2) { bvec4 b1 = bvec4(v1); bvec4 b2 = bvec4(v2); return vec4( b1.r ^^ b2.r , b1.g ^^ b2.g, b1.b ^^ b2.b, b1.a ^^ b2.a ); } `,name:e,type:0}}function wh(){return _h("pow")}function vh(){let e="prelu_";return{body:` float ${e}(float a, float b) { return a < 0.0 ? a * b: a; } vec4 ${e}(vec4 v1, vec4 v2) { return vec4( v1.r < 0.0 ? v1.r * v2.r: v1.r, v1.g < 0.0 ? v1.g * v2.g: v1.g, v1.b < 0.0 ? v1.b * v2.b: v1.b, v1.a < 0.0 ? v1.a * v2.a: v1.a ); } `,name:e,type:0}}function _h(e){let r=`${e}_`;return{body:` float ${r}(float a, float b) { return ${e}(a, b); } vec4 ${r}(vec4 v1, vec4 v2) { return ${e}(v1, v2); } `,name:r,type:0}}var ht,Oh,il,al,sl,ul,ll,fl,cl,pl,dl,hl,ml,bl,gl=L(()=>{fe(),Wt(),we(),ae(),ht=(e,r,a,i=r[0].type,l)=>{let n=e.session.pack?2:0;return{name:a.name,inputNames:["A","B"],inputTypes:[n,n],cacheHint:l,get:()=>Oh(e,r,a,i)}},Oh=(e,r,a,i=r[0].type)=>{let l=e.session.pack?2:0,n=!U.areEqual(r[0].dims,r[1].dims),o=r[0].dims,p=e.session.pack;if(n){let u=Ze.calcShape(r[0].dims,r[1].dims,!1);if(!u)throw new Error("Can't perform binary op on the given tensors");o=u;let s=o.length,d=r[0].dims.length!==0?r[0].dims.length:1,f=r[1].dims.length!==0?r[1].dims.length:1,b=r[0].dims.length!==0?"bcastIndices_A(indices, aindices);":"aindices[0] = 0;",y=r[1].dims.length!==0?"bcastIndices_B(indices, bindices);":"bindices[0] = 0;",v=H(e.session.backend.glContext.version),E=p?` ${a.body} void main() { vec4 a = getAAtOutCoords(); vec4 b = getBAtOutCoords(); vec4 result = ${a.name}(a, b); ${v.output} = result; }`:` ${a.body} float process(int indices[${s}]) { int aindices[${d}]; int bindices[${f}]; ${b} ${y} return ${a.name}(_A(aindices), _B(bindices)); }`;return{name:a.name,inputNames:["A","B"],inputTypes:[l,l],output:{dims:o,type:i,textureType:l},shaderSource:E,hasMain:p}}let c=H(e.session.backend.glContext.version),t=` ${a.body} void main() { vec4 v1 = ${c.texture2D}(A, TexCoords); vec4 v2 = ${c.texture2D}(B, TexCoords); vec4 result = ${a.name}(v1, v2); ${c.output} = result; } `;return{name:a.name,inputNames:["A","B"],inputTypes:[l,l],output:{dims:r[0].dims,type:i,textureType:l},shaderSource:t,hasMain:!0}},il=(e,r)=>[e.run(ht(e,r,ch()),r)],al=(e,r)=>[e.run(ht(e,r,yh(),"bool"),r)],sl=(e,r)=>[e.run(ht(e,r,ph()),r)],ul=(e,r)=>[e.run(ht(e,r,mh(),"bool"),r)],ll=(e,r)=>[e.run(ht(e,r,bh(),"bool"),r)],fl=(e,r)=>[e.run(ht(e,r,gh(),"bool"),r)],cl=(e,r)=>[e.run(ht(e,r,dh()),r)],pl=(e,r)=>[e.run(ht(e,r,Th(),"bool"),r)],dl=(e,r)=>[e.run(ht(e,r,wh()),r)],hl=(e,r)=>[e.run(ht(e,r,vh()),r)],ml=(e,r)=>[e.run(ht(e,r,hh()),r)],bl=(e,r)=>[e.run(ht(e,r,xh(),"bool"),r)]}),yl,Tl,Sh,xl=L(()=>{fe(),yl=(e,r,a)=>(Sh(r),[e.cast(r[0],a)]),Tl=e=>We.tensorDataTypeFromProto(e.attributes.getInt("to")),Sh=e=>{if(!e||e.length!==1)throw new Error("Cast requires 1 input.");if(e[0].type==="string")throw new Error("Invalid input type.")}}),Ah,Ph,wl,eo,vl=L(()=>{we(),ae(),Bt(),Tr(),Ah=(e,r)=>({name:"Concat (packed)",inputNames:Array.from({length:e},(a,i)=>`X${i}`),inputTypes:Array(e).fill(2),cacheHint:r}),Ph=(e,r,a,i)=>{let l=a[0].dims.slice();if(i>=l.length||i<-1*l.length)throw new Error("axis specified for concat doesn't match input dimensionality");i<0&&(i=l.length+i);let n=l.slice(0);for(let C=1;CC.dims),s=Dt(o),d=new Array(u.length-1);d[0]=u[0][i];for(let C=1;C= ${d[C-1]}) { return getChannel( getX${C}(${eo(s,f,J)}), vec2(${eo(b,f,J)})); }`}let E=d.length,T=d[d.length-1];v+=` return getChannel( getX${E}(${eo(s,f,T)}), vec2(${eo(b,f,T)}));`;let $=H(e.session.backend.glContext.version),F=` ${t} float getValue(${s.map(C=>"int "+C)}) { ${v} } void main() { ${c} coords = getOutputCoords(); int lastDim = coords.${s[o-1]}; coords.${s[o-1]} = coords.${s[o-2]}; coords.${s[o-2]} = lastDim; vec4 result = vec4(getValue(${p}), 0., 0., 0.); ${p[o-1]} = ${p[o-1]} + 1; if (${p[o-1]} < ${n[o-1]}) { result.g = getValue(${p}); } ${p[o-2]} = ${p[o-2]} + 1; if (${p[o-2]} < ${n[o-2]}) { result.a = getValue(${p}); } ${p[o-1]} = ${p[o-1]} - 1; if (${p[o-2]} < ${n[o-2]} && ${p[o-1]} < ${n[o-1]}) { result.b = getValue(${p}); } ${$.output} = result; } `;return{...r,output:{dims:n,type:a[0].type,textureType:2},shaderSource:F,hasMain:!0}},wl=(e,r,a)=>{let i=Ah(r.length,a.cacheKey);return{...i,get:()=>Ph(e,i,r,a.axis)}},eo=(e,r,a)=>{let i=e.indexOf(r);return e.map((l,n)=>n===i?`${l} - ${a}`:l).join()}}),_l,Eh,Dh,Lh,Ol,Ch,Fh,$h,Il,kh,Sl=L(()=>{Ue(),ae(),vl(),_l=(e,r,a)=>(kh(r),e.session.pack&&r[0].dims.length>1?[e.run(wl(e,r,a),r)]:[e.run(Lh(e,r,a),r)]),Eh=(e,r)=>({name:"Concat",inputNames:Array.from({length:e},(a,i)=>`X${i}`),inputTypes:Array(e).fill(0),cacheHint:r}),Dh=(e,r,a,i)=>{let l=a[0].dims.slice();if(i>=l.length||i<-1*l.length)throw new Error("axis specified for concat doesn't match input dimensionality");i<0&&(i=l.length+i);let n=l.slice(0);for(let f=1;f{let i=Eh(r.length,a.cacheKey);return{...i,get:()=>Dh(e,i,r,a.axis)}},Ol=e=>`int getTextureWhereDataResides(int index) { ${e.map((r,a)=>`if(index<${r}) {return ${a};} `).join("")} }`,Ch=e=>Ol(e),Fh=(e,r)=>{let a=[`float fetchDataFromCorrectTexture(int textureIndex, int indices[${r}]) {`];for(let i=0;i{let r=["int getSizeInConcatAxisValueFromIndex(int index) {"];for(let a=0;aQ({axis:e.attributes.getInt("axis")}),kh=e=>{if(!e||e.length<1)throw new Error("too few inputs");let r=e[0].type,a=e[0].dims.length;if(r==="string")throw new Error("string tensor is not supported yet");for(let i of e){if(i.type!==r)throw new Error("input tensors should be one type");if(i.dims.length!==a)throw new Error("input tensors should have the same shape")}}});function Bh(){return mt("abs")}function Nh(){return mt("acos")}function Rh(){return mt("asin")}function Mh(){return mt("atan")}function Gh(){return mt("ceil")}function Uh(){return mt("cos")}function zh(e){let r="elu";return{body:` const float alpha = float(${e}); float ${r}_(float a) { return a >= 0.0 ? a: (exp(a) - 1.0) * alpha; } vec4 ${r}_(vec4 v) { return vec4(${r}_(v.x), ${r}_(v.y), ${r}_(v.z), ${r}_(v.w)); } `,name:r,type:0}}function Vh(){return mt("exp")}function Wh(){return mt("floor")}function xi(e,r){let a="clip";return{body:` const float min = float(${e}); const float max = float(${r}); float ${a}_(float a) { return clamp(a, min, max); } vec4 ${a}_(vec4 v) { return clamp(v, min, max); } `,name:a,type:0}}function Hh(){let e="indentity";return{body:` float ${e}_(float a) { return a; } vec4 ${e}_(vec4 v) { return v; } `,name:e,type:0}}function qh(e){let r="leakyRelu";return{body:` const float alpha = float(${e}); float ${r}_(float a) { return a < 0.0 ? a * alpha : a; } vec4 ${r}_(vec4 v) { return vec4(${r}_(v.x), ${r}_(v.y), ${r}_(v.z), ${r}_(v.w)); } `,name:r,type:0}}function jh(){return mt("log")}function Yh(){let e="neg";return{body:` float ${e}_(float a) { return -a; } vec4 ${e}_(vec4 v) { return -v; } `,name:e,type:0}}function Xh(){let e="not";return{body:` float ${e}_(float a) { return float( ! bool(a) ); } bool ${e}_(bool a) { return !a; } vec4 ${e}_(vec4 v) { return vec4(!bool(v.x), !bool(v.y), !bool(v.z), !bool(v.w)); } bvec4 ${e}_(bvec4 v) { return bvec4(!v.x, !v.y, !v.z, !v.w); } `,name:e,type:0}}function Kh(){return mt("sin")}function wi(){let e="relu";return{body:` float ${e}_(float a) { return max( a, 0.0 ); } vec4 ${e}_(vec4 v) { return max( v, 0.0 ); } `,name:e,type:0}}function vi(){let e="sigmoid";return{body:` float ${e}_(float a) { return 1.0 / (1.0 + exp(-a)); } vec4 ${e}_(vec4 v) { return 1.0 / (1.0 + exp(-v)); } `,name:e,type:0}}function Jh(){return mt("sqrt")}function Zh(){return mt("tan")}function Qh(){let e="tanh";return{body:` float ${e}_(float a) { a = clamp(a, -10., 10.); a = exp(2.*a); return (a - 1.) / (a + 1.); } vec4 ${e}_(vec4 v) { v = clamp(v, -10., 10.); v = exp(2.*v); return (v - 1.) / (v + 1.); } `,name:e,type:0}}function mt(e){return{body:` float ${e}_(float a) { return ${e}(a); } vec4 ${e}_(vec4 v) { return ${e}(v); } `,name:e,type:0}}var em,Ee,Al,Pl,El,Dl,_i,Ll,Cl,tm,Fl,$l,kl,Bl,Nl,Rl,Oi,Ml,Gl,Ul,zl,Vl,Wl,Hl,ql,jl,Yl,Xl,Ii=L(()=>{Ue(),fe(),Wt(),we(),ae(),em=(e,r,a,i)=>{let l=e.session.pack?2:0,n=H(e.session.backend.glContext.version);return{...r,output:{dims:a.dims,type:a.type,textureType:l},shaderSource:` ${i.body} void main() { vec4 v = ${n.texture2D}(A, TexCoords); v = ${i.name}_(v); ${n.output} = v; } `,hasMain:!0}},Ee=(e,r,a,i)=>{let l=e.session.pack?2:0,n={name:a.name,inputTypes:[l],inputNames:["A"],cacheHint:i};return{...n,get:()=>em(e,n,r,a)}},Al=(e,r)=>[e.run(Ee(e,r[0],Bh()),r)],Pl=(e,r)=>[e.run(Ee(e,r[0],Nh()),r)],El=(e,r)=>[e.run(Ee(e,r[0],Rh()),r)],Dl=(e,r)=>[e.run(Ee(e,r[0],Mh()),r)],_i=(e,r,a)=>[e.run(Ee(e,r[0],xi(a.min,a.max),a.cacheKey),r)],Ll=e=>Q({min:e.attributes.getFloat("min",br),max:e.attributes.getFloat("max",gr)}),Cl=(e,r)=>{let a=tm(e,r);return _i(e,[r[0]],a)},tm=(e,r)=>{if(r.length>=3&&(!e.session.isInitializer(r[1].dataId)||!e.session.isInitializer(r[2].dataId)))throw new Error("dynamic clip attributes are not allowed");let a=r.length>=3?r[1].numberData[0]:br,i=r.length>=3?r[2].numberData[0]:gr;return Q({min:a,max:i})},Fl=(e,r)=>[e.run(Ee(e,r[0],Gh()),r)],$l=(e,r)=>[e.run(Ee(e,r[0],Uh()),r)],kl=(e,r,a)=>[e.run(Ee(e,r[0],zh(a.alpha),a.cacheKey),r)],Bl=e=>Q({alpha:e.attributes.getFloat("alpha",1)}),Nl=(e,r)=>[e.run(Ee(e,r[0],Vh()),r)],Rl=(e,r)=>[e.run(Ee(e,r[0],Wh()),r)],Oi=(e,r)=>[e.run(Ee(e,r[0],Hh()),r)],Ml=(e,r,a)=>[e.run(Ee(e,r[0],qh(a.alpha),a.cacheKey),r)],Gl=e=>Q({alpha:e.attributes.getFloat("alpha",.01)}),Ul=(e,r)=>[e.run(Ee(e,r[0],jh()),r)],zl=(e,r)=>[e.run(Ee(e,r[0],Yh()),r)],Vl=(e,r)=>[e.run(Ee(e,r[0],Xh()),r)],Wl=(e,r)=>[e.run(Ee(e,r[0],wi()),r)],Hl=(e,r)=>[e.run(Ee(e,r[0],vi()),r)],ql=(e,r)=>[e.run(Ee(e,r[0],Kh()),r)],jl=(e,r)=>[e.run(Ee(e,r[0],Jh()),r)],Yl=(e,r)=>[e.run(Ee(e,r[0],Zh()),r)],Xl=(e,r)=>[e.run(Ee(e,r[0],Qh()),r)]});function Rt(e){let r;switch(e.activation){case"Relu":r=wi();break;case"Sigmoid":r=vi();break;case"Clip":r=xi(e.clipMin,e.clipMax);break;default:return{activationFunction:"",applyActivation:""}}let a=r.name,i=r.body,l=`value = ${a}_(value);`;return{activationFunction:i,applyActivation:l}}var Nr,xr=L(()=>{fe(),Ii(),Nr=e=>{let r=e.getString("activation","");if(r==="Clip"){let[a,i]=e.getFloats("activation_params",[br,gr]);return{activation:r,clipMax:i,clipMin:a,activationCacheKey:`${r}:${a},${i}`}}return{activation:r,activationCacheKey:r}}}),nm,om,Kl,Jl=L(()=>{lt(),we(),ae(),to(),xr(),nm=(e,r)=>({name:"GroupedConv",inputNames:e?["X","W","Bias"]:["X","W"],inputTypes:e?[0,0,0]:[0,0],cacheHint:r}),om=(e,r,a,i)=>{let l=r.length>2?"value += getBias(output_channel);":"",n=r[0].dims.slice(),o=r[1].dims.slice(),p=o[0]/i.group;ce.verbose("GroupedConv",`autpPad:${i.autoPad}, dilations:${i.dilations}, group:${i.group}, kernelShape:${i.kernelShape}, pads:${i.pads}, strides:${i.strides}`);let c=Rr(n,o,i.dilations,i.pads,i.strides),t=H(e.session.backend.glContext.version),{activationFunction:u,applyActivation:s}=Rt(i),d=` const ivec2 strides = ivec2(${i.strides[0]}, ${i.strides[1]}); const ivec2 pads = ivec2(${i.pads[0]}, ${i.pads[1]}); ${u} void main() { ivec4 coords = getOutputCoords(); int batch = coords.x; int output_channel = coords.y; ivec2 xRCCorner = coords.zw * strides - pads; int group_id = output_channel / ${p}; float value = 0.0; for (int wInChannel = 0; wInChannel < ${o[1]}; wInChannel++) { int input_channel = group_id * ${o[1]} + wInChannel; for (int wHeight = 0; wHeight < ${o[2]}; wHeight++) { int xHeight = xRCCorner.x + wHeight * ${i.dilations[0]}; if (xHeight < 0 || xHeight >= ${n[2]}) { continue; } for (int wWidth = 0; wWidth < ${o[3]}; wWidth++) { int xWidth = xRCCorner.y + wWidth * ${i.dilations[1]}; if (xWidth < 0 || xWidth >= ${n[3]}) { continue; } float xVal = getX(batch, input_channel, xWidth, xHeight); float wVal = getW(output_channel, wInChannel, wWidth, wHeight); value += xVal*wVal; } } } ${l} ${s} ${t.output} = vec4(value, .0, .0, .0); } `;return{...a,output:{dims:c,type:r[0].type,textureType:0},shaderSource:d,hasMain:!0}},Kl=(e,r,a)=>{let i=nm(r.length>2,a.cacheKey);return{...i,get:()=>om(e,r,i,a)}}}),im,am,Zl,Ql=L(()=>{we(),ae(),Tr(),im=e=>({name:"Im2Col (packed)",inputNames:["A"],inputTypes:[2],cacheHint:e}),am=(e,r,a,i,l,n)=>{let o=a.dims,p=i.dims,c=2,t=3,u=l.length,s=[p[1]*p[2]*p[3],l[2]*l[3]],d=p[2]*p[3],f=Nt(),b=H(e.session.backend.glContext.version),y="";for(let E=0;E<=1;E++)for(let T=0;T<=1;T++)y+=` blockIndex = rc.x + ${T}; pos = rc.y + ${E}; if(blockIndex < ${s[1]} && pos < ${s[0]}) { offsetY = int(blockIndex / (${l[u-1]})) * ${n.strides[0]} - ${n.pads[0]}; d0 = offsetY + ${n.dilations[0]} * (imod(pos, ${d}) / ${p[2]}); if(d0 < ${o[c]} && d0 >= 0) { offsetX = imod(blockIndex, ${l[u-1]}) * ${n.strides[1]} - ${n.pads[1]}; d1 = offsetX + ${n.dilations[1]} * imod(imod(pos, ${d}), ${p[2]}); if(d1 < ${o[t]} && d1 >= 0) { ch = int(float(pos)/ ${d}.); innerDims = vec2(d0, d1); result[${E*2+T}] = getChannel( getA(0, ch, int(innerDims.x), int(innerDims.y)), innerDims); } } } `;let v=` ${f} void main() { ivec2 rc = getOutputCoords(); vec4 result = vec4(0.0); int blockIndex, pos, offsetY, d0, offsetX, d1, ch; vec2 innerDims; ${y} ${b.output} = result; } `;return{...r,output:{dims:s,type:a.type,textureType:2},shaderSource:v,hasMain:!0}},Zl=(e,r,a,i,l)=>{let n=im(l.cacheKey);return{...n,get:()=>am(e,n,r,a,i,l)}}});function um(e,r,a){let i=r[0].dims,l=r[1].dims,n=Ze.calcShape(i,l,!0);if(!n)throw new Error("Can't use matmul on the given tensors");let o=Qe(n.length),p=Dt(),{activationFunction:c,applyActivation:t}=Rt(a),u=r.length>2,s=u?"value += getBiasForMatmul();":"",d=u?`${Ai(o,p,r[2].dims,n,!1)}`:"",f=n.length,b=i.length,y=l.length,v=i[i.length-1],E=` ${c} ${d} float process(int indices[${f}]) { int a[${b}]; int b[${y}]; bcastMatmulIndices_A(indices, a); bcastMatmulIndices_B(indices, b); float value; for (int k=0; k<${v}; ++k) { a[${b-1}] = k; b[${y-2}] = k; value += _A(a) * _B(b); } ${s} ${t} return value; }`;return{...e,output:{dims:n,type:r[0].type,textureType:0},shaderSource:E}}function Si(e,r){let a=sm(e.length>2,r.activationCacheKey);return{...a,get:()=>um(a,e,r)}}function Ai(e,r,a,i,l){let n="",o=a.length,p=i.length,c=p-o;p<2&&o>0?n="coords":n=a.map((d,f)=>`coords.${r[f+c]}`).join(", ");let t=Ze.getBroadcastDims(a,i).map(d=>`coords.${r[d+c]} = 0;`).join(` `),u=U.size(a)===1,s="vec4(outputValue.xx, outputValue.yy)";return u&&(s="vec4(outputValue.x)"),l?` vec4 getBiasForMatmul() { ${e} coords = getOutputCoords(); ${t} vec4 outputValue = getBias(${n}); return ${s}; }`:` float getBiasForMatmul() { ${e} coords = getOutputCoords(); ${t} return getBias(coords.x); }`}var ef,tf,sm,lm,ro=L(()=>{fe(),ae(),Bt(),xr(),Pi(),ef=(e,r,a)=>(lm(r),e.session.pack?[e.run(no(e,r,a),r)]:[e.run(Si(r,a),r)]),tf=e=>Nr(e.attributes),sm=(e,r)=>({name:"MatMul",inputNames:e?["A","B","Bias"]:["A","B"],inputTypes:e?[0,0,0]:[0,0],cacheHint:r}),lm=e=>{if(!e||e.length!==2)throw new Error("MatMul requires 2 inputs.");if(e[0].dims[e[0].dims.length-1]!==e[1].dims[e[1].dims.length-2])throw new Error("shared dimension does not match.");if(e[0].type!=="float32"&&e[0].type!=="float64"||e[1].type!=="float32"&&e[1].type!=="float64")throw new Error("inputs should be float type");if(e[0].type!==e[1].type)throw new Error("inputs types should match")}});function pm(e,r,a,i){let l=[],n=[],o=a[0].dims,p=a[1].dims,c=o.length,t=p.length,u=i.length,s=u-c,d=u-t;l=o.map((T,$)=>`coords.${r[$+s]}`),l[c-1]="i*2",l.join(", "),n=p.map((T,$)=>`coords.${r[$+d]}`),n[t-2]="i*2",n.join(", ");let f=Ze.getBroadcastDims(o,i),b=Ze.getBroadcastDims(p,i),y=f.map(T=>`coords.${r[T+s]} = 0;`).join(` `),v=b.map(T=>`coords.${r[T+d]} = 0;`).join(` `),E=`int lastDim = coords.${r[u-1]}; coords.${r[u-1]} = coords.${r[u-2]}; coords.${r[u-2]} = lastDim;`;return` vec4 getAAtOutCoordsMatmul(int i) { ${e} coords = getOutputCoords(); ${E} ${y} vec4 outputValue = getA(${l}); return outputValue; } vec4 getBAtOutCoordsMatmul(int i) { ${e} coords = getOutputCoords(); ${E} ${v} vec4 outputValue = getB(${n}); return outputValue; }`}function dm(e,r){let a="";for(let i=0;i{fe(),we(),ae(),Bt(),xr(),ro(),fm=(e,r)=>({name:"MatMul (packed)",inputNames:e?["A","B","Bias"]:["A","B"],inputTypes:e?[2,2,2]:[2,2],cacheHint:r}),cm=(e,r,a,i)=>{let l=a.length>2,n=l?"value += getBiasForMatmul();":"",o=a[0].dims,p=a[1].dims,c=Ze.calcShape(o,p,!0),t=!U.areEqual(a[0].dims,a[1].dims);if(!c)throw new Error("Can't use matmul on the given tensors");let u=o[o.length-1],s=Math.ceil(u/2),d=o.length,f=p.length,b=H(e.session.backend.glContext.version),y=Qe(c.length),v=c.length,E=Dt(),{activationFunction:T,applyActivation:$}=Rt(i),F=l?`${Ai(y,E,a[2].dims,c,!0)}`:"",C=t?`${pm(y,E,a,c)}`:"",J=t?"getAAtOutCoordsMatmul(i)":`getA(${dm(E,d)})`,ge=t?"getBAtOutCoordsMatmul(i)":`getB(${hm(E,f)})`,ze=t?"":`${y} rc = getOutputCoords(); int lastDim = rc.${E[v-1]}; rc.${E[v-1]} = rc.${E[v-2]}; rc.${E[v-2]} = lastDim; `,Fe=` ${C} ${F} ${T} void main() { ${ze} vec4 value = vec4(0); for (int i = 0; i < ${s}; i++) { vec4 a = ${J}; vec4 b = ${ge}; value += (a.rrbb * b.rgrg); value += (a.ggaa * b.baba); } ${n} ${$} ${b.output} = value; }`;return{...r,output:{dims:c,type:a[0].type,textureType:2},shaderSource:Fe,hasMain:!0}},no=(e,r,a)=>{let i=fm(r.length>2,a.activationCacheKey);return{...i,get:()=>cm(e,i,r,a)}}}),rf,nf=L(()=>{to(),Ql(),Pi(),rf=(e,r,a)=>{let i=r[0].dims,l=r[1].dims,n=Rr(i,l,a.dilations,a.pads,a.strides),o=e.run(Zl(e,r[0],r[1],n,a),[r[0]]),p=e.reshapePacked(r[1],[l[0],l[1]*l[2]*l[3]]),c=r.length===3?[p,o,r[2]]:[p,o],t=e.run(no(e,c,a),c);return e.reshapePacked(t,n)}}),mm,bm,of,Ei,Di=L(()=>{ae(),mm=e=>({name:"Im2Col",inputNames:["X"],inputTypes:[0],cacheHint:e}),bm=(e,r,a,i,l,n)=>{let o=a.dims,p=i.dims,c=l.length,t=Ei(o,p,l,4),u=` const int XC = ${o[1]}; const int XH = ${o[2]}; const int XW = ${o[3]}; const int KH = ${n.kernelShape[0]}; const int KW = ${n.kernelShape[1]}; const int dilationH = ${n.dilations[0]}; const int dilationW = ${n.dilations[1]}; const int strideH = ${n.strides[0]}; const int strideW = ${n.strides[1]}; const int padH = ${n.pads[0]}; const int padW = ${n.pads[1]}; const int KHKW = KH*KW; const int XCKHKW = XC * KHKW; const int outputChannels = 4; vec4 process(int indices[${c}]) { int b = indices[0]; // batch size int oh = indices[1] * strideH - padH; //output height int ow = indices[2] * strideW - padW; //output width int p = indices[3] * outputChannels; //patch vec4 value = vec4(0.0); for(int i=0; i < outputChannels; ++i) { if(p < XCKHKW) { int patchC = p / KHKW; int patchH = (p - patchC*KHKW) / KW; int patchW = (p - patchC*KHKW) - patchH * KW; int xh2 = oh + patchH * dilationH; int xw2 = ow + patchW * dilationW; int x[${o.length}]; x[0] = b; x[1] = patchC; x[2] = xh2; x[3] = xw2; if(xh2 >= 0 && xh2 < XH && xw2 >= 0 && xw2 < XW) { value[i] = _X(x); } } ++p; } return value; } `;return{...r,output:{dims:t,type:a.type,textureType:4},shaderSource:u}},of=(e,r,a,i,l)=>{let n=mm(l.cacheKey);return{...n,get:()=>bm(e,n,r,a,i,l)}},Ei=(e,r,a,i=4)=>[a[0],a[2],a[3],Math.ceil(e[1]*r[2]*r[3]/i)]}),gm,ym,af,sf=L(()=>{fe(),we(),ae(),xr(),Di(),gm=(e,r)=>({name:"ConvDotProduct",inputNames:e?["Im2Col","K","B"]:["Im2Col","K"],inputTypes:e?[0,4,0]:[0,4],cacheKey:r.activationCacheKey}),ym=(e,r,a,i,l)=>{let n=a[0].dims,o=a[1].dims,p=[o[0],Math.ceil(n[1]*o[2]*o[3]/4)],c=Ei(n,o,i),[t,u]=e.calculateTextureWidthAndHeight(p,4),s=U.computeStrides(c),[d,f]=e.calculateTextureWidthAndHeight(c,4),b=i.length,y=a.length<3?"0.0":"_B(b)",v=Math.ceil(n[1]*o[2]*o[3]/4),{activationFunction:E,applyActivation:T}=Rt(l),$=H(e.session.backend.glContext.version),F=` ${E} float process(int indices[${b}]) { int b[1]; b[0] = indices[1]; int im2col[4]; im2col[0] = indices[0]; im2col[1] = indices[2]; im2col[2] = indices[3]; int im2colOffset = im2col[0] * ${s[0]} + im2col[1] * ${s[1]} + im2col[2] * ${s[2]}; int kernelOffset = indices[1] * ${p[1]}; float value = ${y}; for (int i = 0; i < ${v}; ++i) { vec2 im2colCoords = offsetToCoords(im2colOffset, ${d}, ${f}); vec2 kernelCoords = offsetToCoords(kernelOffset, ${t}, ${u}); value += dot(${$.texture2D}(Im2Col, im2colCoords), ${$.texture2D}(K, kernelCoords)); ++im2colOffset; ++kernelOffset; } ${T} return value; }`;return{...r,output:{dims:i,type:a[0].type,textureType:0},shaderSource:F}},af=(e,r,a,i)=>{let l=gm(r.length>2,i);return{...l,get:()=>ym(e,l,r,a,i)}}}),Rr,Li,Tm,xm,wm,vm,Ci,_m,to=L(()=>{Ue(),fe(),Jl(),nf(),sf(),xr(),Di(),ro(),Rr=(e,r,a,i,l)=>{let n=e[0],o=e.slice(2),p=o.length,c=r[0],t=r.slice(2).map((s,d)=>s+(s-1)*(a[d]-1)),u=o.map((s,d)=>s+i[d]+i[d+p]).map((s,d)=>Math.floor((s-t[d]+l[d])/l[d]));return[n,c].concat(...u)},Li=(e,r,a)=>(_m(r,a),Tm(e,r,a)),Tm=(e,r,a)=>{let i=vm(a,r),l=e.session.pack,n=i.kernelShape[0]===1&&i.kernelShape[1]===1;return i.group>1?[e.run(Kl(e,r,i),r)]:n&&l?[xm(e,r,i)]:l&&r[0].dims.length===4&&r[0].dims[0]===1&&!n?[rf(e,r,i)]:[wm(e,r,i)]},xm=(e,r,a)=>{let i=r[0].dims,l=r[1].dims,n=Rr(i,l,a.dilations,a.pads,a.strides),o=e.reshapeUnpacked(r[0],[i[1],i[2]*i[3]]),p=e.reshapeUnpacked(r[1],[l[0],l[1]]),c=r.length>2?[p,o,r[2]]:[p,o],t=e.run(Si(c,a),c);return e.reshapeUnpacked(t,n)},wm=(e,r,a)=>{let i=r[0].dims,l=r[1].dims,n=Rr(i,l,a.dilations,a.pads,a.strides),o=e.run(of(e,r[0],r[1],n,a),[r[0]]),p=r.length===3?[o,r[1],r[2]]:[o,r[1]];return e.run(af(e,r,n,a),p)},vm=(e,r)=>{let a=e.kernelShape.slice();if(e.kernelShape.length===0)for(let n=2;n{let r=e.attributes,a=Nr(r),i=r.getString("auto_pad","NOTSET"),l=r.getInts("dilations",[1,1]),n=r.getInt("group",1),o=r.getInts("kernel_shape",[]),p=r.getInts("pads",[0,0,0,0]),c=r.getInts("strides",[1,1]);return Q({autoPad:i,dilations:l,group:n,kernelShape:o,pads:p,strides:c,...a})},_m=(e,r)=>{if(!e||e.length!==2&&e.length!==3)throw new Error("Conv requires 2 or 3 inputs");if(e[0].dims.length!==4||e[1].dims.length!==4)throw new Error("currently only support 2-dimensional conv");let a=e[0].dims[1],i=e[1].dims[1]*r.group;if(a!==i)throw new Error("FILTER_IN_CHANNEL should be equal to DATA_CHANNEL");if(e.length===3&&(e[2].dims.length!==1||e[1].dims[0]!==e[2].dims[0]))throw new Error("invalid bias");let l=e[0].dims.length-2;if(r.dilations.length!==l)throw new Error(`dilations should be ${l}D`);if(r.strides.length!==l)throw new Error(`strides should be ${l}D`);if(r.pads.length!==l*2)throw new Error(`pads should be ${l*2}D`);if(r.kernelShape.length!==0&&r.kernelShape.length!==e[1].dims.length-2)throw new Error("invalid kernel shape");if(e[0].type!=="float32"||e[1].type!=="float32")throw new Error("Conv input(X,W) should be float tensor");if(e.length===3&&e[2].type!=="float32")throw new Error("Conv input(bias) should be float tensor")}}),Om,Im,Sm,uf,Am,Pm,Em,Dm,Lm,Cm,lf,Fm,ff=L(()=>{Ue(),we(),ae(),xr(),Om=(e,r,a,i,l,n)=>(e-1)*r+a+(i-1)*l+1-n,Im=(e,r,a,i,l)=>{let n=Math.floor(e/2);r==="SAME_UPPER"?(a[i]=n,a[l]=e-n):r==="SAME_LOWER"&&(a[i]=e-n,a[l]=n)},Sm=(e,r,a,i,l,n,o,p)=>{let c=e.length-2,t=p.length===0;for(let u=0;u(Fm(r,a),Am(e,r,a)),Am=(e,r,a)=>{let i=Cm(a,r);return[Lm(e,r,i)]},Pm=(e,r)=>({name:"ConvTranspose",inputNames:e?["X","W","B"]:["X","W"],inputTypes:e?[0,0,0]:[0,0],cacheHint:r}),Em=(e,r,a,i)=>{let l=r.length>2?"getB(output_channel)":"0.0",n=r[0].dims,o=r[1].dims,p=o[1],c=o[0]/i.group,t=[r[0].dims[0],r[1].dims[1]*i.group,...i.outputShape],u=H(e.session.backend.glContext.version),{activationFunction:s,applyActivation:d}=Rt(i),f=` const ivec2 strides = ivec2(${i.strides[0]}, ${i.strides[1]}); const ivec2 pads = ivec2(${i.pads[0]}, ${i.pads[1]}); ${s} void main() { ivec4 coords = getOutputCoords(); int batch = coords.x; int output_channel = coords.y; ivec2 loc = coords.zw + pads; int group_id = output_channel / ${p}; int wOutChannel = output_channel - group_id * ${p}; float value = ${l}; for (int inChannelOffset = 0; inChannelOffset < ${c}; inChannelOffset++) { int input_channel = group_id * ${c} + inChannelOffset; for (int wWOff = 0; wWOff < ${o[2]}; wWOff++) { for (int wHOff = 0; wHOff < ${o[3]}; wHOff++) { ivec2 wOff = ivec2(wWOff * ${i.dilations[0]}, wHOff * ${i.dilations[1]}); ivec2 wLoc = loc - wOff; ivec2 wLocIn = wLoc / strides; if ( wLocIn * strides == wLoc && wLocIn.x >= 0 && wLocIn.x < ${n[2]} && wLocIn.y >= 0 && wLocIn.y < ${n[3]} ) { float xVal = getX(batch, input_channel, wLocIn.y, wLocIn.x); float wVal = getW(input_channel, wOutChannel, wHOff, wWOff); value += xVal * wVal; } } } } ${d} ${u.output} = vec4(value, .0, .0, .0); } `;return{...a,output:{dims:t,type:r[0].type,textureType:0},shaderSource:f,hasMain:!0}},Dm=(e,r,a)=>{let i=Pm(r.length>2,a.cacheKey);return{...i,get:()=>Em(e,r,i,a)}},Lm=(e,r,a)=>e.run(Dm(e,r,a),r),Cm=(e,r)=>{let a=e.kernelShape.slice();if(e.kernelShape.length===0)for(let p=2;p{let r=e.attributes,a=Nr(r),i=r.getString("auto_pad","NOTSET"),l=r.getInts("dilations",[1,1]),n=r.getInt("group",1),o=r.getInts("kernel_shape",[]),p=r.getInts("output_padding",[0,0]),c=r.getInts("output_shape",[]),t=r.getInts("pads",[0,0,0,0]),u=r.getInts("strides",[1,1]);return Q({autoPad:i,dilations:l,group:n,kernelShape:o,outputPadding:p,outputShape:c,pads:t,strides:u,...a})},Fm=(e,r)=>{if(!e||e.length!==2&&e.length!==3)throw new Error("Conv requires 2 or 3 inputs");if(e[0].dims.length!==4||e[1].dims.length!==4)throw new Error("currently only support 2-dimensional conv");let a=e[0].dims[1],i=e[1].dims[0];if(a!==i)throw new Error("FILTER_IN_CHANNEL should be equal to DATA_CHANNEL");let l=e[1].dims[1]*r.group;if(e.length===3&&(e[2].dims.length!==1||e[2].dims[0]!==l))throw new Error("invalid bias");let n=e[0].dims.length-2;if(r.dilations.length!==n)throw new Error(`dilations should be ${n}D`);if(r.strides.length!==n)throw new Error(`strides should be ${n}D`);if(r.pads.length!==n*2)throw new Error(`pads should be ${n*2}D`);if(r.outputPadding.length!==n)throw new Error(`output_padding should be ${n}D`);if(r.kernelShape.length!==0&&r.kernelShape.length!==e[1].dims.length-2)throw new Error("invalid kernel shape");if(r.outputShape.length!==0&&r.outputShape.length!==e[0].dims.length-2)throw new Error("invalid output shape");if(e[0].type!=="float32"||e[1].type!=="float32")throw new Error("ConvTranspose input(X,W) should be float tensor");if(e.length===3&&e[2].type!=="float32")throw new Error("ConvTranspose input(bias) should be float tensor")}}),cf,wr,pf,$m,df,km,Bm,Nm,oo=L(()=>{Ue(),fe(),ae(),cf={name:"Transpose",inputNames:["A"],inputTypes:[0]},wr=(e,r,a)=>(Nm(r),[e.run({...cf,cacheHint:a.cacheKey,get:()=>$m(e,r[0],a.perm)},r)]),pf=e=>Q({perm:e.attributes.getInts("perm",[])}),$m=(e,r,a)=>{let i=r.dims;a=df(i,a);let l=km(i,a),n=i.length,o=` ${Bm("perm",a,n)} float process(int indices[${n}]) { int a[${n}]; perm(a, indices); return _A(a); }`;return{...cf,output:{dims:l,type:r.type,textureType:0},shaderSource:o}},df=(e,r)=>(r&&r.length!==e.length&&(r=[...e.keys()].reverse()),r),km=(e,r)=>(r=df(e,r),U.sortBasedOnPerm(e,r)),Bm=(e,r,a)=>{let i=[];i.push(`void ${e}(out int a[${a}], int src[${a}]) {`);for(let l=0;l{if(!e||e.length!==1)throw new Error("Transpose requires 1 input.");if(e[0].type!=="float32"&&e[0].type!=="float64")throw new Error("input should be float tensor")}}),hf,mf,Rm,bf=L(()=>{oo(),hf=(e,r,a)=>{Rm(r);let i=a.blocksize,l=i*i,n=a.mode==="DCR"?[0,3,4,1,5,2]:[0,1,4,2,5,3],o=a.mode==="DCR"?[r[0].dims[0],i,i,r[0].dims[1]/l,r[0].dims[2],r[0].dims[3]]:[r[0].dims[0],r[0].dims[1]/l,i,i,r[0].dims[2],r[0].dims[3]],p=e.reshapeUnpacked(r[0],o),c={perm:n,cacheKey:`${n}`},[t]=wr(e,[p],c),u=[r[0].dims[0],r[0].dims[1]/l,r[0].dims[2]*i,r[0].dims[3]*i];return[e.reshapeUnpacked(t,u)]},mf=e=>{let r=e.attributes.getInt("blocksize");if(r<1)throw new Error(`blocksize must be >= 1, but got : ${r} for DepthToSpace`);let a=e.attributes.getString("mode","DCR");if(a!=="DCR"&&a!=="CRD")throw new Error(`unrecognized mode: ${a} for DepthToSpace`);return{mode:a,blocksize:r}},Rm=e=>{if(e.length!==1)throw new Error(`DepthToSpace expect 1 inputs, but got ${e.length}`);if(e[0].type==="string"||e[0].dims.length!==4)throw new TypeError("DepthToSpace input should be a 4-D numeric tensor")}}),gf,yf,Mm,Tf=L(()=>{fe(),gf=(e,r,a)=>{Mm(r,a);let i=U.flattenShape(r[0].dims,a);return[e.reshapeUnpacked(r[0],i)]},yf=e=>e.attributes.getInt("axis",1),Mm=(e,r)=>{if(!e||e.length!==1)throw new Error("Flatten requires 1 input.");let a=e[0].dims.length;if(a===0)throw new Error("scalar tensor is not supported.");if(r<-a||r>a)throw new Error("Invalid axis");if(e[0].type==="string")throw new Error("string tensor is not supported.")}}),Qt,pn=L(()=>{Qt=["float32","float64","int32","int16","int8","uint16","uint32","uint8"]}),xf,wf,Gm,Um,zm,Vm,vf=L(()=>{Ue(),pn(),fe(),ae(),xf=(e,r,a)=>(Vm(r,a.axis),[e.run(zm(e,r,a),r)]),wf=e=>Q({axis:e.attributes.getInt("axis",0)}),Gm={name:"Gather",inputNames:["A","B"],inputTypes:[0,0]},Um=(e,r,a,i)=>{let l=a[0].dims.slice(),n=a[1].dims.slice(),o=new Array(l.length+n.length-1);i=U.normalizeAxis(i,l.length);let p=[];for(let d=0;d{let i={...Gm,cacheHint:a.cacheKey};return{...i,get:()=>Um(e,i,r,a.axis)}},Vm=(e,r)=>{if(!e||e.length!==2)throw new Error("Gather requires 2 inputs.");let a=e[0].dims.length;if(a<1)throw new Error("Invalid input shape.");if(r<-a||r>a-1)throw new Error("Invalid axis.");if(Qt.indexOf(e[0].type)===-1)throw new Error("Invaid input type.");if(e[1].type!=="int32"&&e[1].type!=="int16")throw new Error("Invaid input type.")}}),Fi,_f,Of,If,Wm,Hm,qm,Sf=L(()=>{Ue(),fe(),ae(),Fi=(e,r,a)=>(qm(r,a),[e.run(Wm(r,a),r)]),_f=(e,r)=>{let a=e.attributes.getInt("transA",0)!==0,i=e.attributes.getInt("transB",0)!==0,l=e.attributes.getFloat("alpha",1),n=e.attributes.getFloat("beta",1);return Q({transA:a,transB:i,alpha:l,beta:n,isOptionalC:r})},Of=e=>_f(e,!1),If=e=>_f(e,!0),Wm=(e,r)=>{let a={name:"Gemm",inputNames:e.length===3?["A","B","C"]:["A","B"],inputTypes:e.length===3?[0,0,0]:[0,0],key:r.cacheKey};return{...a,get:()=>Hm(a,e,r)}},Hm=(e,r,a)=>{let i=r[0].dims.slice(),l=r[1].dims.slice(),[n,o]=jn.getShapeOfGemmResult(i,a.transA,l,a.transB,r.length===3?r[2].dims:void 0),p=[n,o];if(!p)throw new Error("Can't use gemm on the given tensors");let c=i[i.length-1],t="";a.transA&&(c=i[0]),a.transA&&a.transB?t="value += _A_T(a) * _B_T(b);":a.transA&&!a.transB?t="value += _A_T(a) * _B(b);":!a.transA&&a.transB?t="value += _A(a) * _B_T(b);":!a.transA&&!a.transB&&(t="value += _A(a) * _B(b);");let u=p.length,s=r.length===3?`int c[${r[2].dims.length}];`:"",d=r.length===3?"bcastIndices_C(indices, c);":"",f=r.length===3?"value += beta * _C(c);":"",b=` float process(int indices[${u}]) { int a[${u}]; int b[${u}]; ${s} copyVec(indices, a); copyVec(indices, b); ${d} float value = 0.0; for (int k=0; k<${c}; ++k) { a[${u-1}] = k; b[${u-2}] = k; ${t} } value = value * alpha; ${f} return value; }`;return{...e,output:{dims:p,type:r[0].type,textureType:0},variables:[{name:"alpha",type:"float",data:a.alpha},{name:"beta",type:"float",data:a.beta}],shaderSource:b}},qm=(e,r)=>{if(!e)throw new Error("Input is missing");if(r.isOptionalC&&(e.length<2||e.length>3))throw new Error("Invaid input shape.");if(!r.isOptionalC&&e.length!==3)throw new Error("Gemm requires 3 inputs");if(e.length===3&&e[2].dims.length!==1&&e[2].dims.length!==2)throw new Error("Invalid input shape of C");if(e[0].type!=="float32"&&e[0].type!=="float64"||e[1].type!=="float32"&&e[1].type!=="float64"||e.length===3&&e[2].type!=="float32"&&e[2].type!=="float64")throw new Error("Invalid input type.");if(e[0].type!==e[1].type||e.length===3&&e[0].type!==e[2].type)throw new Error("Input types are mismatched")}}),Af,Pf,jm,Ym,Xm,Km,Jm,Ef=L(()=>{Ue(),ae(),Af=(e,r,a)=>(Jm(r),[e.run(Xm(e,r,a),r)]),Pf=e=>{let r=e.attributes.getFloat("scale"),a=e.attributes.getFloats("bias");return Q({scale:r,bias:a})},jm={name:"ImageScaler",inputNames:["X"],inputTypes:[0]},Ym=(e,r,a,i)=>{let l=a[0].dims.slice(),n=l.length,o=` ${Km(i.bias.length)} float process(int indices[${n}]) { return _X(indices) * scale + getBias(bias, indices[1]); }`;return{...r,output:{dims:l,type:a[0].type,textureType:0},variables:[{name:"bias",type:"float",arrayLength:i.bias.length,data:i.bias},{name:"scale",type:"float",data:i.scale}],shaderSource:o}},Xm=(e,r,a)=>{let i={...jm,cacheHint:a.cacheKey};return{...i,get:()=>Ym(e,i,r,a)}},Km=e=>{let r=[`float getBias(float bias[${e}], int channel) {`];for(let a=0;a{if(!e||e.length!==1)throw new Error("ImageScaler requires 1 input.");if(e[0].dims.length!==4)throw new Error("Invalid input shape.");if(e[0].type!=="float32"&&e[0].type!=="float64")throw new Error("Invalid input type.")}}),Lf,Cf,Df,Zm,Qm,eb,tb,rb,nb,Ff=L(()=>{we(),ae(),Lf=(e,r,a)=>{nb(r);let i=e.run(Qm(r[0]),r);return[e.run(rb(e,r[0],a,i.dims),[r[0],i,r[1],r[2]])]},Cf=e=>e.attributes.getFloat("epsilon",1e-5),Df={name:"InstanceNormalization_MeanAndVariance",inputNames:["X"],inputTypes:[0]},Zm=(e,r)=>{let a=r.dims.slice(),i=a[1],l=a[2]*a[3],n=[a[0],i],o=` vec4 process(int[2] indices) { vec4 v = vec4(0.0); int a[4]; a[0] = indices[0]; a[1] = indices[1]; float temp = 0.0; for(int a2=0; a2<${a[2]}; a2++) { a[2] = a2; for(int a3=0; a3<${a[3]}; a3++) { a[3] = a3; float x = _X(a); temp += x; } } float mean = temp / float(${l}); temp = 0.0; for(int a2=0; a2<${a[2]}; a2++) { a[2] = a2; for(int a3=0; a3<${a[3]}; a3++) { a[3] = a3; float x = _X(a); temp += (x - mean) * (x - mean); } } v.r = mean; v.g = temp / float(${l}); return v; }`;return{...e,output:{dims:n,type:r.type,textureType:4},shaderSource:o}},Qm=e=>({...Df,get:()=>Zm(Df,e)}),eb={name:"InstanceNormalization_ComputeOutput",inputNames:["X","MeanAndVariance","Scale","B"],inputTypes:[0,4,0,0]},tb=(e,r,a,i,l)=>{let n=H(e.session.backend.glContext.version),[o,p]=e.calculateTextureWidthAndHeight(l,4),[c,t]=[o/4,p],u=` vec4 get_MeanAndVariance(int[2] mv) { int offset = indicesToOffset_MeanAndVariance(mv); vec2 coords = offsetToCoords(offset, ${c}, ${t}); return ${n.texture2D}(MeanAndVariance, coords); } float process(int[4] indices) { int mv[2]; mv[0] = indices[0]; mv[1] = indices[1]; vec4 mean_and_variance = get_MeanAndVariance(mv); float mean = mean_and_variance.r; float variance = mean_and_variance.g; int sb[1]; sb[0] = indices[1]; float scale = _Scale(sb); float b = _B(sb); return scale * (_X(indices) - mean) / sqrt(variance + epsilon) + b; }`;return{...r,output:{dims:a.dims,type:a.type,textureType:0},variables:[{name:"epsilon",type:"float",data:i}],shaderSource:u}},rb=(e,r,a,i)=>{let l={...eb,cacheHint:`${a}`};return{...l,get:()=>tb(e,l,r,a,i)}},nb=e=>{if(!e||e.length!==3)throw new Error("InstanceNormalization requires 3 inputs.");let r=e[0],a=e[1],i=e[2];if(r.dims.length<3||a.dims.length!==1||i.dims.length!==1)throw new Error("Invalid input shape.");if(a.dims[0]!==r.dims[1]||i.dims[0]!==r.dims[1])throw new Error("Input shapes are mismatched.");if(r.type!=="float32"&&r.type!=="float64"||a.type!=="float32"&&a.type!=="float64"||i.type!=="float32"&&i.type!=="float64")throw new Error("Invalid input type.");if(e[0].dims.length!==4)throw new Error("Only support 4-D input shape.")}});function ob(e,r){let a=e[0].dims[1],i=e[0].dims.length,l=-Math.floor((r.size-1)/2),n=Math.ceil((r.size-1)/2),o=`float(${r.alpha}) / float(${r.size})`,p=`float(${r.bias})`,c=`float(${r.beta})`,t=` float process(int indices[${i}]) { int c = indices[1]; float x = _X(indices); float square_sum = 0.0; for (int i = ${l}; i <= ${n}; i++) { int idx = c + i; if (c >= 0 && c < ${a}) { indices[1] = idx; float j = _X(indices); square_sum += j * j; } } return x / pow(${p} + ${o} * square_sum, ${c}); }`;return{...Bf,cacheHint:r.cacheKey,output:{dims:e[0].dims,type:e[0].type,textureType:0},shaderSource:t}}function ib(e,r){return{...Bf,cacheHint:r.cacheKey,get:()=>ob(e,r)}}var $f,kf,Bf,ab,Nf=L(()=>{Ue(),ae(),$f=(e,r,a)=>(ab(r),[e.run(ib(r,a),r)]),kf=e=>{let r=e.attributes.getFloat("alpha",1e-4),a=e.attributes.getFloat("beta",.75),i=e.attributes.getFloat("bias",1),l=e.attributes.getInt("size");return Q({alpha:r,beta:a,bias:i,size:l})},Bf={name:"LRN",inputNames:["X"],inputTypes:[0]},ab=e=>{if(!e||e.length!==1)throw new Error("LRN requires 1 input.");if(e[0].dims.length!==4)throw new Error('currently only support LRN for input with "NCHW" format');if(e[0].type!=="float32")throw new Error("input should be float type")}}),sb,$i,Rf,Mf,Gf,ub,lb,fb,cb,pb,db,hb,mb,Uf=L(()=>{Ue(),fe(),we(),ae(),sb={name:"Pad",inputNames:["A"],inputTypes:[0]},$i=(e,r,a)=>(fb(r),[e.run({...sb,cacheHint:a.cacheKey,get:()=>lb(e,r[0],a)},r)]),Rf=e=>{let r=e.attributes.getString("mode","constant"),a=e.attributes.getFloat("value",0),i=e.attributes.getInts("pads");return Q({mode:r,value:a,pads:i})},Mf=(e,r,a)=>{cb(r);let i=ub(e,r,a);return $i(e,[r[0]],i)},Gf=e=>e.attributes.getString("mode","constant"),ub=(e,r,a)=>{if(!e.session.isInitializer(r[1].dataId)||r.length>=3&&!e.session.isInitializer(r[2].dataId))throw new Error("dynamic pad attributes are not allowed");let i=Array.from(r[1].integerData),l=r.length>=3?r[2].floatData[0]:0;return Q({mode:a,pads:i,value:l})},lb=(e,r,a)=>{let i=U.padShape(r.dims.slice(),a.pads),l=i.length,n=` ${pb(e,r,a)} float process(int[${l}] indices) { return padA(indices); }`;return{name:"Pad",inputNames:["A"],inputTypes:[0],output:{dims:i,type:r.type,textureType:0},shaderSource:n}},fb=e=>{if(!e||e.length!==1)throw new Error("Pad requires 1 input");if(e[0].type!=="float32"&&e[0].type!=="float64")throw new Error("Invalid input type.")},cb=e=>{if(!e||e.length!==2&&e.length!==3)throw new Error("Pad requires 2 or 3 inputs");if(e[1].type!=="int32")throw new Error("Invalid input type.");if(e.length>=3&&e[2].type==="string")throw new Error("Invalid input type.")},pb=(e,r,a)=>{let i=H(e.session.backend.glContext.version),[l,n]=e.calculateTextureWidthAndHeight(r.dims,0),o=U.computeStrides(r.dims);switch(a.mode){case"constant":return db(i,r.dims,o,l,n,a.pads,a.value);case"reflect":return hb(i,r.dims,o,l,n,a.pads);case"edge":return mb(i,r.dims,o,l,n,a.pads);default:throw new Error("Invalid mode")}},db=(e,r,a,i,l,n,o)=>{let p=r.length,c="";for(let t=p-1;t>=0;--t)c+=` k = m[${t}] - ${n[t]}; if (k < 0) return constant; if (k >= ${r[t]}) return constant; offset += k * ${a[t]}; `;return` float padA(int m[${p}]) { const float constant = float(${o}); int offset = 0; int k = 0; ${c} vec2 coords = offsetToCoords(offset, ${i}, ${l}); float value = getColorAsFloat(${e.texture2D}(A, coords)); return value; } `},hb=(e,r,a,i,l,n)=>{let o=r.length,p="";for(let c=o-1;c>=0;--c)p+=` k = m[${c}] - ${n[c]}; if (k < 0) { k = -k; } { const int _2n_1 = ${2*(r[c]-1)}; k = int( mod( float(k), float(_2n_1) ) ) ; if(k >= ${r[c]}) { k = _2n_1 - k; } } offset += k * ${a[c]}; `;return` float padA(int m[${o}]) { int offset = 0; int k = 0; ${p} vec2 coords = offsetToCoords(offset, ${i}, ${l}); float value = getColorAsFloat(${e.texture2D}(A, coords)); return value; } `},mb=(e,r,a,i,l,n)=>{let o=r.length,p="";for(let c=o-1;c>=0;--c)p+=` k = m[${c}] - ${n[c]}; if (k < 0) k = 0; if (k >= ${r[c]}) k = ${r[c]-1}; offset += k * ${a[c]}; `;return` float padA(int m[${o}]) { int offset = 0; int k = 0; ${p} vec2 coords = offsetToCoords(offset, ${i}, ${l}); float value = getColorAsFloat(${e.texture2D}(A, coords)); return value; } `}}),Vf,Wf,Hf,qf,jf,Yf,Xf,Kf,Jf,bb,zf,Zf,ao,Qf,io,gb,ec=L(()=>{Ue(),fe(),ae(),Vf=(e,r,a)=>{ao(r);let i={name:"AveragePool",inputNames:["X"],inputTypes:[0],cacheHint:a.cacheKey};return[e.run({...i,get:()=>Hf(r,i,!1,a)},r)]},Wf=e=>{let r=e.attributes.getString("auto_pad","NOTSET"),a=e.attributes.getInt("ceil_mode",0),i=e.attributes.getInt("count_include_pad",0)!==0,l=e.attributes.getInts("kernel_shape"),n=e.attributes.getInts("strides",[]),o=e.attributes.getInts("pads",[]);if(a!==0)throw new Error("using ceil() in shape computation is not yet supported for AveragePool");return Q({autoPad:r,ceilMode:a,countIncludePad:i,kernelShape:l,strides:n,pads:o})},Hf=(e,r,a,i)=>{let[l,n]=Jf(e,i,a),o=U.size(l.kernelShape),p="value += _X(x);",c="";l.countIncludePad?c+=`value /= float(${o});`:c+=`value /= float(${o} - pad);`;let t=` ${Qf(e[0].dims,l,p,c,"0.0")} `;return{...r,output:{dims:n,type:e[0].type,textureType:0},shaderSource:t}},qf=(e,r,a)=>{ao(r);let i={name:"GlobalAveragePool",inputNames:["X"],inputTypes:[0],cacheHint:`${a.countIncludePad}`};return[e.run({...i,get:()=>Hf(r,i,!0,a)},r)]},jf=e=>{let r=e.attributes.getInt("count_include_pad",0)!==0;return Q({autoPad:"",ceilMode:0,countIncludePad:r,kernelShape:[],strides:[],pads:[]})},Yf=(e,r,a)=>{ao(r);let i={name:"MaxPool",inputNames:["X"],inputTypes:[0],cacheHint:a.cacheKey};return[e.run({...i,get:()=>Kf(r,i,!1,a)},r)]},Xf=e=>{let r=e.attributes.getString("auto_pad","NOTSET"),a=e.attributes.getInt("ceil_mode",0),i=e.attributes.getInts("kernel_shape"),l=e.attributes.getInts("strides",[]),n=e.attributes.getInts("pads",[]),o=e.attributes.getInt("storage_order",0),p=e.attributes.getInts("dilations",[]);if(o!==0)throw new Error("column major storage order is not yet supported for MaxPool");if(a!==0)throw new Error("using ceil() in shape computation is not yet supported for MaxPool");return Q({autoPad:r,ceilMode:a,countIncludePad:!1,kernelShape:i,strides:l,pads:n,storageOrder:o,dilations:p})},Kf=(e,r,a,i)=>{let[l,n]=Jf(e,i,a),o=` value = max(_X(x), value); `,p="",c=` ${Qf(e[0].dims,l,o,p,"-1e5")} `;return{...r,output:{dims:n,type:e[0].type,textureType:0},shaderSource:c}},Jf=(e,r,a)=>{let i=e[0].dims.slice(),l=Object.hasOwnProperty.call(r,"dilations"),n=r.kernelShape.slice(),o=r.strides.slice(),p=l?r.dilations.slice():[],c=r.pads.slice();mr.adjustPoolAttributes(a,i,n,o,p,c);let t=mr.computePoolOutputShape(a,i,o,p,n,c,r.autoPad),u=Object.assign({},r);return l?Object.assign(u,{kernelShape:n,strides:o,pads:c,dilations:p,cacheKey:r.cacheKey}):Object.assign(u,{kernelShape:n,strides:o,pads:c,cacheKey:r.cacheKey}),[u,t]},bb={autoPad:"",ceilMode:0,countIncludePad:!1,kernelShape:[],strides:[],pads:[],storageOrder:0,dilations:[],cacheKey:""},zf={name:"GlobalMaxPool",inputNames:["X"],inputTypes:[0]},Zf=(e,r)=>(ao(r),[e.run({...zf,get:()=>Kf(r,zf,!0,bb)},r)]),ao=e=>{if(!e||e.length!==1)throw new Error("Pool ops requires 1 input.");if(e[0].type!=="float32"&&e[0].type!=="float64")throw new Error("Invalid input type.")},Qf=(e,r,a,i,l)=>{let n=e.length;if(r.kernelShape.length<=2){let o=r.kernelShape[r.kernelShape.length-1],p=r.strides[r.strides.length-1],c=r.pads[r.pads.length/2-1],t=r.pads[r.pads.length-1],u=e[n-1],s="",d="",f="";if(c+t!==0?s=` for (int i = 0; i < ${o}; i++) { x[${n} - 1] = indices[${n} - 1] * ${p} - ${c} + i; if (x[${n} - 1] < 0 || x[${n} - 1] >= ${u}) { pad++; continue; } ${a} }`:s=` for (int i = 0; i < ${o}; i++) { x[${n} - 1] = indices[${n} - 1] * ${p} - ${c} + i; ${a} }`,r.kernelShape.length===2){let b=r.kernelShape[r.kernelShape.length-2],y=r.strides[r.strides.length-2],v=r.pads[r.pads.length/2-2],E=r.pads[r.pads.length-2],T=e[n-2];v+E!==0?d=` for (int j = 0; j < ${b}; j++) { x[${n} - 2] = indices[${n} - 2] * ${y} - ${v} + j; if (x[${n} - 2] < 0 || x[${n} - 2] >= ${T}) { pad+= ${o}; continue; } `:d=` for (int j = 0; j < ${b}; j++) { x[${n} - 2] = indices[${n} - 2] * ${y} - ${v} + j; `,f=` } `}return` float process(int indices[${n}]) { int x[${n}]; copyVec(indices, x); float value = ${l}; int pad = 0; ${d} ${s} ${f} ${i} return value; } `}else{let o=U.size(r.kernelShape),p=U.computeStrides(r.kernelShape),c=p.length,t=r.pads.length,u=gb(c),s=io(e,"inputDims"),d=io(r.pads,"pads"),f=io(p,"kernelStrides"),b=io(r.strides,"strides"),y=r.pads.reduce((E,T)=>E+T),v="";return y?v=` if (x[j] >= inputDims[j] || x[j] < 0) { pad++; isPad = true; break; } } if (!isPad) { ${a} }`:v=` } ${a} `,` ${u} float process(int indices[${n}]) { int x[${n}]; copyVec(indices, x); int offset[${c}]; int pads[${t}]; int inputDims[${n}]; int kernelStrides[${c}]; int strides[${c}]; ${d} ${s} ${b} ${f} float value = ${l}; int pad = 0; bool isPad = false; for (int i = 0; i < ${o}; i++) { offsetToIndices(i, kernelStrides, offset); isPad = false; for (int j = ${n} - ${c}; j < ${n}; j++) { x[j] = indices[j] * strides[j - ${n} + ${c}] + offset[j - ${n} + ${c}] - pads[j - 2]; ${v} } ${i} return value; } `}},io=(e,r)=>{let a="";for(let i=0;i` void offsetToIndices(int offset, int[${e}] strides, out int[${e}] indices) { if (${e} == 0) { return; } for (int i = 0; i < ${e} - 1; ++i) { indices[i] = offset / strides[i]; offset -= indices[i] * strides[i]; } indices[${e} - 1] = offset; }`}),vr,er,yb,Tb,tc,rc,nc,oc,ic,ac,sc,uc=L(()=>{Ue(),pn(),fe(),ae(),vr=(e,r,a,i,l)=>{Tb(r);let n={name:i,inputNames:["A"],inputTypes:[0]};return[e.run({...n,cacheHint:a.cacheKey,get:()=>yb(e,r,a,i,l,n)},r)]},er=e=>{let r=e.attributes.getInts("axes",[]),a=e.attributes.getInt("keepdims",1)===1;return Q({axes:r,keepDims:a})},yb=(e,r,a,i,l,n)=>{let o=[],p=r[0].dims.length||1,c=[],t=U.normalizeAxes(a.axes,r[0].dims.length),u=l(r,t),s=u[1];for(let f=0;f=0||t.length===0?(a.keepDims&&o.push(1),s=` for(int j${f} = 0; j${f} < ${r[0].dims[f]}; j${f}++) { inputIdx[${f}] = j${f}; ${s} }`):(c.push(`inputIdx[${f}] = outputIdx[${o.length}];`),o.push(r[0].dims[f]));let d=` float process(int outputIdx[${o.length||1}]) { float value; // final result int inputIdx[${p}]; // addressing input data ${c.join(` `)} ${u[0]} // init ops for reduce max/min ${s} ${u[2]} // final computation for reduce mean return value; }`;return{...n,output:{dims:o,type:r[0].type,textureType:0},shaderSource:d}},Tb=e=>{if(!e||e.length!==1)throw new Error("Reduce op requires 1 input.");if(Qt.indexOf(e[0].type)===-1)throw new Error("Invalid input type.")},tc=(e,r,a)=>vr(e,r,a,"ReduceSum",()=>["value = 0.0;","value += _A(inputIdx);",""]),rc=(e,r,a)=>vr(e,r,a,"ReduceMean",(i,l)=>{let n=1;for(let o=0;o=0||l.length===0)&&(n*=i[0].dims[o]);return["value = 0.0;","value += _A(inputIdx);",`value /= ${n}.;`]}),nc=(e,r,a)=>vr(e,r,a,"ReduceMax",(i,l)=>{let n=[];for(let o=0;o=0||l.length===0)&&n.push(`inputIdx[${o}] = 0;`);return[`${n.join(` `)} value = _A(inputIdx);`,"value = max(value, _A(inputIdx));",""]}),oc=(e,r,a)=>vr(e,r,a,"ReduceMin",(i,l)=>{let n=[];for(let o=0;o=0||l.length===0)&&n.push(`inputIdx[${o}] = 0;`);return[`${n.join(` `)} value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),ic=(e,r,a)=>vr(e,r,a,"ReduceProd",()=>["value = 1.0;","value *= _A(inputIdx);",""]),ac=(e,r,a)=>vr(e,r,a,"ReduceLogSum",()=>["value = 0.0;","value += _A(inputIdx);","value = log(value);"]),sc=(e,r,a)=>vr(e,r,a,"ReduceLogSumSquare",()=>["float t; value = 0.0;","t = _A(inputIdx); value += t * t;",""])}),lc,fc=L(()=>{fe(),lc=(e,r)=>{let a=U.calculateReshapedDims(r[0].dims,r[1].integerData);return e.session.pack?[e.reshapePacked(r[0],a)]:[e.reshapeUnpacked(r[0],a)]}}),cc,ki,pc,dc,dn,xb,Bi,so,Ni=L(()=>{Ue(),we(),ae(),cc={name:"Upsample",inputNames:["X"],inputTypes:[0]},ki=(e,r,a)=>(Bi(r,a),[e.run({...cc,cacheHint:a.cacheKey,get:()=>xb(e,r,a)},r)]),pc=e=>dn(e,7),dc=e=>dn(e,9),dn=(e,r)=>{let a=r>=10,i=e.attributes.getString("mode","nearest");if(i!=="nearest"&&i!=="linear"&&(r<11||i!=="cubic"))throw new Error(`unrecognized mode: ${i}`);let l=[];r<9&&(l=e.attributes.getFloats("scales"),so(l,i,a));let n=e.attributes.getFloat("extrapolation_value",0),o=r>10?e.attributes.getString("coordinate_transformation_mode","half_pixel"):"asymmetric";if(["asymmetric","pytorch_half_pixel","tf_half_pixel_for_nn","align_corners","tf_crop_and_resize","half_pixel"].indexOf(o)===-1)throw new Error(`coordinate_transform_mode '${o}' is not supported`);let p=o==="tf_crop_and_resize",c=p,t=i==="nearest"&&r>=11?e.attributes.getString("nearest_mode","round_prefer_floor"):"";if(["round_prefer_floor","round_prefer_ceil","floor","ceil",""].indexOf(t)===-1)throw new Error(`nearest_mode '${t}' is not supported`);let u=e.attributes.getFloat("cubic_coeff_a",-.75),s=e.attributes.getInt("exclude_outside",0)!==0;if(s&&i!=="cubic")throw new Error("exclude_outside can be set to 1 only when mode is CUBIC.");let d=r<11?!0:i==="nearest"&&o==="asymmetric"&&t==="floor",f=0,b=0,y=0;return r>10?e.inputs.length>2?(f=1,b=2,y=3):(b=1,y=2):r===9&&(b=1),Q({opset:r,isResize:a,mode:i,scales:l,extrapolationValue:n,coordinateTransformMode:o,useExtrapolation:c,needRoiInput:p,nearestMode:t,cubicCoefficientA:u,excludeOutside:s,useNearest2xOptimization:d,roiInputIdx:f,scalesInputIdx:b,sizesInputIdx:y})},xb=(e,r,a)=>{let i=H(e.session.backend.glContext.version),[l,n]=e.calculateTextureWidthAndHeight(r[0].dims,0),o=r[0].dims.map((y,v)=>Math.floor(y*a.scales[v])),[p,c]=e.calculateTextureWidthAndHeight(o,0),t=o.length,u=new Array(t),s=new Array(t),d=` int output_pitches[${t}]; int input_pitches[${t}]; `;for(let y=t-1;y>=0;y--)u[y]=y===t-1?1:u[y+1]*o[y+1],s[y]=y===t-1?1:s[y+1]*r[0].dims[y+1],d+=` output_pitches[${y}] = ${u[y]}; input_pitches[${y}] = ${s[y]}; `;let f=` float getInputFloat(int index) { vec2 coords = offsetToCoords(index, ${l}, ${n}); float value = getColorAsFloat(${i.texture2D}(X, coords)); return value; } `,b=a.mode==="nearest"?` ${f} float process(int indices[${t}]) { int input_index = 0; int output_index = coordsToOffset(TexCoords, ${p}, ${c}); ${d} int d, m; for (int dim = 0; dim < ${t}; ++dim) { d = output_index / output_pitches[dim]; m = output_index - d * output_pitches[dim]; output_index = m; if (scales[dim] != 1 && d > 0) { int d2 = d / scales[dim]; m = d - d2 * scales[dim]; d = d2; } input_index += input_pitches[dim] * d; } return getInputFloat(input_index); }`:t===4?` ${f} float process(int indices[4]) { int input_index = 0; int output_index = coordsToOffset(TexCoords, ${p}, ${c}); ${d} int m; int index_of_dim0, index_of_dim1, index_of_dim2, index_of_dim3; index_of_dim0 = output_index / output_pitches[0]; m = output_index - index_of_dim0 * output_pitches[0]; index_of_dim1 = m / output_pitches[1]; m = m - index_of_dim1 * output_pitches[1]; index_of_dim2 = m / output_pitches[2]; m = m - index_of_dim2 * output_pitches[2]; index_of_dim3 = m; int index_of_input_dim2, index_of_input_dim3, x_offset, y_offset; index_of_input_dim2 = index_of_dim2 / scales[2]; y_offset = index_of_dim2 - index_of_input_dim2 * scales[2]; index_of_input_dim3 = index_of_dim3 / scales[3]; x_offset = index_of_dim3 - index_of_input_dim3 * scales[3]; input_index = index_of_dim0 * input_pitches[0] + index_of_dim1 * input_pitches[1] + index_of_input_dim2 * input_pitches[2] + index_of_input_dim3; float x00 = getInputFloat(input_index); float x10, x01, x11; bool end_of_dim2 = false; if (index_of_input_dim2 == (${r[0].dims[2]} - 1)) { // It's the end in dimension 2 x01 = x00; end_of_dim2 = true; } else { x01 = getInputFloat(input_index + input_pitches[2]); } if (index_of_input_dim3 == (input_pitches[2] - 1)) { // It's the end in dimension 3 x10 = x00; x11 = x01; } else { x10 = getInputFloat(input_index + 1); x11 = end_of_dim2 ? x10 : getInputFloat(input_index + input_pitches[2] + 1); } float y0 = x00 + float(y_offset) * (x01 - x00) / float(scales[2]); float y1 = x10 + float(y_offset) * (x11 - x10) / float(scales[2]); return y0 + float(x_offset) * (y1 - y0) / float(scales[3]); }`:` ${f} float process(int indices[2]) { int input_index = 0; int output_index = coordsToOffset(TexCoords, ${p}, ${c}); ${d} int m; int index_of_dim0, index_of_dim1; index_of_dim0 = output_index / output_pitches[0]; m = output_index - index_of_dim0 * output_pitches[0]; index_of_dim1 = m; int index_of_input_dim0, index_of_input_dim1, x_offset, y_offset; index_of_input_dim0 = index_of_dim0 / scales[0]; y_offset = index_of_dim0 - index_of_input_dim0 * scales[0]; index_of_input_dim1 = index_of_dim1 / scales[1]; x_offset = index_of_dim1 - index_of_input_dim1 * scales[1]; input_index = index_of_input_dim0 * input_pitches[0] + index_of_input_dim1; float x00 = getInputFloat(input_index); float x10, x01, x11; bool end_of_dim0 = false; if (index_of_input_dim0 == (${r[0].dims[0]} - 1)) { // It's the end in dimension 0 x01 = x00; end_of_dim0 = true; } else { x01 = getInputFloat(input_index + input_pitches[0]); } if (index_of_input_dim1 == (input_pitches[0] - 1)) { // It's the end in dimension 1 x10 = x00; x11 = x01; } else { x10 = getInputFloat(input_index + 1); x11 = end_of_dim0 ? x10 : getInputFloat(input_index + input_pitches[0] + 1); } float y0 = x00 + float(y_offset) * (x01 - x00) / float(scales[0]); float y1 = x10 + float(y_offset) * (x11 - x10) / float(scales[0]); return y0 + float(x_offset) * (y1 - y0) / float(scales[1]); }`;return{...cc,output:{dims:o,type:r[0].type,textureType:0},shaderSource:b,variables:[{name:"scales",type:"int",arrayLength:a.scales.length,data:a.scales.map(y=>Math.ceil(y))}]}},Bi=(e,r)=>{if(!e||r.opset<9&&e.length!==1||r.opset>=9&&r.opset<11&&e.length!==2||r.opset>=11&&e.length<2)throw new Error("invalid inputs.");if(r.scales.length>0&&e[0].dims.length!==r.scales.length)throw new Error("Invalid input shape.");if(e[0].type==="string")throw new Error("Invalid input tensor types.")},so=(e,r,a)=>{if(a){for(let i of e)if(i<=0)throw new Error("Scale value should be greater than 0.")}else for(let i of e)if(i<1)throw new Error("Scale value should be greater than or equal to 1.");if((r==="linear"||r==="cubic")&&e.length!==2&&(e.length!==4||e[0]!==1||e[1]!==1))throw new Error(`'Linear' mode and 'Cubic' mode only support 2-D inputs ('Bilinear', 'Bicubic') or 4-D inputs with the corresponding outermost 2 scale values being 1 in the ${a?"Resize":"Upsample"} opeartor.`)}}),Ri,Mi,hc,mc,wb,vb,_b,Ob,bc=L(()=>{we(),ae(),Bt(),Tr(),Ni(),Ri={name:"Resize",inputNames:["A"],inputTypes:[2]},Mi=(e,r,a)=>(Bi(r,a),[e.run({...Ri,cacheHint:a.cacheKey,get:()=>wb(e,r,a)},r)]),hc=e=>dn(e,10),mc=e=>dn(e,11),wb=(e,r,a)=>{let i=H(e.session.backend.glContext.version),[l,n]=vb(r,a);if(l.every(T=>T===1)&&a.coordinateTransformMode!=="tf_crop_and_resize")return{...Ri,output:{dims:n,type:r[0].type,textureType:2},hasMain:!0,shaderSource:`void main() { vec4 v = ${i.texture2D}(X, TexCoords); ${i.output} = v; }`};let o=n.length;if(o<2)throw new Error(`output dimension should be at least 2, but got ${o}`);let p=n[o-2],c=n[o-1],t=r[0].dims;if(o!==t.length)throw new Error(`output dimension should match input ${t.length}, but got ${o}`);let u=t[o-2],s=t[o-1],d=l[o-2],f=l[o-1],b="";if(a.mode!=="linear")throw new Error(`resize (packed) does not support mode: '${a.mode}'`);switch(a.coordinateTransformMode){case"asymmetric":b=` vec4 getSourceFracIndex(ivec4 coords) { return vec4(coords) / scaleWHWH; } `;break;case"half_pixel":b=` vec4 getSourceFracIndex(ivec4 coords) { return (vec4(coords) + 0.5) / scaleWHWH - 0.5; } `;break;case"pytorch_half_pixel":b=` vec4 getSourceFracIndex(ivec4 coords) { vec4 fcoords = vec4(coords); return vec4( ${c}.0 > 1.0 ? (fcoords.x + 0.5) / scaleWHWH.x - 0.5 : 0.0, ${p}.0 > 1.0 ? (fcoords.y + 0.5) / scaleWHWH.y - 0.5 : 0.0, ${c}.0 > 1.0 ? (fcoords.z + 0.5) / scaleWHWH.z - 0.5 : 0.0, ${p}.0 > 1.0 ? (fcoords.w + 0.5) / scaleWHWH.w - 0.5 : 0.0 ); } `;break;case"align_corners":b=` vec4 getSourceFracIndex(ivec4 coords) { vec4 resized = vec4(${c}.0 - 1.0, ${p}.0 - 1.0, ${c}.0 - 1.0, ${p}.0 - 1.0); vec4 original = vec4(${s}.0 - 1.0, ${u}.0 - 1.0, ${s}.0 - 1.0, ${u}.0 - 1.0); vec4 new_scale = original / resized; return vec4(coords) * new_scale; } `;break;default:throw new Error(`resize (packed) does not support coordinateTransformMode: '${a.coordinateTransformMode}'`)}let y=Qe(o),v=Nt(),E=` const vec2 inputWH = vec2(${u}.0, ${s}.0); const vec4 scaleWHWH = vec4(float(${d}), float(${f}), float(${d}), float(${f})); ${v} ${b} float getAValue(int x10, int r, int c, int d) { return getChannel(getA(x10, r, c, d), vec2(c, d)); } void main() { ${y} rc = getOutputCoords(); int batch = rc[0]; int depth = rc[1]; // retrieve the 4 coordinates that is used in the 4 packed output values. ivec4 coords = ivec4(rc.wz, rc.w + 1, rc.z + 1); // calculate the source index in fraction vec4 sourceFrac = getSourceFracIndex(coords); // get the lower and upper bound of the 4 values that will be packed into one texel. ivec4 x00 = ivec4(max(sourceFrac.xy, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.xy))); ivec4 x01 = ivec4(max(sourceFrac.xw, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.xw))); ivec4 x10 = ivec4(max(sourceFrac.zy, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.zy))); ivec4 x11 = ivec4(max(sourceFrac.zw, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.zw))); bool hasNextRow = rc.w < ${p-1}; bool hasNextCol = rc.z < ${c-1}; // pack x00, x01, x10, x11's top-left corner into one vec4 structure vec4 topLeft = vec4( getAValue(batch, depth, x00.x, x00.y), hasNextCol ? getAValue(batch, depth, x01.x, x01.y) : 0.0, hasNextRow ? getAValue(batch, depth, x10.x, x10.y) : 0.0, (hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.x, x11.y) : 0.0); // pack x00, x01, x10, x11's top-right corner into one vec4 structure vec4 topRight = vec4( getAValue(batch, depth, x00.x, x00.w), hasNextCol ? getAValue(batch, depth, x01.x, x01.w) : 0.0, hasNextRow ? getAValue(batch, depth, x10.x, x10.w) : 0.0, (hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.x, x11.w) : 0.0); // pack x00, x01, x10, x11's bottom-left corner into one vec4 structure vec4 bottomLeft = vec4( getAValue(batch, depth, x00.z, x00.y), hasNextCol ? getAValue(batch, depth, x01.z, x01.y) : 0.0, hasNextRow ? getAValue(batch, depth, x10.z, x10.y) : 0.0, (hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.z, x11.y) : 0.0); // pack x00, x01, x10, x11's bottom-right corner into one vec4 structure vec4 bottomRight = vec4( getAValue(batch, depth, x00.z, x00.w), hasNextCol ? getAValue(batch, depth, x01.z, x01.w) : 0.0, hasNextRow ? getAValue(batch, depth, x10.z, x10.w) : 0.0, (hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.z, x11.w) : 0.0); // calculate the interpolation fraction on u and v direction vec4 frac = vec4(sourceFrac) - floor(sourceFrac); vec4 clampFrac = clamp(frac, vec4(0.0), vec4(1.0)); vec4 top = mix(topLeft, topRight, clampFrac.ywyw); vec4 bottom = mix(bottomLeft, bottomRight, clampFrac.ywyw); vec4 newValue = mix(top, bottom, clampFrac.xxzz); ${i.output} = vec4(newValue); } `;return{...Ri,output:{dims:n,type:r[0].type,textureType:2},hasMain:!0,shaderSource:E}},vb=(e,r)=>{let a=e[0].dims,i=r.scales,l;if(i.length===0){let o=e[r.scalesInputIdx];if(o&&o.size!==0){if(e[r.sizesInputIdx])throw new Error("Only one of scales or sizes must be provided as input.");i=_b(o,r.mode,r.isResize)}else{let p=e[r.sizesInputIdx];if(!p||p.size===0)throw new Error("Either scales or sizes MUST be provided as input.");l=Array.from(p.integerData),i=Ob(l,a,r.mode,r.isResize)}}else if(e[r.sizesInputIdx])throw new Error("Only one of scales or sizes must be provided as input.");let n=l||a.map((o,p)=>Math.floor(o*i[p]));return[i,n]},_b=(e,r,a)=>{let i=Array.from(e.floatData);return so(i,r,a),i},Ob=(e,r,a,i)=>{let l=r.length,n=new Array(l);for(let o=0,p=l;o{yr(),gc=(e,r)=>(Ib(r),[new $e([r[0].dims.length],"int32",void 0,void 0,new Int32Array(r[0].dims))]),Ib=e=>{if(!e||e.length!==1)throw new Error("Shape requires 1 input.")}}),Gi,Tc,xc,wc,Sb,vc,Ab,Pb,_c=L(()=>{Ue(),pn(),fe(),ae(),Gi={name:"Slice",inputNames:["A"],inputTypes:[0]},Tc=(e,r,a)=>(Sb(r),[e.run({...Gi,cacheHint:a.cacheKey,get:()=>wc(e,r[0],a)},r)]),xc=e=>{let r=e.attributes.getInts("starts"),a=e.attributes.getInts("ends"),i=e.attributes.getInts("axes",[]);return Q({starts:r,ends:a,axes:i})},wc=(e,r,a)=>{let i=a.axes.length===0?r.dims.slice(0).map((u,s)=>s):a.axes,l=U.normalizeAxes(i,r.dims.length),n=a.starts.map((u,s)=>u>r.dims[l[s]]-1?r.dims[l[s]]:U.normalizeAxis(u,r.dims[l[s]])),o=a.ends.map((u,s)=>u>r.dims[l[s]]-1?r.dims[l[s]]:U.normalizeAxis(u,r.dims[l[s]])),p=r.dims.slice(),c=[];for(let u=0;u0&&c.push(`outputIdx[${l[u]}] += ${n[u]};`);let t=` float process(int outputIdx[${p.length}]) { ${c.join(` `)} return _A(outputIdx); }`;return{...Gi,output:{dims:p,type:r.type,textureType:0},shaderSource:t}},Sb=e=>{if(!e||e.length!==1)throw new Error("Slice requires 1 input.");if(Qt.indexOf(e[0].type)===-1)throw new Error("Invalid input type.")},vc=(e,r)=>{Pb(r);let a=Ab(e,r);return[e.run({...Gi,cacheHint:a.cacheKey,get:()=>wc(e,r[0],a)},[r[0]])]},Ab=(e,r)=>{if(!e.session.isInitializer(r[1].dataId)||!e.session.isInitializer(r[2].dataId)||r.length>=4&&!e.session.isInitializer(r[3].dataId)||r.length>=5&&!e.session.isInitializer(r[4].dataId))throw new Error("dynamic slice attributes are not allowed");if(r.length>=5&&r[4].integerData.some(o=>o!==1))throw new Error("currently non-1 steps is not supported for Slice");let a=Array.from(r[1].integerData),i=Array.from(r[2].integerData),l=r.length>=4?Array.from(r[3].integerData):[],n=`${l};${a};${i}`;return{starts:a,ends:i,axes:l,cacheKey:n}},Pb=e=>{if(!e||e.length<3||e.length>5)throw new Error("Invalid input number.");if(e[1].type!=="int32"||e[1].dims.length!==1)throw new Error("Invalid input type.");if(e[2].type!=="int32"||e[2].dims.length!==1)throw new Error("Invalid input type.");if(e.length>=4&&(e[3].type!=="int32"||e[3].dims.length!==1))throw new Error("Invalid input type.");if(e.length>=5&&(e[4].type!=="int32"||e[4].dims.length!==1))throw new Error("Invalid input type.")}}),Oc,Ic,Sc,Ac,Pc,Ec,Dc,Lc,Eb,Db,Lb,Cc,Fc=L(()=>{Ue(),fe(),we(),ae(),oo(),Oc={name:"SoftmaxComputeMax",inputNames:["A"],inputTypes:[0]},Ic={name:"SoftmaxComputeScale",inputNames:["A","Max"],inputTypes:[0,0]},Sc={name:"SoftMax",inputNames:["A","Max","Norm"],inputTypes:[0,0,0]},Ac=(e,r,a)=>{Cc(r);let i=r[0].dims.slice(),l=U.normalizeAxis(a.axis,i.length),n=U.sizeToDimension(i,l),o=U.sizeFromDimension(i,l);return Lc(e,r,a,n,o)},Pc=e=>Q({axis:e.attributes.getInt("axis",1)}),Ec=e=>Q({axis:e.attributes.getInt("axis",-1)}),Dc=(e,r,a)=>{Cc(r);let i=r[0].dims.slice(),l=U.normalizeAxis(a.axis,i.length),n=i.length,o=l!==n-1,p=[],c=[],t=[],u;o&&(c=Array.from({length:n}).map((b,y)=>y),c[l]=n-1,c[n-1]=l,c.map(b=>p.push(i[b])),u=Q({perm:c}),t=wr(e,r,u));let s=o?U.sizeToDimension(p,n-1):U.sizeToDimension(i,n-1),d=o?U.sizeFromDimension(p,n-1):U.sizeFromDimension(i,n-1),f=Lc(e,o?t:r,a,s,d);return o?wr(e,f,u):f},Lc=(e,r,a,i,l)=>{let n=Eb(e,r[0],i,l,[i]),o=e.run({...Oc,cacheHint:a.cacheKey,get:()=>n},r),p=Db(e,r[0],i,l,n.output.dims,[i]),c=e.run({...Ic,cacheHint:a.cacheKey,get:()=>p},[r[0],o]),t=Lb(e,r[0],i,l,n.output.dims,p.output.dims);return[e.run({...Sc,cacheHint:a.cacheKey,get:()=>t},[r[0],o,c])]},Eb=(e,r,a,i,l)=>{let[n,o]=e.calculateTextureWidthAndHeight(r.dims,0),p=l.length;if(a<1||i<1)throw new Error("Logical row count N and feature count D must be greater than or equal to 1");if(l.length!==1)throw new Error("Dimensionality of the output should be 1");if(l[0]!==a)throw new Error("Shape of the output should be equal to logical row count");let c=H(e.session.backend.glContext.version),t=` float process(int[${p}] indices) { int logical_row_start_offset = indices[0] * ${i}; float max = getColorAsFloat(${c.texture2D}(A, offsetToCoords(logical_row_start_offset, ${n}, ${o} ))); for(int i=1; i<${i}; ++i) { float current = getColorAsFloat(${c.texture2D}(A, offsetToCoords(logical_row_start_offset + i, ${n}, ${o}))); if(current > max) max = current; } return max; }`;return{...Oc,output:{dims:l,type:r.type,textureType:0},shaderSource:t}},Db=(e,r,a,i,l,n)=>{let[o,p]=e.calculateTextureWidthAndHeight(r.dims,0),c=n.length;if(a<1||i<1)throw new Error("Logical row count N and feature count D must be greater than or equal to 1");if(n.length!==1)throw new Error("Dimensionality of the output should be 1");if(n[0]!==a)throw new Error("Shape of the output should be equal to logical row count");if(l.length!==1)throw new Error("Dimensionality of the intermediate results should be 1");if(l[0]!==a)throw new Error("Shape of the intermediate results should be equal to logical row count");let t=H(e.session.backend.glContext.version),u=` float process(int[${c}] indices) { int logical_row_start_offset = indices[0] * ${i}; float norm_factor = 0.0; float max = _Max(indices); for(int i=0; i<${i}; ++i) { norm_factor += exp(getColorAsFloat(${t.texture2D}(A, offsetToCoords(logical_row_start_offset + i, ${o}, ${p}))) - max); } return norm_factor; }`;return{...Ic,output:{dims:n,type:r.type,textureType:0},shaderSource:u}},Lb=(e,r,a,i,l,n)=>{let[o,p]=e.calculateTextureWidthAndHeight(r.dims,0),c=r.dims.length;if(a<1||i<1)throw new Error("Logical row count N and feature count D must be greater than or equal to 1");if(l.length!==1||n.length!==1)throw new Error("Dimensionality of the intermediate results should be 1");if(l[0]!==a||n[0]!==a)throw new Error("Shape of the intermediate results should be equal to logical row count");let t=` float process(int[${c}] indices) { // get offset of current logical tensor index from the 2-D texture coordinates (TexCoords) int offset = coordsToOffset(TexCoords, ${o}, ${p}); //determine the logical row for this index int logical_row_index[1]; logical_row_index[0] = offset / ${i}; float norm_factor = _Norm(logical_row_index); // avoid possible division by 0 // if norm_facor is 0, all elements are zero // if so, return 0 if(norm_factor == 0.0) return 0.0; return exp(_A(indices) - _Max(logical_row_index)) / norm_factor; }`;return{...Sc,output:{dims:r.dims,type:r.type,textureType:0},shaderSource:t}},Cc=e=>{if(!e||e.length!==1)throw new Error("Softmax requires 1 input.");if(e[0].type!=="float32"&&e[0].type!=="float64")throw new Error("Invalid input type")}}),$c,kc,Bc,Cb,Fb,$b,Nc=L(()=>{Ue(),fe(),ae(),$c={name:"Split",inputNames:["A"],inputTypes:[0]},kc=(e,r,a)=>{$b(r);let i=U.normalizeAxis(a.axis,r[0].dims.length),l=Cb(e,r,i,a),n=[];for(let o=0;oFb(e,r[0],a,i,o)},r));return n},Bc=e=>{let r=e.attributes.getInt("axis",0),a=e.attributes.getInts("split",[]),i=e.outputs.length;return Q({axis:r,split:a,numOutputs:i})},Cb=(e,r,a,i)=>{let[,l]=an.splitShape(r[0].dims,a,i.split,i.numOutputs);return l.length},Fb=(e,r,a,i,l)=>{let[n,o]=an.splitShape(r.dims,i,a.split,a.numOutputs),p=o[l],c=n[l],t=` float process(int indices[${c.length}]) { indices[${i}] += ${p}; return _A(indices); } `;return{...$c,cacheHint:`${a.cacheKey}:${l}`,output:{dims:c,type:r.type,textureType:0},shaderSource:t}},$b=e=>{if(!e||e.length!==1)throw new Error("Split requires one input.");if(e[0].type!=="int8"&&e[0].type!=="uint8"&&e[0].type!=="int16"&&e[0].type!=="uint16"&&e[0].type!=="int32"&&e[0].type!=="uint32"&&e[0].type!=="float32"&&e[0].type!=="float64"&&e[0].type!=="bool")throw new Error("Invalid input type.")}}),Ui,Rc,Mc,kb,Bb,Gc=L(()=>{fe(),Ui=(e,r,a)=>{kb(r);let i=U.squeezeShape(r[0].dims,a);return[e.reshapeUnpacked(r[0],i)]},Rc=(e,r)=>(Bb(r),Ui(e,[r[0]],Array.from(r[1].integerData))),Mc=e=>e.attributes.getInts("axes"),kb=e=>{if(!e||e.length!==1)throw new Error("Squeeze requires 1 input.");if(e[0].type==="string")throw new Error("invalid input tensor types.")},Bb=e=>{if(!e||e.length!==2)throw new Error("Squeeze requires 2 inputs.");if(e[1].type!=="int32")throw new Error("Invalid input type.")}}),Uc,Nb,Rb,zc=L(()=>{we(),ae(),Uc=(e,r)=>{Rb(r);let a={name:"Sum",inputNames:r.map((i,l)=>`X${l}`),inputTypes:new Array(r.length).fill(0)};return[e.run({...a,get:()=>Nb(e,r,a)},r)]},Nb=(e,r,a)=>{let i=H(e.session.backend.glContext.version),l=r[0].dims.slice(),n=` void main() { vec4 result = ${r.map((o,p)=>`${i.texture2D}(X${p},TexCoords)`).join(" + ")}; ${i.output} = result; } `;return{...a,output:{dims:l,type:r[0].type,textureType:0},hasMain:!0,shaderSource:n}},Rb=e=>{if(!e||e.length===0)throw new Error("Sum requires inputs.");let r=e[0].dims.length;for(let a=1;a{pn(),ae(),Vc=(e,r)=>{Gb(r);let a={name:"Tile",inputNames:["A"],inputTypes:[0]};return[e.run({...a,get:()=>Mb(e,r,a)},r)]},Mb=(e,r,a)=>{let i=r[0].dims.slice(),l=new Array(i.length),n=[];for(let c=0;c{if(!e||e.length!==2)throw new Error("Tile requires 2 input.");if(e[1].dims.length!==1)throw new Error("The second input shape must 1 dimension.");if(e[1].dims[0]!==e[0].dims.length)throw new Error("Invalid input shape.");if(Qt.indexOf(e[0].type)===-1)throw new Error("Invalid input type.");if(e[1].type!=="int32"&&e[1].type!=="int16")throw new Error("Invalid repeat type.")}}),zi,Hc,qc,Ub,zb,jc=L(()=>{fe(),zi=(e,r,a)=>{Ub(r);let i=U.unsqueezeShape(r[0].dims,a);return[e.reshapeUnpacked(r[0],i)]},Hc=(e,r)=>(zb(r),zi(e,[r[0]],Array.from(r[1].integerData))),qc=e=>e.attributes.getInts("axes"),Ub=e=>{if(!e||e.length!==1)throw new Error("Unsqueeze requires 1 input.");if(e[0].type==="string")throw new Error("invalid input tensor types.")},zb=e=>{if(!e||e.length!==2)throw new Error("Unsqueeze requires 2 inputs.");if(e[1].type!=="int32")throw new Error("Invalid input type.")}}),Yc,Xc=L(()=>{ol(),gl(),xl(),Sl(),to(),ff(),bf(),Tf(),vf(),Sf(),Ef(),Ff(),Nf(),ro(),Uf(),ec(),uc(),fc(),bc(),yc(),_c(),Fc(),Nc(),Gc(),zc(),Wc(),oo(),Ii(),jc(),Ni(),Yc=[["Abs","","6+",Al],["Acos","","7+",Pl],["Add","","7+",il],["And","","7+",al],["Asin","","7+",El],["Atan","","7+",Dl],["AveragePool","","7+",Vf,Wf],["BatchNormalization","","7+",rl,nl],["Cast","","6+",yl,Tl],["Ceil","","6+",Fl],["Clip","","6-10",_i,Ll],["Clip","","11+",Cl],["Concat","","4+",_l,Il],["Conv","","1+",Li,Ci],["ConvTranspose","","1+",uf,lf],["Cos","","7+",$l],["Div","","7+",sl],["Dropout","","7+",Oi],["DepthToSpace","","1+",hf,mf],["Equal","","7+",ul],["Elu","","6+",kl,Bl],["Exp","","6+",Nl],["Flatten","","1+",gf,yf],["Floor","","6+",Rl],["FusedConv","com.microsoft","1+",Li,Ci],["Gather","","1+",xf,wf],["Gemm","","7-10",Fi,Of],["Gemm","","11+",Fi,If],["GlobalAveragePool","","1+",qf,jf],["GlobalMaxPool","","1+",Zf],["Greater","","7+",ll],["Identity","","1+",Oi],["ImageScaler","","1+",Af,Pf],["InstanceNormalization","","6+",Lf,Cf],["LeakyRelu","","6+",Ml,Gl],["Less","","7+",fl],["LRN","","1+",$f,kf],["Log","","6+",Ul],["MatMul","","1+",ef,tf],["MaxPool","","1+",Yf,Xf],["Mul","","7+",cl],["Neg","","6+",zl],["Not","","1+",Vl],["Or","","7+",pl],["Pad","","2-10",$i,Rf],["Pad","","11+",Mf,Gf],["Pow","","7+",dl],["PRelu","","7+",hl],["ReduceLogSum","","1+",ac,er],["ReduceMax","","1+",nc,er],["ReduceMean","","1+",rc,er],["ReduceMin","","1+",oc,er],["ReduceProd","","1+",ic,er],["ReduceSum","","1-12",tc,er],["ReduceSumSquare","","1+",sc,er],["Relu","","6+",Wl],["Reshape","","5+",lc],["Resize","","10",Mi,hc],["Resize","","11+",Mi,mc],["Shape","","1+",gc],["Sigmoid","","6+",Hl],["Sin","","7+",ql],["Slice","","10+",vc],["Slice","","1-9",Tc,xc],["Softmax","","1-12",Ac,Pc],["Softmax","","13+",Dc,Ec],["Split","","2-12",kc,Bc],["Sqrt","","6+",jl],["Squeeze","","1-12",Ui,Mc],["Squeeze","","13+",Rc],["Sub","","7+",ml],["Sum","","6+",Uc],["Tan","","7+",Yl],["Tanh","","6+",Xl],["Tile","","6+",Vc],["Transpose","","1+",wr,pf],["Upsample","","7-8",ki,pc],["Upsample","","9",ki,dc],["Unsqueeze","","1-12",zi,qc],["Unsqueeze","","13+",Hc],["Xor","","7+",bl]]});function Jc(e){let r={},a;for(;(a=Kc.exec(e))!==null;){let i=a[3].split(",").map(l=>{let n=l.trim().split(" ");return n&&n.length===2?{type:n[0],name:n[1]}:null}).filter(l=>l!==null);r[a[2]]={params:i,body:a[4]}}for(let i in r){let l=Vb.replace("__FUNC__",i),n=new RegExp(l,"gm");for(;(a=n.exec(e))!==null;){let o=a[1],p=a[2],c=a[3].split(","),t=o?`${o} ${p};`:"",u=r[i].body,s="";r[i].params.forEach((f,b)=>{f&&(s+=`${f.type} ${f.name} = ${c[b]}; `)}),u=`${s} ${u}`,u=u.replace("return",`${p} = `);let d=` ${t} { ${u} } `;e=e.replace(a[0],d)}}return e=e.replace(Kc,""),e}var Kc,Vb,Zc=L(()=>{Kc=/@inline[\s\n\r]+(\w+)[\s\n\r]+([0-9a-zA-Z_]+)\s*\(([^)]*)\)\s*{(([^}]|[\n\r])*)}/gm,Vb="(\\w+)?\\s+([_0-9a-zA-Z]+)\\s+=\\s+__FUNC__\\((.*)\\)\\s*;"});function Mr(e,r){let a=[],i=[];for(let l=0;l{lt(),fe(),uo=class{constructor(e){this.maxTextureSize=e}computeTextureWH(e,r){let a=this.computeTexture(e,r);return r&&r.isPacked&&(a[0]/=2,a[1]/=2),r&&r.reverseWH?[a[1],a[0]]:a}computeTexture(e,r){let a=r&&r.isPacked;if(e.length===0)return a?[2,2]:[1,1];let i=this.maxTextureSize;if(r&&r.breakAxis!==void 0){let o=r.breakAxis>=e.length?1:e.slice(r.breakAxis).reduce((c,t)=>c*t),p=r.breakAxis<=0?1:e.slice(0,r.breakAxis).reduce((c,t)=>c*t);if(o>i||p>i)ce.verbose("TextureLayout",`Given width/height preferences were unattainable: shape:${e}, breakAxis:${r.breakAxis}`);else return[o,p]}let l=e.slice(0);a&&(i=i*2,l=l.map((o,p)=>p>=l.length-2?l[p]%2===0?l[p]:l[p]+1:l[p]),l.length===1&&(l=[2,l[0]])),l.length!==2&&(l=Mr(l).newShape);let n=qb(l);return l.length<=1&&n<=i?[1,n]:l.length===2&&l[0]<=i&&l[1]<=i?l:l.length===3&&l[0]*l[1]<=i&&l[2]<=i?[l[0]*l[1],l[2]]:l.length===3&&l[0]<=i&&l[1]*l[2]<=i?[l[0],l[1]*l[2]]:l.length===4&&l[0]*l[1]*l[2]<=i&&l[3]<=i?[l[0]*l[1]*l[2],l[3]]:l.length===4&&l[0]<=i&&l[1]*l[2]*l[3]<=i?[l[0],l[1]*l[2]*l[3]]:a?Qc(n/4).map(o=>o*2):Qc(n)}}}),lo,ep=L(()=>{fe(),Wt(),we(),Vi(),Bt(),lo=class extends dt{constructor(e){super(e)}getFunctions(){return{...this.offsetToCoords(),...this.coordsToOffset(),...this.toVec(),...this.valueFrom(),...this.getCommonUtilFuncs(),...this.getInputsSamplingSnippets(),...this.getOutputSamplingSnippet()}}getCustomTypes(){return{}}offsetToCoords(){let e="offsetToCoords";return{offsetToCoords:new R(` vec2 ${e}(int offset, int width, int height) { int t = offset / width; int s = offset - t*width; vec2 coords = (vec2(s,t) + vec2(0.5,0.5)) / vec2(width, height); return coords; } `)}}coordsToOffset(){let e="coordsToOffset";return{coordsToOffset:new R(` int ${e}(vec2 coords, int width, int height) { float s = coords.s * float(width); float t = coords.t * float(height); int offset = int(t) * width + int(s); return offset; } `)}}getOutputSamplingSnippet(){let e=this.context.outputTextureLayout;return e.isPacked?this.getPackedOutputSamplingSnippet(e):this.getUnpackedOutputSamplingSnippet(e)}getPackedOutputSamplingSnippet(e){let r=e.unpackedShape,a=[e.width,e.height],i={},l="getOutputCoords";switch(r.length){case 0:i[l]=this.getOutputScalarCoords();break;case 1:i[l]=this.getOutputPacked1DCoords(r,a);break;case 2:i[l]=this.getOutputPacked2DCoords(r,a);break;case 3:i[l]=this.getOutputPacked3DCoords(r,a);break;default:i[l]=this.getOutputPackedNDCoords(r,a)}let n=` void setOutput(vec4 val) { ${H(this.context.glContext.version).output} = val; } `,o="floatTextureSetRGBA";return i[o]=new R(n),i}getUnpackedOutputSamplingSnippet(e){let r=e.unpackedShape,a=[e.width,e.height],i={},l="getOutputCoords";switch(r.length){case 0:i[l]=this.getOutputScalarCoords();break;case 1:i[l]=this.getOutputUnpacked1DCoords(r,a);break;case 2:i[l]=this.getOutputUnpacked2DCoords(r,a);break;case 3:i[l]=this.getOutputUnpacked3DCoords(r,a);break;case 4:i[l]=this.getOutputUnpacked4DCoords(r,a);break;case 5:i[l]=this.getOutputUnpacked5DCoords(r,a);break;case 6:i[l]=this.getOutputUnpacked6DCoords(r,a);break;default:throw new Error(`Unsupported output dimensionality: ${r.length}`)}let n=` void setOutput(float val) { ${H(this.context.glContext.version).output} = vec4(val, 0, 0, 0); } `,o="floatTextureSetR";return i[o]=new R(n),i}getOutputScalarCoords(){return new R(` int getOutputCoords() { return 0; } `)}getOutputPacked1DCoords(e,r){let a=r,i="";return a[0]===1?(i=` int getOutputCoords() { return 2 * int(TexCoords.y * ${a[1]}.0); } `,new R(i)):a[1]===1?(i=` int getOutputCoords() { return 2 * int(TexCoords.x * ${a[0]}.0); } `,new R(i)):(i=` int getOutputCoords() { ivec2 resTexRC = ivec2(TexCoords.xy * vec2(${a[0]}, ${a[1]})); return 2 * (resTexRC.y * ${a[0]} + resTexRC.x); } `,new R(i))}getOutputPacked2DCoords(e,r){let a="";if(hr.arraysEqual(e,r))return a=` ivec2 getOutputCoords() { return 2 * ivec2(TexCoords.xy * vec2(${r[0]}, ${r[1]})); } `,new R(a);let i=r,l=Math.ceil(e[1]/2);return a=` ivec2 getOutputCoords() { ivec2 resTexRC = ivec2(TexCoords.xy * vec2(${i[0]}, ${i[1]})); int index = resTexRC.y * ${i[0]} + resTexRC.x; // reverse r and c order for packed texture int r = imod(index, ${l}) * 2; int c = 2 * (index / ${l}); return ivec2(r, c); } `,new R(a)}getOutputPacked3DCoords(e,r){let a=[r[0],r[1]],i=Math.ceil(e[2]/2),l=i*Math.ceil(e[1]/2),n=` ivec3 getOutputCoords() { ivec2 resTexRC = ivec2(TexCoords.xy * vec2(${a[0]}, ${a[1]})); int index = resTexRC.y * ${a[0]} + resTexRC.x; int b = index / ${l}; index -= b * ${l}; // reverse r and c order for packed texture int r = imod(index, ${i}) * 2; int c = 2 * (index / ${i}); return ivec3(b, r, c); } `;return new R(n)}getOutputPackedNDCoords(e,r){let a=[r[0],r[1]],i=Math.ceil(e[e.length-1]/2),l=i*Math.ceil(e[e.length-2]/2),n=l,o="",p="b, r, c";for(let t=2;t=0;--p)l[p]=l[p+1]*e[p+1];let n=["r","c","d"],o=l.map((p,c)=>{let t=`int ${n[c]} = index / ${p}`,u=c===l.length-1?`int ${n[c+1]} = index - ${n[c]} * ${p}`:`index -= ${n[c]} * ${p}`;return`${t}; ${u};`}).join("");return a=` ivec3 getOutputCoords() { ivec2 resTexRC = ivec2(TexCoords.xy * vec2(${r[0]}, ${r[1]})); int index = resTexRC.y * ${r[0]} + resTexRC.x; ${o} return ivec3(r, c, d); } `,new R(a)}getOutputUnpacked4DCoords(e,r){let a="",i=e.length,l=null;i<2&&(l=[]),l=new Array(i-1),l[i-2]=e[i-1];for(let p=i-3;p>=0;--p)l[p]=l[p+1]*e[p+1];let n=["r","c","d","d2"],o=l.map((p,c)=>{let t=`int ${n[c]} = index / ${p}`,u=c===l.length-1?`int ${n[c+1]} = index - ${n[c]} * ${p}`:`index -= ${n[c]} * ${p}`;return`${t}; ${u};`}).join("");return a=` ivec4 getOutputCoords() { ivec2 resTexRC = ivec2(TexCoords.xy * vec2(${r[0]}, ${r[1]})); int index = resTexRC.y * ${r[0]} + resTexRC.x; ${o} return ivec4(r, c, d, d2); } `,new R(a)}getOutputUnpacked5DCoords(e,r){let a="",i=e.length,l=null;i<2&&(l=[]),l=new Array(i-1),l[i-2]=e[i-1];for(let p=i-3;p>=0;--p)l[p]=l[p+1]*e[p+1];let n=["r","c","d","d2","d3"],o=l.map((p,c)=>{let t=`int ${n[c]} = index / ${p}`,u=c===l.length-1?`int ${n[c+1]} = index - ${n[c]} * ${p}`:`index -= ${n[c]} * ${p}`;return`${t}; ${u};`}).join("");return a=` ivec5 getOutputCoords() { ivec2 resTexRC = ivec2(TexCoords.xy * vec2(${r[0]}, ${r[1]})); int index = resTexRC.y * ${r[0]} + resTexRC.x; ${o} return ivec5(r, c, d, d2, d3); } `,new R(a)}getOutputUnpacked6DCoords(e,r){let a="",i=e.length,l=null;i<2&&(l=[]),l=new Array(i-1),l[i-2]=e[i-1];for(let p=i-3;p>=0;--p)l[p]=l[p+1]*e[p+1];let n=["r","c","d","d2","d3","d4"],o=l.map((p,c)=>{let t=`int ${n[c]} = index / ${p}`,u=c===l.length-1?`int ${n[c+1]} = index - ${n[c]} * ${p}`:`index -= ${n[c]} * ${p}`;return`${t}; ${u};`}).join("");return a=` ivec6 getOutputCoords() { ivec2 resTexRC = ivec2(TexCoords.xy * vec2(${r[0]}, ${r[1]})); int index = resTexRC.y * ${r[0]} + resTexRC.x; ${o} return ivec6(r, c, d, d2, d3, d4); } `,new R(a)}getCommonUtilFuncs(){let e={},r="uvFromFlat";e[r]=new R(` vec2 uvFromFlat(int texNumR, int texNumC, int index) { int texC = index / texNumR; int texR = index - texC * texNumR; // TODO: swap texR, texC order in following function so row is corresponding to u and column is corresponding to // v. return (vec2(texR, texC) + halfCR) / vec2(texNumR, texNumC); } `),r="packedUVfrom1D",e[r]=new R(` 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); } `),r="packedUVfrom2D",e[r]=new R(` vec2 packedUVfrom2D(int texNumR, int texNumC, int texelsInLogicalRow, 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); } `),r="packedUVfrom3D",e[r]=new R(` 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); } `),r="sampleTexture";let a=H(this.context.glContext.version);return e[r]=new R(` float sampleTexture(sampler2D textureSampler, vec2 uv) { return ${a.texture2D}(textureSampler, uv).r; }`),e}getInputsSamplingSnippets(){let e={},r=this.context.outputTextureLayout;return this.context.programInfo.inputNames.forEach((a,i)=>{let l=this.context.inputTextureLayouts[i],n=Yn(a);l.isPacked?e[n]=this.getPackedSamplerFromInput(n,a,l):e[n]=this.getUnpackedSamplerFromInput(n,a,l);let o=Gu(a);l.unpackedShape.length<=r.unpackedShape.length&&(l.isPacked?e[o]=this.getPackedSamplerAtOutputCoords(o,l,r,a):e[o]=this.getUnpackedSamplerAtOutputCoords(o,l,r,a))}),e}getPackedSamplerAtOutputCoords(e,r,a,i){let l=r.unpackedShape,n=a.unpackedShape,o=Yn(i),p=l.length,c=n.length,t=Ze.getBroadcastDims(l,n),u=Qe(c),s=c-p,d,f=Dt();p===0?d="":c<2&&t.length>=1?d="coords = 0;":d=t.map(F=>`coords.${f[F+s]} = 0;`).join(` `);let b="";c<2&&p>0?b="coords":b=l.map((F,C)=>`coords.${f[C+s]}`).join(", ");let y="return outputValue;",v=U.size(l)===1,E=U.size(n)===1;if(p===1&&!v&&!E)y=` return vec4(outputValue.xy, outputValue.xy); `;else if(v&&!E)c===1?y=` return vec4(outputValue.x, outputValue.x, 0., 0.); `:y=` return vec4(outputValue.x); `;else if(t.length){let F=p-2,C=p-1;t.indexOf(F)>-1&&t.indexOf(C)>-1?y="return vec4(outputValue.x);":t.indexOf(F)>-1?y="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":t.indexOf(C)>-1&&(y="return vec4(outputValue.xx, outputValue.zz);")}let T=` int lastDim = coords.${f[c-1]}; coords.${f[c-1]} = coords.${f[c-2]}; coords.${f[c-2]} = lastDim; `,$=` vec4 ${e}() { ${u} coords = getOutputCoords(); ${T} ${d} vec4 outputValue = ${o}(${b}); ${y} } `;return new R($,["coordinates.getOutputCoords"])}getUnpackedSamplerAtOutputCoords(e,r,a,i){let l=[a.width,a.height],n=[r.width,r.height],o=r.unpackedShape.length,p=a.unpackedShape.length,c=r.unpackedShape,t=a.unpackedShape,u=Yn(i);if(o===p&&hr.arraysEqual(n,l)){let T=` float ${e}() { return sampleTexture(${i}, TexCoords); } `;return new R(T,["coordinates.sampleTexture"])}let s=Qe(p),d=Ze.getBroadcastDims(c,t),f=p-o,b,y=Dt();o===0?b="":p<2&&d.length>=1?b="coords = 0;":b=d.map(T=>`coords.${y[T+f]} = 0;`).join(` `);let v="";p<2&&o>0?v="coords":v=r.unpackedShape.map((T,$)=>`coords.${y[$+f]}`).join(", ");let E=` float ${e}() { ${s} coords = getOutputCoords(); ${b} return ${u}(${v}); } `;return new R(E,["coordinates.getOutputCoords"])}getPackedSamplerFromInput(e,r,a){switch(a.unpackedShape.length){case 0:return this.getPackedSamplerScalar(e,r);case 1:return this.getPackedSampler1D(e,r,a);case 2:return this.getPackedSampler2D(e,r,a);case 3:return this.getPackedSampler3D(e,r,a);default:return this.getPackedSamplerND(e,r,a)}}getUnpackedSamplerFromInput(e,r,a){let i=a.unpackedShape;switch(i.length){case 0:return this.getUnpackedSamplerScalar(e,r,a);case 1:return this.getUnpackedSampler1D(e,r,a);case 2:return this.getUnpackedSampler2D(e,r,a);case 3:return this.getUnpackedSampler3D(e,r,a);case 4:return this.getUnpackedSampler4D(e,r,a);case 5:return this.getUnpackedSampler5D(e,r,a);case 6:return this.getUnpackedSampler6D(e,r,a);default:throw new Error(`Unsupported dimension ${i.length}-D`)}}getPackedSamplerScalar(e,r){let a=H(this.context.glContext.version),i=` vec4 ${e}() { return ${a.texture2D}(${r}, halfCR); } `;return new R(i)}getPackedSampler1D(e,r,a){let i=[a.width,a.height],l=[i[1],i[0]],n=H(this.context.glContext.version),o=`vec4 ${e}(int index) { vec2 uv = packedUVfrom1D( ${l[0]}, ${l[1]}, index); return ${n.texture2D}(${r}, uv); }`;return new R(o,["coordinates.packedUVfrom1D"])}getPackedSampler2D(e,r,a){let i=a.unpackedShape,l=[a.width,a.height],n=H(this.context.glContext.version),o=l[0],p=l[1];if(l!=null&&hr.arraysEqual(i,l)){let s=`vec4 ${e}(int row, int col) { vec2 uv = (vec2(col, row) + halfCR) / vec2(${p}.0, ${o}.0); return ${n.texture2D}(${r}, uv); }`;return new R(s)}let c=l,t=Math.ceil(i[1]/2),u=`vec4 ${e}(int row, int col) { vec2 uv = packedUVfrom2D(${c[1]}, ${c[0]}, ${t}, row, col); return ${n.texture2D}(${r}, uv); }`;return new R(u,["coordinates.packedUVfrom2D"])}getPackedSampler3D(e,r,a){let i=a.unpackedShape,l=[a.width,a.height],n=[l[0],l[1]],o=H(this.context.glContext.version);if(i[0]===1){let d=i.slice(1),f=[1,2],b=$r(i,d),y=["b","row","col"],v=JSON.parse(JSON.stringify(a));v.unpackedShape=b;let E=this.getPackedSamplerFromInput(e,r,v),T=`${E.routineBody} vec4 ${e}(int b, int row, int col) { return ${e}(${kr(y,f)}); } `;return new R(T,E.dependencies)}let p=n[0],c=n[1],t=Math.ceil(i[2]/2),u=t*Math.ceil(i[1]/2),s=`vec4 ${e}(int b, int row, int col) { vec2 uv = packedUVfrom3D( ${c}, ${p}, ${u}, ${t}, b, row, col); return ${o.texture2D}(${r}, uv);}`;return new R(s,["coordinates.packedUVfrom3D"])}getPackedSamplerND(e,r,a){let i=a.unpackedShape,l=i.length,n=[a.width,a.height],o=H(this.context.glContext.version),p=[n[0],n[1]],c=p[1],t=p[0],u=Math.ceil(i[l-1]/2),s=u*Math.ceil(i[l-2]/2),d="int b, int row, int col",f=`b * ${s} + (row / 2) * ${u} + (col / 2)`;for(let y=2;y{let i=this.context.inputTextureLayouts[a],l=(i.unpackedShape.length>0?i.unpackedShape:i.shape).length,n=`_${r}`;e[n]=new R(this.getValueFromSingle(r,l,i.width,i.height,!1),[`shapeUtils.indicesToOffset${n}`,"coordinates.offsetToCoords","fragcolor.getColorAsFloat"]),n=n+"_T",e[n]=new R(this.getValueFromSingle(r,l,i.width,i.height,!0),[`shapeUtils.indicesToOffset${n}`,"coordinates.offsetToCoords","fragcolor.getColorAsFloat"])}),e}getValueFromSingle(e,r,a,i,l){let n=`_${e}`;l&&(n=n+"_T");let o=H(this.context.glContext.version);return` float ${n}(int m[${r}]) { int offset = indicesToOffset${n}(m); vec2 coords = offsetToCoords(offset, ${a}, ${i}); float value = getColorAsFloat(${o.texture2D}(${e}, coords)); return value; } `}getPackedValueFrom(e,r,a,i,l){let n=`_${e}_Pack`;l&&(n=n+"_T");let o=H(this.context.glContext.version);return` vec4 ${n}(int m[${r}]) { int offset = indicesToOffset_${e}(m); vec2 coords = offsetToCoords(offset, ${a}, ${i}); return ${o.texture2D}(${e}, coords); } `}}}),fo,tp=L(()=>{Wt(),fo=class Tn extends dt{constructor(r){super(r)}getFunctions(){return{...this.encodeFloat32(),...this.decodeFloat32()}}getCustomTypes(){return{}}encodeFloat32(){return{encode:new R(`highp vec4 encode(highp float f) { return vec4(f, 0.0, 0.0, 0.0); } `)}}decodeFloat32(){return{decode:new R(`highp float decode(highp vec4 rgba) { return rgba.r; } `)}}encodeUint8(){let r=Tn.isLittleEndian()?"rgba.rgba=rgba.abgr;":"";return{encode:new R(` highp vec4 encode(highp float f) { highp float F = abs(f); highp float Sign = step(0.0,-f); highp float Exponent = floor(log2(F)); highp float Mantissa = (exp2(- Exponent) * F); Exponent = floor(log2(F) + 127.0) + floor(log2(Mantissa)); highp vec4 rgba; rgba[0] = 128.0 * Sign + floor(Exponent*exp2(-1.0)); rgba[1] = 128.0 * mod(Exponent,2.0) + mod(floor(Mantissa*128.0),128.0); rgba[2] = floor(mod(floor(Mantissa*exp2(23.0 -8.0)),exp2(8.0))); rgba[3] = floor(exp2(23.0)*mod(Mantissa,exp2(-15.0))); ${r} rgba = rgba / 255.0; // values need to be normalized to [0,1] return rgba; } `)}}decodeUint8(){let r=Tn.isLittleEndian()?"rgba.rgba=rgba.abgr;":"";return{decode:new R(` highp float decode(highp vec4 rgba) { rgba = rgba * 255.0; // values need to be de-normalized from [0,1] to [0,255] ${r} highp float Sign = 1.0 - step(128.0,rgba[0])*2.0; highp float Exponent = 2.0 * mod(rgba[0],128.0) + step(128.0,rgba[1]) - 127.0; highp float Mantissa = mod(rgba[1],128.0)*65536.0 + rgba[2]*256.0 +rgba[3] + float(0x800000); highp float Result = Sign * exp2(Exponent) * (Mantissa * exp2(-23.0 )); return Result; } `)}}static isLittleEndian(){let r=new ArrayBuffer(4),a=new Uint32Array(r),i=new Uint8Array(r);if(a[0]=3735928559,i[0]===239)return!0;if(i[0]===222)return!1;throw new Error("unknown endianness")}}}),co,rp=L(()=>{Wt(),we(),co=class extends dt{constructor(e){super(e)}getFunctions(){return{...this.setFragColor(),...this.getColorAsFloat()}}getCustomTypes(){return{}}setFragColor(){let e=H(this.context.glContext.version);return{setFragColor:new R(` void setFragColor(float value) { ${e.output} = encode(value); } `,["encoding.encode"])}}getColorAsFloat(){return{getColorAsFloat:new R(` float getColorAsFloat(vec4 color) { return decode(color); } `,["encoding.decode"])}}}}),po,np=L(()=>{Wt(),po=class nr extends dt{constructor(r){super(r)}getFunctions(){return{...this.bcastIndex(),...this.bcastMatmulIndex(),...this.offsetToIndices(),...this.indicesToOffset(),...this.incrementIndices()}}getCustomTypes(){return{}}bcastIndex(){let r=this.context.outputTextureLayout.shape.length,a={};return this.context.programInfo.inputNames.forEach((i,l)=>{let n=this.context.inputTextureLayouts[l].unpackedShape;if(n.length<=r){let o=n.length,p=r-o,c=`bcastIndices_${i}`,t="";for(let s=0;s{let n=this.context.inputTextureLayouts[l].shape;if(!(n.length<2||n.length>r)){let o=n.length,p=r-o,c=`bcastMatmulIndices_${i}`,t="";for(let s=0;s{let l=this.context.inputTextureLayouts[i].shape,n=this.context.inputTextureLayouts[i].strides,o=l.length,p=`indicesToOffset_${a}`;r[p]=new R(nr.indexToOffsetSingle(p,o,n)),p=`indicesToOffset_${a}_T`,r[p]=new R(nr.indexToOffsetSingle(p,o,n.slice().reverse()))}),r}static indexToOffsetSingle(r,a,i){let l="";for(let n=a-1;n>=0;--n)l+=` offset += indices[${n}] * ${i[n]}; `;return` int ${r}(int indices[${a}]) { int offset = 0; ${l} return offset; } `}offsetToIndices(){let r={};return this.context.programInfo.inputNames.forEach((a,i)=>{let l=this.context.inputTextureLayouts[i].shape,n=this.context.inputTextureLayouts[i].strides,o=l.length,p=`offsetToIndices_${a}`;r[p]=new R(nr.offsetToIndicesSingle(p,o,n)),p=`offsetToIndices_${a}_T`,r[p]=new R(nr.offsetToIndicesSingle(p,o,n.slice().reverse()))}),r}static offsetToIndicesSingle(r,a,i){let l=[];for(let n=0;n{let l=this.context.inputTextureLayouts[i].shape,n=l.length,o=`incrementIndices_${a}`,p="";for(let t=0;t= 0; --i) { if(i > axis) continue; indices[i] += 1; if(indices[i] < shape[i]) { break; } indices[i] = 0; } } `;r[o]=new R(c)}),r}}}),ho,op=L(()=>{Wt(),ho=class extends dt{constructor(e){super(e)}getCustomTypes(){return{}}getFunctions(){return{...this.binaryVecFunctions(),...this.copyVec(),...this.setVecItem(),...this.getVecItem()}}binaryVecFunctions(){let e=this.context.outputTextureLayout.shape.length,r={add:"+=",sub:"-=",mul:"*=",div:"/="},a={};for(let i in r){let l=`${i}Vec`,n="";for(let p=0;p{ep(),tp(),rp(),np(),op(),Wi={encoding:fo,fragcolor:co,vec:ho,shapeUtils:po,coordinates:lo}}),mo,ap=L(()=>{Wt(),Zc(),ip(),we(),mo=class{constructor(e,r,a,i){this.libs={},this.glslLibRoutineDependencyGraph={},this.context=new Zn(e,r,a,i),Object.keys(Wi).forEach(n=>{let o=new Wi[n](this.context);this.libs[n]=o});let l=this.glslLibRoutineDependencyGraph;for(let n in this.libs){let o=this.libs[n].getFunctions();for(let p in o){let c=n+"."+p,t;l[c]?(t=l[c],t.routineBody=o[p].routineBody):(t=new cn(c,o[p].routineBody),l[c]=t);let u=o[p].dependencies;if(u)for(let s=0;s{let i=a.split(".")[1];e.indexOf(i)!==-1&&r.push(this.glslLibRoutineDependencyGraph[a])}),Qn.returnOrderedNodes(r)}getUniforms(e,r){let a=[];if(e)for(let i of e)a.push(`uniform sampler2D ${i};`);if(r)for(let i of r)a.push(`uniform ${i.type} ${i.name}${i.arrayLength?`[${i.arrayLength}]`:""};`);return a.join(` `)}}}),bo,sp=L(()=>{Ot(),lt(),ap(),we(),bo=class{constructor(e,r,a){this.profiler=e,this.glContext=r,this.textureLayoutStrategy=a,this.repo=new Map,this.attributesBound=!1}getArtifact(e){return this.repo.get(e)}setArtifact(e,r){this.repo.set(e,r)}run(e,r,a){this.profiler.event("op",`ProgramManager.run ${e.programInfo.name??"unknown kernel"}`,()=>{let i=this.glContext.gl,l=e.program;i.useProgram(l);try{this.bindOutput(a),this.attributesBound||this.bindAttributes(e.attribLocations),this.bindUniforms(e.uniformLocations,e.programInfo.variables??[],r)}catch(n){throw ce.error("ProgramManager",e.programInfo.shaderSource),n}this.profiler.event("backend","GlContext.draw()",()=>{this.glContext.draw()})},this.glContext)}dispose(){this.vertexShader&&this.glContext.deleteShader(this.vertexShader),this.repo.forEach(e=>this.glContext.deleteProgram(e.program))}build(e,r,a){return this.profiler.event("backend","ProgramManager.build",()=>{let i=new mo(this.glContext,e,r,a),l=i.preprocess(),n=this.compile(l);return{programInfo:e,program:n,uniformLocations:this.getUniformLocations(n,i.context.programInfo.inputNames,i.context.programInfo.variables),attribLocations:this.getAttribLocations(n)}})}compile(e){if(!this.vertexShader){ce.verbose("ProrgramManager","Compiling and caching Vertex shader for the first time");let i=Nu(this.glContext.version);this.vertexShader=this.glContext.compileShader(i,this.glContext.gl.VERTEX_SHADER)}Z.debug&&ce.verbose("ProrgramManager",`FragShader: ${e} `);let r=this.glContext.compileShader(e,this.glContext.gl.FRAGMENT_SHADER),a=this.glContext.createProgram(this.vertexShader,r);return this.glContext.deleteShader(r),a}bindOutput(e){let r=e.width,a=e.height;ce.verbose("ProrgramManager",`Binding output texture to Framebuffer: w/h=${r}/${a}, shape=${e.shape}, type=${e.tensor.type}`),this.glContext.attachFramebuffer(e.texture,r,a)}bindAttributes(e){let r=e.position,a=e.textureCoord;this.glContext.setVertexAttributes(r,a),this.attributesBound=!0}bindUniforms(e,r,a){var n;let i=this.glContext.gl,l=0;for(let{name:o,type:p,location:c,arrayLength:t}of e){let u=(n=r.find(s=>s.name===o))==null?void 0:n.data;if(p!=="sampler2D"&&!u)throw new Error(`variable '${o}' does not have data defined in program info`);switch(p){case"sampler2D":this.bindTexture(a[l],c,l),l++;break;case"float":t?i.uniform1fv(c,u):i.uniform1f(c,u);break;case"int":t?i.uniform1iv(c,u):i.uniform1i(c,u);break;default:throw new Error(`Uniform not implemented: ${p}`)}}}bindTexture(e,r,a){this.glContext.bindTextureToUniform(e.texture,a,r)}getAttribLocations(e){return{position:this.getAttribLocation(e,"position"),textureCoord:this.getAttribLocation(e,"textureCoord")}}getUniformLocations(e,r,a){let i=[];if(r)for(let l of r)i.push({name:l,type:"sampler2D",location:this.getUniformLocation(e,l)});if(a)for(let l of a)i.push({...l,location:this.getUniformLocation(e,l.name)});return i}getUniformLocation(e,r){let a=this.glContext.gl.getUniformLocation(e,r);if(a===null)throw new Error(`Uniform ${r} not found.`);return a}getAttribLocation(e,r){return this.glContext.gl.getAttribLocation(e,r)}}}),go,up=L(()=>{lt(),ln(),go=class{constructor(e,r,a,i){this.glContext=e,this.layoutStrategy=r,this.profiler=a,this.config=i,this.pendingRead=new Map,i.reuseTextures&&(this.inUseTextures=new Map,this.idleTextures=new Map,this.textureLookup=new Map)}createTextureFromLayout(e,r,a,i){let l=this.toEncoderType(e),n=this.glContext.getEncoder(l,r.channels||1,i);if(r.isPacked&&i===1)throw new Error("not implemented");let o=r.width,p=r.height,c,t;if(this.config.reuseTextures){c=`${o}x${p}_${n.format}_${n.internalFormat}_${n.textureType}`,t=this.inUseTextures.get(c),t||(t=[],this.inUseTextures.set(c,t));let s=this.idleTextures.get(c);if(s&&s.length>0){let d=s.pop();return t.push(d),i===1&&this.glContext.updateTexture(d,o,p,n,this.toTextureData(e,a)),d}}ce.verbose("TextureManager",`Creating new texture of size ${r.width}x${r.height}`);let u=this.glContext.allocateTexture(o,p,n,this.toTextureData(e,a));return this.config.reuseTextures&&(t.push(u),this.textureLookup.set(u,c)),u}readTexture(e,r,a){return a||(a=1),this.profiler.event("backend","TextureManager.readTexture",()=>{let i=e.shape.reduce((n,o)=>n*o)*a,l=this.glContext.readTexture(e.texture,e.width,e.height,i,this.toEncoderType(r),a);return this.toTensorData(r,l)})}async readTextureAsync(e,r,a){let i=e.tensor.dataId;if(a||(a=1),this.pendingRead.has(i)){let l=this.pendingRead.get(i);return new Promise(n=>l==null?void 0:l.push(n))}return this.profiler.event("backend","TextureManager.readTextureAsync",async()=>{this.pendingRead.set(i,[]);let l=e.shape.reduce((c,t)=>c*t)*a;await this.glContext.createAndWaitForFence();let n=this.glContext.readTexture(e.texture,e.width,e.height,l,this.toEncoderType(r),a),o=this.toTensorData(r,n),p=this.pendingRead.get(i);return this.pendingRead.delete(i),p==null||p.forEach(c=>c(o)),o})}readUint8TextureAsFloat(e){return this.profiler.event("backend","TextureManager.readUint8TextureAsFloat",()=>{let r=e.shape.reduce((i,l)=>i*l),a=this.glContext.readTexture(e.texture,e.width,e.height,r*4,"byte",4);return new Float32Array(a.buffer,a.byteOffset,r)})}releaseTexture(e,r){let a;if(this.config.reuseTextures&&(a=this.textureLookup.get(e.texture),a)){r&&this.textureLookup.delete(a);let i=this.inUseTextures.get(a);if(i){let l=i.indexOf(e.texture);if(l!==-1){i.splice(l,1);let n=this.idleTextures.get(a);n||(n=[],this.idleTextures.set(a,n)),n.push(e.texture)}}}(!a||r)&&(ce.verbose("TextureManager",`Deleting texture of size ${e.width}x${e.height}`),this.glContext.deleteTexture(e.texture))}toTensorData(e,r){switch(e){case"int16":return r instanceof Int16Array?r:Int16Array.from(r);case"int32":return r instanceof Int32Array?r:Int32Array.from(r);case"int8":return r instanceof Int8Array?r:Int8Array.from(r);case"uint16":return r instanceof Uint16Array?r:Uint16Array.from(r);case"uint32":return r instanceof Uint32Array?r:Uint32Array.from(r);case"uint8":case"bool":return r instanceof Uint8Array?r:Uint8Array.from(r);case"float32":return r instanceof Float32Array?r:Float32Array.from(r);case"float64":return r instanceof Float64Array?r:Float64Array.from(r);default:throw new Error(`TensorData type ${e} is not supported`)}}toTextureData(e,r){if(r)return r instanceof Float32Array?r:new Float32Array(r)}toEncoderType(e){return"float"}clearActiveTextures(){this.glContext.clearActiveTextures()}}}),yo,lp=L(()=>{lt(),_s(),el(),Xc(),sp(),Vi(),up(),yo=class{constructor(e,r){this.backend=e,this.context=r,this.layoutStrategy=new uo(e.glContext.maxTextureSize),this.programManager=new bo(this.context.profiler,e.glContext,this.layoutStrategy),this.textureManager=new go(e.glContext,this.layoutStrategy,this.context.profiler,{reuseTextures:e.textureCacheMode==="full"}),this.packedTextureDataCache=new Map,this.unpackedTextureDataCache=new Map,this.pack=e.pack,this.pack2unpackMap=new Map,this.unpack2packMap=new Map}createInferenceHandler(){return new Jn(this)}onGraphInitialized(e){let r=e.getValues().filter(a=>a.from===-1&&a.tensor).map(a=>a.tensor.dataId);this.initializers=new Set(r)}isInitializer(e){return this.initializers?this.initializers.has(e):!1}addInitializer(e){this.initializers.add(e)}getTextureData(e,r){return r?this.packedTextureDataCache.get(e):this.unpackedTextureDataCache.get(e)}setTextureData(e,r,a=!1){ce.verbose("WebGLSessionHandler","Storing Texture data in cache"),a?this.packedTextureDataCache.set(e,r):this.unpackedTextureDataCache.set(e,r)}dispose(){this.programManager.dispose(),this.textureManager.clearActiveTextures(),this.packedTextureDataCache.forEach(e=>this.textureManager.releaseTexture(e,!0)),this.packedTextureDataCache=new Map,this.unpackedTextureDataCache.forEach(e=>this.textureManager.releaseTexture(e,!0)),this.unpackedTextureDataCache=new Map}resolve(e,r,a){let i=vs(e,r,Yc);return{impl:i.opImpl,context:i.opInit?i.opInit(e,a):e}}}});function jb(e){let r=0;for(;r{Ot(),ln(),ln(),Bt(),hn=class{constructor(e,r){this.frameBufferBound=!1,this.itemsToPoll=[],this.gl=e,this.version=r,this.getExtensions(),this.vertexbuffer=this.createVertexbuffer(),this.framebuffer=this.createFramebuffer(),this.queryVitalParameters()}allocateTexture(e,r,a,i){let l=this.gl,n=l.createTexture();l.bindTexture(l.TEXTURE_2D,n),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MIN_FILTER,l.NEAREST),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MAG_FILTER,l.NEAREST),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE);let o=i?a.encode(i,e*r):null;return l.texImage2D(l.TEXTURE_2D,0,a.internalFormat,e,r,0,a.format,a.textureType,o),this.checkError(),n}updateTexture(e,r,a,i,l){let n=this.gl;n.bindTexture(n.TEXTURE_2D,e);let o=i.encode(l,r*a);n.texSubImage2D(n.TEXTURE_2D,0,0,0,r,a,i.format,i.textureType,o),this.checkError()}attachFramebuffer(e,r,a){let i=this.gl;i.bindTexture(i.TEXTURE_2D,e),i.bindFramebuffer(i.FRAMEBUFFER,this.framebuffer),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,e,0),this.checkError(),i.viewport(0,0,r,a),i.scissor(0,0,r,a)}readTexture(e,r,a,i,l,n){let o=this.gl;n||(n=1),this.frameBufferBound||this.attachFramebuffer(e,r,a);let p=this.getEncoder(l,n),c=p.allocate(r*a);return o.bindTexture(o.TEXTURE_2D,e),o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,e,0),o.readPixels(0,0,r,a,o.RGBA,p.textureType,c),this.checkError(),p.decode(c,i)}isFramebufferReady(){return!0}getActiveTexture(){let e=this.gl;return`TEXTURE${e.getParameter(this.gl.ACTIVE_TEXTURE)-e.TEXTURE0}`}getTextureBinding(){return this.gl.getParameter(this.gl.TEXTURE_BINDING_2D)}getFramebufferBinding(){return this.gl.getParameter(this.gl.FRAMEBUFFER_BINDING)}setVertexAttributes(e,r){let a=this.gl;a.vertexAttribPointer(e,3,a.FLOAT,!1,20,0),a.enableVertexAttribArray(e),r!==-1&&(a.vertexAttribPointer(r,2,a.FLOAT,!1,20,12),a.enableVertexAttribArray(r)),this.checkError()}createProgram(e,r){let a=this.gl,i=a.createProgram();return a.attachShader(i,e),a.attachShader(i,r),a.linkProgram(i),i}compileShader(e,r){let a=this.gl,i=a.createShader(r);if(!i)throw new Error(`createShader() returned null with type ${r}`);if(a.shaderSource(i,e),a.compileShader(i),a.getShaderParameter(i,a.COMPILE_STATUS)===!1)throw new Error(`Failed to compile shader: ${a.getShaderInfoLog(i)} Shader source: ${e}`);return i}deleteShader(e){this.gl.deleteShader(e)}bindTextureToUniform(e,r,a){let i=this.gl;i.activeTexture(i.TEXTURE0+r),this.checkError(),i.bindTexture(i.TEXTURE_2D,e),this.checkError(),i.uniform1i(a,r),this.checkError()}draw(){this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4),this.checkError()}checkError(){if(Z.debug){let e=this.gl,r=e.getError(),a="";switch(r){case e.NO_ERROR:return;case e.INVALID_ENUM:a="INVALID_ENUM";break;case e.INVALID_VALUE:a="INVALID_VALUE";break;case e.INVALID_OPERATION:a="INVALID_OPERATION";break;case e.INVALID_FRAMEBUFFER_OPERATION:a="INVALID_FRAMEBUFFER_OPERATION";break;case e.OUT_OF_MEMORY:a="OUT_OF_MEMORY";break;case e.CONTEXT_LOST_WEBGL:a="CONTEXT_LOST_WEBGL";break;default:a=`Unknown WebGL Error: ${r.toString(16)}`}throw new Error(a)}}deleteTexture(e){this.gl.deleteTexture(e)}deleteProgram(e){this.gl.deleteProgram(e)}getEncoder(e,r,a=0){if(this.version===2)return new Xn(this.gl,r);switch(e){case"float":return a===1||this.isRenderFloat32Supported?new un(this.gl,r):new un(this.gl,r,this.textureHalfFloatExtension.HALF_FLOAT_OES);case"int":throw new Error("not implemented");case"byte":return new Kn(this.gl,r);default:throw new Error(`Invalid dataType: ${e}`)}}clearActiveTextures(){let e=this.gl;for(let r=0;rthis.isTimerResultAvailable(e)),this.getTimerResult(e)}async createAndWaitForFence(){let e=this.createFence(this.gl);return this.pollFence(e)}createFence(e){let r,a=e,i=a.fenceSync(a.SYNC_GPU_COMMANDS_COMPLETE,0);return e.flush(),i===null?r=()=>!0:r=()=>{let l=a.clientWaitSync(i,0,0);return l===a.ALREADY_SIGNALED||l===a.CONDITION_SATISFIED},{query:i,isFencePassed:r}}async pollFence(e){return new Promise(r=>{this.addItemToPoll(()=>e.isFencePassed(),()=>r())})}pollItems(){let e=jb(this.itemsToPoll.map(r=>r.isDoneFn));for(let r=0;r<=e;++r){let{resolveFn:a}=this.itemsToPoll[r];a()}this.itemsToPoll=this.itemsToPoll.slice(e+1)}async addItemToPoll(e,r){this.itemsToPoll.push({isDoneFn:e,resolveFn:r}),!(this.itemsToPoll.length>1)&&await mi(()=>(this.pollItems(),this.itemsToPoll.length===0))}}});function Hi(e){let r;if((!e||e==="webgl2")&&"webgl2"in Gr?r=Gr.webgl2:(!e||e==="webgl")&&"webgl"in Gr&&(r=Gr.webgl),!r)try{let i=Xb();r=cp(i,e)}catch{let i=Yb();r=cp(i,e)}e=e||r.version===1?"webgl":"webgl2";let a=r.gl;return Gr[e]=r,a.isContextLost()?(delete Gr[e],Hi(e)):(a.disable(a.DEPTH_TEST),a.disable(a.STENCIL_TEST),a.disable(a.BLEND),a.disable(a.DITHER),a.disable(a.POLYGON_OFFSET_FILL),a.disable(a.SAMPLE_COVERAGE),a.enable(a.SCISSOR_TEST),a.enable(a.CULL_FACE),a.cullFace(a.BACK),r)}function cp(e,r){let a={alpha:!1,depth:!1,antialias:!1,stencil:!1,preserveDrawingBuffer:!1,premultipliedAlpha:!1,failIfMajorPerformanceCaveat:!1},i,l=a;if((!r||r==="webgl2")&&(i=e.getContext("webgl2",l),i))try{return new hn(i,2)}catch(n){ce.warning("GlContextFactory",`failed to create WebGLContext using contextId 'webgl2'. Error: ${n}`)}if((!r||r==="webgl")&&(i=e.getContext("webgl",l)||e.getContext("experimental-webgl",l),i))try{return new hn(i,1)}catch(n){ce.warning("GlContextFactory",`failed to create WebGLContext using contextId 'webgl' or 'experimental-webgl'. Error: ${n}`)}throw new Error("WebGL is not supported")}function Yb(){if(typeof document>"u")throw new TypeError("failed to create canvas: document is not supported");let e=document.createElement("canvas");return e.width=1,e.height=1,e}function Xb(){if(typeof OffscreenCanvas>"u")throw new TypeError("failed to create offscreen canvas: OffscreenCanvas is not supported");return new OffscreenCanvas(1,1)}var Gr,pp=L(()=>{lt(),fp(),Gr={}}),To,dp=L(()=>{Ot(),lt(),lp(),pp(),To=class{get contextId(){return Z.webgl.contextId}set contextId(e){Z.webgl.contextId=e}get matmulMaxBatchSize(){return Z.webgl.matmulMaxBatchSize}set matmulMaxBatchSize(e){Z.webgl.matmulMaxBatchSize=e}get textureCacheMode(){return Z.webgl.textureCacheMode}set textureCacheMode(e){Z.webgl.textureCacheMode=e}get pack(){return Z.webgl.pack}set pack(e){Z.webgl.pack=e}get async(){return Z.webgl.async}set async(e){Z.webgl.async=e}initialize(){try{return this.glContext=Hi(this.contextId),typeof this.matmulMaxBatchSize!="number"&&(this.matmulMaxBatchSize=16),typeof this.textureCacheMode!="string"&&(this.textureCacheMode="full"),typeof this.pack!="boolean"&&(this.pack=!1),typeof this.async!="boolean"&&(this.async=!1),ce.setWithEnv(Z),Z.webgl.context||Object.defineProperty(Z.webgl,"context",{value:this.glContext.gl}),ce.verbose("WebGLBackend",`Created WebGLContext: ${typeof this.glContext} with matmulMaxBatchSize: ${this.matmulMaxBatchSize}; textureCacheMode: ${this.textureCacheMode}; pack: ${this.pack}; async: ${this.async}.`),!0}catch(e){return ce.warning("WebGLBackend",`Unable to initialize WebGLBackend. ${e}`),!1}}createSessionHandler(e){return new yo(this,e)}dispose(){this.glContext.dispose()}}});async function qi(e){if(e){let r=typeof e=="string"?[e]:e;for(let a of r){let i=hp.get(a);if(i)return i;let l=await Jb(a);if(l)return l}}else return qi(["webgl"]);throw new Error("no available backend to use")}async function Jb(e){let r=Kb;if(typeof r[e]<"u"&&Zb(r[e])){let a=r[e],i=a.initialize();if(typeof i=="object"&&"then"in i&&(i=await i),i)return hp.set(e,a),a}}function Zb(e){let r=e;return"initialize"in r&&typeof r.initialize=="function"&&"createSessionHandler"in r&&typeof r.createSessionHandler=="function"&&"dispose"in r&&typeof r.dispose=="function"}var hp,Kb,mp=L(()=>{dp(),hp=new Map,Kb={webgl:new To}}),ji,xo,bp=L(()=>{lt(),ji=class{constructor(e,r){this.op=e,this.node=r}},xo=class{constructor(e,r,a){this.graph=e,this.profiler=a,this.initialize(r)}initialize(e){this.profiler.event("session","ExecutionPlan.initialize",()=>{let r=this.graph.getNodes();if(r.length!==e.length)throw new Error("The size of nodes and OPs do not match.");this._ops=e.map((a,i)=>new ji(a,r[i])),this.reset(),this._starter=[],this._ops.forEach((a,i)=>{let l=!0;for(let n of a.node.inputs)if(!this._values[n]&&this.graph.getInputIndices().indexOf(n)===-1){l=!1;break}l&&this._starter.push(i)})})}reset(){this._values=this.graph.getValues().map(e=>e.tensor)}async execute(e,r){return this.profiler.event("session","ExecutionPlan.execute",async()=>{this.reset();let a=e.createInferenceHandler(),i=this.graph.getInputIndices();if(r.length!==i.length)throw new Error(`number of input tensors don't match the number of inputs to the model: actual: ${r.length} expected: ${i.length}`);r.forEach((t,u)=>{let s=i[u];this._values[s]=t});let l=this._starter.slice(0),n=this.graph.getValues(),o=this.graph.getNodes(),p=0;for(;pthis._values[y]);if(s.indexOf(void 0)!==-1)throw new Error(`unresolved input detected: op: ${u.node}`);let d=s;ce.verbose("ExecPlan",`Runing op:${u.node.name} (${d.map((y,v)=>`'${u.node.inputs[v]}': ${y.type}[${y.dims.join(",")}]`).join(", ")})`);let f=await this.profiler.event("node",u.node.name,async()=>u.op.impl(a,d,u.op.context));if(f.length!==u.node.outputs.length)throw new Error("the size of output does not match model definition.");f.forEach((y,v)=>{let E=u.node.outputs[v];if(this._values[E])throw new Error(`output [${E}] already has value: op:${u.node.name}`);this._values[E]=y});let b=new Set;f.forEach((y,v)=>{let E=u.node.outputs[v];for(let T of n[E].to){let $=o[T],F=!0;for(let C of $.inputs)if(!this._values[C]){F=!1;break}F&&b.add(T)}}),l.push(...b)}let c=[];for(let t=0;t{tn(),oe=Ar(Cr()),yr(),fe(),bt=V.experimental.fbs,mn=class or{constructor(r){if(this._attributes=new Map,r!=null){for(let a of r)a instanceof oe.onnx.AttributeProto?this._attributes.set(a.name,[or.getValue(a),or.getType(a)]):a instanceof bt.Attribute&&this._attributes.set(a.name(),[or.getValue(a),or.getType(a)]);if(this._attributes.size$e.fromProto(l));if(r instanceof bt.Attribute)return i.map(l=>$e.fromOrtTensor(l))}return a===oe.onnx.AttributeProto.AttributeType.STRING&&r instanceof oe.onnx.AttributeProto?sn(i):a===oe.onnx.AttributeProto.AttributeType.STRINGS&&r instanceof oe.onnx.AttributeProto?i.map(sn):i}static getValueNoCheck(r){return r instanceof oe.onnx.AttributeProto?this.getValueNoCheckFromOnnxFormat(r):this.getValueNoCheckFromOrtFormat(r)}static getValueNoCheckFromOnnxFormat(r){switch(r.type){case oe.onnx.AttributeProto.AttributeType.FLOAT:return r.f;case oe.onnx.AttributeProto.AttributeType.INT:return r.i;case oe.onnx.AttributeProto.AttributeType.STRING:return r.s;case oe.onnx.AttributeProto.AttributeType.TENSOR:return r.t;case oe.onnx.AttributeProto.AttributeType.GRAPH:return r.g;case oe.onnx.AttributeProto.AttributeType.FLOATS:return r.floats;case oe.onnx.AttributeProto.AttributeType.INTS:return r.ints;case oe.onnx.AttributeProto.AttributeType.STRINGS:return r.strings;case oe.onnx.AttributeProto.AttributeType.TENSORS:return r.tensors;case oe.onnx.AttributeProto.AttributeType.GRAPHS:return r.graphs;default:throw new Error(`unsupported attribute type: ${oe.onnx.AttributeProto.AttributeType[r.type]}`)}}static getValueNoCheckFromOrtFormat(r){switch(r.type()){case bt.AttributeType.FLOAT:return r.f();case bt.AttributeType.INT:return r.i();case bt.AttributeType.STRING:return r.s();case bt.AttributeType.TENSOR:return r.t();case bt.AttributeType.GRAPH:return r.g();case bt.AttributeType.FLOATS:return r.floatsArray();case bt.AttributeType.INTS:{let a=[];for(let i=0;i{gp(),tn(),Xi=Ar(Cr()),yr(),fe(),wo=V.experimental.fbs,Ki={from:(e,r)=>new Yi(e,r)},Mt=class{constructor(e){this._from=void 0,this._to=[],this.tensor=void 0,this.type=void 0,e&&(this.type=We.tensorValueTypeFromProto(e.type.tensorType))}get from(){return this._from}get to(){return this._to}},vo=class{constructor(e,r){e instanceof Xi.onnx.NodeProto?(this.name=e.name,this.opType=e.opType,this.attributes=new mn(e.attribute)):e instanceof wo.Node&&(this.name=r??e.name(),this.opType=e.opType(),this.attributes=new mn(We.tensorAttributesFromORTFormat(e))),this.inputs=[],this.outputs=[],this.executeNode=!0}},Yi=class{constructor(e,r){if(!e)throw new TypeError("graph is empty");this.buildGraph(e),this.transformGraph(r),this.checkIsAcyclic()}getInputIndices(){return this._allInputIndices}getInputNames(){return this._allInputNames}getOutputIndices(){return this._allOutputIndices}getOutputNames(){return this._allOutputNames}getValues(){return this._allData}getNodes(){return this._nodes}buildGraph(e){if(e instanceof Xi.onnx.GraphProto)this.buildGraphFromOnnxFormat(e);else if(e instanceof wo.Graph)this.buildGraphFromOrtFormat(e);else throw new TypeError("Graph type is not supported.")}buildGraphFromOnnxFormat(e){let r=new Map;this._allData=[],this._allInputIndices=[],this._allInputNames=[],this._allOutputIndices=[],this._allOutputNames=[],this._nodes=[];let a=new Map;if(!e.input)throw new Error("missing information in graph: input");let i=[];for(let l of e.input){if(r.has(l.name))throw new Error(`duplicated input name: ${l.name}`);let n=this._allData.push(new Mt(l))-1;r.set(l.name,n),i.push(l.name)}if(!e.initializer)throw new Error("missing information in graph: initializer");for(let l of e.initializer){let n=r.get(l.name);if(n===void 0){let o=new Mt;o.type={shape:{dims:We.tensorDimsFromProto(l.dims)},tensorType:We.tensorDataTypeFromProto(l.dataType)},n=this._allData.push(o)-1,r.set(l.name,n)}this._allData[n]._from=-1,this._allData[n].tensor=$e.fromProto(l)}for(let l=0;l"u"&&(c=this._allData.push(new Mt)-1,r.set(p,c)),n.outputs.push(c),this._allData[c]._from!==void 0)throw new Error(`multiple nodes output to one data value: ${c}`);if(this._allData[c]._from=l,o.opType==="Constant"){if(!o.attribute||o.attribute.length!==1||!o.attribute[0].t)throw new Error("missing attributes or missing tensor value in attributes for this Constant operator");if(!o.output||o.output.length!==1)throw new Error("missing output or incorrect number of outputs for this Constant operator");n.outputs.pop(),n.executeNode=!1,this._allData[c]._from=-1,this._allData[c].tensor=$e.fromProto(o.attribute[0].t)}}}for(let l=0;l"u"){if(p===""&&(o.input.length===3||o.input.length===4)&&o.opType==="Resize")continue;throw new Error(`unrecognized input '${p}' for node: ${o.name}`)}n.inputs.push(c),this._allData[c]._to.push(l)}}return!0}buildGraphFromOrtFormat(e){var l,n,o;let r=new Map;this._allData=[],this._allInputIndices=[],this._allInputNames=[],this._allOutputIndices=[],this._allOutputNames=[],this._nodes=[];let a=new Map,i=[];for(let p=0;p"u"&&(d=this._allData.push(new Mt)-1,r.set(s,d)),c.outputs.push(d),this._allData[d]._from!==void 0)throw new Error(`multiple nodes output to one data value: ${d}`);if(this._allData[d]._from=p,t.opType()==="Constant"){if(t.attributesLength()!==1||!t.attributes(0).t())throw new Error("missing attributes or missing tensor value in attributes for this Constant operator");if(t.outputsLength()!==1)throw new Error("missing output or incorrect number of outputs for this Constant operator");c.outputs.pop(),c.executeNode=!1,this._allData[d]._from=-1,this._allData[d].tensor=$e.fromOrtTensor(t.attributes(0).t())}}}for(let p=0;p"u")throw new Error(`unrecognized input '${s}' for node: ${t.name()}`);c.inputs.push(d),this._allData[d]._to.push(p)}}}checkIsAcyclic(){let e=new Set;this._allInputIndices.forEach(i=>{this._allData[i]._to.forEach(l=>{e.add(l)})});let r=Array.from(e),a=new Array(this._nodes.length).fill("white");for(;r.length>0;){let i=r.pop();a[i]==="gray"?a[i]="black":(r.push(i),a[i]="gray",this._nodes[i].outputs.forEach(l=>{let n=this._allData[l];if(typeof n.tensor<"u")throw new Error("node outputs should not be initialized");if(n._from!==i)throw new Error("from property of the Value object doesn't match index of Node being processed");n._to.forEach(o=>{if(a[o]==="gray")throw new Error("model graph is cyclic");a[o]==="white"&&r.push(o)})}))}}transformGraph(e){this.removeAllIdentityNodes(),this.removeAllDropoutNodes(),this.fuseConvActivationNodes(),e&&e.transformGraph(this),this.finalizeGraph()}finalizeGraph(){let e=0,r=new Array(this._nodes.length,0),a=0;for(let i=0;i{this._allData[l]._from=-2});this._nodes.splice(a,this._nodes.length-a);for(let i=0;i=0)l._to[n]=r[l._to[n]];else throw new Error("Trying to update a removed node")}e=0;for(let i=0;i0){let l=-1;this._allData[i].from!==void 0&&this._allData[i].from!==-1?(l=this._nodes[this._allData[i].from].outputs.indexOf(i+e),l!==-1&&(this._nodes[this._allData[i].from].outputs[l]=i)):(l=this._allInputIndices.indexOf(i+e),l!==-1&&(this._allInputIndices[l]=i)),this._allData[i].to.forEach(n=>{l=this._nodes[n].inputs.indexOf(i+e),l!==-1&&(this._nodes[n].inputs[l]=i)}),this._allData[i].to.length===0&&(l=this._allOutputIndices.indexOf(i+e),l!==-1&&(this._allOutputIndices[l]=i))}}}deleteNode(e){let r=this._nodes[e];if(r.outputs.length>1){for(let o=1;o0)throw new Error("Node deletion with more than one output connected to other nodes is not supported. ")}r.executeNode=!1;let a=r.inputs[0],i=r.outputs[0],l=this._allData[i].to;for(let o=0;o0)for(let o of l){let p=this._nodes[o].inputs.indexOf(i);if(p===-1)throw new Error("The Node object doesn't have the output Value in it's 'inputs' property ");this._nodes[o].inputs[p]=a,this._allData[a].to.push(o)}}removeAllDropoutNodes(){let e=0;for(let r of this._nodes){if(r.opType==="Dropout"){if(r.inputs.length!==1)throw new Error("Dropout nodes should only contain one input. ");if(r.outputs.length!==1&&r.outputs.length!==2)throw new Error("Dropout nodes should contain either 1 or 2 output(s)");if(r.outputs.length===2&&this._allData[r.outputs[1]]._to.length!==0)throw new Error("Dropout nodes's second output should not be referenced by other nodes");this.deleteNode(e)}e++}}removeAllIdentityNodes(){let e=0;for(let r of this._nodes)r.opType==="Identity"&&this.deleteNode(e),e++}isActivation(e){switch(e.opType){case"Relu":case"Sigmoid":case"Clip":return!0;default:return!1}}fuseConvActivationNodes(){for(let e of this._nodes)if(e.opType==="Conv"){let r=this._allData[e.outputs[0]]._to;if(r.length===1&&this.isActivation(this._nodes[r[0]])){let a=this._nodes[r[0]];if(a.opType==="Clip")if(a.inputs.length===1)try{e.attributes.set("activation_params","floats",[a.attributes.getFloat("min"),a.attributes.getFloat("max")])}catch{e.attributes.set("activation_params","floats",[br,gr])}else if(a.inputs.length>=3&&this._allData[a.inputs[1]].tensor!==void 0&&this._allData[a.inputs[2]].tensor!==void 0)e.attributes.set("activation_params","floats",[this._allData[a.inputs[1]].tensor.floatData[0],this._allData[a.inputs[2]].tensor.floatData[0]]);else continue;e.attributes.set("activation","string",a.opType),this.deleteNode(r[0])}}}}}),Tp,Qb,_o,xp=L(()=>{zn(),yp(),tn(),Tp=Ar(Cr()),fe(),Qb=V.experimental.fbs,_o=class{constructor(){}load(e,r,a){let i;if(!a)try{this.loadFromOnnxFormat(e,r);return}catch(l){if(a!==void 0)throw l;i=l}try{this.loadFromOrtFormat(e,r)}catch(l){throw a!==void 0?l:new Error(`Failed to load model as ONNX format: ${i} as ORT format: ${l}`)}}loadFromOnnxFormat(e,r){let a=Tp.onnx.ModelProto.decode(e);if(it.longToNumber(a.irVersion)<3)throw new Error("only support ONNX model with IR_VERSION>=3");this._opsets=a.opsetImport.map(i=>({domain:i.domain,version:it.longToNumber(i.version)})),this._graph=Ki.from(a.graph,r)}loadFromOrtFormat(e,r){let a=new _.ByteBuffer(e),i=Qb.InferenceSession.getRootAsInferenceSession(a).model();if(it.longToNumber(i.irVersion())<3)throw new Error("only support ONNX model with IR_VERSION>=3");this._opsets=[];for(let l=0;l{mp(),bp(),lt(),xp(),Oo=class{constructor(e={}){this._initialized=!1,this.backendHint=e.backendHint,this.profiler=Gn.create(e.profiler),this.context={profiler:this.profiler,graphInputTypes:[],graphInputDims:[]}}get inputNames(){return this._model.graph.getInputNames()}get outputNames(){return this._model.graph.getOutputNames()}startProfiling(){this.profiler.start()}endProfiling(){this.profiler.stop()}async loadModel(e,r,a){await this.profiler.event("session","Session.loadModel",async()=>{let i=await qi(this.backendHint);if(this.sessionHandler=i.createSessionHandler(this.context),this._model=new _o,typeof e=="string"){let l=e.endsWith(".ort");if(typeof process<"u"&&process.versions&&process.versions.node){let n=await(void 0)(e);this.initialize(n,l)}else{let n=await(await fetch(e)).arrayBuffer();this.initialize(new Uint8Array(n),l)}}else if(ArrayBuffer.isView(e))this.initialize(e);else{let l=new Uint8Array(e,r||0,a||e.byteLength);this.initialize(l)}})}initialize(e,r){if(this._initialized)throw new Error("already initialized");this.profiler.event("session","Session.initialize",()=>{let a=this.sessionHandler.transformGraph?this.sessionHandler:void 0;this._model.load(e,a,r),this.sessionHandler.onGraphInitialized&&this.sessionHandler.onGraphInitialized(this._model.graph),this.initializeOps(this._model.graph),this._executionPlan=new xo(this._model.graph,this._ops,this.profiler)}),this._initialized=!0}async run(e){if(!this._initialized)throw new Error("session not initialized yet");return this.profiler.event("session","Session.run",async()=>{let r=this.normalizeAndValidateInputs(e),a=await this._executionPlan.execute(this.sessionHandler,r);return this.createOutput(a)})}normalizeAndValidateInputs(e){let r=this._model.graph.getInputNames();if(Array.isArray(e)){if(e.length!==r.length)throw new Error(`incorrect input array length: expected ${r.length} but got ${e.length}`)}else{if(e.size!==r.length)throw new Error(`incorrect input map size: expected ${r.length} but got ${e.size}`);let a=new Array(e.size),i=0;for(let l=0;l{Ot(),yr(),Io=class{constructor(e){this.session=e,this.inputNames=this.session.inputNames,this.outputNames=this.session.outputNames}async dispose(){}async run(e,r,a){let i=new Map;for(let o in e)if(Object.hasOwnProperty.call(e,o)){let p=e[o];i.set(o,new $e(p.dims,p.type,void 0,void 0,p.data))}let l=await this.session.run(i),n={};return l.forEach((o,p)=>{n[p]=new Me(o.type,o.data,o.dims)}),n}startProfiling(){this.session.startProfiling()}endProfiling(){this.session.endProfiling()}}}),_p={};Sr(_p,{onnxjsBackend:()=>tg});var Ji,tg,Op=L(()=>{wp(),vp(),Ji=class{async init(){}async createInferenceSessionHandler(e,r){let a=new Oo(r);return typeof e=="string"?await a.loadModel(e):await a.loadModel(e),new Io(a)}},tg=new Ji}),Zi={};Sr(Zi,{createReadStream:()=>Ip,readFile:()=>rg,readFileSync:()=>ng});var rg,ng,Ip,Qi=L(()=>{rg=void 0,ng=void 0,Ip=void 0}),ea={};Sr(ea,{join:()=>og});var og,ta=L(()=>{og=void 0}),Pp=me((e,r)=>{var a=(()=>{var l;var i=typeof document<"u"?(l=document.currentScript)==null?void 0:l.src:void 0;return typeof __filename<"u"&&(i||(i=__filename)),function(n={}){var o=n,p,c,t=new Promise((g,x)=>{p=g,c=x}),u=Object.assign({},o),s="./this.program",d=typeof window=="object",f=typeof importScripts=="function",b=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",y="",v,E,T;if(b){var $=(Qi(),ar(Zi)),F=(ta(),ar(ea));y=f?F.dirname(y)+"/":__dirname+"/",v=(g,x)=>(g=Ne(g)?new URL(g):F.normalize(g),$.readFileSync(g,x?void 0:"utf8")),T=g=>(g=v(g,!0),g.buffer||(g=new Uint8Array(g)),g),E=(g,x,O,P=!0)=>{g=Ne(g)?new URL(g):F.normalize(g),$.readFile(g,P?void 0:"utf8",(k,z)=>{k?O(k):x(P?z.buffer:z)})},!o.thisProgram&&1{var x=new XMLHttpRequest;return x.open("GET",g,!1),x.send(null),x.responseText},f&&(T=g=>{var x=new XMLHttpRequest;return x.open("GET",g,!1),x.responseType="arraybuffer",x.send(null),new Uint8Array(x.response)}),E=(g,x,O)=>{var P=new XMLHttpRequest;P.open("GET",g,!0),P.responseType="arraybuffer",P.onload=()=>{P.status==200||P.status==0&&P.response?x(P.response):O()},P.onerror=O,P.send(null)});var C=console.log.bind(console),J=console.error.bind(console);Object.assign(o,u),u=null;var ge,ze=!1,Fe,ee,j,xe,xt;function st(){var g=ge.buffer;o.HEAP8=Fe=new Int8Array(g),o.HEAP16=new Int16Array(g),o.HEAPU8=ee=new Uint8Array(g),o.HEAPU16=new Uint16Array(g),o.HEAP32=j=new Int32Array(g),o.HEAPU32=xe=new Uint32Array(g),o.HEAPF32=new Float32Array(g),o.HEAPF64=xt=new Float64Array(g)}var He=[],q=[],se=[],Ke=0,Ie=null;function je(g){throw g="Aborted("+g+")",J(g),ze=!0,g=new WebAssembly.RuntimeError(g+". Build with -sASSERTIONS for more info."),c(g),g}var he=g=>g.startsWith("data:application/octet-stream;base64,"),Ne=g=>g.startsWith("file://"),Re;if(Re="ort-wasm.wasm",!he(Re)){var pt=Re;Re=o.locateFile?o.locateFile(pt,y):y+pt}function yt(g){if(T)return T(g);throw"both async and sync fetching of the wasm failed"}function Ge(g){if(d||f){if(typeof fetch=="function"&&!Ne(g))return fetch(g,{credentials:"same-origin"}).then(x=>{if(!x.ok)throw`failed to load wasm binary file at '${g}'`;return x.arrayBuffer()}).catch(()=>yt(g));if(E)return new Promise((x,O)=>{E(g,P=>x(new Uint8Array(P)),O)})}return Promise.resolve().then(()=>yt(g))}function qe(g,x,O){return Ge(g).then(P=>WebAssembly.instantiate(P,x)).then(O,P=>{J(`failed to asynchronously prepare wasm: ${P}`),je(P)})}function Ye(g,x){var O=Re;return typeof WebAssembly.instantiateStreaming!="function"||he(O)||Ne(O)||b||typeof fetch!="function"?qe(O,g,x):fetch(O,{credentials:"same-origin"}).then(P=>WebAssembly.instantiateStreaming(P,g).then(x,function(k){return J(`wasm streaming compile failed: ${k}`),J("falling back to ArrayBuffer instantiation"),qe(O,g,x)}))}var Le,Oe={798088:(g,x,O,P)=>{if(typeof o>"u"||!o.ya)return 1;if(g=At(g>>>0),g.startsWith("./")&&(g=g.substring(2)),g=o.ya.get(g),!g)return 2;if(x>>>=0,O>>>=0,x+O>g.byteLength)return 3;try{return ee.set(g.subarray(x,x+O),P>>>0>>>0),0}catch{return 4}}};class ue{constructor(x){this.wa=x-24}}var Ce=0,wt=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,Et=(g,x,O)=>{x>>>=0;var P=x+O;for(O=x;g[O]&&!(O>=P);)++O;if(16k?P+=String.fromCharCode(k):(k-=65536,P+=String.fromCharCode(55296|k>>10,56320|k&1023))}}else P+=String.fromCharCode(k)}return P},At=(g,x)=>(g>>>=0)?Et(ee,g,x):"",Pt=g=>{for(var x=0,O=0;O=P?x++:2047>=P?x+=2:55296<=P&&57343>=P?(x+=4,++O):x+=3}return x},Ve=(g,x,O,P)=>{if(O>>>=0,!(0=Y){var Te=g.charCodeAt(++z);Y=65536+((Y&1023)<<10)|Te&1023}if(127>=Y){if(O>=P)break;x[O++>>>0]=Y}else{if(2047>=Y){if(O+1>=P)break;x[O++>>>0]=192|Y>>6}else{if(65535>=Y){if(O+2>=P)break;x[O++>>>0]=224|Y>>12}else{if(O+3>=P)break;x[O++>>>0]=240|Y>>18,x[O++>>>0]=128|Y>>12&63}x[O++>>>0]=128|Y>>6&63}x[O++>>>0]=128|Y&63}}return x[O>>>0]=0,O-k},ot=g=>g%4===0&&(g%100!==0||g%400===0),ir=[0,31,60,91,121,152,182,213,244,274,305,335],jt=[0,31,59,90,120,151,181,212,243,273,304,334],Ut=[],et={},Ht=()=>{if(!vt){var g={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:s||"./this.program"},x;for(x in et)et[x]===void 0?delete g[x]:g[x]=et[x];var O=[];for(x in g)O.push(`${x}=${g[x]}`);vt=O}return vt},vt,Gt=[null,[],[]],qt=[31,29,31,30,31,30,31,31,30,31,30,31],at=[31,28,31,30,31,30,31,31,30,31,30,31];function Xr(g){var x=Array(Pt(g)+1);return Ve(g,x,0,x.length),x}function te(g,x,O,P){function k(A,K,ie){for(A=typeof A=="number"?A.toString():A||"";A.lengthKt?-1:0tt-A.getDate())K-=tt-A.getDate()+1,A.setDate(1),11>ie?A.setMonth(ie+1):(A.setMonth(0),A.setFullYear(A.getFullYear()+1));else{A.setDate(A.getDate()+K);break}}return ie=new Date(A.getFullYear()+1,0,4),K=Te(new Date(A.getFullYear(),0,4)),ie=Te(ie),0>=Y(K,A)?0>=Y(ie,A)?A.getFullYear()+1:A.getFullYear():A.getFullYear()-1}g>>>=0,x>>>=0,O>>>=0,P>>>=0;var Se=xe[P+40>>>2>>>0];P={Ba:j[P>>>2>>>0],Aa:j[P+4>>>2>>>0],ua:j[P+8>>>2>>>0],xa:j[P+12>>>2>>>0],va:j[P+16>>>2>>>0],ta:j[P+20>>>2>>>0],na:j[P+24>>>2>>>0],sa:j[P+28>>>2>>>0],Da:j[P+32>>>2>>>0],za:j[P+36>>>2>>>0],Ca:Se?At(Se):""},O=At(O),Se={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var Ae in Se)O=O.replace(new RegExp(Ae,"g"),Se[Ae]);var Yt="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),_t="January February March April May June July August September October November December".split(" ");Se={"%a":A=>Yt[A.na].substring(0,3),"%A":A=>Yt[A.na],"%b":A=>_t[A.va].substring(0,3),"%B":A=>_t[A.va],"%C":A=>z((A.ta+1900)/100|0,2),"%d":A=>z(A.xa,2),"%e":A=>k(A.xa,2," "),"%g":A=>Be(A).toString().substring(2),"%G":Be,"%H":A=>z(A.ua,2),"%I":A=>(A=A.ua,A==0?A=12:12{for(var K=0,ie=0;ie<=A.va-1;K+=(ot(A.ta+1900)?qt:at)[ie++]);return z(A.xa+K,3)},"%m":A=>z(A.va+1,2),"%M":A=>z(A.Aa,2),"%n":()=>` `,"%p":A=>0<=A.ua&&12>A.ua?"AM":"PM","%S":A=>z(A.Ba,2),"%t":()=>" ","%u":A=>A.na||7,"%U":A=>z(Math.floor((A.sa+7-A.na)/7),2),"%V":A=>{var K=Math.floor((A.sa+7-(A.na+6)%7)/7);if(2>=(A.na+371-A.sa-2)%7&&K++,K)K==53&&(ie=(A.na+371-A.sa)%7,ie==4||ie==3&&ot(A.ta)||(K=1));else{K=52;var ie=(A.na+7-A.sa-1)%7;(ie==4||ie==5&&ot(A.ta%400-1))&&K++}return z(K,2)},"%w":A=>A.na,"%W":A=>z(Math.floor((A.sa+7-(A.na+6)%7)/7),2),"%y":A=>(A.ta+1900).toString().substring(2),"%Y":A=>A.ta+1900,"%z":A=>{A=A.za;var K=0<=A;return A=Math.abs(A)/60,(K?"+":"-")+("0000"+(A/60*100+A%60)).slice(-4)},"%Z":A=>A.Ca,"%%":()=>"%"},O=O.replace(/%%/g,"\0\0");for(Ae in Se)O.includes(Ae)&&(O=O.replace(new RegExp(Ae,"g"),Se[Ae](P)));return O=O.replace(/\0\0/g,"%"),Ae=Xr(O),Ae.length>x?0:(Fe.set(Ae,g>>>0),Ae.length-1)}var pr={a:function(g,x,O){g>>>=0;var P=new ue(g);throw xe[P.wa+16>>>2>>>0]=0,xe[P.wa+4>>>2>>>0]=x>>>0,xe[P.wa+8>>>2>>>0]=O>>>0,Ce=g,Ce},e:function(){return 0},H:function(){},x:function(){},z:function(){},J:function(){return 0},F:function(){},A:function(){},E:function(){},g:function(){},y:function(){},v:function(){},G:function(){},w:function(){},k:()=>1,I:function(g,x,O){return x>>>=0,ee.copyWithin(g>>>0>>>0,x>>>0,x+(O>>>0)>>>0)},n:function(g,x,O){g=x+2097152>>>0<4194305-!!g?(g>>>0)+4294967296*x:NaN,O>>>=0,g=new Date(1e3*g),j[O>>>2>>>0]=g.getUTCSeconds(),j[O+4>>>2>>>0]=g.getUTCMinutes(),j[O+8>>>2>>>0]=g.getUTCHours(),j[O+12>>>2>>>0]=g.getUTCDate(),j[O+16>>>2>>>0]=g.getUTCMonth(),j[O+20>>>2>>>0]=g.getUTCFullYear()-1900,j[O+24>>>2>>>0]=g.getUTCDay(),j[O+28>>>2>>>0]=(g.getTime()-Date.UTC(g.getUTCFullYear(),0,1,0,0,0,0))/864e5|0},o:function(g,x,O){g=x+2097152>>>0<4194305-!!g?(g>>>0)+4294967296*x:NaN,O>>>=0,g=new Date(1e3*g),j[O>>>2>>>0]=g.getSeconds(),j[O+4>>>2>>>0]=g.getMinutes(),j[O+8>>>2>>>0]=g.getHours(),j[O+12>>>2>>>0]=g.getDate(),j[O+16>>>2>>>0]=g.getMonth(),j[O+20>>>2>>>0]=g.getFullYear()-1900,j[O+24>>>2>>>0]=g.getDay(),j[O+28>>>2>>>0]=(ot(g.getFullYear())?ir:jt)[g.getMonth()]+g.getDate()-1|0,j[O+36>>>2>>>0]=-(60*g.getTimezoneOffset()),x=new Date(g.getFullYear(),6,1).getTimezoneOffset();var P=new Date(g.getFullYear(),0,1).getTimezoneOffset();j[O+32>>>2>>>0]=(x!=P&&g.getTimezoneOffset()==Math.min(P,x))|0},p:function(g){g>>>=0;var x=new Date(j[g+20>>>2>>>0]+1900,j[g+16>>>2>>>0],j[g+12>>>2>>>0],j[g+8>>>2>>>0],j[g+4>>>2>>>0],j[g>>>2>>>0],0),O=j[g+32>>>2>>>0],P=x.getTimezoneOffset(),k=new Date(x.getFullYear(),6,1).getTimezoneOffset(),z=new Date(x.getFullYear(),0,1).getTimezoneOffset(),Y=Math.min(z,k);return 0>O?j[g+32>>>2>>>0]=+(k!=z&&Y==P):0>>2>>>0]=x.getDay(),j[g+28>>>2>>>0]=(ot(x.getFullYear())?ir:jt)[x.getMonth()]+x.getDate()-1|0,j[g>>>2>>>0]=x.getSeconds(),j[g+4>>>2>>>0]=x.getMinutes(),j[g+8>>>2>>>0]=x.getHours(),j[g+12>>>2>>>0]=x.getDate(),j[g+16>>>2>>>0]=x.getMonth(),j[g+20>>>2>>>0]=x.getYear(),g=x.getTime(),g=isNaN(g)?-1:g/1e3,dr((Le=g,1<=+Math.abs(Le)?0>>0:~~+Math.ceil((Le-+(~~Le>>>0))/4294967296)>>>0:0)),g>>>0},l:function(){return-52},m:function(){},t:function(g,x,O,P){O>>>=0,P>>>=0;var k=new Date().getFullYear(),z=new Date(k,0,1),Y=new Date(k,6,1);k=z.getTimezoneOffset();var Te=Y.getTimezoneOffset();xe[g>>>0>>>2>>>0]=60*Math.max(k,Te),j[x>>>0>>>2>>>0]=+(k!=Te),g=Be=>Be.toLocaleTimeString(void 0,{hour12:!1,timeZoneName:"short"}).split(" ")[1],z=g(z),Y=g(Y),Te{je("")},B:function(g,x,O){g>>>=0,x>>>=0,O>>>=0,Ut.length=0;for(var P;P=ee[x++>>>0];){var k=P!=105;k&=P!=112,O+=k&&O%8?4:0,Ut.push(P==112?xe[O>>>2>>>0]:P==105?j[O>>>2>>>0]:xt[O>>>3>>>0]),O+=k?8:4}return Oe[g](...Ut)},h:()=>Date.now(),u:function(){return 4294901760},b:()=>performance.now(),s:function(g){g>>>=0;var x=ee.length;if(4294901760=O;O*=2){var P=x*(1+.2/O);P=Math.min(P,g+100663296);var k=Math;P=Math.max(g,P);e:{k=(k.min.call(k,4294901760,P+(65536-P%65536)%65536)-ge.buffer.byteLength+65535)/65536;try{ge.grow(k),st();var z=1;break e}catch{}z=void 0}if(z)return!0}return!1},C:function(g,x){g>>>=0,x>>>=0;var O=0;return Ht().forEach((P,k)=>{var z=x+O;for(k=xe[g+4*k>>>2>>>0]=z,z=0;z>>0]=P.charCodeAt(z);Fe[k>>>0]=0,O+=P.length+1}),0},D:function(g,x){g>>>=0,x>>>=0;var O=Ht();xe[g>>>2>>>0]=O.length;var P=0;return O.forEach(k=>P+=k.length+1),xe[x>>>2>>>0]=P,0},f:()=>52,j:function(){return 52},q:function(){return 70},i:function(g,x,O,P){x>>>=0,O>>>=0,P>>>=0;for(var k=0,z=0;z>>2>>>0],Te=xe[x+4>>>2>>>0];x+=8;for(var Be=0;Be>>0],Ae=Gt[g];Se===0||Se===10?((g===1?C:J)(Et(Ae,0)),Ae.length=0):Ae.push(Se)}k+=Te}return xe[P>>>2>>>0]=k,0},r:te,c:function(g,x,O,P){return te(g>>>0,x>>>0,O>>>0,P>>>0)}},X=function(){function g(O){return X=O.exports,X=kt(),ge=X.K,st(),q.unshift(X.L),Ke--,Ke==0&&Ie&&(O=Ie,Ie=null,O()),X}var x={a:pr};if(Ke++,o.instantiateWasm)try{return o.instantiateWasm(x,g)}catch(O){J(`Module.instantiateWasm callback failed with error: ${O}`),c(O)}return Ye(x,function(O){g(O.instance)}).catch(c),{}}();o._OrtInit=(g,x)=>(o._OrtInit=X.M)(g,x),o._OrtGetLastError=(g,x)=>(o._OrtGetLastError=X.N)(g,x),o._OrtCreateSessionOptions=(g,x,O,P,k,z,Y,Te,Be,Se)=>(o._OrtCreateSessionOptions=X.O)(g,x,O,P,k,z,Y,Te,Be,Se),o._OrtAppendExecutionProvider=(g,x)=>(o._OrtAppendExecutionProvider=X.P)(g,x),o._OrtAddFreeDimensionOverride=(g,x,O)=>(o._OrtAddFreeDimensionOverride=X.Q)(g,x,O),o._OrtAddSessionConfigEntry=(g,x,O)=>(o._OrtAddSessionConfigEntry=X.R)(g,x,O),o._OrtReleaseSessionOptions=g=>(o._OrtReleaseSessionOptions=X.S)(g),o._OrtCreateSession=(g,x,O)=>(o._OrtCreateSession=X.T)(g,x,O),o._OrtReleaseSession=g=>(o._OrtReleaseSession=X.U)(g),o._OrtGetInputOutputCount=(g,x,O)=>(o._OrtGetInputOutputCount=X.V)(g,x,O),o._OrtGetInputName=(g,x)=>(o._OrtGetInputName=X.W)(g,x),o._OrtGetOutputName=(g,x)=>(o._OrtGetOutputName=X.X)(g,x),o._OrtFree=g=>(o._OrtFree=X.Y)(g),o._OrtCreateTensor=(g,x,O,P,k,z)=>(o._OrtCreateTensor=X.Z)(g,x,O,P,k,z),o._OrtGetTensorData=(g,x,O,P,k)=>(o._OrtGetTensorData=X._)(g,x,O,P,k),o._OrtReleaseTensor=g=>(o._OrtReleaseTensor=X.$)(g),o._OrtCreateRunOptions=(g,x,O,P)=>(o._OrtCreateRunOptions=X.aa)(g,x,O,P),o._OrtAddRunConfigEntry=(g,x,O)=>(o._OrtAddRunConfigEntry=X.ba)(g,x,O),o._OrtReleaseRunOptions=g=>(o._OrtReleaseRunOptions=X.ca)(g),o._OrtCreateBinding=g=>(o._OrtCreateBinding=X.da)(g),o._OrtBindInput=(g,x,O)=>(o._OrtBindInput=X.ea)(g,x,O),o._OrtBindOutput=(g,x,O,P)=>(o._OrtBindOutput=X.fa)(g,x,O,P),o._OrtClearBoundOutputs=g=>(o._OrtClearBoundOutputs=X.ga)(g),o._OrtReleaseBinding=g=>(o._OrtReleaseBinding=X.ha)(g),o._OrtRunWithBinding=(g,x,O,P,k)=>(o._OrtRunWithBinding=X.ia)(g,x,O,P,k),o._OrtRun=(g,x,O,P,k,z,Y,Te)=>(o._OrtRun=X.ja)(g,x,O,P,k,z,Y,Te),o._OrtEndProfiling=g=>(o._OrtEndProfiling=X.ka)(g),o._malloc=g=>(o._malloc=X.la)(g),o._free=g=>(o._free=X.ma)(g);var dr=g=>(dr=X.oa)(g),Zt=g=>(Zt=X.pa)(g),Or=g=>(Or=X.qa)(g),G=()=>(G=X.ra)();function kt(){var g=X;g=Object.assign({},g);var x=O=>P=>O(P)>>>0;return g.la=x(g.la),g.qa=x(g.qa),g.ra=(O=>()=>O()>>>0)(g.ra),g}o.stackSave=()=>G(),o.stackRestore=g=>Zt(g),o.stackAlloc=g=>Or(g),o.UTF8ToString=At,o.stringToUTF8=(g,x,O)=>Ve(g,ee,x,O),o.lengthBytesUTF8=Pt;var $t;Ie=function g(){$t||Ct(),$t||(Ie=g)};function Ct(){if(!(0a)}),Ep=me(()=>{}),Dp=me(()=>{}),Lp={};Sr(Lp,{cpus:()=>ig});var ig,Cp=L(()=>{ig=void 0}),kp=me((e,r)=>{var a=(()=>{var l;var i=typeof document<"u"?(l=document.currentScript)==null?void 0:l.src:void 0;return typeof __filename<"u"&&(i||(i=__filename)),function(n={}){function o(){return se.buffer!=he.buffer&&Ge(),he}function p(){return se.buffer!=he.buffer&&Ge(),Ne}function c(){return se.buffer!=he.buffer&&Ge(),Re}function t(){return se.buffer!=he.buffer&&Ge(),pt}function u(){return se.buffer!=he.buffer&&Ge(),yt}var s=n,d,f,b=new Promise((h,m)=>{d=h,f=m}),y=Object.assign({},s),v="./this.program",E=(h,m)=>{throw m},T=typeof window=="object",$=typeof importScripts=="function",F=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",C=s.ENVIRONMENT_IS_PTHREAD||!1,J="";function ge(h){return s.locateFile?s.locateFile(h,J):J+h}var ze,Fe,ee;if(F){var j=(Qi(),ar(Zi)),xe=(ta(),ar(ea));J=$?xe.dirname(J)+"/":__dirname+"/",ze=(h,m)=>(h=Pt(h)?new URL(h):xe.normalize(h),j.readFileSync(h,m?void 0:"utf8")),ee=h=>(h=ze(h,!0),h.buffer||(h=new Uint8Array(h)),h),Fe=(h,m,w,S=!0)=>{h=Pt(h)?new URL(h):xe.normalize(h),j.readFile(h,S?void 0:"utf8",(N,D)=>{N?w(N):m(S?D.buffer:D)})},!s.thisProgram&&1{throw process.exitCode=h,m},global.Worker=Ep().Worker}else(T||$)&&($?J=self.location.href:typeof document<"u"&&document.currentScript&&(J=document.currentScript.src),typeof i<"u"&&i&&(J=i),J.startsWith("blob:")?J="":J=J.substr(0,J.replace(/[?#].*/,"").lastIndexOf("/")+1),F||(ze=h=>{var m=new XMLHttpRequest;return m.open("GET",h,!1),m.send(null),m.responseText},$&&(ee=h=>{var m=new XMLHttpRequest;return m.open("GET",h,!1),m.responseType="arraybuffer",m.send(null),new Uint8Array(m.response)}),Fe=(h,m,w)=>{var S=new XMLHttpRequest;S.open("GET",h,!0),S.responseType="arraybuffer",S.onload=()=>{S.status==200||S.status==0&&S.response?m(S.response):w()},S.onerror=w,S.send(null)}));F&&typeof performance>"u"&&(global.performance=Dp().performance);var xt=console.log.bind(console),st=console.error.bind(console);F&&(xt=(...h)=>j.writeSync(1,h.join(" ")+` `),st=(...h)=>j.writeSync(2,h.join(" ")+` `));var He=xt,q=st;Object.assign(s,y),y=null;var se,Ke,Ie=!1,je,he,Ne,Re,pt,yt;function Ge(){var h=se.buffer;s.HEAP8=he=new Int8Array(h),s.HEAP16=new Int16Array(h),s.HEAPU8=Ne=new Uint8Array(h),s.HEAPU16=new Uint16Array(h),s.HEAP32=Re=new Int32Array(h),s.HEAPU32=pt=new Uint32Array(h),s.HEAPF32=new Float32Array(h),s.HEAPF64=yt=new Float64Array(h)}var qe=16777216;if(C)se=s.wasmMemory;else if(s.wasmMemory)se=s.wasmMemory;else if(se=new WebAssembly.Memory({initial:qe/65536,maximum:65536,shared:!0}),!(se.buffer instanceof SharedArrayBuffer))throw q("requested a shared WebAssembly.Memory but the returned buffer is not a SharedArrayBuffer, indicating that while the browser has SharedArrayBuffer it does not have WebAssembly threads support - you may need to set a flag"),F&&q("(on node you may need: --experimental-wasm-threads --experimental-wasm-bulk-memory and/or recent version)"),Error("bad memory");Ge(),qe=se.buffer.byteLength;var Ye=[],Le=[],Oe=[],ue=0,Ce=null;function wt(){if(ue--,ue==0&&Ce){var h=Ce;Ce=null,h()}}function Et(h){throw h="Aborted("+h+")",q(h),Ie=!0,je=1,h=new WebAssembly.RuntimeError(h+". Build with -sASSERTIONS for more info."),f(h),h}var At=h=>h.startsWith("data:application/octet-stream;base64,"),Pt=h=>h.startsWith("file://"),Ve;Ve="ort-wasm-threaded.wasm",At(Ve)||(Ve=ge(Ve));function ot(h){if(ee)return ee(h);throw"both async and sync fetching of the wasm failed"}function ir(h){if(T||$){if(typeof fetch=="function"&&!Pt(h))return fetch(h,{credentials:"same-origin"}).then(m=>{if(!m.ok)throw`failed to load wasm binary file at '${h}'`;return m.arrayBuffer()}).catch(()=>ot(h));if(Fe)return new Promise((m,w)=>{Fe(h,S=>m(new Uint8Array(S)),w)})}return Promise.resolve().then(()=>ot(h))}function jt(h,m,w){return ir(h).then(S=>WebAssembly.instantiate(S,m)).then(w,S=>{q(`failed to asynchronously prepare wasm: ${S}`),Et(S)})}function Ut(h,m){var w=Ve;return typeof WebAssembly.instantiateStreaming!="function"||At(w)||Pt(w)||F||typeof fetch!="function"?jt(w,h,m):fetch(w,{credentials:"same-origin"}).then(S=>WebAssembly.instantiateStreaming(S,h).then(m,function(N){return q(`wasm streaming compile failed: ${N}`),q("falling back to ArrayBuffer instantiation"),jt(w,h,m)}))}var et,Ht={799444:(h,m,w,S)=>{if(typeof s>"u"||!s.bb)return 1;if(h=Te(h>>>0),h.startsWith("./")&&(h=h.substring(2)),h=s.bb.get(h),!h)return 2;if(m>>>=0,w>>>=0,S>>>=0,m+w>h.byteLength)return 3;try{return p().set(h.subarray(m,m+w),S>>>0),0}catch{return 4}}};function vt(h){this.name="ExitStatus",this.message=`Program terminated with exit(${h})`,this.status=h}var Gt=h=>{h.terminate(),h.onmessage=()=>{}},qt=h=>{G.Oa.length==0&&(Zt(),G.Xa(G.Oa[0]));var m=G.Oa.pop();if(!m)return 6;G.Pa.push(m),G.La[h.Na]=m,m.Na=h.Na;var w={cmd:"run",start_routine:h.gb,arg:h.cb,pthread_ptr:h.Na};return F&&m.unref(),m.postMessage(w,h.mb),0},at=0,Xr=h=>{var m=vn();return h=h(),jr(m),h},te=(h,m,...w)=>Xr(()=>{for(var S=w.length,N=wn(8*S),D=N>>>3,M=0;M>>0]=pe}return ti(h,0,S,N,m)});function pr(h){var m;if(C)return te(0,1,h);je=h,0{if(je=h,C)throw $t(h),"unwind";pr(h)};function dr(){for(var h=s.numThreads;h--;)Zt();Ye.unshift(()=>{ue++,Or(()=>wt())})}function Zt(){var h=ge("ort-wasm-threaded.worker.js");h=new Worker(h),G.Oa.push(h)}function Or(h){C?h():Promise.all(G.Oa.map(G.Xa)).then(h)}var G={Oa:[],Pa:[],ab:[],La:{},Va(){C?(G.receiveObjectTransfer=G.fb,G.threadInitTLS=G.$a,G.setExitStatus=G.Za):dr()},Za:h=>je=h,pb:["$terminateWorker"],hb:()=>{for(var h of G.Pa)Gt(h);for(h of G.Oa)Gt(h);G.Oa=[],G.Pa=[],G.La=[]},Ya:h=>{var m=h.Na;delete G.La[m],G.Oa.push(h),G.Pa.splice(G.Pa.indexOf(h),1),h.Na=0,nn(m)},fb(){},$a(){G.ab.forEach(h=>h())},Xa:h=>new Promise(m=>{h.onmessage=D=>{D=D.data;var M=D.cmd;if(D.targetThread&&D.targetThread!=Lr()){var pe=G.La[D.targetThread];pe?pe.postMessage(D,D.transferList):q(`Internal error! Worker sent a message "${M}" to target pthread ${D.targetThread}, but that thread no longer exists!`)}else M==="checkMailbox"?Ir():M==="spawnThread"?qt(D):M==="cleanupThread"?G.Ya(G.La[D.thread]):M==="killThread"?(D=D.thread,M=G.La[D],delete G.La[D],Gt(M),nn(D),G.Pa.splice(G.Pa.indexOf(M),1),M.Na=0):M==="cancelThread"?G.La[D.thread].postMessage({cmd:"cancel"}):M==="loaded"?(h.loaded=!0,F&&!h.Na&&h.unref(),m(h)):M==="alert"?alert(`Thread ${D.threadId}: ${D.text}`):D.target==="setimmediate"?h.postMessage(D):M==="callHandler"?s[D.handler](...D.args):M&&q(`worker sent an unknown command ${M}`)},h.onerror=D=>{throw q(`worker sent an error! ${D.filename}:${D.lineno}: ${D.message}`),D},F&&(h.on("message",D=>h.onmessage({data:D})),h.on("error",D=>h.onerror(D)));var w=[],S=["onExit"],N;for(N of S)s.hasOwnProperty(N)&&w.push(N);h.postMessage({cmd:"load",handlers:w,urlOrBlob:s.mainScriptUrlOrBlob||i,wasmMemory:se,wasmModule:Ke})})};s.PThread=G;var kt=h=>{for(;0{var h=Lr(),m=t()[h+52>>>2>>>0];h=t()[h+56>>>2>>>0],oi(m,m-h),jr(m)};function $t(h){if(C)return te(1,0,h);X(h)}var Ct=[],g;s.invokeEntryPoint=(h,m)=>{at=0;var w=Ct[h];w||(h>=Ct.length&&(Ct.length=h+1),Ct[h]=w=g.get(h)),h=w(m),0>>2>>>0]=0,t()[this.Ua+4>>>2>>>0]=m,t()[this.Ua+8>>>2>>>0]=w}}var O=0;function P(h,m,w,S){return C?te(2,1,h,m,w,S):k(h,m,w,S)}function k(h,m,w,S){if(h>>>=0,m>>>=0,w>>>=0,S>>>=0,typeof SharedArrayBuffer>"u")return q("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var N=[];return C&&N.length===0?P(h,m,w,S):(h={gb:w,Na:h,cb:S,mb:N},C?(h.ob="spawnThread",postMessage(h,N),0):qt(h))}var z=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,Y=(h,m,w)=>{m>>>=0;var S=m+w;for(w=m;h[w]&&!(w>=S);)++w;if(16N?S+=String.fromCharCode(N):(N-=65536,S+=String.fromCharCode(55296|N>>10,56320|N&1023))}}else S+=String.fromCharCode(N)}return S},Te=(h,m)=>(h>>>=0)?Y(p(),h,m):"";function Be(h,m,w){return C?te(3,1,h,m,w):0}function Se(h,m){if(C)return te(4,1,h,m)}var Ae=h=>{for(var m=0,w=0;w=S?m++:2047>=S?m+=2:55296<=S&&57343>=S?(m+=4,++w):m+=3}return m},Yt=(h,m,w,S)=>{if(w>>>=0,!(0=M){var pe=h.charCodeAt(++D);M=65536+((M&1023)<<10)|pe&1023}if(127>=M){if(w>=S)break;m[w++>>>0]=M}else{if(2047>=M){if(w+1>=S)break;m[w++>>>0]=192|M>>6}else{if(65535>=M){if(w+2>=S)break;m[w++>>>0]=224|M>>12}else{if(w+3>=S)break;m[w++>>>0]=240|M>>18,m[w++>>>0]=128|M>>12&63}m[w++>>>0]=128|M>>6&63}m[w++>>>0]=128|M&63}}return m[w>>>0]=0,w-N},_t=(h,m,w)=>Yt(h,p(),m,w);function A(h,m){if(C)return te(5,1,h,m)}function K(h,m,w){if(C)return te(6,1,h,m,w)}function ie(h,m,w){return C?te(7,1,h,m,w):0}function tt(h,m){if(C)return te(8,1,h,m)}function Kt(h,m,w){if(C)return te(9,1,h,m,w)}function xn(h,m,w,S){if(C)return te(10,1,h,m,w,S)}function On(h,m,w,S){if(C)return te(11,1,h,m,w,S)}function Sn(h,m,w,S){if(C)return te(12,1,h,m,w,S)}function An(h){if(C)return te(13,1,h)}function In(h,m){if(C)return te(14,1,h,m)}function Vn(h,m,w){if(C)return te(15,1,h,m,w)}function Zr(h){h>>>=0,typeof Atomics.nb=="function"&&(Atomics.nb(c(),h>>>2,h).value.then(Ir),h+=128,Atomics.store(c(),h>>>2,1))}s.__emscripten_thread_mailbox_await=Zr;var Ir=()=>{var h=Lr();if(h&&(Zr(h),h=ri,!Ie))try{if(h(),!(0h%4===0&&(h%100!==0||h%400===0),Hn=[0,31,60,91,121,152,182,213,244,274,305,335],Wn=[0,31,59,90,120,151,181,212,243,273,304,334];function qn(h,m,w,S,N,D,M,pe){return C?te(16,1,h,m,w,S,N,D,M,pe):-52}function $o(h,m,w,S,N,D,M){if(C)return te(17,1,h,m,w,S,N,D,M)}var Jr=[],Kr={},No=()=>{if(!rn){var h={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:v||"./this.program"},m;for(m in Kr)Kr[m]===void 0?delete h[m]:h[m]=Kr[m];var w=[];for(m in h)w.push(`${m}=${h[m]}`);rn=w}return rn},rn;function ko(h,m){if(C)return te(18,1,h,m);h>>>=0,m>>>=0;var w=0;return No().forEach((S,N)=>{var D=m+w;for(N=t()[h+4*N>>>2>>>0]=D,D=0;D>>0]=S.charCodeAt(D);o()[N>>>0]=0,w+=S.length+1}),0}function Ro(h,m){if(C)return te(19,1,h,m);h>>>=0,m>>>=0;var w=No();t()[h>>>2>>>0]=w.length;var S=0;return w.forEach(N=>S+=N.length+1),t()[m>>>2>>>0]=S,0}function Bo(h){return C?te(20,1,h):52}function Mo(h,m,w,S){return C?te(21,1,h,m,w,S):52}function Uo(h,m,w,S,N){return C?te(22,1,h,m,w,S,N):70}var ha=[null,[],[]];function zo(h,m,w,S){if(C)return te(23,1,h,m,w,S);m>>>=0,w>>>=0,S>>>=0;for(var N=0,D=0;D>>2>>>0],pe=t()[m+4>>>2>>>0];m+=8;for(var rt=0;rt>>0],ke=ha[h];Pe===0||Pe===10?((h===1?He:q)(Y(ke,0)),ke.length=0):ke.push(Pe)}N+=pe}return t()[S>>>2>>>0]=N,0}var Go=[31,29,31,30,31,30,31,31,30,31,30,31],Xo=[31,28,31,30,31,30,31,31,30,31,30,31];function ga(h){var m=Array(Ae(h)+1);return Yt(h,m,0,m.length),m}var ma=(h,m)=>{o().set(h,m>>>0)};function Qo(h,m,w,S){function N(I,re,de){for(I=typeof I=="number"?I.toString():I||"";I.lengthli?-1:0Ft-I.getDate())re-=Ft-I.getDate()+1,I.setDate(1),11>de?I.setMonth(de+1):(I.setMonth(0),I.setFullYear(I.getFullYear()+1));else{I.setDate(I.getDate()+re);break}}return de=new Date(I.getFullYear()+1,0,4),re=pe(new Date(I.getFullYear(),0,4)),de=pe(de),0>=M(re,I)?0>=M(de,I)?I.getFullYear()+1:I.getFullYear():I.getFullYear()-1}h>>>=0,m>>>=0,w>>>=0,S>>>=0;var Pe=t()[S+40>>>2>>>0];S={kb:c()[S>>>2>>>0],jb:c()[S+4>>>2>>>0],Sa:c()[S+8>>>2>>>0],Wa:c()[S+12>>>2>>>0],Ta:c()[S+16>>>2>>>0],Ra:c()[S+20>>>2>>>0],Ma:c()[S+24>>>2>>>0],Qa:c()[S+28>>>2>>>0],qb:c()[S+32>>>2>>>0],ib:c()[S+36>>>2>>>0],lb:Pe?Te(Pe):""},w=Te(w),Pe={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var ke in Pe)w=w.replace(new RegExp(ke,"g"),Pe[ke]);var ai="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),ui="January February March April May June July August September October November December".split(" ");Pe={"%a":I=>ai[I.Ma].substring(0,3),"%A":I=>ai[I.Ma],"%b":I=>ui[I.Ta].substring(0,3),"%B":I=>ui[I.Ta],"%C":I=>D((I.Ra+1900)/100|0,2),"%d":I=>D(I.Wa,2),"%e":I=>N(I.Wa,2," "),"%g":I=>rt(I).toString().substring(2),"%G":rt,"%H":I=>D(I.Sa,2),"%I":I=>(I=I.Sa,I==0?I=12:12{for(var re=0,de=0;de<=I.Ta-1;re+=(Lt(I.Ra+1900)?Go:Xo)[de++]);return D(I.Wa+re,3)},"%m":I=>D(I.Ta+1,2),"%M":I=>D(I.jb,2),"%n":()=>` `,"%p":I=>0<=I.Sa&&12>I.Sa?"AM":"PM","%S":I=>D(I.kb,2),"%t":()=>" ","%u":I=>I.Ma||7,"%U":I=>D(Math.floor((I.Qa+7-I.Ma)/7),2),"%V":I=>{var re=Math.floor((I.Qa+7-(I.Ma+6)%7)/7);if(2>=(I.Ma+371-I.Qa-2)%7&&re++,re)re==53&&(de=(I.Ma+371-I.Qa)%7,de==4||de==3&&Lt(I.Ra)||(re=1));else{re=52;var de=(I.Ma+7-I.Qa-1)%7;(de==4||de==5&&Lt(I.Ra%400-1))&&re++}return D(re,2)},"%w":I=>I.Ma,"%W":I=>D(Math.floor((I.Qa+7-(I.Ma+6)%7)/7),2),"%y":I=>(I.Ra+1900).toString().substring(2),"%Y":I=>I.Ra+1900,"%z":I=>{I=I.ib;var re=0<=I;return I=Math.abs(I)/60,(re?"+":"-")+("0000"+(I/60*100+I%60)).slice(-4)},"%Z":I=>I.lb,"%%":()=>"%"},w=w.replace(/%%/g,"\0\0");for(ke in Pe)w.includes(ke)&&(w=w.replace(new RegExp(ke,"g"),Pe[ke](S)));return w=w.replace(/\0\0/g,"%"),ke=ga(w),ke.length>m?0:(ma(ke,h),ke.length-1)}G.Va();var ba=[pr,$t,P,Be,Se,A,K,ie,tt,Kt,xn,On,Sn,An,In,Vn,qn,$o,ko,Ro,Bo,Mo,Uo,zo],ya={b:function(h,m,w){throw h>>>=0,new x(h).Va(m>>>0,w>>>0),O=h,O},L:function(h){ei(h>>>0,!$,1,!T,131072,!1),G.$a()},j:function(h){h>>>=0,C?postMessage({cmd:"cleanupThread",thread:h}):G.Ya(G.La[h])},H:k,h:Be,S:Se,D:A,F:K,T:ie,Q:tt,J:Kt,P:xn,n:On,E:Sn,B:An,R:In,C:Vn,p:()=>1,z:function(h,m){h>>>=0,h==m>>>0?setTimeout(Ir):C?postMessage({targetThread:h,cmd:"checkMailbox"}):(h=G.La[h])&&h.postMessage({cmd:"checkMailbox"})},I:function(h,m,w,S,N){m>>>=0,w>>>=0,Yr.length=S,N=N>>>0>>>3;for(var D=0;D>>0];return h=m?Ht[m]:ba[h],G.eb=w,w=h(...Yr),G.eb=0,w},K:Zr,o:function(h){F&&G.La[h>>>0].ref()},s:function(h,m,w){h=m+2097152>>>0<4194305-!!h?(h>>>0)+4294967296*m:NaN,w>>>=0,h=new Date(1e3*h),c()[w>>>2>>>0]=h.getUTCSeconds(),c()[w+4>>>2>>>0]=h.getUTCMinutes(),c()[w+8>>>2>>>0]=h.getUTCHours(),c()[w+12>>>2>>>0]=h.getUTCDate(),c()[w+16>>>2>>>0]=h.getUTCMonth(),c()[w+20>>>2>>>0]=h.getUTCFullYear()-1900,c()[w+24>>>2>>>0]=h.getUTCDay(),h=(h.getTime()-Date.UTC(h.getUTCFullYear(),0,1,0,0,0,0))/864e5|0,c()[w+28>>>2>>>0]=h},t:function(h,m,w){h=m+2097152>>>0<4194305-!!h?(h>>>0)+4294967296*m:NaN,w>>>=0,h=new Date(1e3*h),c()[w>>>2>>>0]=h.getSeconds(),c()[w+4>>>2>>>0]=h.getMinutes(),c()[w+8>>>2>>>0]=h.getHours(),c()[w+12>>>2>>>0]=h.getDate(),c()[w+16>>>2>>>0]=h.getMonth(),c()[w+20>>>2>>>0]=h.getFullYear()-1900,c()[w+24>>>2>>>0]=h.getDay(),m=(Lt(h.getFullYear())?Hn:Wn)[h.getMonth()]+h.getDate()-1|0,c()[w+28>>>2>>>0]=m,c()[w+36>>>2>>>0]=-(60*h.getTimezoneOffset()),m=new Date(h.getFullYear(),6,1).getTimezoneOffset();var S=new Date(h.getFullYear(),0,1).getTimezoneOffset();h=(m!=S&&h.getTimezoneOffset()==Math.min(S,m))|0,c()[w+32>>>2>>>0]=h},u:function(h){h>>>=0;var m=new Date(c()[h+20>>>2>>>0]+1900,c()[h+16>>>2>>>0],c()[h+12>>>2>>>0],c()[h+8>>>2>>>0],c()[h+4>>>2>>>0],c()[h>>>2>>>0],0),w=c()[h+32>>>2>>>0],S=m.getTimezoneOffset(),N=new Date(m.getFullYear(),6,1).getTimezoneOffset(),D=new Date(m.getFullYear(),0,1).getTimezoneOffset(),M=Math.min(D,N);return 0>w?c()[h+32>>>2>>>0]=+(N!=D&&M==S):0>>2>>>0]=m.getDay(),w=(Lt(m.getFullYear())?Hn:Wn)[m.getMonth()]+m.getDate()-1|0,c()[h+28>>>2>>>0]=w,c()[h>>>2>>>0]=m.getSeconds(),c()[h+4>>>2>>>0]=m.getMinutes(),c()[h+8>>>2>>>0]=m.getHours(),c()[h+12>>>2>>>0]=m.getDate(),c()[h+16>>>2>>>0]=m.getMonth(),c()[h+20>>>2>>>0]=m.getYear(),h=m.getTime(),h=isNaN(h)?-1:h/1e3,ni((et=h,1<=+Math.abs(et)?0>>0:~~+Math.ceil((et-+(~~et>>>0))/4294967296)>>>0:0)),h>>>0},q:qn,r:$o,y:function(h,m,w,S){h>>>=0,m>>>=0,w>>>=0,S>>>=0;var N=new Date().getFullYear(),D=new Date(N,0,1),M=new Date(N,6,1);N=D.getTimezoneOffset();var pe=M.getTimezoneOffset(),rt=Math.max(N,pe);t()[h>>>2>>>0]=60*rt,c()[m>>>2>>>0]=+(N!=pe),h=Pe=>Pe.toLocaleTimeString(void 0,{hour12:!1,timeZoneName:"short"}).split(" ")[1],D=h(D),M=h(M),pe{Et("")},O:function(h,m,w){h>>>=0,m>>>=0,w>>>=0,Jr.length=0;for(var S;S=p()[m++>>>0];){var N=S!=105;N&=S!=112,w+=N&&w%8?4:0,Jr.push(S==112?t()[w>>>2>>>0]:S==105?c()[w>>>2>>>0]:u()[w>>>3>>>0]),w+=N?8:4}return Ht[h](...Jr)},k:()=>{},i:()=>Date.now(),U:()=>{throw at+=1,"unwind"},A:function(){return 4294901760},e:()=>performance.timeOrigin+performance.now(),f:()=>F?(Cp(),ar(Lp)).cpus().length:navigator.hardwareConcurrency,x:function(h){h>>>=0;var m=p().length;if(h<=m||4294901760=w;w*=2){var S=m*(1+.2/w);S=Math.min(S,h+100663296);var N=Math;S=Math.max(h,S);e:{N=(N.min.call(N,4294901760,S+(65536-S%65536)%65536)-se.buffer.byteLength+65535)/65536;try{se.grow(N),Ge();var D=1;break e}catch{}D=void 0}if(D)return!0}return!1},M:ko,N:Ro,G:X,g:Bo,m:Mo,v:Uo,l:zo,a:se||s.wasmMemory,w:Qo,d:function(h,m,w,S){return Qo(h>>>0,m>>>0,w>>>0,S>>>0)}},W=function(){function h(w,S){return W=w.exports,W=wa(),G.ab.push(W.ya),g=W.za,Le.unshift(W.V),Ke=S,wt(),W}var m={a:ya};if(ue++,s.instantiateWasm)try{return s.instantiateWasm(m,h)}catch(w){q(`Module.instantiateWasm callback failed with error: ${w}`),f(w)}return Ut(m,function(w){h(w.instance,w.module)}).catch(f),{}}();s._OrtInit=(h,m)=>(s._OrtInit=W.W)(h,m),s._OrtGetLastError=(h,m)=>(s._OrtGetLastError=W.X)(h,m),s._OrtCreateSessionOptions=(h,m,w,S,N,D,M,pe,rt,Pe)=>(s._OrtCreateSessionOptions=W.Y)(h,m,w,S,N,D,M,pe,rt,Pe),s._OrtAppendExecutionProvider=(h,m)=>(s._OrtAppendExecutionProvider=W.Z)(h,m),s._OrtAddFreeDimensionOverride=(h,m,w)=>(s._OrtAddFreeDimensionOverride=W._)(h,m,w),s._OrtAddSessionConfigEntry=(h,m,w)=>(s._OrtAddSessionConfigEntry=W.$)(h,m,w),s._OrtReleaseSessionOptions=h=>(s._OrtReleaseSessionOptions=W.aa)(h),s._OrtCreateSession=(h,m,w)=>(s._OrtCreateSession=W.ba)(h,m,w),s._OrtReleaseSession=h=>(s._OrtReleaseSession=W.ca)(h),s._OrtGetInputOutputCount=(h,m,w)=>(s._OrtGetInputOutputCount=W.da)(h,m,w),s._OrtGetInputName=(h,m)=>(s._OrtGetInputName=W.ea)(h,m),s._OrtGetOutputName=(h,m)=>(s._OrtGetOutputName=W.fa)(h,m),s._OrtFree=h=>(s._OrtFree=W.ga)(h),s._OrtCreateTensor=(h,m,w,S,N,D)=>(s._OrtCreateTensor=W.ha)(h,m,w,S,N,D),s._OrtGetTensorData=(h,m,w,S,N)=>(s._OrtGetTensorData=W.ia)(h,m,w,S,N),s._OrtReleaseTensor=h=>(s._OrtReleaseTensor=W.ja)(h),s._OrtCreateRunOptions=(h,m,w,S)=>(s._OrtCreateRunOptions=W.ka)(h,m,w,S),s._OrtAddRunConfigEntry=(h,m,w)=>(s._OrtAddRunConfigEntry=W.la)(h,m,w),s._OrtReleaseRunOptions=h=>(s._OrtReleaseRunOptions=W.ma)(h),s._OrtCreateBinding=h=>(s._OrtCreateBinding=W.na)(h),s._OrtBindInput=(h,m,w)=>(s._OrtBindInput=W.oa)(h,m,w),s._OrtBindOutput=(h,m,w,S)=>(s._OrtBindOutput=W.pa)(h,m,w,S),s._OrtClearBoundOutputs=h=>(s._OrtClearBoundOutputs=W.qa)(h),s._OrtReleaseBinding=h=>(s._OrtReleaseBinding=W.ra)(h),s._OrtRunWithBinding=(h,m,w,S,N)=>(s._OrtRunWithBinding=W.sa)(h,m,w,S,N),s._OrtRun=(h,m,w,S,N,D,M,pe)=>(s._OrtRun=W.ta)(h,m,w,S,N,D,M,pe),s._OrtEndProfiling=h=>(s._OrtEndProfiling=W.ua)(h);var Lr=s._pthread_self=()=>(Lr=s._pthread_self=W.va)();s._malloc=h=>(s._malloc=W.wa)(h),s._free=h=>(s._free=W.xa)(h),s.__emscripten_tls_init=()=>(s.__emscripten_tls_init=W.ya)();var ei=s.__emscripten_thread_init=(h,m,w,S,N,D)=>(ei=s.__emscripten_thread_init=W.Aa)(h,m,w,S,N,D);s.__emscripten_thread_crashed=()=>(s.__emscripten_thread_crashed=W.Ba)();var ti=(h,m,w,S,N)=>(ti=W.Ca)(h,m,w,S,N),nn=h=>(nn=W.Da)(h),on=s.__emscripten_thread_exit=h=>(on=s.__emscripten_thread_exit=W.Ea)(h),ri=()=>(ri=W.Fa)(),ni=h=>(ni=W.Ga)(h),oi=(h,m)=>(oi=W.Ha)(h,m),jr=h=>(jr=W.Ia)(h),wn=h=>(wn=W.Ja)(h),vn=()=>(vn=W.Ka)();function wa(){var h=W;h=Object.assign({},h);var m=S=>()=>S()>>>0,w=S=>N=>S(N)>>>0;return h.va=m(h.va),h.wa=w(h.wa),h.emscripten_main_runtime_thread_id=m(h.emscripten_main_runtime_thread_id),h.Ja=w(h.Ja),h.Ka=m(h.Ka),h}s.wasmMemory=se,s.stackSave=()=>vn(),s.stackRestore=h=>jr(h),s.stackAlloc=h=>wn(h),s.keepRuntimeAlive=()=>0a)}),Bp=me((e,r)=>{r.exports='"use strict";var Module={},ENVIRONMENT_IS_NODE=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string";if(ENVIRONMENT_IS_NODE){var nodeWorkerThreads=require("worker_threads"),parentPort=nodeWorkerThreads.parentPort;parentPort.on("message",e=>onmessage({data:e}));var fs=require("fs"),vm=require("vm");Object.assign(global,{self:global,require,Module,location:{href:__filename},Worker:nodeWorkerThreads.Worker,importScripts:e=>vm.runInThisContext(fs.readFileSync(e,"utf8"),{filename:e}),postMessage:e=>parentPort.postMessage(e),performance:global.performance||{now:Date.now}})}var initializedJS=!1;function threadPrintErr(...e){var a=e.join(" ");if(ENVIRONMENT_IS_NODE){fs.writeSync(2,a+`\n`);return}console.error(a)}function threadAlert(...e){var a=e.join(" ");postMessage({cmd:"alert",text:a,threadId:Module._pthread_self()})}var err=threadPrintErr;self.alert=threadAlert,Module.instantiateWasm=(e,a)=>{var r=Module.wasmModule;Module.wasmModule=null;var t=new WebAssembly.Instance(r,e);return a(t)},self.onunhandledrejection=e=>{throw e.reason||e};function handleMessage(e){try{if(e.data.cmd==="load"){let r=[];self.onmessage=t=>r.push(t),self.startWorker=t=>{Module=t,postMessage({cmd:"loaded"});for(let s of r)handleMessage(s);self.onmessage=handleMessage},Module.wasmModule=e.data.wasmModule;for(const t of e.data.handlers)Module[t]=(...s)=>{postMessage({cmd:"callHandler",handler:t,args:s})};if(Module.wasmMemory=e.data.wasmMemory,Module.buffer=Module.wasmMemory.buffer,Module.ENVIRONMENT_IS_PTHREAD=!0,typeof e.data.urlOrBlob=="string")importScripts(e.data.urlOrBlob);else{var a=URL.createObjectURL(e.data.urlOrBlob);importScripts(a),URL.revokeObjectURL(a)}ortWasmThreaded(Module)}else if(e.data.cmd==="run"){Module.__emscripten_thread_init(e.data.pthread_ptr,0,0,1),Module.__emscripten_thread_mailbox_await(e.data.pthread_ptr),Module.establishStackSpace(),Module.PThread.receiveObjectTransfer(e.data),Module.PThread.threadInitTLS(),initializedJS||(initializedJS=!0);try{Module.invokeEntryPoint(e.data.start_routine,e.data.arg)}catch(r){if(r!="unwind")throw r}}else e.data.cmd==="cancel"?Module._pthread_self()&&Module.__emscripten_thread_exit(-1):e.data.target==="setimmediate"||(e.data.cmd==="checkMailbox"?initializedJS&&Module.checkMailbox():e.data.cmd&&(err(`worker.js received unknown command ${e.data.cmd}`),err(e.data)))}catch(r){throw Module.__emscripten_thread_crashed?.(),r}}self.onmessage=handleMessage;\n'}),Rp,sg,oa,ia,So,Np,ug,lg,fg,Mp,De,Ur=L(()=>{Rp=Pp(),sg=kp(),ia=!1,So=!1,Np=!1,ug=e=>{if(e===1)return!1;if(typeof SharedArrayBuffer>"u")return typeof self<"u"&&!self.crossOriginIsolated&&console.warn("env.wasm.numThreads is set to "+e+", but this will not work unless you enable crossOriginIsolated mode. See https://web.dev/cross-origin-isolation-guide/ for more info."),!1;typeof process<"u"&&process.versions&&process.versions.node&&console.warn("env.wasm.numThreads is set to "+e+", however, currently onnxruntime-web does not support multi-threads in Node.js. Please consider using onnxruntime-node for performance critical scenarios.");try{return typeof MessageChannel<"u"&&new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11]))}catch{return!1}},lg=()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,30,1,28,0,65,0,253,15,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,253,186,1,26,11]))}catch{return!1}},fg=(e,r)=>e?r?"ort-wasm-simd-threaded.wasm":"ort-wasm-simd.wasm":r?"ort-wasm-threaded.wasm":"ort-wasm.wasm",Mp=async e=>{if(ia)return Promise.resolve();if(So)throw new Error("multiple calls to 'initializeWebAssembly()' detected.");if(Np)throw new Error("previous call to 'initializeWebAssembly()' failed.");So=!0;let r=e.initTimeout,a=e.numThreads,i=e.simd,l=ug(a),n=i&&lg(),o=e.wasmPaths,p=typeof o=="string"?o:void 0,c=fg(n,l),t=typeof o=="object"?o[c]:void 0,u=!1,s=[];if(r>0&&s.push(new Promise(d=>{setTimeout(()=>{u=!0,d()},r)})),s.push(new Promise((d,f)=>{let b=l?sg:Rp,y={locateFile:(v,E)=>l&&v.endsWith(".worker.js")&&typeof Blob<"u"?URL.createObjectURL(new Blob([Bp()],{type:"text/javascript"})):v.endsWith(".wasm")?t||(p??E)+c:E+v};if(l)if(y.numThreads=a,typeof Blob>"u")y.mainScriptUrlOrBlob=(void 0)(__dirname,"ort-wasm-threaded.js");else{let v=`var ortWasmThreaded=${b.toString()};`;y.mainScriptUrlOrBlob=new Blob([v],{type:"text/javascript"})}b(y).then(v=>{So=!1,ia=!0,oa=v,d()},v=>{So=!1,Np=!0,f(v)})})),await Promise.race(s),u)throw new Error(`WebAssembly backend initializing failed due to timeout: ${r}ms`)},De=()=>{if(ia&&oa)return oa;throw new Error("WebAssembly is not initialized yet.")}}),ve,bn,_e,Ao=L(()=>{Ur(),ve=(e,r)=>{let a=De(),i=a.lengthBytesUTF8(e)+1,l=a._malloc(i);return a.stringToUTF8(e,l,i),r.push(l),l},bn=(e,r,a,i)=>{if(typeof e=="object"&&e!==null){if(a.has(e))throw new Error("Circular reference in options");a.add(e)}Object.entries(e).forEach(([l,n])=>{let o=r?r+l:l;if(typeof n=="object")bn(n,o+".",a,i);else if(typeof n=="string"||typeof n=="number")i(o,n.toString());else if(typeof n=="boolean")i(o,n?"1":"0");else throw new Error(`Can't handle extra config type: ${typeof n}`)})},_e=e=>{let r=De(),a=r.stackSave();try{let i=r.stackAlloc(8);r._OrtGetLastError(i,i+4);let l=r.HEAP32[i/4],n=r.HEAPU32[i/4+1],o=n?r.UTF8ToString(n):"";throw new Error(`${e} ERROR_CODE: ${l}, ERROR_MESSAGE: ${o}`)}finally{r.stackRestore(a)}}}),Gp,Up=L(()=>{Ur(),Ao(),Gp=e=>{let r=De(),a=0,i=[],l=e||{};try{if((e==null?void 0:e.logSeverityLevel)===void 0)l.logSeverityLevel=2;else if(typeof e.logSeverityLevel!="number"||!Number.isInteger(e.logSeverityLevel)||e.logSeverityLevel<0||e.logSeverityLevel>4)throw new Error(`log serverity level is not valid: ${e.logSeverityLevel}`);if((e==null?void 0:e.logVerbosityLevel)===void 0)l.logVerbosityLevel=0;else if(typeof e.logVerbosityLevel!="number"||!Number.isInteger(e.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${e.logVerbosityLevel}`);(e==null?void 0:e.terminate)===void 0&&(l.terminate=!1);let n=0;return(e==null?void 0:e.tag)!==void 0&&(n=ve(e.tag,i)),a=r._OrtCreateRunOptions(l.logSeverityLevel,l.logVerbosityLevel,!!l.terminate,n),a===0&&_e("Can't create run options."),(e==null?void 0:e.extra)!==void 0&&bn(e.extra,"",new WeakSet,(o,p)=>{let c=ve(o,i),t=ve(p,i);r._OrtAddRunConfigEntry(a,c,t)!==0&&_e(`Can't set a run config entry: ${o} - ${p}.`)}),[a,i]}catch(n){throw a!==0&&r._OrtReleaseRunOptions(a),i.forEach(o=>r._free(o)),n}}}),cg,pg,dg,hg,zp,Vp=L(()=>{Ur(),Ao(),cg=e=>{switch(e){case"disabled":return 0;case"basic":return 1;case"extended":return 2;case"all":return 99;default:throw new Error(`unsupported graph optimization level: ${e}`)}},pg=e=>{switch(e){case"sequential":return 0;case"parallel":return 1;default:throw new Error(`unsupported execution mode: ${e}`)}},dg=e=>{e.extra||(e.extra={}),e.extra.session||(e.extra.session={});let r=e.extra.session;r.use_ort_model_bytes_directly||(r.use_ort_model_bytes_directly="1"),e.executionProviders&&e.executionProviders.some(a=>(typeof a=="string"?a:a.name)==="webgpu")&&(e.enableMemPattern=!1)},hg=(e,r,a)=>{for(let i of r){let l=typeof i=="string"?i:i.name;switch(l){case"webnn":if(l="WEBNN",typeof i!="string"){let o=i;if(o!=null&&o.deviceType){let p=ve("deviceType",a),c=ve(o.deviceType,a);De()._OrtAddSessionConfigEntry(e,p,c)!==0&&_e(`Can't set a session config entry: 'deviceType' - ${o.deviceType}.`)}if(o!=null&&o.numThreads){let p=o.numThreads;(typeof p!="number"||!Number.isInteger(p)||p<0)&&(p=0);let c=ve("numThreads",a),t=ve(p.toString(),a);De()._OrtAddSessionConfigEntry(e,c,t)!==0&&_e(`Can't set a session config entry: 'numThreads' - ${o.numThreads}.`)}if(o!=null&&o.powerPreference){let p=ve("powerPreference",a),c=ve(o.powerPreference,a);De()._OrtAddSessionConfigEntry(e,p,c)!==0&&_e(`Can't set a session config entry: 'powerPreference' - ${o.powerPreference}.`)}}break;case"webgpu":if(l="JS",typeof i!="string"){let o=i;if(o!=null&&o.preferredLayout){if(o.preferredLayout!=="NCHW"&&o.preferredLayout!=="NHWC")throw new Error(`preferredLayout must be either 'NCHW' or 'NHWC': ${o.preferredLayout}`);let p=ve("preferredLayout",a),c=ve(o.preferredLayout,a);De()._OrtAddSessionConfigEntry(e,p,c)!==0&&_e(`Can't set a session config entry: 'preferredLayout' - ${o.preferredLayout}.`)}}break;case"wasm":case"cpu":continue;default:throw new Error(`not supported execution provider: ${l}`)}let n=ve(l,a);De()._OrtAppendExecutionProvider(e,n)!==0&&_e(`Can't append execution provider: ${l}.`)}},zp=e=>{let r=De(),a=0,i=[],l=e||{};dg(l);try{let n=cg(l.graphOptimizationLevel??"all"),o=pg(l.executionMode??"sequential"),p=typeof l.logId=="string"?ve(l.logId,i):0,c=l.logSeverityLevel??2;if(!Number.isInteger(c)||c<0||c>4)throw new Error(`log serverity level is not valid: ${c}`);let t=l.logVerbosityLevel??0;if(!Number.isInteger(t)||t<0||t>4)throw new Error(`log verbosity level is not valid: ${t}`);let u=typeof l.optimizedModelFilePath=="string"?ve(l.optimizedModelFilePath,i):0;if(a=r._OrtCreateSessionOptions(n,!!l.enableCpuMemArena,!!l.enableMemPattern,o,!!l.enableProfiling,0,p,c,t,u),a===0&&_e("Can't create session options."),l.executionProviders&&hg(a,l.executionProviders,i),l.enableGraphCapture!==void 0){if(typeof l.enableGraphCapture!="boolean")throw new Error(`enableGraphCapture must be a boolean value: ${l.enableGraphCapture}`);let s=ve("enableGraphCapture",i),d=ve(l.enableGraphCapture.toString(),i);r._OrtAddSessionConfigEntry(a,s,d)!==0&&_e(`Can't set a session config entry: 'enableGraphCapture' - ${l.enableGraphCapture}.`)}if(l.freeDimensionOverrides)for(let[s,d]of Object.entries(l.freeDimensionOverrides)){if(typeof s!="string")throw new Error(`free dimension override name must be a string: ${s}`);if(typeof d!="number"||!Number.isInteger(d)||d<0)throw new Error(`free dimension override value must be a non-negative integer: ${d}`);let f=ve(s,i);r._OrtAddFreeDimensionOverride(a,f,d)!==0&&_e(`Can't set a free dimension override: ${s} - ${d}.`)}return l.extra!==void 0&&bn(l.extra,"",new WeakSet,(s,d)=>{let f=ve(s,i),b=ve(d,i);r._OrtAddSessionConfigEntry(a,f,b)!==0&&_e(`Can't set a session config entry: ${s} - ${d}.`)}),[a,i]}catch(n){throw a!==0&&r._OrtReleaseSessionOptions(a),i.forEach(o=>r._free(o)),n}}}),aa,Wp,sa,Hp,qp,Po,jp,ua=L(()=>{aa=e=>{switch(e){case"int8":return 3;case"uint8":return 2;case"bool":return 9;case"int16":return 5;case"uint16":return 4;case"int32":return 6;case"uint32":return 12;case"float16":return 10;case"float32":return 1;case"float64":return 11;case"string":return 8;case"int64":return 7;case"uint64":return 13;default:throw new Error(`unsupported data type: ${e}`)}},Wp=e=>{switch(e){case 3:return"int8";case 2:return"uint8";case 9:return"bool";case 5:return"int16";case 4:return"uint16";case 6:return"int32";case 12:return"uint32";case 10:return"float16";case 1:return"float32";case 11:return"float64";case 8:return"string";case 7:return"int64";case 13:return"uint64";default:throw new Error(`unsupported data type: ${e}`)}},sa=e=>[void 0,4,1,1,2,2,4,8,void 0,1,2,8,4,8,void 0,void 0,void 0][e],Hp=e=>{switch(e){case"float16":return typeof Float16Array<"u"&&Float16Array.from?Float16Array:Uint16Array;case"float32":return Float32Array;case"uint8":return Uint8Array;case"int8":return Int8Array;case"uint16":return Uint16Array;case"int16":return Int16Array;case"int32":return Int32Array;case"bool":return Uint8Array;case"float64":return Float64Array;case"uint32":return Uint32Array;case"int64":return BigInt64Array;case"uint64":return BigUint64Array;default:throw new Error(`unsupported type: ${e}`)}},qp=e=>{switch(e){case"verbose":return 0;case"info":return 1;case"warning":return 2;case"error":return 3;case"fatal":return 4;default:throw new Error(`unsupported logging level: ${e}`)}},Po=e=>e==="float32"||e==="float16"||e==="int32"||e==="int64"||e==="uint32"||e==="uint8"||e==="bool",jp=e=>{switch(e){case"none":return 0;case"cpu":return 1;case"cpu-pinned":return 2;case"texture":return 3;case"gpu-buffer":return 4;default:throw new Error(`unsupported data location: ${e}`)}}}),gn,la=L(()=>{gn=async e=>{if(typeof e=="string")if(typeof process<"u"&&process.versions&&process.versions.node)try{return new Uint8Array(await(void 0)(e))}catch(r){if(r.code==="ERR_FS_FILE_TOO_LARGE"){let a=(void 0)(e),i=[];for await(let l of a)i.push(l);return new Uint8Array(Buffer.concat(i))}throw r}else{let r=await fetch(e);if(!r.ok)throw new Error(`failed to load external data file: ${e}`);let a=r.headers.get("Content-Length"),i=a?parseInt(a,10):0;if(i<1073741824)return new Uint8Array(await r.arrayBuffer());{if(!r.body)throw new Error(`failed to load external data file: ${e}, no response body.`);let l=r.body.getReader(),n;try{n=new ArrayBuffer(i)}catch(p){if(p instanceof RangeError){let c=Math.ceil(i/65536);n=new WebAssembly.Memory({initial:c,maximum:c}).buffer}else throw p}let o=0;for(;;){let{done:p,value:c}=await l.read();if(p)break;let t=c.byteLength;new Uint8Array(n,o,t).set(c),o+=t}return new Uint8Array(n,0,i)}}else return e instanceof Blob?new Uint8Array(await e.arrayBuffer()):e instanceof Uint8Array?e:new Uint8Array(e)}}),mg,Xp,Kp,zr,bg,fa,Jp,Zp,Yp,Qp,ed,td,rd=L(()=>{Up(),Vp(),ua(),Ur(),Ao(),la(),mg=(e,r)=>{De()._OrtInit(e,r)!==0&&_e("Can't initialize onnxruntime.")},Xp=async e=>{mg(e.wasm.numThreads,qp(e.logLevel))},Kp=async(e,r)=>{},zr=new Map,bg=e=>{let r=De(),a=r.stackSave();try{let i=r.stackAlloc(8);return r._OrtGetInputOutputCount(e,i,i+4)!==0&&_e("Can't get session input/output count."),[r.HEAP32[i/4],r.HEAP32[i/4+1]]}finally{r.stackRestore(a)}},fa=e=>{let r=De(),a=r._malloc(e.byteLength);if(a===0)throw new Error(`Can't create a session. failed to allocate a buffer of size ${e.byteLength}.`);return r.HEAPU8.set(e,a),[a,e.byteLength]},Jp=async(e,r)=>{var u;let a,i,l=De();Array.isArray(e)?[a,i]=e:e.buffer===l.HEAPU8.buffer?[a,i]=[e.byteOffset,e.byteLength]:[a,i]=fa(e);let n=0,o=0,p=[],c=[],t=[];try{if([o,p]=zp(r),(r==null?void 0:r.externalData)&&l.mountExternalData){let T=[];for(let $ of r.externalData){let F=typeof $=="string"?$:$.path;T.push(gn(typeof $=="string"?$:$.data).then(C=>{l.mountExternalData(F,C)}))}await Promise.all(T)}n=await l._OrtCreateSession(a,i,o),n===0&&_e("Can't create a session.");let[s,d]=bg(n),f=!!(r!=null&&r.enableGraphCapture),b=[],y=[],v=[];for(let T=0;Tl._OrtFree(d)),t.forEach(d=>l._OrtFree(d)),n!==0&&l._OrtReleaseSession(n),s}finally{l._free(a),o!==0&&l._OrtReleaseSessionOptions(o),p.forEach(s=>l._free(s)),(u=l.unmountExternalData)==null||u.call(l)}},Zp=e=>{var c;let r=De(),a=zr.get(e);if(!a)throw new Error(`cannot release session. invalid session id: ${e}`);let[i,l,n,o,p]=a;o&&(p&&r._OrtClearBoundOutputs(o.handle),r._OrtReleaseBinding(o.handle)),(c=r.jsepOnReleaseSession)==null||c.call(r,e),l.forEach(t=>r._OrtFree(t)),n.forEach(t=>r._OrtFree(t)),r._OrtReleaseSession(i),zr.delete(e)},Yp=(e,r,a,i,l,n=!1)=>{if(!e){r.push(0);return}let o=De(),p=e[0],c=e[1],t=e[3],u,s;if(p==="string"&&t==="gpu-buffer")throw new Error("String tensor is not supported on GPU.");if(n&&t!=="gpu-buffer")throw new Error(`External buffer must be provided for input/output index ${l} when enableGraphCapture is true.`);if(t==="gpu-buffer"){let b=e[2].gpuBuffer,y=sa(aa(p));s=c.reduce((E,T)=>E*T,1)*y;let v=o.jsepRegisterBuffer;if(!v)throw new Error('Tensor location "gpu-buffer" is not supported without using WebGPU.');u=v(i,l,b,s)}else{let b=e[2];if(Array.isArray(b)){s=4*b.length,u=o._malloc(s),a.push(u);let y=u/4;for(let v=0;vo.HEAP32[b++]=v);let y=o._OrtCreateTensor(aa(p),u,s,f,c.length,jp(t));y===0&&_e(`Can't create tensor for input/output. session=${i}, index=${l}.`),r.push(y)}finally{o.stackRestore(d)}},Qp=async(e,r,a,i,l,n)=>{var Fe;let o=De(),p=zr.get(e);if(!p)throw new Error(`cannot run inference. invalid session id: ${e}`);let c=p[0],t=p[1],u=p[2],s=p[3],d=p[4];p[5];let f=r.length,b=i.length,y=0,v=[],E=[],T=[],$=[],F=o.stackSave(),C=o.stackAlloc(f*4),J=o.stackAlloc(f*4),ge=o.stackAlloc(b*4),ze=o.stackAlloc(b*4);try{[y,v]=Gp(n);for(let q=0;qOe*ue,1);he=Wp(pt);let Le=s==null?void 0:s.outputPreferredLocations[i[q]];if(he==="string"){if(Le==="gpu-buffer")throw new Error("String tensor is not supported on GPU.");let Oe=[],ue=Ne/4;for(let Ce=0;Ce0){let Oe=o.jsepGetBuffer;if(!Oe)throw new Error('preferredLocation "gpu-buffer" is not supported without using WebGPU.');let ue=Oe(Ne),Ce=sa(pt);if(Ce===void 0||!Po(he))throw new Error(`Unsupported data type: ${he}`);je=!0,He.push([he,qe,{gpuBuffer:ue,download:o.jsepCreateDownloader(ue,Ye*Ce,he),dispose:()=>{o._OrtReleaseTensor(se)}},"gpu-buffer"])}else{let Oe=Hp(he),ue=new Oe(Ye);new Uint8Array(ue.buffer,ue.byteOffset,ue.byteLength).set(o.HEAPU8.subarray(Ne,Ne+ue.byteLength)),He.push([he,qe,ue,"cpu"])}}finally{o.stackRestore(Ke),he==="string"&&Ne&&o._free(Ne),je||o._OrtReleaseTensor(se)}}return s&&!d&&(o._OrtClearBoundOutputs(s.handle),zr.set(e,[c,t,u,s,d,!1])),He}finally{o.stackRestore(F),E.forEach(ee=>o._OrtReleaseTensor(ee)),T.forEach(ee=>o._OrtReleaseTensor(ee)),$.forEach(ee=>o._free(ee)),y!==0&&o._OrtReleaseRunOptions(y),v.forEach(ee=>o._free(ee))}},ed=e=>{let r=De(),a=zr.get(e);if(!a)throw new Error("invalid session id");let i=a[0],l=r._OrtEndProfiling(i);l===0&&_e("Can't get an profile file name."),r._OrtFree(l)},td=e=>{let r=[];for(let a of e){let i=a[2];!Array.isArray(i)&&"buffer"in i&&r.push(i.buffer)}return r}}),nd=me((e,r)=>{r.exports='/*!\n * ONNX Runtime Web v1.18.0\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n"use strict";(()=>{var vt=Object.defineProperty;var qr=Object.getOwnPropertyDescriptor;var Vr=Object.getOwnPropertyNames;var Jr=Object.prototype.hasOwnProperty;var _t=(i,c)=>()=>(i&&(c=i(i=0)),c);var Ke=(i,c)=>()=>(c||i((c={exports:{}}).exports,c),c.exports),Et=(i,c)=>{for(var a in c)vt(i,a,{get:c[a],enumerable:!0})},Xr=(i,c,a,h)=>{if(c&&typeof c=="object"||typeof c=="function")for(let f of Vr(c))!Jr.call(i,f)&&f!==a&&vt(i,f,{get:()=>c[f],enumerable:!(h=qr(c,f))||h.enumerable});return i};var et=i=>Xr(vt({},"__esModule",{value:!0}),i);var St={};Et(St,{createReadStream:()=>lr,readFile:()=>Qr,readFileSync:()=>Zr});var Qr,Zr,lr,At=_t(()=>{Qr=void 0,Zr=void 0,lr=void 0});var Tt={};Et(Tt,{join:()=>Kr});var Kr,Mt=_t(()=>{Kr=void 0});var pr=Ke((dr,Ct)=>{"use strict";var cr=(()=>{var i=typeof document<"u"?document.currentScript?.src:void 0;return typeof __filename<"u"&&(i||=__filename),function(c={}){var a=c,h,f,w=new Promise((t,o)=>{h=t,f=o}),g=Object.assign({},a),s="./this.program",S=typeof window=="object",x=typeof importScripts=="function",H=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",A="",I,V,R;if(H){var B=(At(),et(St)),D=(Mt(),et(Tt));A=x?D.dirname(A)+"/":__dirname+"/",I=(t,o)=>(t=ce(t)?new URL(t):D.normalize(t),B.readFileSync(t,o?void 0:"utf8")),R=t=>(t=I(t,!0),t.buffer||(t=new Uint8Array(t)),t),V=(t,o,u,m=!0)=>{t=ce(t)?new URL(t):D.normalize(t),B.readFile(t,m?void 0:"utf8",(O,E)=>{O?u(O):o(m?E.buffer:E)})},!a.thisProgram&&1{var o=new XMLHttpRequest;return o.open("GET",t,!1),o.send(null),o.responseText},x&&(R=t=>{var o=new XMLHttpRequest;return o.open("GET",t,!1),o.responseType="arraybuffer",o.send(null),new Uint8Array(o.response)}),V=(t,o,u)=>{var m=new XMLHttpRequest;m.open("GET",t,!0),m.responseType="arraybuffer",m.onload=()=>{m.status==200||m.status==0&&m.response?o(m.response):u()},m.onerror=u,m.send(null)});var T=console.log.bind(console),L=console.error.bind(console);Object.assign(a,g),g=null;var W,de=!1,pe,Z,_,J,Pe;function le(){var t=W.buffer;a.HEAP8=pe=new Int8Array(t),a.HEAP16=new Int16Array(t),a.HEAPU8=Z=new Uint8Array(t),a.HEAPU16=new Uint16Array(t),a.HEAP32=_=new Int32Array(t),a.HEAPU32=J=new Uint32Array(t),a.HEAPF32=new Float32Array(t),a.HEAPF64=Pe=new Float64Array(t)}var Ie=[],ne=[],X=[],we=0,me=null,F=null;function ie(t){throw t="Aborted("+t+")",L(t),de=!0,t=new WebAssembly.RuntimeError(t+". Build with -sASSERTIONS for more info."),f(t),t}var xe=t=>t.startsWith("data:application/octet-stream;base64,"),ce=t=>t.startsWith("file://"),be;if(be="ort-wasm.wasm",!xe(be)){var ae=be;be=a.locateFile?a.locateFile(ae,A):A+ae}function K(t){if(R)return R(t);throw"both async and sync fetching of the wasm failed"}function je(t){if(S||x){if(typeof fetch=="function"&&!ce(t))return fetch(t,{credentials:"same-origin"}).then(o=>{if(!o.ok)throw`failed to load wasm binary file at \'${t}\'`;return o.arrayBuffer()}).catch(()=>K(t));if(V)return new Promise((o,u)=>{V(t,m=>o(new Uint8Array(m)),u)})}return Promise.resolve().then(()=>K(t))}function Oe(t,o,u){return je(t).then(m=>WebAssembly.instantiate(m,o)).then(u,m=>{L(`failed to asynchronously prepare wasm: ${m}`),ie(m)})}function Ue(t,o){var u=be;return typeof WebAssembly.instantiateStreaming!="function"||xe(u)||ce(u)||H||typeof fetch!="function"?Oe(u,t,o):fetch(u,{credentials:"same-origin"}).then(m=>WebAssembly.instantiateStreaming(m,t).then(o,function(O){return L(`wasm streaming compile failed: ${O}`),L("falling back to ArrayBuffer instantiation"),Oe(u,t,o)}))}var ve,Ae={798088:(t,o,u,m)=>{if(typeof a>"u"||!a.ya)return 1;if(t=ue(t>>>0),t.startsWith("./")&&(t=t.substring(2)),t=a.ya.get(t),!t)return 2;if(o>>>=0,u>>>=0,o+u>t.byteLength)return 3;try{return Z.set(t.subarray(o,o+u),m>>>0>>>0),0}catch{return 4}}};class _e{constructor(o){this.wa=o-24}}var ge=0,Be=0,te=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,re=(t,o,u)=>{o>>>=0;var m=o+u;for(u=o;t[u]&&!(u>=m);)++u;if(16O?m+=String.fromCharCode(O):(O-=65536,m+=String.fromCharCode(55296|O>>10,56320|O&1023))}}else m+=String.fromCharCode(O)}return m},ue=(t,o)=>(t>>>=0)?re(Z,t,o):"",Ee=t=>{for(var o=0,u=0;u=m?o++:2047>=m?o+=2:55296<=m&&57343>=m?(o+=4,++u):o+=3}return o},Se=(t,o,u,m)=>{if(u>>>=0,!(0=U){var ee=t.charCodeAt(++E);U=65536+((U&1023)<<10)|ee&1023}if(127>=U){if(u>=m)break;o[u++>>>0]=U}else{if(2047>=U){if(u+1>=m)break;o[u++>>>0]=192|U>>6}else{if(65535>=U){if(u+2>=m)break;o[u++>>>0]=224|U>>12}else{if(u+3>=m)break;o[u++>>>0]=240|U>>18,o[u++>>>0]=128|U>>12&63}o[u++>>>0]=128|U>>6&63}o[u++>>>0]=128|U&63}}return o[u>>>0]=0,u-O},Le=t=>t%4===0&&(t%100!==0||t%400===0),ze=[0,31,60,91,121,152,182,213,244,274,305,335],rt=[0,31,59,90,120,151,181,212,243,273,304,334],Te=[],Ge={},ke=()=>{if(!We){var t={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:s||"./this.program"},o;for(o in Ge)Ge[o]===void 0?delete t[o]:t[o]=Ge[o];var u=[];for(o in t)u.push(`${o}=${t[o]}`);We=u}return We},We,nt=[null,[],[]],De=[31,29,31,30,31,30,31,31,30,31,30,31],at=[31,28,31,30,31,30,31,31,30,31,30,31];function G(t){var o=Array(Ee(t)+1);return Se(t,o,0,o.length),o}function qe(t,o,u,m){function O(d,k,$){for(d=typeof d=="number"?d.toString():d||"";d.lengthZe?-1:0Me-d.getDate())k-=Me-d.getDate()+1,d.setDate(1),11>$?d.setMonth($+1):(d.setMonth(0),d.setFullYear(d.getFullYear()+1));else{d.setDate(d.getDate()+k);break}}return $=new Date(d.getFullYear()+1,0,4),k=ee(new Date(d.getFullYear(),0,4)),$=ee($),0>=U(k,d)?0>=U($,d)?d.getFullYear()+1:d.getFullYear():d.getFullYear()-1}t>>>=0,o>>>=0,u>>>=0,m>>>=0;var oe=J[m+40>>>2>>>0];m={Ba:_[m>>>2>>>0],Aa:_[m+4>>>2>>>0],ua:_[m+8>>>2>>>0],xa:_[m+12>>>2>>>0],va:_[m+16>>>2>>>0],ta:_[m+20>>>2>>>0],na:_[m+24>>>2>>>0],sa:_[m+28>>>2>>>0],Da:_[m+32>>>2>>>0],za:_[m+36>>>2>>>0],Ca:oe?ue(oe):""},u=ue(u),oe={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var se in oe)u=u.replace(new RegExp(se,"g"),oe[se]);var Qe="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),Re="January February March April May June July August September October November December".split(" ");oe={"%a":d=>Qe[d.na].substring(0,3),"%A":d=>Qe[d.na],"%b":d=>Re[d.va].substring(0,3),"%B":d=>Re[d.va],"%C":d=>E((d.ta+1900)/100|0,2),"%d":d=>E(d.xa,2),"%e":d=>O(d.xa,2," "),"%g":d=>ye(d).toString().substring(2),"%G":ye,"%H":d=>E(d.ua,2),"%I":d=>(d=d.ua,d==0?d=12:12{for(var k=0,$=0;$<=d.va-1;k+=(Le(d.ta+1900)?De:at)[$++]);return E(d.xa+k,3)},"%m":d=>E(d.va+1,2),"%M":d=>E(d.Aa,2),"%n":()=>`\n`,"%p":d=>0<=d.ua&&12>d.ua?"AM":"PM","%S":d=>E(d.Ba,2),"%t":()=>" ","%u":d=>d.na||7,"%U":d=>E(Math.floor((d.sa+7-d.na)/7),2),"%V":d=>{var k=Math.floor((d.sa+7-(d.na+6)%7)/7);if(2>=(d.na+371-d.sa-2)%7&&k++,k)k==53&&($=(d.na+371-d.sa)%7,$==4||$==3&&Le(d.ta)||(k=1));else{k=52;var $=(d.na+7-d.sa-1)%7;($==4||$==5&&Le(d.ta%400-1))&&k++}return E(k,2)},"%w":d=>d.na,"%W":d=>E(Math.floor((d.sa+7-(d.na+6)%7)/7),2),"%y":d=>(d.ta+1900).toString().substring(2),"%Y":d=>d.ta+1900,"%z":d=>{d=d.za;var k=0<=d;return d=Math.abs(d)/60,(k?"+":"-")+("0000"+(d/60*100+d%60)).slice(-4)},"%Z":d=>d.Ca,"%%":()=>"%"},u=u.replace(/%%/g,"\\0\\0");for(se in oe)u.includes(se)&&(u=u.replace(new RegExp(se,"g"),oe[se](m)));return u=u.replace(/\\0\\0/g,"%"),se=G(u),se.length>o?0:(pe.set(se,t>>>0),se.length-1)}var Ve={a:function(t,o,u){t>>>=0;var m=new _e(t);throw J[m.wa+16>>>2>>>0]=0,J[m.wa+4>>>2>>>0]=o>>>0,J[m.wa+8>>>2>>>0]=u>>>0,ge=t,Be++,ge},e:function(){return 0},H:function(){},x:function(){},z:function(){},J:function(){return 0},F:function(){},A:function(){},E:function(){},g:function(){},y:function(){},v:function(){},G:function(){},w:function(){},k:()=>1,I:function(t,o,u){return o>>>=0,Z.copyWithin(t>>>0>>>0,o>>>0,o+(u>>>0)>>>0)},n:function(t,o,u){t=o+2097152>>>0<4194305-!!t?(t>>>0)+4294967296*o:NaN,u>>>=0,t=new Date(1e3*t),_[u>>>2>>>0]=t.getUTCSeconds(),_[u+4>>>2>>>0]=t.getUTCMinutes(),_[u+8>>>2>>>0]=t.getUTCHours(),_[u+12>>>2>>>0]=t.getUTCDate(),_[u+16>>>2>>>0]=t.getUTCMonth(),_[u+20>>>2>>>0]=t.getUTCFullYear()-1900,_[u+24>>>2>>>0]=t.getUTCDay(),_[u+28>>>2>>>0]=(t.getTime()-Date.UTC(t.getUTCFullYear(),0,1,0,0,0,0))/864e5|0},o:function(t,o,u){t=o+2097152>>>0<4194305-!!t?(t>>>0)+4294967296*o:NaN,u>>>=0,t=new Date(1e3*t),_[u>>>2>>>0]=t.getSeconds(),_[u+4>>>2>>>0]=t.getMinutes(),_[u+8>>>2>>>0]=t.getHours(),_[u+12>>>2>>>0]=t.getDate(),_[u+16>>>2>>>0]=t.getMonth(),_[u+20>>>2>>>0]=t.getFullYear()-1900,_[u+24>>>2>>>0]=t.getDay(),_[u+28>>>2>>>0]=(Le(t.getFullYear())?ze:rt)[t.getMonth()]+t.getDate()-1|0,_[u+36>>>2>>>0]=-(60*t.getTimezoneOffset()),o=new Date(t.getFullYear(),6,1).getTimezoneOffset();var m=new Date(t.getFullYear(),0,1).getTimezoneOffset();_[u+32>>>2>>>0]=(o!=m&&t.getTimezoneOffset()==Math.min(m,o))|0},p:function(t){t>>>=0;var o=new Date(_[t+20>>>2>>>0]+1900,_[t+16>>>2>>>0],_[t+12>>>2>>>0],_[t+8>>>2>>>0],_[t+4>>>2>>>0],_[t>>>2>>>0],0),u=_[t+32>>>2>>>0],m=o.getTimezoneOffset(),O=new Date(o.getFullYear(),6,1).getTimezoneOffset(),E=new Date(o.getFullYear(),0,1).getTimezoneOffset(),U=Math.min(E,O);return 0>u?_[t+32>>>2>>>0]=+(O!=E&&U==m):0>>2>>>0]=o.getDay(),_[t+28>>>2>>>0]=(Le(o.getFullYear())?ze:rt)[o.getMonth()]+o.getDate()-1|0,_[t>>>2>>>0]=o.getSeconds(),_[t+4>>>2>>>0]=o.getMinutes(),_[t+8>>>2>>>0]=o.getHours(),_[t+12>>>2>>>0]=o.getDate(),_[t+16>>>2>>>0]=o.getMonth(),_[t+20>>>2>>>0]=o.getYear(),t=o.getTime(),t=isNaN(t)?-1:t/1e3,Je((ve=t,1<=+Math.abs(ve)?0>>0:~~+Math.ceil((ve-+(~~ve>>>0))/4294967296)>>>0:0)),t>>>0},l:function(){return-52},m:function(){},t:function(t,o,u,m){u>>>=0,m>>>=0;var O=new Date().getFullYear(),E=new Date(O,0,1),U=new Date(O,6,1);O=E.getTimezoneOffset();var ee=U.getTimezoneOffset();J[t>>>0>>>2>>>0]=60*Math.max(O,ee),_[o>>>0>>>2>>>0]=+(O!=ee),t=ye=>ye.toLocaleTimeString(void 0,{hour12:!1,timeZoneName:"short"}).split(" ")[1],E=t(E),U=t(U),ee{ie("")},B:function(t,o,u){t>>>=0,o>>>=0,u>>>=0,Te.length=0;for(var m;m=Z[o++>>>0];){var O=m!=105;O&=m!=112,u+=O&&u%8?4:0,Te.push(m==112?J[u>>>2>>>0]:m==105?_[u>>>2>>>0]:Pe[u>>>3>>>0]),u+=O?8:4}return Ae[t](...Te)},h:()=>Date.now(),u:function(){return 4294901760},b:()=>performance.now(),s:function(t){t>>>=0;var o=Z.length;if(4294901760=u;u*=2){var m=o*(1+.2/u);m=Math.min(m,t+100663296);var O=Math;m=Math.max(t,m);e:{O=(O.min.call(O,4294901760,m+(65536-m%65536)%65536)-W.buffer.byteLength+65535)/65536;try{W.grow(O),le();var E=1;break e}catch{}E=void 0}if(E)return!0}return!1},C:function(t,o){t>>>=0,o>>>=0;var u=0;return ke().forEach((m,O)=>{var E=o+u;for(O=J[t+4*O>>>2>>>0]=E,E=0;E>>0]=m.charCodeAt(E);pe[O>>>0]=0,u+=m.length+1}),0},D:function(t,o){t>>>=0,o>>>=0;var u=ke();J[t>>>2>>>0]=u.length;var m=0;return u.forEach(O=>m+=O.length+1),J[o>>>2>>>0]=m,0},f:()=>52,j:function(){return 52},q:function(){return 70},i:function(t,o,u,m){o>>>=0,u>>>=0,m>>>=0;for(var O=0,E=0;E>>2>>>0],ee=J[o+4>>>2>>>0];o+=8;for(var ye=0;ye>>0],se=nt[t];oe===0||oe===10?((t===1?T:L)(re(se,0)),se.length=0):se.push(oe)}O+=ee}return J[m>>>2>>>0]=O,0},r:qe,c:function(t,o,u,m){return qe(t>>>0,o>>>0,u>>>0,m>>>0)}},P=function(){function t(u){return P=u.exports,P=st(),W=P.K,le(),ne.unshift(P.L),we--,we==0&&(me!==null&&(clearInterval(me),me=null),F&&(u=F,F=null,u())),P}var o={a:Ve};if(we++,a.instantiateWasm)try{return a.instantiateWasm(o,t)}catch(u){L(`Module.instantiateWasm callback failed with error: ${u}`),f(u)}return Ue(o,function(u){t(u.instance)}).catch(f),{}}();a._OrtInit=(t,o)=>(a._OrtInit=P.M)(t,o),a._OrtGetLastError=(t,o)=>(a._OrtGetLastError=P.N)(t,o),a._OrtCreateSessionOptions=(t,o,u,m,O,E,U,ee,ye,oe)=>(a._OrtCreateSessionOptions=P.O)(t,o,u,m,O,E,U,ee,ye,oe),a._OrtAppendExecutionProvider=(t,o)=>(a._OrtAppendExecutionProvider=P.P)(t,o),a._OrtAddFreeDimensionOverride=(t,o,u)=>(a._OrtAddFreeDimensionOverride=P.Q)(t,o,u),a._OrtAddSessionConfigEntry=(t,o,u)=>(a._OrtAddSessionConfigEntry=P.R)(t,o,u),a._OrtReleaseSessionOptions=t=>(a._OrtReleaseSessionOptions=P.S)(t),a._OrtCreateSession=(t,o,u)=>(a._OrtCreateSession=P.T)(t,o,u),a._OrtReleaseSession=t=>(a._OrtReleaseSession=P.U)(t),a._OrtGetInputOutputCount=(t,o,u)=>(a._OrtGetInputOutputCount=P.V)(t,o,u),a._OrtGetInputName=(t,o)=>(a._OrtGetInputName=P.W)(t,o),a._OrtGetOutputName=(t,o)=>(a._OrtGetOutputName=P.X)(t,o),a._OrtFree=t=>(a._OrtFree=P.Y)(t),a._OrtCreateTensor=(t,o,u,m,O,E)=>(a._OrtCreateTensor=P.Z)(t,o,u,m,O,E),a._OrtGetTensorData=(t,o,u,m,O)=>(a._OrtGetTensorData=P._)(t,o,u,m,O),a._OrtReleaseTensor=t=>(a._OrtReleaseTensor=P.$)(t),a._OrtCreateRunOptions=(t,o,u,m)=>(a._OrtCreateRunOptions=P.aa)(t,o,u,m),a._OrtAddRunConfigEntry=(t,o,u)=>(a._OrtAddRunConfigEntry=P.ba)(t,o,u),a._OrtReleaseRunOptions=t=>(a._OrtReleaseRunOptions=P.ca)(t),a._OrtCreateBinding=t=>(a._OrtCreateBinding=P.da)(t),a._OrtBindInput=(t,o,u)=>(a._OrtBindInput=P.ea)(t,o,u),a._OrtBindOutput=(t,o,u,m)=>(a._OrtBindOutput=P.fa)(t,o,u,m),a._OrtClearBoundOutputs=t=>(a._OrtClearBoundOutputs=P.ga)(t),a._OrtReleaseBinding=t=>(a._OrtReleaseBinding=P.ha)(t),a._OrtRunWithBinding=(t,o,u,m,O)=>(a._OrtRunWithBinding=P.ia)(t,o,u,m,O),a._OrtRun=(t,o,u,m,O,E,U,ee)=>(a._OrtRun=P.ja)(t,o,u,m,O,E,U,ee),a._OrtEndProfiling=t=>(a._OrtEndProfiling=P.ka)(t),a._malloc=t=>(a._malloc=P.la)(t),a._free=t=>(a._free=P.ma)(t);var Je=t=>(Je=P.oa)(t),ot=t=>(ot=P.pa)(t),M=t=>(M=P.qa)(t),Ne=()=>(Ne=P.ra)();function st(){var t=P;t=Object.assign({},t);var o=u=>m=>u(m)>>>0;return t.la=o(t.la),t.qa=o(t.qa),t.ra=(u=>()=>u()>>>0)(t.ra),t}a.stackSave=()=>Ne(),a.stackRestore=t=>ot(t),a.stackAlloc=t=>M(t),a.UTF8ToString=ue,a.stringToUTF8=(t,o,u)=>Se(t,Z,o,u),a.lengthBytesUTF8=Ee;var Fe;F=function t(){Fe||Xe(),Fe||(F=t)};function Xe(){if(!(0cr)});var mr=Ke(()=>{});var gr=Ke(()=>{});var hr={};Et(hr,{cpus:()=>en});var en,br=_t(()=>{en=void 0});var Or=Ke((wr,Dt)=>{"use strict";var yr=(()=>{var i=typeof document<"u"?document.currentScript?.src:void 0;return typeof __filename<"u"&&(i||=__filename),function(c={}){function a(){return X.buffer!=ie.buffer&&K(),ie}function h(){return X.buffer!=ie.buffer&&K(),xe}function f(){return X.buffer!=ie.buffer&&K(),ce}function w(){return X.buffer!=ie.buffer&&K(),be}function g(){return X.buffer!=ie.buffer&&K(),ae}var s=c,S,x,H=new Promise((e,r)=>{S=e,x=r}),A=Object.assign({},s),I="./this.program",V=(e,r)=>{throw r},R=typeof window=="object",B=typeof importScripts=="function",D=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",T=s.ENVIRONMENT_IS_PTHREAD||!1,L="";function W(e){return s.locateFile?s.locateFile(e,L):L+e}var de,pe,Z;if(D){var _=(At(),et(St)),J=(Mt(),et(Tt));L=B?J.dirname(L)+"/":__dirname+"/",de=(e,r)=>(e=ue(e)?new URL(e):J.normalize(e),_.readFileSync(e,r?void 0:"utf8")),Z=e=>(e=de(e,!0),e.buffer||(e=new Uint8Array(e)),e),pe=(e,r,n,l=!0)=>{e=ue(e)?new URL(e):J.normalize(e),_.readFile(e,l?void 0:"utf8",(y,b)=>{y?n(y):r(l?b.buffer:b)})},!s.thisProgram&&1{throw process.exitCode=e,r},global.Worker=mr().Worker}else(R||B)&&(B?L=self.location.href:typeof document<"u"&&document.currentScript&&(L=document.currentScript.src),typeof i<"u"&&i&&(L=i),L.startsWith("blob:")?L="":L=L.substr(0,L.replace(/[?#].*/,"").lastIndexOf("/")+1),D||(de=e=>{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.send(null),r.responseText},B&&(Z=e=>{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.responseType="arraybuffer",r.send(null),new Uint8Array(r.response)}),pe=(e,r,n)=>{var l=new XMLHttpRequest;l.open("GET",e,!0),l.responseType="arraybuffer",l.onload=()=>{l.status==200||l.status==0&&l.response?r(l.response):n()},l.onerror=n,l.send(null)}));D&&typeof performance>"u"&&(global.performance=gr().performance);var Pe=console.log.bind(console),le=console.error.bind(console);D&&(Pe=(...e)=>_.writeSync(1,e.join(" ")+`\n`),le=(...e)=>_.writeSync(2,e.join(" ")+`\n`));var Ie=Pe,ne=le;Object.assign(s,A),A=null;var X,we,me=!1,F,ie,xe,ce,be,ae;function K(){var e=X.buffer;s.HEAP8=ie=new Int8Array(e),s.HEAP16=new Int16Array(e),s.HEAPU8=xe=new Uint8Array(e),s.HEAPU16=new Uint16Array(e),s.HEAP32=ce=new Int32Array(e),s.HEAPU32=be=new Uint32Array(e),s.HEAPF32=new Float32Array(e),s.HEAPF64=ae=new Float64Array(e)}var je=16777216;if(T)X=s.wasmMemory;else if(s.wasmMemory)X=s.wasmMemory;else if(X=new WebAssembly.Memory({initial:je/65536,maximum:65536,shared:!0}),!(X.buffer instanceof SharedArrayBuffer))throw ne("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"),D&&ne("(on node you may need: --experimental-wasm-threads --experimental-wasm-bulk-memory and/or recent version)"),Error("bad memory");K(),je=X.buffer.byteLength;var Oe=[],Ue=[],ve=[],Ae=0,_e=null,ge=null;function Be(){if(Ae--,Ae==0&&(_e!==null&&(clearInterval(_e),_e=null),ge)){var e=ge;ge=null,e()}}function te(e){throw e="Aborted("+e+")",ne(e),me=!0,F=1,e=new WebAssembly.RuntimeError(e+". Build with -sASSERTIONS for more info."),x(e),e}var re=e=>e.startsWith("data:application/octet-stream;base64,"),ue=e=>e.startsWith("file://"),Ee;Ee="ort-wasm-threaded.wasm",re(Ee)||(Ee=W(Ee));function Se(e){if(Z)return Z(e);throw"both async and sync fetching of the wasm failed"}function Le(e){if(R||B){if(typeof fetch=="function"&&!ue(e))return fetch(e,{credentials:"same-origin"}).then(r=>{if(!r.ok)throw`failed to load wasm binary file at \'${e}\'`;return r.arrayBuffer()}).catch(()=>Se(e));if(pe)return new Promise((r,n)=>{pe(e,l=>r(new Uint8Array(l)),n)})}return Promise.resolve().then(()=>Se(e))}function ze(e,r,n){return Le(e).then(l=>WebAssembly.instantiate(l,r)).then(n,l=>{ne(`failed to asynchronously prepare wasm: ${l}`),te(l)})}function rt(e,r){var n=Ee;return typeof WebAssembly.instantiateStreaming!="function"||re(n)||ue(n)||D||typeof fetch!="function"?ze(n,e,r):fetch(n,{credentials:"same-origin"}).then(l=>WebAssembly.instantiateStreaming(l,e).then(r,function(y){return ne(`wasm streaming compile failed: ${y}`),ne("falling back to ArrayBuffer instantiation"),ze(n,e,r)}))}var Te,Ge={799444:(e,r,n,l)=>{if(typeof s>"u"||!s.bb)return 1;if(e=ee(e>>>0),e.startsWith("./")&&(e=e.substring(2)),e=s.bb.get(e),!e)return 2;if(r>>>=0,n>>>=0,l>>>=0,r+n>e.byteLength)return 3;try{return h().set(e.subarray(r,r+n),l>>>0),0}catch{return 4}}};function ke(e){this.name="ExitStatus",this.message=`Program terminated with exit(${e})`,this.status=e}var We=e=>{e.terminate(),e.onmessage=()=>{}},nt=e=>{M.Oa.length==0&&(Je(),M.Xa(M.Oa[0]));var r=M.Oa.pop();if(!r)return 6;M.Pa.push(r),M.La[e.Na]=r,r.Na=e.Na;var n={cmd:"run",start_routine:e.gb,arg:e.cb,pthread_ptr:e.Na};return D&&r.unref(),r.postMessage(n,e.mb),0},De=0,at=e=>{var r=Ot();return e=e(),ft(r),e},G=(e,r,...n)=>at(()=>{for(var l=n.length,y=wt(8*l),b=y>>>3,v=0;v>>0]=z}return rr(e,0,l,y,r)});function qe(e){if(T)return G(0,1,e);F=e,0{if(F=e,T)throw st(e),"unwind";qe(e)};function P(){for(var e=s.numThreads;e--;)Je();Oe.unshift(()=>{Ae++,ot(()=>Be())})}function Je(){var e=W("ort-wasm-threaded.worker.js");e=new Worker(e),M.Oa.push(e)}function ot(e){T?e():Promise.all(M.Oa.map(M.Xa)).then(e)}var M={Oa:[],Pa:[],ab:[],La:{},Va(){T?(M.receiveObjectTransfer=M.fb,M.threadInitTLS=M.$a,M.setExitStatus=M.Za):P()},Za:e=>F=e,pb:["$terminateWorker"],hb:()=>{for(var e of M.Pa)We(e);for(e of M.Oa)We(e);M.Oa=[],M.Pa=[],M.La=[]},Ya:e=>{var r=e.Na;delete M.La[r],M.Oa.push(e),M.Pa.splice(M.Pa.indexOf(e),1),e.Na=0,bt(r)},fb(){},$a(){M.ab.forEach(e=>e())},Xa:e=>new Promise(r=>{e.onmessage=b=>{b=b.data;var v=b.cmd;if(b.targetThread&&b.targetThread!=ut()){var z=M.La[b.targetThread];z?z.postMessage(b,b.transferList):ne(`Internal error! Worker sent a message "${v}" to target pthread ${b.targetThread}, but that thread no longer exists!`)}else v==="checkMailbox"?it():v==="spawnThread"?nt(b):v==="cleanupThread"?M.Ya(M.La[b.thread]):v==="killThread"?(b=b.thread,v=M.La[b],delete M.La[b],We(v),bt(b),M.Pa.splice(M.Pa.indexOf(v),1),v.Na=0):v==="cancelThread"?M.La[b.thread].postMessage({cmd:"cancel"}):v==="loaded"?(e.loaded=!0,D&&!e.Na&&e.unref(),r(e)):v==="alert"?alert(`Thread ${b.threadId}: ${b.text}`):b.target==="setimmediate"?e.postMessage(b):v==="callHandler"?s[b.handler](...b.args):v&&ne(`worker sent an unknown command ${v}`)},e.onerror=b=>{throw ne(`worker sent an error! ${b.filename}:${b.lineno}: ${b.message}`),b},D&&(e.on("message",b=>e.onmessage({data:b})),e.on("error",b=>e.onerror(b)));var n=[],l=["onExit"],y;for(y of l)s.hasOwnProperty(y)&&n.push(y);e.postMessage({cmd:"load",handlers:n,urlOrBlob:s.mainScriptUrlOrBlob||i,wasmMemory:X,wasmModule:we})})};s.PThread=M;var Ne=e=>{for(;0{var e=ut(),r=w()[e+52>>>2>>>0];e=w()[e+56>>>2>>>0],or(r,r-e),ft(r)};function st(e){if(T)return G(1,0,e);Ve(e)}var Fe=[],Xe;s.invokeEntryPoint=(e,r)=>{De=0;var n=Fe[e];n||(e>=Fe.length&&(Fe.length=e+1),Fe[e]=n=Xe.get(e)),e=n(r),0>>2>>>0]=0,w()[this.Ua+4>>>2>>>0]=r,w()[this.Ua+8>>>2>>>0]=n}}var o=0,u=0;function m(e,r,n,l){return T?G(2,1,e,r,n,l):O(e,r,n,l)}function O(e,r,n,l){if(e>>>=0,r>>>=0,n>>>=0,l>>>=0,typeof SharedArrayBuffer>"u")return ne("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var y=[];return T&&y.length===0?m(e,r,n,l):(e={gb:n,Na:e,cb:l,mb:y},T?(e.ob="spawnThread",postMessage(e,y),0):nt(e))}var E=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,U=(e,r,n)=>{r>>>=0;var l=r+n;for(n=r;e[n]&&!(n>=l);)++n;if(16y?l+=String.fromCharCode(y):(y-=65536,l+=String.fromCharCode(55296|y>>10,56320|y&1023))}}else l+=String.fromCharCode(y)}return l},ee=(e,r)=>(e>>>=0)?U(h(),e,r):"";function ye(e,r,n){return T?G(3,1,e,r,n):0}function oe(e,r){if(T)return G(4,1,e,r)}var se=e=>{for(var r=0,n=0;n=l?r++:2047>=l?r+=2:55296<=l&&57343>=l?(r+=4,++n):r+=3}return r},Qe=(e,r,n,l)=>{if(n>>>=0,!(0=v){var z=e.charCodeAt(++b);v=65536+((v&1023)<<10)|z&1023}if(127>=v){if(n>=l)break;r[n++>>>0]=v}else{if(2047>=v){if(n+1>=l)break;r[n++>>>0]=192|v>>6}else{if(65535>=v){if(n+2>=l)break;r[n++>>>0]=224|v>>12}else{if(n+3>=l)break;r[n++>>>0]=240|v>>18,r[n++>>>0]=128|v>>12&63}r[n++>>>0]=128|v>>6&63}r[n++>>>0]=128|v&63}}return r[n>>>0]=0,n-y},Re=(e,r,n)=>Qe(e,h(),r,n);function d(e,r){if(T)return G(5,1,e,r)}function k(e,r,n){if(T)return G(6,1,e,r,n)}function $(e,r,n){return T?G(7,1,e,r,n):0}function Me(e,r){if(T)return G(8,1,e,r)}function Ze(e,r,n){if(T)return G(9,1,e,r,n)}function Rt(e,r,n,l){if(T)return G(10,1,e,r,n,l)}function It(e,r,n,l){if(T)return G(11,1,e,r,n,l)}function Bt(e,r,n,l){if(T)return G(12,1,e,r,n,l)}function kt(e){if(T)return G(13,1,e)}function Wt(e,r){if(T)return G(14,1,e,r)}function Nt(e,r,n){if(T)return G(15,1,e,r,n)}function dt(e){e>>>=0,typeof Atomics.nb=="function"&&(Atomics.nb(f(),e>>>2,e).value.then(it),e+=128,Atomics.store(f(),e>>>2,1))}s.__emscripten_thread_mailbox_await=dt;var it=()=>{var e=ut();if(e&&(dt(e),e=nr,!me))try{if(e(),!(0e%4===0&&(e%100!==0||e%400===0),Ht=[0,31,60,91,121,152,182,213,244,274,305,335],Gt=[0,31,59,90,120,151,181,212,243,273,304,334];function $t(e,r,n,l,y,b,v,z){return T?G(16,1,e,r,n,l,y,b,v,z):-52}function Yt(e,r,n,l,y,b,v){if(T)return G(17,1,e,r,n,l,y,b,v)}var mt=[],gt={},jt=()=>{if(!ht){var e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:I||"./this.program"},r;for(r in gt)gt[r]===void 0?delete e[r]:e[r]=gt[r];var n=[];for(r in e)n.push(`${r}=${e[r]}`);ht=n}return ht},ht;function zt(e,r){if(T)return G(18,1,e,r);e>>>=0,r>>>=0;var n=0;return jt().forEach((l,y)=>{var b=r+n;for(y=w()[e+4*y>>>2>>>0]=b,b=0;b>>0]=l.charCodeAt(b);a()[y>>>0]=0,n+=l.length+1}),0}function qt(e,r){if(T)return G(19,1,e,r);e>>>=0,r>>>=0;var n=jt();w()[e>>>2>>>0]=n.length;var l=0;return n.forEach(y=>l+=y.length+1),w()[r>>>2>>>0]=l,0}function Vt(e){return T?G(20,1,e):52}function Jt(e,r,n,l){return T?G(21,1,e,r,n,l):52}function Xt(e,r,n,l,y){return T?G(22,1,e,r,n,l,y):70}var Hr=[null,[],[]];function Qt(e,r,n,l){if(T)return G(23,1,e,r,n,l);r>>>=0,n>>>=0,l>>>=0;for(var y=0,b=0;b>>2>>>0],z=w()[r+4>>>2>>>0];r+=8;for(var Ce=0;Ce>>0],he=Hr[e];fe===0||fe===10?((e===1?Ie:ne)(U(he,0)),he.length=0):he.push(fe)}y+=z}return w()[l>>>2>>>0]=y,0}var Zt=[31,29,31,30,31,30,31,31,30,31,30,31],Kt=[31,28,31,30,31,30,31,31,30,31,30,31];function Gr(e){var r=Array(se(e)+1);return Qe(e,r,0,r.length),r}var $r=(e,r)=>{a().set(e,r>>>0)};function er(e,r,n,l){function y(p,N,q){for(p=typeof p=="number"?p.toString():p||"";p.lengthfr?-1:0He-p.getDate())N-=He-p.getDate()+1,p.setDate(1),11>q?p.setMonth(q+1):(p.setMonth(0),p.setFullYear(p.getFullYear()+1));else{p.setDate(p.getDate()+N);break}}return q=new Date(p.getFullYear()+1,0,4),N=z(new Date(p.getFullYear(),0,4)),q=z(q),0>=v(N,p)?0>=v(q,p)?p.getFullYear()+1:p.getFullYear():p.getFullYear()-1}e>>>=0,r>>>=0,n>>>=0,l>>>=0;var fe=w()[l+40>>>2>>>0];l={kb:f()[l>>>2>>>0],jb:f()[l+4>>>2>>>0],Sa:f()[l+8>>>2>>>0],Wa:f()[l+12>>>2>>>0],Ta:f()[l+16>>>2>>>0],Ra:f()[l+20>>>2>>>0],Ma:f()[l+24>>>2>>>0],Qa:f()[l+28>>>2>>>0],qb:f()[l+32>>>2>>>0],ib:f()[l+36>>>2>>>0],lb:fe?ee(fe):""},n=ee(n),fe={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var he in fe)n=n.replace(new RegExp(he,"g"),fe[he]);var ir="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),ur="January February March April May June July August September October November December".split(" ");fe={"%a":p=>ir[p.Ma].substring(0,3),"%A":p=>ir[p.Ma],"%b":p=>ur[p.Ta].substring(0,3),"%B":p=>ur[p.Ta],"%C":p=>b((p.Ra+1900)/100|0,2),"%d":p=>b(p.Wa,2),"%e":p=>y(p.Wa,2," "),"%g":p=>Ce(p).toString().substring(2),"%G":Ce,"%H":p=>b(p.Sa,2),"%I":p=>(p=p.Sa,p==0?p=12:12{for(var N=0,q=0;q<=p.Ta-1;N+=($e(p.Ra+1900)?Zt:Kt)[q++]);return b(p.Wa+N,3)},"%m":p=>b(p.Ta+1,2),"%M":p=>b(p.jb,2),"%n":()=>`\n`,"%p":p=>0<=p.Sa&&12>p.Sa?"AM":"PM","%S":p=>b(p.kb,2),"%t":()=>" ","%u":p=>p.Ma||7,"%U":p=>b(Math.floor((p.Qa+7-p.Ma)/7),2),"%V":p=>{var N=Math.floor((p.Qa+7-(p.Ma+6)%7)/7);if(2>=(p.Ma+371-p.Qa-2)%7&&N++,N)N==53&&(q=(p.Ma+371-p.Qa)%7,q==4||q==3&&$e(p.Ra)||(N=1));else{N=52;var q=(p.Ma+7-p.Qa-1)%7;(q==4||q==5&&$e(p.Ra%400-1))&&N++}return b(N,2)},"%w":p=>p.Ma,"%W":p=>b(Math.floor((p.Qa+7-(p.Ma+6)%7)/7),2),"%y":p=>(p.Ra+1900).toString().substring(2),"%Y":p=>p.Ra+1900,"%z":p=>{p=p.ib;var N=0<=p;return p=Math.abs(p)/60,(N?"+":"-")+("0000"+(p/60*100+p%60)).slice(-4)},"%Z":p=>p.lb,"%%":()=>"%"},n=n.replace(/%%/g,"\\0\\0");for(he in fe)n.includes(he)&&(n=n.replace(new RegExp(he,"g"),fe[he](l)));return n=n.replace(/\\0\\0/g,"%"),he=Gr(n),he.length>r?0:($r(he,e),he.length-1)}M.Va();var Yr=[qe,st,m,ye,oe,d,k,$,Me,Ze,Rt,It,Bt,kt,Wt,Nt,$t,Yt,zt,qt,Vt,Jt,Xt,Qt],jr={b:function(e,r,n){throw e>>>=0,new t(e).Va(r>>>0,n>>>0),o=e,u++,o},L:function(e){tr(e>>>0,!B,1,!R,131072,!1),M.$a()},j:function(e){e>>>=0,T?postMessage({cmd:"cleanupThread",thread:e}):M.Ya(M.La[e])},H:O,h:ye,S:oe,D:d,F:k,T:$,Q:Me,J:Ze,P:Rt,n:It,E:Bt,B:kt,R:Wt,C:Nt,p:()=>1,z:function(e,r){e>>>=0,e==r>>>0?setTimeout(it):T?postMessage({targetThread:e,cmd:"checkMailbox"}):(e=M.La[e])&&e.postMessage({cmd:"checkMailbox"})},I:function(e,r,n,l,y){r>>>=0,n>>>=0,pt.length=l,y=y>>>0>>>3;for(var b=0;b>>0];return e=r?Ge[r]:Yr[e],M.eb=n,n=e(...pt),M.eb=0,n},K:dt,o:function(e){D&&M.La[e>>>0].ref()},s:function(e,r,n){e=r+2097152>>>0<4194305-!!e?(e>>>0)+4294967296*r:NaN,n>>>=0,e=new Date(1e3*e),f()[n>>>2>>>0]=e.getUTCSeconds(),f()[n+4>>>2>>>0]=e.getUTCMinutes(),f()[n+8>>>2>>>0]=e.getUTCHours(),f()[n+12>>>2>>>0]=e.getUTCDate(),f()[n+16>>>2>>>0]=e.getUTCMonth(),f()[n+20>>>2>>>0]=e.getUTCFullYear()-1900,f()[n+24>>>2>>>0]=e.getUTCDay(),e=(e.getTime()-Date.UTC(e.getUTCFullYear(),0,1,0,0,0,0))/864e5|0,f()[n+28>>>2>>>0]=e},t:function(e,r,n){e=r+2097152>>>0<4194305-!!e?(e>>>0)+4294967296*r:NaN,n>>>=0,e=new Date(1e3*e),f()[n>>>2>>>0]=e.getSeconds(),f()[n+4>>>2>>>0]=e.getMinutes(),f()[n+8>>>2>>>0]=e.getHours(),f()[n+12>>>2>>>0]=e.getDate(),f()[n+16>>>2>>>0]=e.getMonth(),f()[n+20>>>2>>>0]=e.getFullYear()-1900,f()[n+24>>>2>>>0]=e.getDay(),r=($e(e.getFullYear())?Ht:Gt)[e.getMonth()]+e.getDate()-1|0,f()[n+28>>>2>>>0]=r,f()[n+36>>>2>>>0]=-(60*e.getTimezoneOffset()),r=new Date(e.getFullYear(),6,1).getTimezoneOffset();var l=new Date(e.getFullYear(),0,1).getTimezoneOffset();e=(r!=l&&e.getTimezoneOffset()==Math.min(l,r))|0,f()[n+32>>>2>>>0]=e},u:function(e){e>>>=0;var r=new Date(f()[e+20>>>2>>>0]+1900,f()[e+16>>>2>>>0],f()[e+12>>>2>>>0],f()[e+8>>>2>>>0],f()[e+4>>>2>>>0],f()[e>>>2>>>0],0),n=f()[e+32>>>2>>>0],l=r.getTimezoneOffset(),y=new Date(r.getFullYear(),6,1).getTimezoneOffset(),b=new Date(r.getFullYear(),0,1).getTimezoneOffset(),v=Math.min(b,y);return 0>n?f()[e+32>>>2>>>0]=+(y!=b&&v==l):0>>2>>>0]=r.getDay(),n=($e(r.getFullYear())?Ht:Gt)[r.getMonth()]+r.getDate()-1|0,f()[e+28>>>2>>>0]=n,f()[e>>>2>>>0]=r.getSeconds(),f()[e+4>>>2>>>0]=r.getMinutes(),f()[e+8>>>2>>>0]=r.getHours(),f()[e+12>>>2>>>0]=r.getDate(),f()[e+16>>>2>>>0]=r.getMonth(),f()[e+20>>>2>>>0]=r.getYear(),e=r.getTime(),e=isNaN(e)?-1:e/1e3,ar((Te=e,1<=+Math.abs(Te)?0>>0:~~+Math.ceil((Te-+(~~Te>>>0))/4294967296)>>>0:0)),e>>>0},q:$t,r:Yt,y:function(e,r,n,l){e>>>=0,r>>>=0,n>>>=0,l>>>=0;var y=new Date().getFullYear(),b=new Date(y,0,1),v=new Date(y,6,1);y=b.getTimezoneOffset();var z=v.getTimezoneOffset(),Ce=Math.max(y,z);w()[e>>>2>>>0]=60*Ce,f()[r>>>2>>>0]=+(y!=z),e=fe=>fe.toLocaleTimeString(void 0,{hour12:!1,timeZoneName:"short"}).split(" ")[1],b=e(b),v=e(v),z{te("")},O:function(e,r,n){e>>>=0,r>>>=0,n>>>=0,mt.length=0;for(var l;l=h()[r++>>>0];){var y=l!=105;y&=l!=112,n+=y&&n%8?4:0,mt.push(l==112?w()[n>>>2>>>0]:l==105?f()[n>>>2>>>0]:g()[n>>>3>>>0]),n+=y?8:4}return Ge[e](...mt)},k:()=>{},i:()=>Date.now(),U:()=>{throw De+=1,"unwind"},A:function(){return 4294901760},e:()=>performance.timeOrigin+performance.now(),f:()=>D?(br(),et(hr)).cpus().length:navigator.hardwareConcurrency,x:function(e){e>>>=0;var r=h().length;if(e<=r||4294901760=n;n*=2){var l=r*(1+.2/n);l=Math.min(l,e+100663296);var y=Math;l=Math.max(e,l);e:{y=(y.min.call(y,4294901760,l+(65536-l%65536)%65536)-X.buffer.byteLength+65535)/65536;try{X.grow(y),K();var b=1;break e}catch{}b=void 0}if(b)return!0}return!1},M:zt,N:qt,G:Ve,g:Vt,m:Jt,v:Xt,l:Qt,a:X||s.wasmMemory,w:er,d:function(e,r,n,l){return er(e>>>0,r>>>0,n>>>0,l>>>0)}},C=function(){function e(n,l){return C=n.exports,C=zr(),M.ab.push(C.ya),Xe=C.za,Ue.unshift(C.V),we=l,Be(),C}var r={a:jr};if(Ae++,s.instantiateWasm)try{return s.instantiateWasm(r,e)}catch(n){ne(`Module.instantiateWasm callback failed with error: ${n}`),x(n)}return rt(r,function(n){e(n.instance,n.module)}).catch(x),{}}();s._OrtInit=(e,r)=>(s._OrtInit=C.W)(e,r),s._OrtGetLastError=(e,r)=>(s._OrtGetLastError=C.X)(e,r),s._OrtCreateSessionOptions=(e,r,n,l,y,b,v,z,Ce,fe)=>(s._OrtCreateSessionOptions=C.Y)(e,r,n,l,y,b,v,z,Ce,fe),s._OrtAppendExecutionProvider=(e,r)=>(s._OrtAppendExecutionProvider=C.Z)(e,r),s._OrtAddFreeDimensionOverride=(e,r,n)=>(s._OrtAddFreeDimensionOverride=C._)(e,r,n),s._OrtAddSessionConfigEntry=(e,r,n)=>(s._OrtAddSessionConfigEntry=C.$)(e,r,n),s._OrtReleaseSessionOptions=e=>(s._OrtReleaseSessionOptions=C.aa)(e),s._OrtCreateSession=(e,r,n)=>(s._OrtCreateSession=C.ba)(e,r,n),s._OrtReleaseSession=e=>(s._OrtReleaseSession=C.ca)(e),s._OrtGetInputOutputCount=(e,r,n)=>(s._OrtGetInputOutputCount=C.da)(e,r,n),s._OrtGetInputName=(e,r)=>(s._OrtGetInputName=C.ea)(e,r),s._OrtGetOutputName=(e,r)=>(s._OrtGetOutputName=C.fa)(e,r),s._OrtFree=e=>(s._OrtFree=C.ga)(e),s._OrtCreateTensor=(e,r,n,l,y,b)=>(s._OrtCreateTensor=C.ha)(e,r,n,l,y,b),s._OrtGetTensorData=(e,r,n,l,y)=>(s._OrtGetTensorData=C.ia)(e,r,n,l,y),s._OrtReleaseTensor=e=>(s._OrtReleaseTensor=C.ja)(e),s._OrtCreateRunOptions=(e,r,n,l)=>(s._OrtCreateRunOptions=C.ka)(e,r,n,l),s._OrtAddRunConfigEntry=(e,r,n)=>(s._OrtAddRunConfigEntry=C.la)(e,r,n),s._OrtReleaseRunOptions=e=>(s._OrtReleaseRunOptions=C.ma)(e),s._OrtCreateBinding=e=>(s._OrtCreateBinding=C.na)(e),s._OrtBindInput=(e,r,n)=>(s._OrtBindInput=C.oa)(e,r,n),s._OrtBindOutput=(e,r,n,l)=>(s._OrtBindOutput=C.pa)(e,r,n,l),s._OrtClearBoundOutputs=e=>(s._OrtClearBoundOutputs=C.qa)(e),s._OrtReleaseBinding=e=>(s._OrtReleaseBinding=C.ra)(e),s._OrtRunWithBinding=(e,r,n,l,y)=>(s._OrtRunWithBinding=C.sa)(e,r,n,l,y),s._OrtRun=(e,r,n,l,y,b,v,z)=>(s._OrtRun=C.ta)(e,r,n,l,y,b,v,z),s._OrtEndProfiling=e=>(s._OrtEndProfiling=C.ua)(e);var ut=s._pthread_self=()=>(ut=s._pthread_self=C.va)();s._malloc=e=>(s._malloc=C.wa)(e),s._free=e=>(s._free=C.xa)(e),s.__emscripten_tls_init=()=>(s.__emscripten_tls_init=C.ya)();var tr=s.__emscripten_thread_init=(e,r,n,l,y,b)=>(tr=s.__emscripten_thread_init=C.Aa)(e,r,n,l,y,b);s.__emscripten_thread_crashed=()=>(s.__emscripten_thread_crashed=C.Ba)();var rr=(e,r,n,l,y)=>(rr=C.Ca)(e,r,n,l,y),bt=e=>(bt=C.Da)(e),yt=s.__emscripten_thread_exit=e=>(yt=s.__emscripten_thread_exit=C.Ea)(e),nr=()=>(nr=C.Fa)(),ar=e=>(ar=C.Ga)(e),or=(e,r)=>(or=C.Ha)(e,r),ft=e=>(ft=C.Ia)(e),wt=e=>(wt=C.Ja)(e),Ot=()=>(Ot=C.Ka)();function zr(){var e=C;e=Object.assign({},e);var r=l=>()=>l()>>>0,n=l=>y=>l(y)>>>0;return e.va=r(e.va),e.wa=n(e.wa),e.emscripten_main_runtime_thread_id=r(e.emscripten_main_runtime_thread_id),e.Ja=n(e.Ja),e.Ka=r(e.Ka),e}s.wasmMemory=X,s.stackSave=()=>Ot(),s.stackRestore=e=>ft(e),s.stackAlloc=e=>wt(e),s.keepRuntimeAlive=()=>0yr)});var vr=Ke((yn,tn)=>{tn.exports=\'"use strict";var Module={},ENVIRONMENT_IS_NODE=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string";if(ENVIRONMENT_IS_NODE){var nodeWorkerThreads=require("worker_threads"),parentPort=nodeWorkerThreads.parentPort;parentPort.on("message",e=>onmessage({data:e}));var fs=require("fs"),vm=require("vm");Object.assign(global,{self:global,require,Module,location:{href:__filename},Worker:nodeWorkerThreads.Worker,importScripts:e=>vm.runInThisContext(fs.readFileSync(e,"utf8"),{filename:e}),postMessage:e=>parentPort.postMessage(e),performance:global.performance||{now:Date.now}})}var initializedJS=!1;function threadPrintErr(...e){var a=e.join(" ");if(ENVIRONMENT_IS_NODE){fs.writeSync(2,a+`\\n`);return}console.error(a)}function threadAlert(...e){var a=e.join(" ");postMessage({cmd:"alert",text:a,threadId:Module._pthread_self()})}var err=threadPrintErr;self.alert=threadAlert,Module.instantiateWasm=(e,a)=>{var r=Module.wasmModule;Module.wasmModule=null;var t=new WebAssembly.Instance(r,e);return a(t)},self.onunhandledrejection=e=>{throw e.reason||e};function handleMessage(e){try{if(e.data.cmd==="load"){let r=[];self.onmessage=t=>r.push(t),self.startWorker=t=>{Module=t,postMessage({cmd:"loaded"});for(let s of r)handleMessage(s);self.onmessage=handleMessage},Module.wasmModule=e.data.wasmModule;for(const t of e.data.handlers)Module[t]=(...s)=>{postMessage({cmd:"callHandler",handler:t,args:s})};if(Module.wasmMemory=e.data.wasmMemory,Module.buffer=Module.wasmMemory.buffer,Module.ENVIRONMENT_IS_PTHREAD=!0,typeof e.data.urlOrBlob=="string")importScripts(e.data.urlOrBlob);else{var a=URL.createObjectURL(e.data.urlOrBlob);importScripts(a),URL.revokeObjectURL(a)}ortWasmThreaded(Module)}else if(e.data.cmd==="run"){Module.__emscripten_thread_init(e.data.pthread_ptr,0,0,1),Module.__emscripten_thread_mailbox_await(e.data.pthread_ptr),Module.establishStackSpace(),Module.PThread.receiveObjectTransfer(e.data),Module.PThread.threadInitTLS(),initializedJS||(initializedJS=!0);try{Module.invokeEntryPoint(e.data.start_routine,e.data.arg)}catch(r){if(r!="unwind")throw r}}else e.data.cmd==="cancel"?Module._pthread_self()&&Module.__emscripten_thread_exit(-1):e.data.target==="setimmediate"||(e.data.cmd==="checkMailbox"?initializedJS&&Module.checkMailbox():e.data.cmd&&(err(`worker.js received unknown command ${e.data.cmd}`),err(e.data)))}catch(r){throw Module.__emscripten_thread_crashed?.(),r}}self.onmessage=handleMessage;\\n\'});var Er;Er=pr();var rn=Or(),Ft,Pt=!1,ct=!1,_r=!1,nn=i=>{if(i===1)return!1;if(typeof SharedArrayBuffer>"u")return typeof self<"u"&&!self.crossOriginIsolated&&console.warn("env.wasm.numThreads is set to "+i+", but this will not work unless you enable crossOriginIsolated mode. See https://web.dev/cross-origin-isolation-guide/ for more info."),!1;typeof process<"u"&&process.versions&&process.versions.node&&console.warn("env.wasm.numThreads is set to "+i+", however, currently onnxruntime-web does not support multi-threads in Node.js. Please consider using onnxruntime-node for performance critical scenarios.");try{return typeof MessageChannel<"u"&&new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11]))}catch{return!1}},an=()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,30,1,28,0,65,0,253,15,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,253,186,1,26,11]))}catch{return!1}},on=(i,c)=>i?c?"ort-wasm-simd-threaded.wasm":"ort-wasm-simd.wasm":c?"ort-wasm-threaded.wasm":"ort-wasm.wasm",Sr=async i=>{if(Pt)return Promise.resolve();if(ct)throw new Error("multiple calls to \'initializeWebAssembly()\' detected.");if(_r)throw new Error("previous call to \'initializeWebAssembly()\' failed.");ct=!0;let c=i.initTimeout,a=i.numThreads,h=i.simd,f=nn(a),w=h&&an(),g=i.wasmPaths,s=typeof g=="string"?g:void 0,S=on(w,f),x=typeof g=="object"?g[S]:void 0,H=!1,A=[];if(c>0&&A.push(new Promise(I=>{setTimeout(()=>{H=!0,I()},c)})),A.push(new Promise((I,V)=>{let R=f?rn:Er,B={locateFile:(D,T)=>f&&D.endsWith(".worker.js")&&typeof Blob<"u"?URL.createObjectURL(new Blob([vr()],{type:"text/javascript"})):D.endsWith(".wasm")?x||(s??T)+S:T+D};if(f)if(B.numThreads=a,typeof Blob>"u")B.mainScriptUrlOrBlob=(void 0)(__dirname,"ort-wasm-threaded.js");else{let D=`var ortWasmThreaded=${R.toString()};`;B.mainScriptUrlOrBlob=new Blob([D],{type:"text/javascript"})}R(B).then(D=>{ct=!1,Pt=!0,Ft=D,I()},D=>{ct=!1,_r=!0,V(D)})})),await Promise.race(A),H)throw new Error(`WebAssembly backend initializing failed due to timeout: ${c}ms`)},Q=()=>{if(Pt&&Ft)return Ft;throw new Error("WebAssembly is not initialized yet.")};var Y=(i,c)=>{let a=Q(),h=a.lengthBytesUTF8(i)+1,f=a._malloc(h);return a.stringToUTF8(i,f,h),c.push(f),f},tt=(i,c,a,h)=>{if(typeof i=="object"&&i!==null){if(a.has(i))throw new Error("Circular reference in options");a.add(i)}Object.entries(i).forEach(([f,w])=>{let g=c?c+f:f;if(typeof w=="object")tt(w,g+".",a,h);else if(typeof w=="string"||typeof w=="number")h(g,w.toString());else if(typeof w=="boolean")h(g,w?"1":"0");else throw new Error(`Can\'t handle extra config type: ${typeof w}`)})},j=i=>{let c=Q(),a=c.stackSave();try{let h=c.stackAlloc(8);c._OrtGetLastError(h,h+4);let f=c.HEAP32[h/4],w=c.HEAPU32[h/4+1],g=w?c.UTF8ToString(w):"";throw new Error(`${i} ERROR_CODE: ${f}, ERROR_MESSAGE: ${g}`)}finally{c.stackRestore(a)}};var Ar=i=>{let c=Q(),a=0,h=[],f=i||{};try{if(i?.logSeverityLevel===void 0)f.logSeverityLevel=2;else if(typeof i.logSeverityLevel!="number"||!Number.isInteger(i.logSeverityLevel)||i.logSeverityLevel<0||i.logSeverityLevel>4)throw new Error(`log serverity level is not valid: ${i.logSeverityLevel}`);if(i?.logVerbosityLevel===void 0)f.logVerbosityLevel=0;else if(typeof i.logVerbosityLevel!="number"||!Number.isInteger(i.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${i.logVerbosityLevel}`);i?.terminate===void 0&&(f.terminate=!1);let w=0;return i?.tag!==void 0&&(w=Y(i.tag,h)),a=c._OrtCreateRunOptions(f.logSeverityLevel,f.logVerbosityLevel,!!f.terminate,w),a===0&&j("Can\'t create run options."),i?.extra!==void 0&&tt(i.extra,"",new WeakSet,(g,s)=>{let S=Y(g,h),x=Y(s,h);c._OrtAddRunConfigEntry(a,S,x)!==0&&j(`Can\'t set a run config entry: ${g} - ${s}.`)}),[a,h]}catch(w){throw a!==0&&c._OrtReleaseRunOptions(a),h.forEach(g=>c._free(g)),w}};var sn=i=>{switch(i){case"disabled":return 0;case"basic":return 1;case"extended":return 2;case"all":return 99;default:throw new Error(`unsupported graph optimization level: ${i}`)}},un=i=>{switch(i){case"sequential":return 0;case"parallel":return 1;default:throw new Error(`unsupported execution mode: ${i}`)}},fn=i=>{i.extra||(i.extra={}),i.extra.session||(i.extra.session={});let c=i.extra.session;c.use_ort_model_bytes_directly||(c.use_ort_model_bytes_directly="1"),i.executionProviders&&i.executionProviders.some(a=>(typeof a=="string"?a:a.name)==="webgpu")&&(i.enableMemPattern=!1)},ln=(i,c,a)=>{for(let h of c){let f=typeof h=="string"?h:h.name;switch(f){case"webnn":if(f="WEBNN",typeof h!="string"){let g=h;if(g?.deviceType){let s=Y("deviceType",a),S=Y(g.deviceType,a);Q()._OrtAddSessionConfigEntry(i,s,S)!==0&&j(`Can\'t set a session config entry: \'deviceType\' - ${g.deviceType}.`)}if(g?.numThreads){let s=g.numThreads;(typeof s!="number"||!Number.isInteger(s)||s<0)&&(s=0);let S=Y("numThreads",a),x=Y(s.toString(),a);Q()._OrtAddSessionConfigEntry(i,S,x)!==0&&j(`Can\'t set a session config entry: \'numThreads\' - ${g.numThreads}.`)}if(g?.powerPreference){let s=Y("powerPreference",a),S=Y(g.powerPreference,a);Q()._OrtAddSessionConfigEntry(i,s,S)!==0&&j(`Can\'t set a session config entry: \'powerPreference\' - ${g.powerPreference}.`)}}break;case"webgpu":if(f="JS",typeof h!="string"){let g=h;if(g?.preferredLayout){if(g.preferredLayout!=="NCHW"&&g.preferredLayout!=="NHWC")throw new Error(`preferredLayout must be either \'NCHW\' or \'NHWC\': ${g.preferredLayout}`);let s=Y("preferredLayout",a),S=Y(g.preferredLayout,a);Q()._OrtAddSessionConfigEntry(i,s,S)!==0&&j(`Can\'t set a session config entry: \'preferredLayout\' - ${g.preferredLayout}.`)}}break;case"wasm":case"cpu":continue;default:throw new Error(`not supported execution provider: ${f}`)}let w=Y(f,a);Q()._OrtAppendExecutionProvider(i,w)!==0&&j(`Can\'t append execution provider: ${f}.`)}},Tr=i=>{let c=Q(),a=0,h=[],f=i||{};fn(f);try{let w=sn(f.graphOptimizationLevel??"all"),g=un(f.executionMode??"sequential"),s=typeof f.logId=="string"?Y(f.logId,h):0,S=f.logSeverityLevel??2;if(!Number.isInteger(S)||S<0||S>4)throw new Error(`log serverity level is not valid: ${S}`);let x=f.logVerbosityLevel??0;if(!Number.isInteger(x)||x<0||x>4)throw new Error(`log verbosity level is not valid: ${x}`);let H=typeof f.optimizedModelFilePath=="string"?Y(f.optimizedModelFilePath,h):0;if(a=c._OrtCreateSessionOptions(w,!!f.enableCpuMemArena,!!f.enableMemPattern,g,!!f.enableProfiling,0,s,S,x,H),a===0&&j("Can\'t create session options."),f.executionProviders&&ln(a,f.executionProviders,h),f.enableGraphCapture!==void 0){if(typeof f.enableGraphCapture!="boolean")throw new Error(`enableGraphCapture must be a boolean value: ${f.enableGraphCapture}`);let A=Y("enableGraphCapture",h),I=Y(f.enableGraphCapture.toString(),h);c._OrtAddSessionConfigEntry(a,A,I)!==0&&j(`Can\'t set a session config entry: \'enableGraphCapture\' - ${f.enableGraphCapture}.`)}if(f.freeDimensionOverrides)for(let[A,I]of Object.entries(f.freeDimensionOverrides)){if(typeof A!="string")throw new Error(`free dimension override name must be a string: ${A}`);if(typeof I!="number"||!Number.isInteger(I)||I<0)throw new Error(`free dimension override value must be a non-negative integer: ${I}`);let V=Y(A,h);c._OrtAddFreeDimensionOverride(a,V,I)!==0&&j(`Can\'t set a free dimension override: ${A} - ${I}.`)}return f.extra!==void 0&&tt(f.extra,"",new WeakSet,(A,I)=>{let V=Y(A,h),R=Y(I,h);c._OrtAddSessionConfigEntry(a,V,R)!==0&&j(`Can\'t set a session config entry: ${A} - ${I}.`)}),[a,h]}catch(w){throw a!==0&&c._OrtReleaseSessionOptions(a),h.forEach(g=>c._free(g)),w}};var xt=i=>{switch(i){case"int8":return 3;case"uint8":return 2;case"bool":return 9;case"int16":return 5;case"uint16":return 4;case"int32":return 6;case"uint32":return 12;case"float16":return 10;case"float32":return 1;case"float64":return 11;case"string":return 8;case"int64":return 7;case"uint64":return 13;default:throw new Error(`unsupported data type: ${i}`)}},Mr=i=>{switch(i){case 3:return"int8";case 2:return"uint8";case 9:return"bool";case 5:return"int16";case 4:return"uint16";case 6:return"int32";case 12:return"uint32";case 10:return"float16";case 1:return"float32";case 11:return"float64";case 8:return"string";case 7:return"int64";case 13:return"uint64";default:throw new Error(`unsupported data type: ${i}`)}},Ut=i=>[void 0,4,1,1,2,2,4,8,void 0,1,2,8,4,8,void 0,void 0,void 0][i],Cr=i=>{switch(i){case"float16":return typeof Float16Array<"u"&&Float16Array.from?Float16Array:Uint16Array;case"float32":return Float32Array;case"uint8":return Uint8Array;case"int8":return Int8Array;case"uint16":return Uint16Array;case"int16":return Int16Array;case"int32":return Int32Array;case"bool":return Uint8Array;case"float64":return Float64Array;case"uint32":return Uint32Array;case"int64":return BigInt64Array;case"uint64":return BigUint64Array;default:throw new Error(`unsupported type: ${i}`)}},Dr=i=>{switch(i){case"verbose":return 0;case"info":return 1;case"warning":return 2;case"error":return 3;case"fatal":return 4;default:throw new Error(`unsupported logging level: ${i}`)}},Fr=i=>i==="float32"||i==="float16"||i==="int32"||i==="int64"||i==="uint32"||i==="uint8"||i==="bool",Pr=i=>{switch(i){case"none":return 0;case"cpu":return 1;case"cpu-pinned":return 2;case"texture":return 3;case"gpu-buffer":return 4;default:throw new Error(`unsupported data location: ${i}`)}};var xr=async i=>{if(typeof i=="string")if(typeof process<"u"&&process.versions&&process.versions.node)try{return new Uint8Array(await(void 0)(i))}catch(c){if(c.code==="ERR_FS_FILE_TOO_LARGE"){let a=(void 0)(i),h=[];for await(let f of a)h.push(f);return new Uint8Array(Buffer.concat(h))}throw c}else{let c=await fetch(i);if(!c.ok)throw new Error(`failed to load external data file: ${i}`);let a=c.headers.get("Content-Length"),h=a?parseInt(a,10):0;if(h<1073741824)return new Uint8Array(await c.arrayBuffer());{if(!c.body)throw new Error(`failed to load external data file: ${i}, no response body.`);let f=c.body.getReader(),w;try{w=new ArrayBuffer(h)}catch(s){if(s instanceof RangeError){let S=Math.ceil(h/65536);w=new WebAssembly.Memory({initial:S,maximum:S}).buffer}else throw s}let g=0;for(;;){let{done:s,value:S}=await f.read();if(s)break;let x=S.byteLength;new Uint8Array(w,g,x).set(S),g+=x}return new Uint8Array(w,0,h)}}else return i instanceof Blob?new Uint8Array(await i.arrayBuffer()):i instanceof Uint8Array?i:new Uint8Array(i)};var cn=(i,c)=>{Q()._OrtInit(i,c)!==0&&j("Can\'t initialize onnxruntime.")},Lr=async i=>{cn(i.wasm.numThreads,Dr(i.logLevel))},Rr=async(i,c)=>{},Ye=new Map,dn=i=>{let c=Q(),a=c.stackSave();try{let h=c.stackAlloc(8);return c._OrtGetInputOutputCount(i,h,h+4)!==0&&j("Can\'t get session input/output count."),[c.HEAP32[h/4],c.HEAP32[h/4+1]]}finally{c.stackRestore(a)}},Lt=i=>{let c=Q(),a=c._malloc(i.byteLength);if(a===0)throw new Error(`Can\'t create a session. failed to allocate a buffer of size ${i.byteLength}.`);return c.HEAPU8.set(i,a),[a,i.byteLength]},Ir=async(i,c)=>{let a,h,f=Q();Array.isArray(i)?[a,h]=i:i.buffer===f.HEAPU8.buffer?[a,h]=[i.byteOffset,i.byteLength]:[a,h]=Lt(i);let w=0,g=0,s=0,S=[],x=[],H=[];try{if([g,S]=Tr(c),c?.externalData&&f.mountExternalData){let L=[];for(let W of c.externalData){let de=typeof W=="string"?W:W.path;L.push(xr(typeof W=="string"?W:W.data).then(pe=>{f.mountExternalData(de,pe)}))}await Promise.all(L)}w=await f._OrtCreateSession(a,h,g),w===0&&j("Can\'t create a session.");let[A,I]=dn(w),V=!!c?.enableGraphCapture,R=[],B=[],D=[];for(let L=0;Lf._OrtFree(I)),H.forEach(I=>f._OrtFree(I)),s!==0&&f._OrtReleaseBinding(s),w!==0&&f._OrtReleaseSession(w),A}finally{f._free(a),g!==0&&f._OrtReleaseSessionOptions(g),S.forEach(A=>f._free(A)),f.unmountExternalData?.()}},Br=i=>{let c=Q(),a=Ye.get(i);if(!a)throw new Error(`cannot release session. invalid session id: ${i}`);let[h,f,w,g,s]=a;g&&(s&&c._OrtClearBoundOutputs(g.handle),c._OrtReleaseBinding(g.handle)),c.jsepOnReleaseSession?.(i),f.forEach(S=>c._OrtFree(S)),w.forEach(S=>c._OrtFree(S)),c._OrtReleaseSession(h),Ye.delete(i)},Ur=(i,c,a,h,f,w=!1)=>{if(!i){c.push(0);return}let g=Q(),s=i[0],S=i[1],x=i[3],H,A;if(s==="string"&&x==="gpu-buffer")throw new Error("String tensor is not supported on GPU.");if(w&&x!=="gpu-buffer")throw new Error(`External buffer must be provided for input/output index ${f} when enableGraphCapture is true.`);if(x==="gpu-buffer"){let R=i[2].gpuBuffer,B=Ut(xt(s));A=S.reduce((T,L)=>T*L,1)*B;let D=g.jsepRegisterBuffer;if(!D)throw new Error(\'Tensor location "gpu-buffer" is not supported without using WebGPU.\');H=D(h,f,R,A)}else{let R=i[2];if(Array.isArray(R)){A=4*R.length,H=g._malloc(A),a.push(H);let B=H/4;for(let D=0;Dg.HEAP32[R++]=D);let B=g._OrtCreateTensor(xt(s),H,A,V,S.length,Pr(x));B===0&&j(`Can\'t create tensor for input/output. session=${h}, index=${f}.`),c.push(B)}finally{g.stackRestore(I)}},kr=async(i,c,a,h,f,w)=>{let g=Q(),s=Ye.get(i);if(!s)throw new Error(`cannot run inference. invalid session id: ${i}`);let S=s[0],x=s[1],H=s[2],A=s[3],I=s[4],V=s[5],R=c.length,B=h.length,D=0,T=[],L=[],W=[],de=[],pe=g.stackSave(),Z=g.stackAlloc(R*4),_=g.stackAlloc(R*4),J=g.stackAlloc(B*4),Pe=g.stackAlloc(B*4);try{[D,T]=Ar(w);for(let F=0;Fte*re,1);ae=Mr(Ue);let Be=A?.outputPreferredLocations[h[F]];if(ae==="string"){if(Be==="gpu-buffer")throw new Error("String tensor is not supported on GPU.");let te=[],re=K/4;for(let ue=0;ue0){let te=g.jsepGetBuffer;if(!te)throw new Error(\'preferredLocation "gpu-buffer" is not supported without using WebGPU.\');let re=te(K),ue=Ut(Ue);if(ue===void 0||!Fr(ae))throw new Error(`Unsupported data type: ${ae}`);be=!0,me.push([ae,_e,{gpuBuffer:re,download:g.jsepCreateDownloader(re,ge*ue,ae),dispose:()=>{g._OrtReleaseTensor(ie)}},"gpu-buffer"])}else{let te=Cr(ae),re=new te(ge);new Uint8Array(re.buffer,re.byteOffset,re.byteLength).set(g.HEAPU8.subarray(K,K+re.byteLength)),me.push([ae,_e,re,"cpu"])}}finally{g.stackRestore(xe),ae==="string"&&K&&g._free(K),be||g._OrtReleaseTensor(ie)}}return A&&!I&&(g._OrtClearBoundOutputs(A.handle),Ye.set(i,[S,x,H,A,I,!1])),me}finally{g.stackRestore(pe),L.forEach(le=>g._OrtReleaseTensor(le)),W.forEach(le=>g._OrtReleaseTensor(le)),de.forEach(le=>g._free(le)),D!==0&&g._OrtReleaseRunOptions(D),T.forEach(le=>g._free(le))}},Wr=i=>{let c=Q(),a=Ye.get(i);if(!a)throw new Error("invalid session id");let h=a[0],f=c._OrtEndProfiling(h);f===0&&j("Can\'t get an profile file name."),c._OrtFree(f)},Nr=i=>{let c=[];for(let a of i){let h=a[2];!Array.isArray(h)&&"buffer"in h&&c.push(h.buffer)}return c};self.onmessage=i=>{let{type:c,in:a}=i.data;try{switch(c){case"init-wasm":Sr(a.wasm).then(()=>{Lr(a).then(()=>{postMessage({type:c})},h=>{postMessage({type:c,err:h})})},h=>{postMessage({type:c,err:h})});break;case"init-ep":{let{epName:h,env:f}=a;Rr(f,h).then(()=>{postMessage({type:c})},w=>{postMessage({type:c,err:w})});break}case"copy-from":{let{buffer:h}=a,f=Lt(h);postMessage({type:c,out:f});break}case"create":{let{model:h,options:f}=a;Ir(h,f).then(w=>{postMessage({type:c,out:w})},w=>{postMessage({type:c,err:w})});break}case"release":Br(a),postMessage({type:c});break;case"run":{let{sessionId:h,inputIndices:f,inputs:w,outputIndices:g,options:s}=a;kr(h,f,w,g,new Array(g.length).fill(null),s).then(S=>{S.some(x=>x[3]!=="cpu")?postMessage({type:c,err:"Proxy does not support non-cpu tensor location."}):postMessage({type:c,out:S},Nr([...w,...S]))},S=>{postMessage({type:c,err:S})});break}case"end-profiling":Wr(a),postMessage({type:c});break;default:}}catch(h){postMessage({type:c,err:h})}};})();\n'}),_r,gt,yn,Do,Lo,ca,pa,Vr,Wr,Tg,Eo,od,id,ad,sd,ud,ld,fd,da=L(()=>{var e;Ot(),rd(),Ur(),_r=()=>!!Z.wasm.proxy&&typeof document<"u",yn=!1,Do=!1,Lo=!1,pa=new Map,Vr=(r,a)=>{let i=pa.get(r);i?i.push(a):pa.set(r,[a])},Wr=()=>{if(yn||!Do||Lo||!gt)throw new Error("worker not ready")},Tg=r=>{switch(r.data.type){case"init-wasm":yn=!1,r.data.err?(Lo=!0,ca[1](r.data.err)):(Do=!0,ca[0]());break;case"init-ep":case"copy-from":case"create":case"release":case"run":case"end-profiling":{let a=pa.get(r.data.type);r.data.err?a.shift()[1](r.data.err):a.shift()[0](r.data.out);break}}},Eo=typeof document<"u"?(e=document==null?void 0:document.currentScript)==null?void 0:e.src:void 0,od=async()=>{if(!Do){if(yn)throw new Error("multiple calls to 'initWasm()' detected.");if(Lo)throw new Error("previous call to 'initWasm()' failed.");if(yn=!0,_r())return Z.wasm.wasmPaths===void 0&&Eo&&Eo.indexOf("blob:")!==0&&(Z.wasm.wasmPaths=Eo.substr(0,+Eo.lastIndexOf("/")+1)),new Promise((r,a)=>{gt==null||gt.terminate();let i=URL.createObjectURL(new Blob([nd()],{type:"text/javascript"}));gt=new Worker(i,{name:"ort-wasm-proxy-worker"}),gt.onerror=n=>a(n),gt.onmessage=Tg,URL.revokeObjectURL(i),ca=[r,a];let l={type:"init-wasm",in:Z};gt.postMessage(l)});try{await Mp(Z.wasm),await Xp(Z),Do=!0}catch(r){throw Lo=!0,r}finally{yn=!1}}},id=async r=>{if(_r())return Wr(),new Promise((a,i)=>{Vr("init-ep",[a,i]);let l={type:"init-ep",in:{epName:r,env:Z}};gt.postMessage(l)});await Kp(Z,r)},ad=async r=>_r()?(Wr(),new Promise((a,i)=>{Vr("copy-from",[a,i]);let l={type:"copy-from",in:{buffer:r}};gt.postMessage(l,[r.buffer])})):fa(r),sd=async(r,a)=>{if(_r()){if(a!=null&&a.preferredOutputLocation)throw new Error('session option "preferredOutputLocation" is not supported for proxy.');return Wr(),new Promise((i,l)=>{Vr("create",[i,l]);let n={type:"create",in:{model:r,options:{...a}}},o=[];r instanceof Uint8Array&&o.push(r.buffer),gt.postMessage(n,o)})}else return Jp(r,a)},ud=async r=>{if(_r())return Wr(),new Promise((a,i)=>{Vr("release",[a,i]);let l={type:"release",in:r};gt.postMessage(l)});Zp(r)},ld=async(r,a,i,l,n,o)=>{if(_r()){if(i.some(p=>p[3]!=="cpu"))throw new Error("input tensor on GPU is not supported for proxy.");if(n.some(p=>p))throw new Error("pre-allocated output tensor is not supported for proxy.");return Wr(),new Promise((p,c)=>{Vr("run",[p,c]);let t=i,u={type:"run",in:{sessionId:r,inputIndices:a,inputs:t,outputIndices:l,options:o}};gt.postMessage(u,td(t))})}else return Qp(r,a,i,l,n,o)},fd=async r=>{if(_r())return Wr(),new Promise((a,i)=>{Vr("end-profiling",[a,i]);let l={type:"end-profiling",in:r};gt.postMessage(l)});ed(r)}}),cd,xg,Co,pd=L(()=>{Ot(),da(),ua(),la(),cd=(e,r)=>{switch(e.location){case"cpu":return[e.type,e.dims,e.data,"cpu"];case"gpu-buffer":return[e.type,e.dims,{gpuBuffer:e.gpuBuffer},"gpu-buffer"];default:throw new Error(`invalid data location: ${e.location} for ${r()}`)}},xg=e=>{switch(e[3]){case"cpu":return new Me(e[0],e[2],e[1]);case"gpu-buffer":{let r=e[0];if(!Po(r))throw new Error(`not supported data type: ${r} for deserializing GPU tensor`);let{gpuBuffer:a,download:i,dispose:l}=e[2];return Me.fromGpuBuffer(a,{dataType:r,dims:e[1],download:i,dispose:l})}default:throw new Error(`invalid data location: ${e[3]}`)}},Co=class{async fetchModelAndCopyToWasmMemory(e){return ad(await gn(e))}async loadModel(e,r){lr();let a;typeof e=="string"?typeof process<"u"&&process.versions&&process.versions.node?a=await gn(e):a=await this.fetchModelAndCopyToWasmMemory(e):a=e,[this.sessionId,this.inputNames,this.outputNames]=await sd(a,r),fr()}async dispose(){return ud(this.sessionId)}async run(e,r,a){lr();let i=[],l=[];Object.entries(e).forEach(s=>{let d=s[0],f=s[1],b=this.inputNames.indexOf(d);if(b===-1)throw new Error(`invalid input '${d}'`);i.push(f),l.push(b)});let n=[],o=[];Object.entries(r).forEach(s=>{let d=s[0],f=s[1],b=this.outputNames.indexOf(d);if(b===-1)throw new Error(`invalid output '${d}'`);n.push(f),o.push(b)});let p=i.map((s,d)=>cd(s,()=>`input "${this.inputNames[l[d]]}"`)),c=n.map((s,d)=>s?cd(s,()=>`output "${this.outputNames[o[d]]}"`):null),t=await ld(this.sessionId,l,p,o,c,a),u={};for(let s=0;s{Ot(),da(),pd(),wg=()=>{if((typeof Z.wasm.initTimeout!="number"||Z.wasm.initTimeout<0)&&(Z.wasm.initTimeout=0),typeof Z.wasm.simd!="boolean"&&(Z.wasm.simd=!0),typeof Z.wasm.proxy!="boolean"&&(Z.wasm.proxy=!1),typeof Z.wasm.trace!="boolean"&&(Z.wasm.trace=!1),typeof Z.wasm.numThreads!="number"||!Number.isInteger(Z.wasm.numThreads)||Z.wasm.numThreads<=0){(typeof self<"u"&&!self.crossOriginIsolated||typeof process<"u"&&process.versions&&process.versions.node)&&(Z.wasm.numThreads=1);let e=typeof navigator>"u"?(void 0)().length:navigator.hardwareConcurrency;Z.wasm.numThreads=Math.min(4,Math.ceil((e||1)/2))}},Fo=class{async init(e){wg(),await od(),await id(e)}async createInferenceSessionHandler(e,r){let a=new Co;return await a.loadModel(e,r),Promise.resolve(a)}}}),hd={};Sr(hd,{wasmBackend:()=>vg});var vg,md=L(()=>{dd(),vg=new Fo});Ot();Ot();Ot();var Ts="1.18.0",jO=qo;{let e=(Op(),ar(_p)).onnxjsBackend;Pr("webgl",e,-10)}{let e=(md(),ar(hd)).wasmBackend;Pr("cpu",e,10),Pr("wasm",e,10)}Object.defineProperty(Z.versions,"web",{value:Ts,enumerable:!0});/*! Bundled license information: long/index.js: (** * @license * Copyright 2009 The Closure Library Authors * Copyright 2020 Daniel Wirtz / The long.js Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0 *) */export{Pd as InferenceSession,ls as TRACE,lr as TRACE_FUNC_BEGIN,fr as TRACE_FUNC_END,Me as Tensor,Dd as TrainingSession,jO as default,Z as env,Pr as registerBackend};