@webex/ladon-ts 5.4.6 → 5.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/build/module/index.d.ts +3 -2
  3. package/build/module/index.js +35 -34
  4. package/build/module/index.js.map +1 -1
  5. package/build/module/lib/config-builder.d.ts +1 -1
  6. package/build/module/lib/config-builder.js +59 -58
  7. package/build/module/lib/config-builder.js.map +1 -1
  8. package/build/module/lib/config-types.d.ts +1 -1
  9. package/build/module/lib/config-types.js.map +1 -1
  10. package/build/module/lib/generator-types.d.ts +25 -0
  11. package/build/module/lib/generator.d.ts +2 -74
  12. package/build/module/lib/pipeline.js +16 -26
  13. package/build/module/lib/pipeline.js.map +1 -1
  14. package/build/module/lib/preload.js +4 -4
  15. package/build/module/lib/preload.js.map +1 -1
  16. package/build/module/lib/resource-loader.d.ts +22 -0
  17. package/build/module/lib/resource-loader.js +33 -0
  18. package/build/module/lib/resource-loader.js.map +1 -0
  19. package/build/module/lib/util.d.ts +1 -2
  20. package/build/module/lib/util.js +63 -82
  21. package/build/module/lib/util.js.map +1 -1
  22. package/build/module/lib/version.d.ts +1 -1
  23. package/build/module/lib/version.js +1 -1
  24. package/build/module/lib/version.js.map +1 -1
  25. package/build/module/lib/worker-generator.d.ts +15 -0
  26. package/build/module/lib/worker-generator.js +93 -0
  27. package/build/module/lib/worker-generator.js.map +1 -0
  28. package/build/module/lib/worker-manager.d.ts +41 -0
  29. package/build/module/lib/worker-manager.js +63 -0
  30. package/build/module/lib/worker-manager.js.map +1 -0
  31. package/build/worker/segmentation.js +791 -791
  32. package/build/worker/segmentation.js.map +1 -1
  33. package/package.json +1 -4
  34. package/build/module/lib/generator.js +0 -224
  35. package/build/module/lib/generator.js.map +0 -1
  36. package/build/module/lib/shared-resource-manager.d.ts +0 -93
  37. package/build/module/lib/shared-resource-manager.js +0 -166
  38. package/build/module/lib/shared-resource-manager.js.map +0 -1
@@ -1,29 +1,29 @@
1
1
  /**
2
2
  * Cisco Ladon-TS
3
3
  * Copyright (c) Cisco Systems, Inc. All rights reserved.
4
- * Build timestamp: April 7, 2025 at 03:24:33 PM UTC
4
+ * Build timestamp: April 16, 2025 at 12:19:28 AM UTC
5
5
  */
6
- (function(){"use strict";var _documentCurrentScript=typeof document<"u"?document.currentScript:null;self.document={baseURI:location.origin};const originalConsoleLog=console.log,originalConsoleWarn=console.warn,originalConsoleError=console.error;console.log=(...t)=>{postMessage({type:"log",message:t.join(" "),severity:"log"}),originalConsoleLog(...t)},console.warn=(...t)=>{postMessage({type:"log",message:t.join(" "),severity:"warn"}),originalConsoleWarn(...t)},console.error=(...t)=>{postMessage({type:"log",message:t.join(" "),severity:"error"}),originalConsoleError(...t)};/*!
6
+ (function(){"use strict";var _documentCurrentScript=typeof document<"u"?document.currentScript:null;self.document={baseURI:location.origin};const originalConsoleLog=console.log,originalConsoleWarn=console.warn,originalConsoleError=console.error;console.log=(...e)=>{postMessage({type:"log",message:e.join(" "),severity:"log"}),originalConsoleLog(...e)},console.warn=(...e)=>{postMessage({type:"log",message:e.join(" "),severity:"warn"}),originalConsoleWarn(...e)},console.error=(...e)=>{postMessage({type:"log",message:e.join(" "),severity:"error"}),originalConsoleError(...e)};/*!
7
7
  * ONNX Runtime Web v1.20.1
8
8
  * Copyright (c) Microsoft Corporation. All rights reserved.
9
9
  * Licensed under the MIT License.
10
- */var Hd=Object.create,an=Object.defineProperty,qd=Object.getOwnPropertyDescriptor,jd=Object.getOwnPropertyNames,Xd=Object.getPrototypeOf,Kd=Object.prototype.hasOwnProperty,Co=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(r,o)=>(typeof require<"u"?require:r)[o]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')}),O=(t,r)=>()=>(t&&(r=t(t=0)),r),mt=(t,r)=>()=>(r||t((r={exports:{}}).exports,r),r.exports),Or=(t,r)=>{for(var o in r)an(t,o,{get:r[o],enumerable:!0})},Qa=(t,r,o,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let u of jd(r))!Kd.call(t,u)&&u!==o&&an(t,u,{get:()=>r[u],enumerable:!(i=qd(r,u))||i.enumerable});return t},rr=(t,r,o)=>(o=t!=null?Hd(Xd(t)):{},Qa(!t||!t.__esModule?an(o,"default",{value:t,enumerable:!0}):o,t)),sn=t=>Qa(an({},"__esModule",{value:!0}),t),un,ke,nr,Jd,ln,fn=O(()=>{un=new Map,ke=[],nr=(t,r,o)=>{if(r&&typeof r.init=="function"&&typeof r.createInferenceSessionHandler=="function"){let i=un.get(t);if(i===void 0)un.set(t,{backend:r,priority:o});else{if(i.priority>o)return;if(i.priority===o&&i.backend!==r)throw new Error(`cannot register backend "${t}" using priority ${o}`)}if(o>=0){let u=ke.indexOf(t);u!==-1&&ke.splice(u,1);for(let n=0;n<ke.length;n++)if(un.get(ke[n]).priority<=o){ke.splice(n,0,t);return}ke.push(t)}return}throw new TypeError("not a valid backend")},Jd=async t=>{let r=un.get(t);if(!r)return"backend not found.";if(r.initialized)return r.backend;if(r.aborted)return r.error;{let o=!!r.initPromise;try{return o||(r.initPromise=r.backend.init(t)),await r.initPromise,r.initialized=!0,r.backend}catch(i){return o||(r.error=`${i}`,r.aborted=!0),r.error}finally{delete r.initPromise}}},ln=async t=>{let r=t.executionProviders||[],o=r.map(c=>typeof c=="string"?c:c.name),i=o.length===0?ke:o,u,n=[],a=new Set;for(let c of i){let e=await Jd(c);typeof e=="string"?n.push({name:c,err:e}):(u||(u=e),u===e&&a.add(c))}if(!u)throw new Error(`no available backend found. ERR: ${n.map(c=>`[${c.name}] ${c.err}`).join(", ")}`);for(let{name:c,err:e}of n)o.includes(c)&&console.warn(`removing requested execution provider "${c}" from session options because it is not available: ${e}`);let d=r.filter(c=>a.has(typeof c=="string"?c:c.name));return[u,new Proxy(t,{get:(c,e)=>e==="executionProviders"?d:Reflect.get(c,e)})]}}),ts=O(()=>{fn()}),es,rs=O(()=>{es="1.20.1"}),ns,Gt,No=O(()=>{rs(),ns="warning",Gt={wasm:{},webgl:{},webgpu:{},versions:{common:es},set logLevel(t){if(t!==void 0){if(typeof t!="string"||["verbose","info","warning","error","fatal"].indexOf(t)===-1)throw new Error(`Unsupported logging level: ${t}`);ns=t}},get logLevel(){return ns}},Object.defineProperty(Gt,"logLevel",{enumerable:!0})}),z,os=O(()=>{No(),z=Gt}),is,as,ss=O(()=>{is=(t,r)=>{let o=typeof document<"u"?document.createElement("canvas"):new OffscreenCanvas(1,1);o.width=t.dims[3],o.height=t.dims[2];let i=o.getContext("2d");if(i!=null){let u,n;(r==null?void 0:r.tensorLayout)!==void 0&&r.tensorLayout==="NHWC"?(u=t.dims[2],n=t.dims[3]):(u=t.dims[3],n=t.dims[2]);let a=(r==null?void 0:r.format)!==void 0?r.format:"RGB",d=r==null?void 0:r.norm,c,e;d===void 0||d.mean===void 0?c=[255,255,255,255]:typeof d.mean=="number"?c=[d.mean,d.mean,d.mean,d.mean]:(c=[d.mean[0],d.mean[1],d.mean[2],0],d.mean[3]!==void 0&&(c[3]=d.mean[3])),d===void 0||d.bias===void 0?e=[0,0,0,0]:typeof d.bias=="number"?e=[d.bias,d.bias,d.bias,d.bias]:(e=[d.bias[0],d.bias[1],d.bias[2],0],d.bias[3]!==void 0&&(e[3]=d.bias[3]));let l=n*u,s=0,h=l,f=l*2,m=-1;a==="RGBA"?(s=0,h=l,f=l*2,m=l*3):a==="RGB"?(s=0,h=l,f=l*2):a==="RBG"&&(s=0,f=l,h=l*2);for(let v=0;v<n;v++)for(let _=0;_<u;_++){let I=(t.data[s++]-e[0])*c[0],T=(t.data[h++]-e[1])*c[1],P=(t.data[f++]-e[2])*c[2],C=m===-1?255:(t.data[m++]-e[3])*c[3];i.fillStyle="rgba("+I+","+T+","+P+","+C+")",i.fillRect(_,v,1,1)}if("toDataURL"in o)return o.toDataURL();throw new Error("toDataURL is not supported")}else throw new Error("Can not access image data")},as=(t,r)=>{let o=typeof document<"u"?document.createElement("canvas").getContext("2d"):new OffscreenCanvas(1,1).getContext("2d"),i;if(o!=null){let u,n,a;(r==null?void 0:r.tensorLayout)!==void 0&&r.tensorLayout==="NHWC"?(u=t.dims[2],n=t.dims[1],a=t.dims[3]):(u=t.dims[3],n=t.dims[2],a=t.dims[1]);let d=r!==void 0&&r.format!==void 0?r.format:"RGB",c=r==null?void 0:r.norm,e,l;c===void 0||c.mean===void 0?e=[255,255,255,255]:typeof c.mean=="number"?e=[c.mean,c.mean,c.mean,c.mean]:(e=[c.mean[0],c.mean[1],c.mean[2],255],c.mean[3]!==void 0&&(e[3]=c.mean[3])),c===void 0||c.bias===void 0?l=[0,0,0,0]:typeof c.bias=="number"?l=[c.bias,c.bias,c.bias,c.bias]:(l=[c.bias[0],c.bias[1],c.bias[2],0],c.bias[3]!==void 0&&(l[3]=c.bias[3]));let s=n*u;if(r!==void 0&&(r.format!==void 0&&a===4&&r.format!=="RGBA"||a===3&&r.format!=="RGB"&&r.format!=="BGR"))throw new Error("Tensor format doesn't match input tensor dims");let h=4,f=0,m=1,v=2,_=3,I=0,T=s,P=s*2,C=-1;d==="RGBA"?(I=0,T=s,P=s*2,C=s*3):d==="RGB"?(I=0,T=s,P=s*2):d==="RBG"&&(I=0,P=s,T=s*2),i=o.createImageData(u,n);for(let V=0;V<n*u;f+=h,m+=h,v+=h,_+=h,V++)i.data[f]=(t.data[I++]-l[0])*e[0],i.data[m]=(t.data[T++]-l[1])*e[1],i.data[v]=(t.data[P++]-l[2])*e[2],i.data[_]=C===-1?255:(t.data[C++]-l[3])*e[3]}else throw new Error("Can not access image data");return i}}),Ro,us,ls,fs,cs,ps,ds=O(()=>{cn(),Ro=(t,r)=>{if(t===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:o,width:i}=r,u=r.norm??{mean:255,bias:0},n,a;typeof u.mean=="number"?n=[u.mean,u.mean,u.mean,u.mean]:n=[u.mean[0],u.mean[1],u.mean[2],u.mean[3]??255],typeof u.bias=="number"?a=[u.bias,u.bias,u.bias,u.bias]:a=[u.bias[0],u.bias[1],u.bias[2],u.bias[3]??0];let d=r.format!==void 0?r.format:"RGBA",c=r.tensorFormat!==void 0&&r.tensorFormat!==void 0?r.tensorFormat:"RGB",e=o*i,l=c==="RGBA"?new Float32Array(e*4):new Float32Array(e*3),s=4,h=0,f=1,m=2,v=3,_=0,I=e,T=e*2,P=-1;d==="RGB"&&(s=3,h=0,f=1,m=2,v=-1),c==="RGBA"?P=e*3:c==="RBG"?(_=0,T=e,I=e*2):c==="BGR"&&(T=0,I=e,_=e*2);for(let C=0;C<e;C++,h+=s,m+=s,f+=s,v+=s)l[_++]=(t[h]+a[0])/n[0],l[I++]=(t[f]+a[1])/n[1],l[T++]=(t[m]+a[2])/n[2],P!==-1&&v!==-1&&(l[P++]=(t[v]+a[3])/n[3]);return c==="RGBA"?new St("float32",l,[1,4,o,i]):new St("float32",l,[1,3,o,i])},us=async(t,r)=>{let o=typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement,i=typeof ImageData<"u"&&t instanceof ImageData,u=typeof ImageBitmap<"u"&&t instanceof ImageBitmap,n=typeof t=="string",a,d=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")},e=l=>typeof HTMLCanvasElement<"u"&&l instanceof HTMLCanvasElement||l instanceof OffscreenCanvas?l.getContext("2d"):null;if(o){let l=c();l.width=t.width,l.height=t.height;let s=e(l);if(s!=null){let h=t.height,f=t.width;if(r!==void 0&&r.resizedHeight!==void 0&&r.resizedWidth!==void 0&&(h=r.resizedHeight,f=r.resizedWidth),r!==void 0){if(d=r,r.tensorFormat!==void 0)throw new Error("Image input config format must be RGBA for HTMLImageElement");d.tensorFormat="RGBA",d.height=h,d.width=f}else d.tensorFormat="RGBA",d.height=h,d.width=f;s.drawImage(t,0,0),a=s.getImageData(0,0,f,h).data}else throw new Error("Can not access image data")}else if(i){let l,s;if(r!==void 0&&r.resizedWidth!==void 0&&r.resizedHeight!==void 0?(l=r.resizedHeight,s=r.resizedWidth):(l=t.height,s=t.width),r!==void 0&&(d=r),d.format="RGBA",d.height=l,d.width=s,r!==void 0){let h=c();h.width=s,h.height=l;let f=e(h);if(f!=null)f.putImageData(t,0,0),a=f.getImageData(0,0,s,l).data;else throw new Error("Can not access image data")}else a=t.data}else if(u){if(r===void 0)throw new Error("Please provide image config with format for Imagebitmap");let l=c();l.width=t.width,l.height=t.height;let s=e(l);if(s!=null){let h=t.height,f=t.width;return s.drawImage(t,0,0,f,h),a=s.getImageData(0,0,f,h).data,d.height=h,d.width=f,Ro(a,d)}else throw new Error("Can not access image data")}else{if(n)return new Promise((l,s)=>{let h=c(),f=e(h);if(!t||!f)return s();let m=new Image;m.crossOrigin="Anonymous",m.src=t,m.onload=()=>{h.width=m.width,h.height=m.height,f.drawImage(m,0,0,h.width,h.height);let v=f.getImageData(0,0,h.width,h.height);d.height=h.height,d.width=h.width,l(Ro(v.data,d))}});throw new Error("Input data provided is not supported - aborted tensor creation")}if(a!==void 0)return Ro(a,d);throw new Error("Input data provided is not supported - aborted tensor creation")},ls=(t,r)=>{let{width:o,height:i,download:u,dispose:n}=r,a=[1,i,o,4];return new St({location:"texture",type:"float32",texture:t,dims:a,download:u,dispose:n})},fs=(t,r)=>{let{dataType:o,dims:i,download:u,dispose:n}=r;return new St({location:"gpu-buffer",type:o??"float32",gpuBuffer:t,dims:i,download:u,dispose:n})},cs=(t,r)=>{let{dataType:o,dims:i,download:u,dispose:n}=r;return new St({location:"ml-tensor",type:o??"float32",mlTensor:t,dims:i,download:u,dispose:n})},ps=(t,r,o)=>new St({location:"cpu-pinned",type:t,data:r,dims:o??[r.length]})}),Be,Sr,hs,ms,bs=O(()=>{Be=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array],["int4",Uint8Array],["uint4",Uint8Array]]),Sr=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]),hs=!1,ms=()=>{if(!hs){hs=!0;let t=typeof BigInt64Array<"u"&&BigInt64Array.from,r=typeof BigUint64Array<"u"&&BigUint64Array.from,o=typeof Float16Array<"u"&&Float16Array.from;t&&(Be.set("int64",BigInt64Array),Sr.set(BigInt64Array,"int64")),r&&(Be.set("uint64",BigUint64Array),Sr.set(BigUint64Array,"uint64")),o?(Be.set("float16",Float16Array),Sr.set(Float16Array,"float16")):Be.set("float16",Uint16Array)}}}),gs,ys,xs=O(()=>{cn(),gs=t=>{let r=1;for(let o=0;o<t.length;o++){let i=t[o];if(typeof i!="number"||!Number.isSafeInteger(i))throw new TypeError(`dims[${o}] must be an integer, got: ${i}`);if(i<0)throw new RangeError(`dims[${o}] must be a non-negative integer, got: ${i}`);r*=i}return r},ys=(t,r)=>{switch(t.location){case"cpu":return new St(t.type,t.data,r);case"cpu-pinned":return new St({location:"cpu-pinned",data:t.data,type:t.type,dims:r});case"texture":return new St({location:"texture",texture:t.texture,type:t.type,dims:r});case"gpu-buffer":return new St({location:"gpu-buffer",gpuBuffer:t.gpuBuffer,type:t.type,dims:r});case"ml-tensor":return new St({location:"ml-tensor",mlTensor:t.mlTensor,type:t.type,dims:r});default:throw new Error(`tensorReshape: tensor location ${t.location} is not supported`)}}}),St,cn=O(()=>{ss(),ds(),bs(),xs(),St=class{constructor(t,r,o){ms();let i,u;if(typeof t=="object"&&"location"in t)switch(this.dataLocation=t.location,i=t.type,u=t.dims,t.location){case"cpu-pinned":{let a=Be.get(i);if(!a)throw new TypeError(`unsupported type "${i}" to create tensor from pinned buffer`);if(!(t.data instanceof a))throw new TypeError(`buffer should be of type ${a.name}`);this.cpuData=t.data;break}case"texture":{if(i!=="float32")throw new TypeError(`unsupported type "${i}" to create tensor from texture`);this.gpuTextureData=t.texture,this.downloader=t.download,this.disposer=t.dispose;break}case"gpu-buffer":{if(i!=="float32"&&i!=="float16"&&i!=="int32"&&i!=="int64"&&i!=="uint32"&&i!=="uint8"&&i!=="bool"&&i!=="uint4"&&i!=="int4")throw new TypeError(`unsupported type "${i}" to create tensor from gpu buffer`);this.gpuBufferData=t.gpuBuffer,this.downloader=t.download,this.disposer=t.dispose;break}case"ml-tensor":{if(i!=="float32"&&i!=="float16"&&i!=="int32"&&i!=="int64"&&i!=="uint32"&&i!=="uint64"&&i!=="int8"&&i!=="uint8"&&i!=="bool")throw new TypeError(`unsupported type "${i}" to create tensor from MLTensor`);this.mlTensorData=t.mlTensor,this.downloader=t.download,this.disposer=t.dispose;break}default:throw new Error(`Tensor constructor: unsupported location '${this.dataLocation}'`)}else{let a,d;if(typeof t=="string")if(i=t,d=o,t==="string"){if(!Array.isArray(r))throw new TypeError("A string tensor's data must be a string array.");a=r}else{let c=Be.get(t);if(c===void 0)throw new TypeError(`Unsupported tensor type: ${t}.`);if(Array.isArray(r)){if(t==="float16"&&c===Uint16Array||t==="uint4"||t==="int4")throw new TypeError(`Creating a ${t} tensor from number array is not supported. Please use ${c.name} as data.`);t==="uint64"||t==="int64"?a=c.from(r,BigInt):a=c.from(r)}else if(r instanceof c)a=r;else if(r instanceof Uint8ClampedArray)if(t==="uint8")a=Uint8Array.from(r);else throw new TypeError("A Uint8ClampedArray tensor's data must be type of uint8");else throw new TypeError(`A ${i} tensor's data must be type of ${c}`)}else if(d=r,Array.isArray(t)){if(t.length===0)throw new TypeError("Tensor type cannot be inferred from an empty array.");let c=typeof t[0];if(c==="string")i="string",a=t;else if(c==="boolean")i="bool",a=Uint8Array.from(t);else throw new TypeError(`Invalid element type of data array: ${c}.`)}else if(t instanceof Uint8ClampedArray)i="uint8",a=Uint8Array.from(t);else{let c=Sr.get(t.constructor);if(c===void 0)throw new TypeError(`Unsupported type for tensor data: ${t.constructor}.`);i=c,a=t}if(d===void 0)d=[a.length];else if(!Array.isArray(d))throw new TypeError("A tensor's dims must be a number array");u=d,this.cpuData=a,this.dataLocation="cpu"}let n=gs(u);if(this.cpuData&&n!==this.cpuData.length&&!((i==="uint4"||i==="int4")&&Math.ceil(n/2)===this.cpuData.length))throw new Error(`Tensor's size(${n}) does not match data length(${this.cpuData.length}).`);this.type=i,this.dims=u,this.size=n}static async fromImage(t,r){return us(t,r)}static fromTexture(t,r){return ls(t,r)}static fromGpuBuffer(t,r){return fs(t,r)}static fromMLTensor(t,r){return cs(t,r)}static fromPinnedBuffer(t,r,o){return ps(t,r,o)}toDataURL(t){return is(this,t)}toImageData(t){return as(this,t)}get data(){if(this.ensureValid(),!this.cpuData)throw new Error("The data is not on CPU. Use `getData()` to download GPU data to CPU, or use `texture` or `gpuBuffer` property to access the GPU data directly.");return this.cpuData}get location(){return this.dataLocation}get texture(){if(this.ensureValid(),!this.gpuTextureData)throw new Error("The data is not stored as a WebGL texture.");return this.gpuTextureData}get gpuBuffer(){if(this.ensureValid(),!this.gpuBufferData)throw new Error("The data is not stored as a WebGPU buffer.");return this.gpuBufferData}get mlTensor(){if(this.ensureValid(),!this.mlTensorData)throw new Error("The data is not stored as a WebNN MLTensor.");return this.mlTensorData}async getData(t){switch(this.ensureValid(),this.dataLocation){case"cpu":case"cpu-pinned":return this.data;case"texture":case"gpu-buffer":case"ml-tensor":{if(!this.downloader)throw new Error("The current tensor is not created with a specified data downloader.");if(this.isDownloading)throw new Error("The current tensor is being downloaded.");try{this.isDownloading=!0;let r=await this.downloader();return this.downloader=void 0,this.dataLocation="cpu",this.cpuData=r,t&&this.disposer&&(this.disposer(),this.disposer=void 0),r}finally{this.isDownloading=!1}}default:throw new Error(`cannot get data from location: ${this.dataLocation}`)}}dispose(){if(this.isDownloading)throw new Error("The current tensor is being downloaded.");this.disposer&&(this.disposer(),this.disposer=void 0),this.cpuData=void 0,this.gpuTextureData=void 0,this.gpuBufferData=void 0,this.mlTensorData=void 0,this.downloader=void 0,this.isDownloading=void 0,this.dataLocation="none"}ensureValid(){if(this.dataLocation==="none")throw new Error("The tensor is disposed.")}reshape(t){if(this.ensureValid(),this.downloader||this.disposer)throw new Error("Cannot reshape a tensor that owns GPU resource.");return ys(this,t)}}}),yt,pn=O(()=>{cn(),yt=St}),Ts,ws,Fe,Ce,Go=O(()=>{No(),Ts=(t,r)=>{(typeof Gt.trace>"u"?!Gt.wasm.trace:!Gt.trace)||console.timeStamp(`${t}::ORT::${r}`)},ws=(t,r)=>{var u;let o=((u=new Error().stack)==null?void 0:u.split(/\r\n|\r|\n/g))||[],i=!1;for(let n=0;n<o.length;n++){if(i&&!o[n].includes("TRACE_FUNC")){let a=`FUNC_${t}::${o[n].trim().split(" ")[1]}`;r&&(a+=`::${r}`),Ts("CPU",a);return}o[n].includes("TRACE_FUNC")&&(i=!0)}},Fe=t=>{(typeof Gt.trace>"u"?!Gt.wasm.trace:!Gt.trace)||ws("BEGIN",t)},Ce=t=>{(typeof Gt.trace>"u"?!Gt.wasm.trace:!Gt.trace)||ws("END",t)}}),dn,vs=O(()=>{fn(),pn(),Go(),dn=class Sa{constructor(r){this.handler=r}async run(r,o,i){Fe();let u={},n={};if(typeof r!="object"||r===null||r instanceof yt||Array.isArray(r))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let a=!0;if(typeof o=="object"){if(o===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(o instanceof yt)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(o)){if(o.length===0)throw new TypeError("'fetches' cannot be an empty array.");a=!1;for(let e of o){if(typeof e!="string")throw new TypeError("'fetches' must be a string array or an object.");if(this.outputNames.indexOf(e)===-1)throw new RangeError(`'fetches' contains invalid output name: ${e}.`);u[e]=null}if(typeof i=="object"&&i!==null)n=i;else if(typeof i<"u")throw new TypeError("'options' must be an object.")}else{let e=!1,l=Object.getOwnPropertyNames(o);for(let s of this.outputNames)if(l.indexOf(s)!==-1){let h=o[s];(h===null||h instanceof yt)&&(e=!0,a=!1,u[s]=h)}if(e){if(typeof i=="object"&&i!==null)n=i;else if(typeof i<"u")throw new TypeError("'options' must be an object.")}else n=o}}else if(typeof o<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let e of this.inputNames)if(typeof r[e]>"u")throw new Error(`input '${e}' is missing in 'feeds'.`);if(a)for(let e of this.outputNames)u[e]=null;let d=await this.handler.run(r,u,n),c={};for(let e in d)if(Object.hasOwnProperty.call(d,e)){let l=d[e];l instanceof yt?c[e]=l:c[e]=new yt(l.type,l.data,l.dims)}return Ce(),c}async release(){return this.handler.dispose()}static async create(r,o,i,u){Fe();let n,a={};if(typeof r=="string"){if(n=r,typeof o=="object"&&o!==null)a=o;else if(typeof o<"u")throw new TypeError("'options' must be an object.")}else if(r instanceof Uint8Array){if(n=r,typeof o=="object"&&o!==null)a=o;else if(typeof o<"u")throw new TypeError("'options' must be an object.")}else if(r instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&r instanceof SharedArrayBuffer){let l=r,s=0,h=r.byteLength;if(typeof o=="object"&&o!==null)a=o;else if(typeof o=="number"){if(s=o,!Number.isSafeInteger(s))throw new RangeError("'byteOffset' must be an integer.");if(s<0||s>=l.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${l.byteLength}).`);if(h=r.byteLength-s,typeof i=="number"){if(h=i,!Number.isSafeInteger(h))throw new RangeError("'byteLength' must be an integer.");if(h<=0||s+h>l.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${l.byteLength-s}].`);if(typeof u=="object"&&u!==null)a=u;else if(typeof u<"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 o<"u")throw new TypeError("'options' must be an object.");n=new Uint8Array(l,s,h)}else throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");let[d,c]=await ln(a),e=await d.createInferenceSessionHandler(n,c);return Ce(),new Sa(e)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}}}),Yd,Is=O(()=>{vs(),Yd=dn}),_s=O(()=>{}),Os=O(()=>{}),Ss=O(()=>{}),As=O(()=>{}),Zd,hn,Ps=O(()=>{fn(),pn(),Zd="Training backend could not be resolved. Make sure you're using the correct configuration & WebAssembly files.",hn=class Ea{constructor(r,o,i){this.handler=r,this.hasOptimizerModel=o,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,o){let i=r.evalModel||"",u=r.optimizerModel||"",n=o||{},[a,d]=await ln(n);if(a.createTrainingSessionHandler){let c=await a.createTrainingSessionHandler(r.checkpointState,r.trainModel,i,u,d);return new Ea(c,!!r.optimizerModel,!!r.evalModel)}else throw new Error(Zd)}typeNarrowingForRunStep(r,o,i,u,n){let a={},d={};if(typeof i!="object"||i===null||i instanceof yt||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 u=="object"){if(u===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(u instanceof yt)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(u)){if(u.length===0)throw new TypeError("'fetches' cannot be an empty array.");c=!1;for(let e of u){if(typeof e!="string")throw new TypeError("'fetches' must be a string array or an object.");if(o.indexOf(e)===-1)throw new RangeError(`'fetches' contains invalid output name: ${e}.`);a[e]=null}if(typeof n=="object"&&n!==null)d=n;else if(typeof n<"u")throw new TypeError("'options' must be an object.")}else{let e=!1,l=Object.getOwnPropertyNames(u);for(let s of o)if(l.indexOf(s)!==-1){let h=u[s];(h===null||h instanceof yt)&&(e=!0,c=!1,a[s]=h)}if(e){if(typeof n=="object"&&n!==null)d=n;else if(typeof n<"u")throw new TypeError("'options' must be an object.")}else d=u}}else if(typeof u<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let e of r)if(typeof i[e]>"u")throw new Error(`input '${e}' is missing in 'feeds'.`);if(c)for(let e of o)a[e]=null;return[a,d]}convertHandlerReturnTypeToMapOfTensors(r){let o={};for(let i in r)if(Object.hasOwnProperty.call(r,i)){let u=r[i];u instanceof yt?o[i]=u:o[i]=new yt(u.type,u.data,u.dims)}return o}async lazyResetGrad(){await this.handler.lazyResetGrad()}async runTrainStep(r,o,i){let[u,n]=this.typeNarrowingForRunStep(this.trainingInputNames,this.trainingOutputNames,r,o,i),a=await this.handler.runTrainStep(r,u,n);return this.convertHandlerReturnTypeToMapOfTensors(a)}async runOptimizerStep(r){if(this.hasOptimizerModel)await this.handler.runOptimizerStep(r||{});else throw new Error("This TrainingSession has no OptimizerModel loaded.")}async runEvalStep(r,o,i){if(this.hasEvalModel){let[u,n]=this.typeNarrowingForRunStep(this.evalInputNames,this.evalOutputNames,r,o,i),a=await this.handler.runEvalStep(r,u,n);return this.convertHandlerReturnTypeToMapOfTensors(a)}else throw new Error("This TrainingSession has no EvalModel loaded.")}async getParametersSize(r=!0){return this.handler.getParametersSize(r)}async loadParametersBuffer(r,o=!0){let i=await this.getParametersSize(o);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,o)}async getContiguousParameters(r=!0){return this.handler.getContiguousParameters(r)}async release(){return this.handler.dispose()}}}),Qd,Es=O(()=>{Ps(),Qd=hn}),Mo={};Or(Mo,{InferenceSession:()=>Yd,TRACE:()=>Ts,TRACE_FUNC_BEGIN:()=>Fe,TRACE_FUNC_END:()=>Ce,Tensor:()=>yt,TrainingSession:()=>Qd,env:()=>z,registerBackend:()=>nr});var Yt=O(()=>{ts(),os(),Is(),pn(),_s(),Os(),Go(),Ss(),As(),Es()});function _e(t,r,o,i){if(r===void 0)return eh(t);if(o===void 0)mn(t,r);else if(typeof o=="number"&&i===void 0)mn(t,r);else if(typeof o=="string"&&i===void 0)mn(t,o,1,r);else if(typeof o=="string"&&typeof i=="number")mn(t,o,i,r);else throw new TypeError("input is valid")}function eh(t){return{verbose:_e.verbose.bind(null,t),info:_e.info.bind(null,t),warning:_e.warning.bind(null,t),error:_e.error.bind(null,t),fatal:_e.fatal.bind(null,t)}}function mn(t,r,o,i){let u=Ar[i||""]||Ar[""];Ls[t]<Ls[u.minimalSeverity]||(u.logDateTime&&(r=`${new Date().toISOString()}|${r}`),u.logSourceLocation,th[u.provider].log(t,r,i))}var Uo,Vo,Ls,th,$s,Ar,tt,gn,yn,xn,bn,Ut=O(()=>{Uo=class{log(t,r,o){}},Vo=class{log(t,r,o){console.log(`${this.color(t)} ${o?"\x1B[35m"+o+"\x1B[0m ":""}${r}`)}color(t){switch(t){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: ${t}`)}}},Ls={verbose:1e3,info:2e3,warning:4e3,error:5e3,fatal:6e3},th={none:new Uo,console:new Vo},$s={provider:"console",minimalSeverity:"warning",logDateTime:!0,logSourceLocation:!1},Ar={"":$s},(t=>{function r(e,l){t("verbose",e,l)}t.verbose=r;function o(e,l){t("info",e,l)}t.info=o;function i(e,l){t("warning",e,l)}t.warning=i;function u(e,l){t("error",e,l)}t.error=u;function n(e,l){t("fatal",e,l)}t.fatal=n;function a(e){Ar={},d("",e||{})}t.reset=a;function d(e,l){if(e==="*")a(l);else{let s=Ar[e]||$s;Ar[e]={provider:l.provider||s.provider,minimalSeverity:l.minimalSeverity||s.minimalSeverity,logDateTime:l.logDateTime===void 0?s.logDateTime:l.logDateTime,logSourceLocation:l.logSourceLocation===void 0?s.logSourceLocation:l.logSourceLocation}}}t.set=d;function c(e){let l={};e.logLevel&&(l.minimalSeverity=e.logLevel),d("",l)}t.setWithEnv=c})(_e||(_e={})),tt=_e,gn=class{constructor(t,r,o,i,u,n){this.category=t,this.name=r,this.startTime=o,this.endCallback=i,this.timer=u,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)}},yn=class{constructor(t,r,o,i){this.category=t,this.name=r,this.startTime=o,this.endTime=i}},xn=class{constructor(t,r,o){this._started=!1,this._flushPointer=0,this._started=!1,this._maxNumberEvents=t===void 0?1e4:t,this._flushBatchSize=r===void 0?10:r,this._flushIntervalInMilliseconds=o===void 0?5e3:o}static create(t){return t===void 0?new this:new this(t.maxNumberEvents,t.flushBatchSize,t.flushIntervalInMilliseconds)}start(){this._started=!0,this._timingEvents=[],this._flushTime=bn(),this._flushPointer=0}stop(){for(this._started=!1;this._flushPointer<this._timingEvents.length;this._flushPointer++)this.logOneEvent(this._timingEvents[this._flushPointer])}event(t,r,o,i){let u=this._started?this.begin(t,r,i):void 0,n=!1,a=o();if(a&&typeof a.then=="function")return n=!0,new Promise((d,c)=>{a.then(async e=>{u&&await u.end(),d(e)},async e=>{u&&await u.end(),c(e)})});if(!n&&u){let d=u.end();if(d&&typeof d.then=="function")return new Promise((c,e)=>{d.then(()=>{c(a)},l=>{e(l)})})}return a}begin(t,r,o){if(!this._started)throw new Error("profiler is not started yet");if(o===void 0){let i=bn();return this.flush(i),new gn(t,r,i,u=>this.endSync(u))}else{let i=o.beginTimer();return new gn(t,r,0,async u=>this.end(u),i,o)}}async end(t){let r=await t.checkTimer();this._timingEvents.length<this._maxNumberEvents&&(this._timingEvents.push(new yn(t.category,t.name,t.startTime,r)),this.flush(r))}endSync(t){let r=bn();this._timingEvents.length<this._maxNumberEvents&&(this._timingEvents.push(new yn(t.category,t.name,t.startTime,r)),this.flush(r))}logOneEvent(t){tt.verbose(`Profiler.${t.category}`,`${(t.endTime-t.startTime).toFixed(2)}ms on event '${t.name}' at ${t.endTime.toFixed(2)}`)}flush(t){if(this._timingEvents.length-this._flushPointer>=this._flushBatchSize||t-this._flushTime>=this._flushIntervalInMilliseconds){for(let r=this._flushPointer;this._flushPointer<r+this._flushBatchSize&&this._flushPointer<this._timingEvents.length;this._flushPointer++)this.logOneEvent(this._timingEvents[this._flushPointer]);this._flushTime=bn()}}get started(){return this._started}},bn=typeof performance<"u"&&performance.now?()=>performance.now():Date.now});function ks(t,r,o){for(let i of o){let u=i[0],n=i[1],a=i[2],d=i[3],c=i[4];if(t.opType===u){for(let e of r)if((e.domain===n||e.domain==="ai.onnx"&&n==="")&&rh(e.version,a))return{opImpl:d,opInit:c}}}throw new TypeError(`cannot resolve operator '${t.opType}' with opsets: ${r.map(i=>`${i.domain||"ai.onnx"} v${i.version}`).join(", ")}`)}function rh(t,r){if(r.endsWith("+")){let o=Number.parseInt(r.substring(0,r.length-1),10);return!isNaN(o)&&o<=t}else if(r.split("-").length===2){let o=r.split("-"),i=Number.parseInt(o[0],10),u=Number.parseInt(o[1],10);return!isNaN(i)&&!isNaN(u)&&i<=t&&t<=u}else return Number.parseInt(r,10)===t}var Bs=O(()=>{}),Fs=mt(t=>{t.__esModule=!0;var r=function(){function o(i){if(!i)throw new TypeError("Invalid argument; `value` has no value.");this.value=o.EMPTY,i&&o.isGuid(i)&&(this.value=i)}return o.isGuid=function(i){var u=i.toString();return i&&(i instanceof o||o.validator.test(u))},o.create=function(){return new o([o.gen(2),o.gen(1),o.gen(1),o.gen(1),o.gen(3)].join("-"))},o.createEmpty=function(){return new o("emptyguid")},o.parse=function(i){return new o(i)},o.raw=function(){return[o.gen(2),o.gen(1),o.gen(1),o.gen(1),o.gen(3)].join("-")},o.gen=function(i){for(var u="",n=0;n<i;n++)u+=((1+Math.random())*65536|0).toString(16).substring(1);return u},o.prototype.equals=function(i){return o.isGuid(i)&&this.value===i.toString()},o.prototype.isEmpty=function(){return this.value===o.EMPTY},o.prototype.toString=function(){return this.value},o.prototype.toJSON=function(){return{value:this.value}},o.validator=new RegExp("^[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$","i"),o.EMPTY="00000000-0000-0000-0000-000000000000",o}();t.Guid=r});function rt(t,r,o){this.low=t|0,this.high=r|0,this.unsigned=!!o}function Et(t){return(t&&t.__isLong__)===!0}function Cs(t){var r=Math.clz32(t&-t);return t?31-r:r}function Ne(t,r){var o,i,u;return r?(t>>>=0,(u=0<=t&&t<256)&&(i=Rs[t],i)?i:(o=J(t,0,!0),u&&(Rs[t]=o),o)):(t|=0,(u=-128<=t&&t<128)&&(i=Ns[t],i)?i:(o=J(t,t<0?-1:0,!1),u&&(Ns[t]=o),o))}function zt(t,r){if(isNaN(t))return r?ye:Zt;if(r){if(t<0)return ye;if(t>=Vs)return Hs}else{if(t<=-Ms)return Ct;if(t+1>=Ms)return Ws}return t<0?zt(-t,r).neg():J(t%ir|0,t/ir|0,r)}function J(t,r,o){return new rt(t,r,o)}function Ho(t,r,o){if(t.length===0)throw Error("empty string");if(typeof r=="number"?(o=r,r=!1):r=!!r,t==="NaN"||t==="Infinity"||t==="+Infinity"||t==="-Infinity")return r?ye:Zt;if(o=o||10,o<2||36<o)throw RangeError("radix");var i;if((i=t.indexOf("-"))>0)throw Error("interior hyphen");if(i===0)return Ho(t.substring(1),r,o).neg();for(var u=zt(Tn(o,8)),n=Zt,a=0;a<t.length;a+=8){var d=Math.min(8,t.length-a),c=parseInt(t.substring(a,a+d),o);if(d<8){var e=zt(Tn(o,d));n=n.mul(e).add(zt(c))}else n=n.mul(u),n=n.add(zt(c))}return n.unsigned=r,n}function Qt(t,r){return typeof t=="number"?zt(t,r):typeof t=="string"?Ho(t,r):J(t.low,t.high,typeof r=="boolean"?r:t.unsigned)}var Vt,Ns,Rs,Tn,Gs,oh,ir,Vs,Ms,Us,Zt,ye,or,zs,Wo,Ws,Hs,Ct,D,xe,qo=O(()=>{Vt=null;try{Vt=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{}rt.prototype.__isLong__,Object.defineProperty(rt.prototype,"__isLong__",{value:!0}),rt.isLong=Et,Ns={},Rs={},rt.fromInt=Ne,rt.fromNumber=zt,rt.fromBits=J,Tn=Math.pow,rt.fromString=Ho,rt.fromValue=Qt,Gs=65536,oh=1<<24,ir=Gs*Gs,Vs=ir*ir,Ms=Vs/2,Us=Ne(oh),Zt=Ne(0),rt.ZERO=Zt,ye=Ne(0,!0),rt.UZERO=ye,or=Ne(1),rt.ONE=or,zs=Ne(1,!0),rt.UONE=zs,Wo=Ne(-1),rt.NEG_ONE=Wo,Ws=J(-1,2147483647,!1),rt.MAX_VALUE=Ws,Hs=J(-1,-1,!0),rt.MAX_UNSIGNED_VALUE=Hs,Ct=J(0,-2147483648,!1),rt.MIN_VALUE=Ct,D=rt.prototype,D.toInt=function(){return this.unsigned?this.low>>>0:this.low},D.toNumber=function(){return this.unsigned?(this.high>>>0)*ir+(this.low>>>0):this.high*ir+(this.low>>>0)},D.toString=function(t){if(t=t||10,t<2||36<t)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(Ct)){var r=zt(t),o=this.div(r),i=o.mul(r).sub(this);return o.toString(t)+i.toInt().toString(t)}else return"-"+this.neg().toString(t);for(var u=zt(Tn(t,6),this.unsigned),n=this,a="";;){var d=n.div(u),c=n.sub(d.mul(u)).toInt()>>>0,e=c.toString(t);if(n=d,n.isZero())return e+a;for(;e.length<6;)e="0"+e;a=""+e+a}},D.getHighBits=function(){return this.high},D.getHighBitsUnsigned=function(){return this.high>>>0},D.getLowBits=function(){return this.low},D.getLowBitsUnsigned=function(){return this.low>>>0},D.getNumBitsAbs=function(){if(this.isNegative())return this.eq(Ct)?64:this.neg().getNumBitsAbs();for(var t=this.high!=0?this.high:this.low,r=31;r>0&&!(t&1<<r);r--);return this.high!=0?r+33:r+1},D.isZero=function(){return this.high===0&&this.low===0},D.eqz=D.isZero,D.isNegative=function(){return!this.unsigned&&this.high<0},D.isPositive=function(){return this.unsigned||this.high>=0},D.isOdd=function(){return(this.low&1)===1},D.isEven=function(){return(this.low&1)===0},D.equals=function(t){return Et(t)||(t=Qt(t)),this.unsigned!==t.unsigned&&this.high>>>31===1&&t.high>>>31===1?!1:this.high===t.high&&this.low===t.low},D.eq=D.equals,D.notEquals=function(t){return!this.eq(t)},D.neq=D.notEquals,D.ne=D.notEquals,D.lessThan=function(t){return this.comp(t)<0},D.lt=D.lessThan,D.lessThanOrEqual=function(t){return this.comp(t)<=0},D.lte=D.lessThanOrEqual,D.le=D.lessThanOrEqual,D.greaterThan=function(t){return this.comp(t)>0},D.gt=D.greaterThan,D.greaterThanOrEqual=function(t){return this.comp(t)>=0},D.gte=D.greaterThanOrEqual,D.ge=D.greaterThanOrEqual,D.compare=function(t){if(Et(t)||(t=Qt(t)),this.eq(t))return 0;var r=this.isNegative(),o=t.isNegative();return r&&!o?-1:!r&&o?1:this.unsigned?t.high>>>0>this.high>>>0||t.high===this.high&&t.low>>>0>this.low>>>0?-1:1:this.sub(t).isNegative()?-1:1},D.comp=D.compare,D.negate=function(){return!this.unsigned&&this.eq(Ct)?Ct:this.not().add(or)},D.neg=D.negate,D.add=function(t){Et(t)||(t=Qt(t));var r=this.high>>>16,o=this.high&65535,i=this.low>>>16,u=this.low&65535,n=t.high>>>16,a=t.high&65535,d=t.low>>>16,c=t.low&65535,e=0,l=0,s=0,h=0;return h+=u+c,s+=h>>>16,h&=65535,s+=i+d,l+=s>>>16,s&=65535,l+=o+a,e+=l>>>16,l&=65535,e+=r+n,e&=65535,J(s<<16|h,e<<16|l,this.unsigned)},D.subtract=function(t){return Et(t)||(t=Qt(t)),this.add(t.neg())},D.sub=D.subtract,D.multiply=function(t){if(this.isZero())return this;if(Et(t)||(t=Qt(t)),Vt){var r=Vt.mul(this.low,this.high,t.low,t.high);return J(r,Vt.get_high(),this.unsigned)}if(t.isZero())return this.unsigned?ye:Zt;if(this.eq(Ct))return t.isOdd()?Ct:Zt;if(t.eq(Ct))return this.isOdd()?Ct:Zt;if(this.isNegative())return t.isNegative()?this.neg().mul(t.neg()):this.neg().mul(t).neg();if(t.isNegative())return this.mul(t.neg()).neg();if(this.lt(Us)&&t.lt(Us))return zt(this.toNumber()*t.toNumber(),this.unsigned);var o=this.high>>>16,i=this.high&65535,u=this.low>>>16,n=this.low&65535,a=t.high>>>16,d=t.high&65535,c=t.low>>>16,e=t.low&65535,l=0,s=0,h=0,f=0;return f+=n*e,h+=f>>>16,f&=65535,h+=u*e,s+=h>>>16,h&=65535,h+=n*c,s+=h>>>16,h&=65535,s+=i*e,l+=s>>>16,s&=65535,s+=u*c,l+=s>>>16,s&=65535,s+=n*d,l+=s>>>16,s&=65535,l+=o*e+i*c+u*d+n*a,l&=65535,J(h<<16|f,l<<16|s,this.unsigned)},D.mul=D.multiply,D.divide=function(t){if(Et(t)||(t=Qt(t)),t.isZero())throw Error("division by zero");if(Vt){if(!this.unsigned&&this.high===-2147483648&&t.low===-1&&t.high===-1)return this;var r=(this.unsigned?Vt.div_u:Vt.div_s)(this.low,this.high,t.low,t.high);return J(r,Vt.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?ye:Zt;var o,i,u;if(this.unsigned){if(t.unsigned||(t=t.toUnsigned()),t.gt(this))return ye;if(t.gt(this.shru(1)))return zs;u=ye}else{if(this.eq(Ct)){if(t.eq(or)||t.eq(Wo))return Ct;if(t.eq(Ct))return or;var n=this.shr(1);return o=n.div(t).shl(1),o.eq(Zt)?t.isNegative()?or:Wo:(i=this.sub(t.mul(o)),u=o.add(i.div(t)),u)}else if(t.eq(Ct))return this.unsigned?ye:Zt;if(this.isNegative())return t.isNegative()?this.neg().div(t.neg()):this.neg().div(t).neg();if(t.isNegative())return this.div(t.neg()).neg();u=Zt}for(i=this;i.gte(t);){o=Math.max(1,Math.floor(i.toNumber()/t.toNumber()));for(var a=Math.ceil(Math.log(o)/Math.LN2),d=a<=48?1:Tn(2,a-48),c=zt(o),e=c.mul(t);e.isNegative()||e.gt(i);)o-=d,c=zt(o,this.unsigned),e=c.mul(t);c.isZero()&&(c=or),u=u.add(c),i=i.sub(e)}return u},D.div=D.divide,D.modulo=function(t){if(Et(t)||(t=Qt(t)),Vt){var r=(this.unsigned?Vt.rem_u:Vt.rem_s)(this.low,this.high,t.low,t.high);return J(r,Vt.get_high(),this.unsigned)}return this.sub(this.div(t).mul(t))},D.mod=D.modulo,D.rem=D.modulo,D.not=function(){return J(~this.low,~this.high,this.unsigned)},D.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32},D.clz=D.countLeadingZeros,D.countTrailingZeros=function(){return this.low?Cs(this.low):Cs(this.high)+32},D.ctz=D.countTrailingZeros,D.and=function(t){return Et(t)||(t=Qt(t)),J(this.low&t.low,this.high&t.high,this.unsigned)},D.or=function(t){return Et(t)||(t=Qt(t)),J(this.low|t.low,this.high|t.high,this.unsigned)},D.xor=function(t){return Et(t)||(t=Qt(t)),J(this.low^t.low,this.high^t.high,this.unsigned)},D.shiftLeft=function(t){return Et(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?J(this.low<<t,this.high<<t|this.low>>>32-t,this.unsigned):J(0,this.low<<t-32,this.unsigned)},D.shl=D.shiftLeft,D.shiftRight=function(t){return Et(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?J(this.low>>>t|this.high<<32-t,this.high>>t,this.unsigned):J(this.high>>t-32,this.high>=0?0:-1,this.unsigned)},D.shr=D.shiftRight,D.shiftRightUnsigned=function(t){return Et(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?J(this.low>>>t|this.high<<32-t,this.high>>>t,this.unsigned):t===32?J(this.high,0,this.unsigned):J(this.high>>>t-32,0,this.unsigned)},D.shru=D.shiftRightUnsigned,D.shr_u=D.shiftRightUnsigned,D.rotateLeft=function(t){var r;return Et(t)&&(t=t.toInt()),(t&=63)===0?this:t===32?J(this.high,this.low,this.unsigned):t<32?(r=32-t,J(this.low<<t|this.high>>>r,this.high<<t|this.low>>>r,this.unsigned)):(t-=32,r=32-t,J(this.high<<t|this.low>>>r,this.low<<t|this.high>>>r,this.unsigned))},D.rotl=D.rotateLeft,D.rotateRight=function(t){var r;return Et(t)&&(t=t.toInt()),(t&=63)===0?this:t===32?J(this.high,this.low,this.unsigned):t<32?(r=32-t,J(this.high<<r|this.low>>>t,this.low<<r|this.high>>>t,this.unsigned)):(t-=32,r=32-t,J(this.low<<r|this.high>>>t,this.high<<r|this.low>>>t,this.unsigned))},D.rotr=D.rotateRight,D.toSigned=function(){return this.unsigned?J(this.low,this.high,!1):this},D.toUnsigned=function(){return this.unsigned?this:J(this.low,this.high,!0)},D.toBytes=function(t){return t?this.toBytesLE():this.toBytesBE()},D.toBytesLE=function(){var t=this.high,r=this.low;return[r&255,r>>>8&255,r>>>16&255,r>>>24,t&255,t>>>8&255,t>>>16&255,t>>>24]},D.toBytesBE=function(){var t=this.high,r=this.low;return[t>>>24,t>>>16&255,t>>>8&255,t&255,r>>>24,r>>>16&255,r>>>8&255,r&255]},rt.fromBytes=function(t,r,o){return o?rt.fromBytesLE(t,r):rt.fromBytesBE(t,r)},rt.fromBytesLE=function(t,r){return new rt(t[0]|t[1]<<8|t[2]<<16|t[3]<<24,t[4]|t[5]<<8|t[6]<<16|t[7]<<24,r)},rt.fromBytesBE=function(t,r){return new rt(t[4]<<24|t[5]<<16|t[6]<<8|t[7],t[0]<<24|t[1]<<16|t[2]<<8|t[3],r)},xe=rt}),w,wn=O(()=>{w={},w.Offset,w.Table,w.SIZEOF_SHORT=2,w.SIZEOF_INT=4,w.FILE_IDENTIFIER_LENGTH=4,w.SIZE_PREFIX_LENGTH=4,w.Encoding={UTF8_BYTES:1,UTF16_STRING:2},w.int32=new Int32Array(2),w.float32=new Float32Array(w.int32.buffer),w.float64=new Float64Array(w.int32.buffer),w.isLittleEndian=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1,w.Long=function(t,r){this.low=t|0,this.high=r|0},w.Long.create=function(t,r){return t==0&&r==0?w.Long.ZERO:new w.Long(t,r)},w.Long.prototype.toFloat64=function(){return(this.low>>>0)+this.high*4294967296},w.Long.prototype.equals=function(t){return this.low==t.low&&this.high==t.high},w.Long.ZERO=new w.Long(0,0),w.Builder=function(t){if(t)var r=t;else var r=1024;this.bb=w.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},w.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},w.Builder.prototype.forceDefaults=function(t){this.force_defaults=t},w.Builder.prototype.dataBuffer=function(){return this.bb},w.Builder.prototype.asUint8Array=function(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())},w.Builder.prototype.prep=function(t,r){t>this.minalign&&(this.minalign=t);for(var o=~(this.bb.capacity()-this.space+r)+1&t-1;this.space<o+t+r;){var i=this.bb.capacity();this.bb=w.Builder.growByteBuffer(this.bb),this.space+=this.bb.capacity()-i}this.pad(o)},w.Builder.prototype.pad=function(t){for(var r=0;r<t;r++)this.bb.writeInt8(--this.space,0)},w.Builder.prototype.writeInt8=function(t){this.bb.writeInt8(this.space-=1,t)},w.Builder.prototype.writeInt16=function(t){this.bb.writeInt16(this.space-=2,t)},w.Builder.prototype.writeInt32=function(t){this.bb.writeInt32(this.space-=4,t)},w.Builder.prototype.writeInt64=function(t){this.bb.writeInt64(this.space-=8,t)},w.Builder.prototype.writeFloat32=function(t){this.bb.writeFloat32(this.space-=4,t)},w.Builder.prototype.writeFloat64=function(t){this.bb.writeFloat64(this.space-=8,t)},w.Builder.prototype.addInt8=function(t){this.prep(1,0),this.writeInt8(t)},w.Builder.prototype.addInt16=function(t){this.prep(2,0),this.writeInt16(t)},w.Builder.prototype.addInt32=function(t){this.prep(4,0),this.writeInt32(t)},w.Builder.prototype.addInt64=function(t){this.prep(8,0),this.writeInt64(t)},w.Builder.prototype.addFloat32=function(t){this.prep(4,0),this.writeFloat32(t)},w.Builder.prototype.addFloat64=function(t){this.prep(8,0),this.writeFloat64(t)},w.Builder.prototype.addFieldInt8=function(t,r,o){(this.force_defaults||r!=o)&&(this.addInt8(r),this.slot(t))},w.Builder.prototype.addFieldInt16=function(t,r,o){(this.force_defaults||r!=o)&&(this.addInt16(r),this.slot(t))},w.Builder.prototype.addFieldInt32=function(t,r,o){(this.force_defaults||r!=o)&&(this.addInt32(r),this.slot(t))},w.Builder.prototype.addFieldInt64=function(t,r,o){(this.force_defaults||!r.equals(o))&&(this.addInt64(r),this.slot(t))},w.Builder.prototype.addFieldFloat32=function(t,r,o){(this.force_defaults||r!=o)&&(this.addFloat32(r),this.slot(t))},w.Builder.prototype.addFieldFloat64=function(t,r,o){(this.force_defaults||r!=o)&&(this.addFloat64(r),this.slot(t))},w.Builder.prototype.addFieldOffset=function(t,r,o){(this.force_defaults||r!=o)&&(this.addOffset(r),this.slot(t))},w.Builder.prototype.addFieldStruct=function(t,r,o){r!=o&&(this.nested(r),this.slot(t))},w.Builder.prototype.nested=function(t){if(t!=this.offset())throw new Error("FlatBuffers: struct must be serialized inline.")},w.Builder.prototype.notNested=function(){if(this.isNested)throw new Error("FlatBuffers: object serialization must not be nested.")},w.Builder.prototype.slot=function(t){this.vtable[t]=this.offset()},w.Builder.prototype.offset=function(){return this.bb.capacity()-this.space},w.Builder.growByteBuffer=function(t){var r=t.capacity();if(r&3221225472)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");var o=r<<1,i=w.ByteBuffer.allocate(o);return i.setPosition(o-r),i.bytes().set(t.bytes(),o-r),i},w.Builder.prototype.addOffset=function(t){this.prep(w.SIZEOF_INT,0),this.writeInt32(this.offset()-t+w.SIZEOF_INT)},w.Builder.prototype.startObject=function(t){this.notNested(),this.vtable==null&&(this.vtable=[]),this.vtable_in_use=t;for(var r=0;r<t;r++)this.vtable[r]=0;this.isNested=!0,this.object_start=this.offset()},w.Builder.prototype.endObject=function(){if(this.vtable==null||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);for(var t=this.offset(),r=this.vtable_in_use-1;r>=0&&this.vtable[r]==0;r--);for(var o=r+1;r>=0;r--)this.addInt16(this.vtable[r]!=0?t-this.vtable[r]:0);var i=2;this.addInt16(t-this.object_start);var u=(o+i)*w.SIZEOF_SHORT;this.addInt16(u);var n=0,a=this.space;t:for(r=0;r<this.vtables.length;r++){var d=this.bb.capacity()-this.vtables[r];if(u==this.bb.readInt16(d)){for(var c=w.SIZEOF_SHORT;c<u;c+=w.SIZEOF_SHORT)if(this.bb.readInt16(a+c)!=this.bb.readInt16(d+c))continue t;n=this.vtables[r];break}}return n?(this.space=this.bb.capacity()-t,this.bb.writeInt32(this.space,n-t)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-t,this.offset()-t)),this.isNested=!1,t},w.Builder.prototype.finish=function(t,r,o){var i=o?w.SIZE_PREFIX_LENGTH:0;if(r){var u=r;if(this.prep(this.minalign,w.SIZEOF_INT+w.FILE_IDENTIFIER_LENGTH+i),u.length!=w.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+w.FILE_IDENTIFIER_LENGTH);for(var n=w.FILE_IDENTIFIER_LENGTH-1;n>=0;n--)this.writeInt8(u.charCodeAt(n))}this.prep(this.minalign,w.SIZEOF_INT+i),this.addOffset(t),i&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)},w.Builder.prototype.finishSizePrefixed=function(t,r){this.finish(t,r,!0)},w.Builder.prototype.requiredField=function(t,r){var o=this.bb.capacity()-t,i=o-this.bb.readInt32(o),u=this.bb.readInt16(i+r)!=0;if(!u)throw new Error("FlatBuffers: field "+r+" must be set")},w.Builder.prototype.startVector=function(t,r,o){this.notNested(),this.vector_num_elems=r,this.prep(w.SIZEOF_INT,t*r),this.prep(o,t*r)},w.Builder.prototype.endVector=function(){return this.writeInt32(this.vector_num_elems),this.offset()},w.Builder.prototype.createString=function(t){if(t instanceof Uint8Array)var r=t;else for(var r=[],o=0;o<t.length;){var i,u=t.charCodeAt(o++);if(u<55296||u>=56320)i=u;else{var n=t.charCodeAt(o++);i=(u<<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 o=0,a=this.space,d=this.bb.bytes();o<r.length;o++)d[a++]=r[o];return this.endVector()},w.Builder.prototype.createLong=function(t,r){return w.Long.create(t,r)},w.ByteBuffer=function(t){this.bytes_=t,this.position_=0},w.ByteBuffer.allocate=function(t){return new w.ByteBuffer(new Uint8Array(t))},w.ByteBuffer.prototype.clear=function(){this.position_=0},w.ByteBuffer.prototype.bytes=function(){return this.bytes_},w.ByteBuffer.prototype.position=function(){return this.position_},w.ByteBuffer.prototype.setPosition=function(t){this.position_=t},w.ByteBuffer.prototype.capacity=function(){return this.bytes_.length},w.ByteBuffer.prototype.readInt8=function(t){return this.readUint8(t)<<24>>24},w.ByteBuffer.prototype.readUint8=function(t){return this.bytes_[t]},w.ByteBuffer.prototype.readInt16=function(t){return this.readUint16(t)<<16>>16},w.ByteBuffer.prototype.readUint16=function(t){return this.bytes_[t]|this.bytes_[t+1]<<8},w.ByteBuffer.prototype.readInt32=function(t){return this.bytes_[t]|this.bytes_[t+1]<<8|this.bytes_[t+2]<<16|this.bytes_[t+3]<<24},w.ByteBuffer.prototype.readUint32=function(t){return this.readInt32(t)>>>0},w.ByteBuffer.prototype.readInt64=function(t){return new w.Long(this.readInt32(t),this.readInt32(t+4))},w.ByteBuffer.prototype.readUint64=function(t){return new w.Long(this.readUint32(t),this.readUint32(t+4))},w.ByteBuffer.prototype.readFloat32=function(t){return w.int32[0]=this.readInt32(t),w.float32[0]},w.ByteBuffer.prototype.readFloat64=function(t){return w.int32[w.isLittleEndian?0:1]=this.readInt32(t),w.int32[w.isLittleEndian?1:0]=this.readInt32(t+4),w.float64[0]},w.ByteBuffer.prototype.writeInt8=function(t,r){this.bytes_[t]=r},w.ByteBuffer.prototype.writeUint8=function(t,r){this.bytes_[t]=r},w.ByteBuffer.prototype.writeInt16=function(t,r){this.bytes_[t]=r,this.bytes_[t+1]=r>>8},w.ByteBuffer.prototype.writeUint16=function(t,r){this.bytes_[t]=r,this.bytes_[t+1]=r>>8},w.ByteBuffer.prototype.writeInt32=function(t,r){this.bytes_[t]=r,this.bytes_[t+1]=r>>8,this.bytes_[t+2]=r>>16,this.bytes_[t+3]=r>>24},w.ByteBuffer.prototype.writeUint32=function(t,r){this.bytes_[t]=r,this.bytes_[t+1]=r>>8,this.bytes_[t+2]=r>>16,this.bytes_[t+3]=r>>24},w.ByteBuffer.prototype.writeInt64=function(t,r){this.writeInt32(t,r.low),this.writeInt32(t+4,r.high)},w.ByteBuffer.prototype.writeUint64=function(t,r){this.writeUint32(t,r.low),this.writeUint32(t+4,r.high)},w.ByteBuffer.prototype.writeFloat32=function(t,r){w.float32[0]=r,this.writeInt32(t,w.int32[0])},w.ByteBuffer.prototype.writeFloat64=function(t,r){w.float64[0]=r,this.writeInt32(t,w.int32[w.isLittleEndian?0:1]),this.writeInt32(t+4,w.int32[w.isLittleEndian?1:0])},w.ByteBuffer.prototype.getBufferIdentifier=function(){if(this.bytes_.length<this.position_+w.SIZEOF_INT+w.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");for(var t="",r=0;r<w.FILE_IDENTIFIER_LENGTH;r++)t+=String.fromCharCode(this.readInt8(this.position_+w.SIZEOF_INT+r));return t},w.ByteBuffer.prototype.__offset=function(t,r){var o=t-this.readInt32(t);return r<this.readInt16(o)?this.readInt16(o+r):0},w.ByteBuffer.prototype.__union=function(t,r){return t.bb_pos=r+this.readInt32(r),t.bb=this,t},w.ByteBuffer.prototype.__string=function(t,r){t+=this.readInt32(t);var o=this.readInt32(t),i="",u=0;if(t+=w.SIZEOF_INT,r===w.Encoding.UTF8_BYTES)return this.bytes_.subarray(t,t+o);for(;u<o;){var n,a=this.readUint8(t+u++);if(a<192)n=a;else{var d=this.readUint8(t+u++);if(a<224)n=(a&31)<<6|d&63;else{var c=this.readUint8(t+u++);if(a<240)n=(a&15)<<12|(d&63)<<6|c&63;else{var e=this.readUint8(t+u++);n=(a&7)<<18|(d&63)<<12|(c&63)<<6|e&63}}}n<65536?i+=String.fromCharCode(n):(n-=65536,i+=String.fromCharCode((n>>10)+55296,(n&1023)+56320))}return i},w.ByteBuffer.prototype.__indirect=function(t){return t+this.readInt32(t)},w.ByteBuffer.prototype.__vector=function(t){return t+this.readInt32(t)+w.SIZEOF_INT},w.ByteBuffer.prototype.__vector_len=function(t){return this.readInt32(t+this.readInt32(t))},w.ByteBuffer.prototype.__has_identifier=function(t){if(t.length!=w.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+w.FILE_IDENTIFIER_LENGTH);for(var r=0;r<w.FILE_IDENTIFIER_LENGTH;r++)if(t.charCodeAt(r)!=this.readInt8(this.position_+w.SIZEOF_INT+r))return!1;return!0},w.ByteBuffer.prototype.createLong=function(t,r){return w.Long.create(t,r)}}),F,Pr=O(()=>{wn(),(t=>{(r=>{(o=>{(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"))(o.AttributeType||(o.AttributeType={}))})(r.fbs||(r.fbs={}))})(t.experimental||(t.experimental={}))})(F||(F={})),(t=>{(r=>{(o=>{(i=>(i[i.UNKNOWN=0]="UNKNOWN",i[i.VALUE=1]="VALUE",i[i.PARAM=2]="PARAM"))(o.DimensionValueType||(o.DimensionValueType={}))})(r.fbs||(r.fbs={}))})(t.experimental||(t.experimental={}))})(F||(F={})),(t=>{(r=>{(o=>{(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"))(o.TensorDataType||(o.TensorDataType={}))})(r.fbs||(r.fbs={}))})(t.experimental||(t.experimental={}))})(F||(F={})),(t=>{(r=>{(o=>{(i=>(i[i.Primitive=0]="Primitive",i[i.Fused=1]="Fused"))(o.NodeType||(o.NodeType={}))})(r.fbs||(r.fbs={}))})(t.experimental||(t.experimental={}))})(F||(F={})),(t=>{(r=>{(o=>{(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"))(o.TypeInfoValue||(o.TypeInfoValue={}))})(r.fbs||(r.fbs={}))})(t.experimental||(t.experimental={}))})(F||(F={})),(t=>{(r=>{(o=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(n,a){return this.bb_pos=n,this.bb=a,this}static getRootAsShape(n,a){return(a||new i).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsShape(n,a){return n.setPosition(n.position()+w.SIZE_PREFIX_LENGTH),(a||new i).__init(n.readInt32(n.position())+n.position(),n)}dim(n,a){let d=this.bb.__offset(this.bb_pos,4);return d?(a||new t.experimental.fbs.Dimension).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+d)+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,a){n.addFieldOffset(0,a,0)}static createDimVector(n,a){n.startVector(4,a.length,4);for(let d=a.length-1;d>=0;d--)n.addOffset(a[d]);return n.endVector()}static startDimVector(n,a){n.startVector(4,a,4)}static endShape(n){return n.endObject()}static createShape(n,a){return i.startShape(n),i.addDim(n,a),i.endShape(n)}}o.Shape=i})(r.fbs||(r.fbs={}))})(t.experimental||(t.experimental={}))})(F||(F={})),(t=>{(r=>{(o=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(n,a){return this.bb_pos=n,this.bb=a,this}static getRootAsDimension(n,a){return(a||new i).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsDimension(n,a){return n.setPosition(n.position()+w.SIZE_PREFIX_LENGTH),(a||new i).__init(n.readInt32(n.position())+n.position(),n)}value(n){let a=this.bb.__offset(this.bb_pos,4);return a?(n||new t.experimental.fbs.DimensionValue).__init(this.bb.__indirect(this.bb_pos+a),this.bb):null}denotation(n){let a=this.bb.__offset(this.bb_pos,6);return a?this.bb.__string(this.bb_pos+a,n):null}static startDimension(n){n.startObject(2)}static addValue(n,a){n.addFieldOffset(0,a,0)}static addDenotation(n,a){n.addFieldOffset(1,a,0)}static endDimension(n){return n.endObject()}static createDimension(n,a,d){return i.startDimension(n),i.addValue(n,a),i.addDenotation(n,d),i.endDimension(n)}}o.Dimension=i})(r.fbs||(r.fbs={}))})(t.experimental||(t.experimental={}))})(F||(F={})),(t=>{(r=>{(o=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(n,a){return this.bb_pos=n,this.bb=a,this}static getRootAsDimensionValue(n,a){return(a||new i).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsDimensionValue(n,a){return n.setPosition(n.position()+w.SIZE_PREFIX_LENGTH),(a||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 a=this.bb.__offset(this.bb_pos,8);return a?this.bb.__string(this.bb_pos+a,n):null}static startDimensionValue(n){n.startObject(3)}static addDimType(n,a){n.addFieldInt8(0,a,0)}static addDimValue(n,a){n.addFieldInt64(1,a,n.createLong(0,0))}static addDimParam(n,a){n.addFieldOffset(2,a,0)}static endDimensionValue(n){return n.endObject()}static createDimensionValue(n,a,d,c){return i.startDimensionValue(n),i.addDimType(n,a),i.addDimValue(n,d),i.addDimParam(n,c),i.endDimensionValue(n)}}o.DimensionValue=i})(r.fbs||(r.fbs={}))})(t.experimental||(t.experimental={}))})(F||(F={})),(t=>{(r=>{(o=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(n,a){return this.bb_pos=n,this.bb=a,this}static getRootAsTensorTypeAndShape(n,a){return(a||new i).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsTensorTypeAndShape(n,a){return n.setPosition(n.position()+w.SIZE_PREFIX_LENGTH),(a||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 a=this.bb.__offset(this.bb_pos,6);return a?(n||new t.experimental.fbs.Shape).__init(this.bb.__indirect(this.bb_pos+a),this.bb):null}static startTensorTypeAndShape(n){n.startObject(2)}static addElemType(n,a){n.addFieldInt32(0,a,0)}static addShape(n,a){n.addFieldOffset(1,a,0)}static endTensorTypeAndShape(n){return n.endObject()}static createTensorTypeAndShape(n,a,d){return i.startTensorTypeAndShape(n),i.addElemType(n,a),i.addShape(n,d),i.endTensorTypeAndShape(n)}}o.TensorTypeAndShape=i})(r.fbs||(r.fbs={}))})(t.experimental||(t.experimental={}))})(F||(F={})),(t=>{(r=>{(o=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(n,a){return this.bb_pos=n,this.bb=a,this}static getRootAsMapType(n,a){return(a||new i).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsMapType(n,a){return n.setPosition(n.position()+w.SIZE_PREFIX_LENGTH),(a||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 a=this.bb.__offset(this.bb_pos,6);return a?(n||new t.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+a),this.bb):null}static startMapType(n){n.startObject(2)}static addKeyType(n,a){n.addFieldInt32(0,a,0)}static addValueType(n,a){n.addFieldOffset(1,a,0)}static endMapType(n){return n.endObject()}static createMapType(n,a,d){return i.startMapType(n),i.addKeyType(n,a),i.addValueType(n,d),i.endMapType(n)}}o.MapType=i})(r.fbs||(r.fbs={}))})(t.experimental||(t.experimental={}))})(F||(F={})),(t=>{(r=>{(o=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(n,a){return this.bb_pos=n,this.bb=a,this}static getRootAsSequenceType(n,a){return(a||new i).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsSequenceType(n,a){return n.setPosition(n.position()+w.SIZE_PREFIX_LENGTH),(a||new i).__init(n.readInt32(n.position())+n.position(),n)}elemType(n){let a=this.bb.__offset(this.bb_pos,4);return a?(n||new t.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+a),this.bb):null}static startSequenceType(n){n.startObject(1)}static addElemType(n,a){n.addFieldOffset(0,a,0)}static endSequenceType(n){return n.endObject()}static createSequenceType(n,a){return i.startSequenceType(n),i.addElemType(n,a),i.endSequenceType(n)}}o.SequenceType=i})(r.fbs||(r.fbs={}))})(t.experimental||(t.experimental={}))})(F||(F={})),(t=>{(r=>{(o=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(n,a){return this.bb_pos=n,this.bb=a,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,a,d,c){return n.prep(4,12),n.writeInt32(c),n.writeInt32(d),n.writeInt32(a),n.offset()}}o.EdgeEnd=i})(r.fbs||(r.fbs={}))})(t.experimental||(t.experimental={}))})(F||(F={})),(t=>{(r=>{(o=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(n,a){return this.bb_pos=n,this.bb=a,this}static getRootAsNodeEdge(n,a){return(a||new i).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsNodeEdge(n,a){return n.setPosition(n.position()+w.SIZE_PREFIX_LENGTH),(a||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,a){let d=this.bb.__offset(this.bb_pos,6);return d?(a||new t.experimental.fbs.EdgeEnd).__init(this.bb.__vector(this.bb_pos+d)+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,a){let d=this.bb.__offset(this.bb_pos,8);return d?(a||new t.experimental.fbs.EdgeEnd).__init(this.bb.__vector(this.bb_pos+d)+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,a){n.addFieldInt32(0,a,0)}static addInputEdges(n,a){n.addFieldOffset(1,a,0)}static startInputEdgesVector(n,a){n.startVector(12,a,4)}static addOutputEdges(n,a){n.addFieldOffset(2,a,0)}static startOutputEdgesVector(n,a){n.startVector(12,a,4)}static endNodeEdge(n){return n.endObject()}static createNodeEdge(n,a,d,c){return i.startNodeEdge(n),i.addNodeIndex(n,a),i.addInputEdges(n,d),i.addOutputEdges(n,c),i.endNodeEdge(n)}}o.NodeEdge=i})(r.fbs||(r.fbs={}))})(t.experimental||(t.experimental={}))})(F||(F={})),(t=>{(r=>{(o=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(n,a){return this.bb_pos=n,this.bb=a,this}static getRootAsNode(n,a){return(a||new i).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsNode(n,a){return n.setPosition(n.position()+w.SIZE_PREFIX_LENGTH),(a||new i).__init(n.readInt32(n.position())+n.position(),n)}name(n){let a=this.bb.__offset(this.bb_pos,4);return a?this.bb.__string(this.bb_pos+a,n):null}docString(n){let a=this.bb.__offset(this.bb_pos,6);return a?this.bb.__string(this.bb_pos+a,n):null}domain(n){let a=this.bb.__offset(this.bb_pos,8);return a?this.bb.__string(this.bb_pos+a,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 a=this.bb.__offset(this.bb_pos,14);return a?this.bb.__string(this.bb_pos+a,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 a=this.bb.__offset(this.bb_pos,18);return a?this.bb.__string(this.bb_pos+a,n):null}inputs(n,a){let d=this.bb.__offset(this.bb_pos,20);return d?this.bb.__string(this.bb.__vector(this.bb_pos+d)+n*4,a):null}inputsLength(){let n=this.bb.__offset(this.bb_pos,20);return n?this.bb.__vector_len(this.bb_pos+n):0}outputs(n,a){let d=this.bb.__offset(this.bb_pos,22);return d?this.bb.__string(this.bb.__vector(this.bb_pos+d)+n*4,a):null}outputsLength(){let n=this.bb.__offset(this.bb_pos,22);return n?this.bb.__vector_len(this.bb_pos+n):0}attributes(n,a){let d=this.bb.__offset(this.bb_pos,24);return d?(a||new t.experimental.fbs.Attribute).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+d)+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 a=this.bb.__offset(this.bb_pos,26);return a?this.bb.readInt32(this.bb.__vector(this.bb_pos+a)+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,a){let d=this.bb.__offset(this.bb_pos,28);return d?this.bb.__string(this.bb.__vector(this.bb_pos+d)+n*4,a):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,a){n.addFieldOffset(0,a,0)}static addDocString(n,a){n.addFieldOffset(1,a,0)}static addDomain(n,a){n.addFieldOffset(2,a,0)}static addSinceVersion(n,a){n.addFieldInt32(3,a,0)}static addIndex(n,a){n.addFieldInt32(4,a,0)}static addOpType(n,a){n.addFieldOffset(5,a,0)}static addType(n,a){n.addFieldInt32(6,a,0)}static addExecutionProviderType(n,a){n.addFieldOffset(7,a,0)}static addInputs(n,a){n.addFieldOffset(8,a,0)}static createInputsVector(n,a){n.startVector(4,a.length,4);for(let d=a.length-1;d>=0;d--)n.addOffset(a[d]);return n.endVector()}static startInputsVector(n,a){n.startVector(4,a,4)}static addOutputs(n,a){n.addFieldOffset(9,a,0)}static createOutputsVector(n,a){n.startVector(4,a.length,4);for(let d=a.length-1;d>=0;d--)n.addOffset(a[d]);return n.endVector()}static startOutputsVector(n,a){n.startVector(4,a,4)}static addAttributes(n,a){n.addFieldOffset(10,a,0)}static createAttributesVector(n,a){n.startVector(4,a.length,4);for(let d=a.length-1;d>=0;d--)n.addOffset(a[d]);return n.endVector()}static startAttributesVector(n,a){n.startVector(4,a,4)}static addInputArgCounts(n,a){n.addFieldOffset(11,a,0)}static createInputArgCountsVector(n,a){n.startVector(4,a.length,4);for(let d=a.length-1;d>=0;d--)n.addInt32(a[d]);return n.endVector()}static startInputArgCountsVector(n,a){n.startVector(4,a,4)}static addImplicitInputs(n,a){n.addFieldOffset(12,a,0)}static createImplicitInputsVector(n,a){n.startVector(4,a.length,4);for(let d=a.length-1;d>=0;d--)n.addOffset(a[d]);return n.endVector()}static startImplicitInputsVector(n,a){n.startVector(4,a,4)}static endNode(n){return n.endObject()}static createNode(n,a,d,c,e,l,s,h,f,m,v,_,I,T){return i.startNode(n),i.addName(n,a),i.addDocString(n,d),i.addDomain(n,c),i.addSinceVersion(n,e),i.addIndex(n,l),i.addOpType(n,s),i.addType(n,h),i.addExecutionProviderType(n,f),i.addInputs(n,m),i.addOutputs(n,v),i.addAttributes(n,_),i.addInputArgCounts(n,I),i.addImplicitInputs(n,T),i.endNode(n)}}o.Node=i})(r.fbs||(r.fbs={}))})(t.experimental||(t.experimental={}))})(F||(F={})),(t=>{(r=>{(o=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(n,a){return this.bb_pos=n,this.bb=a,this}static getRootAsValueInfo(n,a){return(a||new i).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsValueInfo(n,a){return n.setPosition(n.position()+w.SIZE_PREFIX_LENGTH),(a||new i).__init(n.readInt32(n.position())+n.position(),n)}name(n){let a=this.bb.__offset(this.bb_pos,4);return a?this.bb.__string(this.bb_pos+a,n):null}docString(n){let a=this.bb.__offset(this.bb_pos,6);return a?this.bb.__string(this.bb_pos+a,n):null}type(n){let a=this.bb.__offset(this.bb_pos,8);return a?(n||new t.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+a),this.bb):null}static startValueInfo(n){n.startObject(3)}static addName(n,a){n.addFieldOffset(0,a,0)}static addDocString(n,a){n.addFieldOffset(1,a,0)}static addType(n,a){n.addFieldOffset(2,a,0)}static endValueInfo(n){return n.endObject()}static createValueInfo(n,a,d,c){return i.startValueInfo(n),i.addName(n,a),i.addDocString(n,d),i.addType(n,c),i.endValueInfo(n)}}o.ValueInfo=i})(r.fbs||(r.fbs={}))})(t.experimental||(t.experimental={}))})(F||(F={})),(t=>{(r=>{(o=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(n,a){return this.bb_pos=n,this.bb=a,this}static getRootAsTypeInfo(n,a){return(a||new i).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsTypeInfo(n,a){return n.setPosition(n.position()+w.SIZE_PREFIX_LENGTH),(a||new i).__init(n.readInt32(n.position())+n.position(),n)}denotation(n){let a=this.bb.__offset(this.bb_pos,4);return a?this.bb.__string(this.bb_pos+a,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 a=this.bb.__offset(this.bb_pos,8);return a?this.bb.__union(n,this.bb_pos+a):null}static startTypeInfo(n){n.startObject(3)}static addDenotation(n,a){n.addFieldOffset(0,a,0)}static addValueType(n,a){n.addFieldInt8(1,a,0)}static addValue(n,a){n.addFieldOffset(2,a,0)}static endTypeInfo(n){return n.endObject()}static createTypeInfo(n,a,d,c){return i.startTypeInfo(n),i.addDenotation(n,a),i.addValueType(n,d),i.addValue(n,c),i.endTypeInfo(n)}}o.TypeInfo=i})(r.fbs||(r.fbs={}))})(t.experimental||(t.experimental={}))})(F||(F={})),(t=>{(r=>{(o=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(n,a){return this.bb_pos=n,this.bb=a,this}static getRootAsOperatorSetId(n,a){return(a||new i).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsOperatorSetId(n,a){return n.setPosition(n.position()+w.SIZE_PREFIX_LENGTH),(a||new i).__init(n.readInt32(n.position())+n.position(),n)}domain(n){let a=this.bb.__offset(this.bb_pos,4);return a?this.bb.__string(this.bb_pos+a,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,a){n.addFieldOffset(0,a,0)}static addVersion(n,a){n.addFieldInt64(1,a,n.createLong(0,0))}static endOperatorSetId(n){return n.endObject()}static createOperatorSetId(n,a,d){return i.startOperatorSetId(n),i.addDomain(n,a),i.addVersion(n,d),i.endOperatorSetId(n)}}o.OperatorSetId=i})(r.fbs||(r.fbs={}))})(t.experimental||(t.experimental={}))})(F||(F={})),(t=>{(r=>{(o=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(n,a){return this.bb_pos=n,this.bb=a,this}static getRootAsTensor(n,a){return(a||new i).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsTensor(n,a){return n.setPosition(n.position()+w.SIZE_PREFIX_LENGTH),(a||new i).__init(n.readInt32(n.position())+n.position(),n)}name(n){let a=this.bb.__offset(this.bb_pos,4);return a?this.bb.__string(this.bb_pos+a,n):null}docString(n){let a=this.bb.__offset(this.bb_pos,6);return a?this.bb.__string(this.bb_pos+a,n):null}dims(n){let a=this.bb.__offset(this.bb_pos,8);return a?this.bb.readInt64(this.bb.__vector(this.bb_pos+a)+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 a=this.bb.__offset(this.bb_pos,12);return a?this.bb.readUint8(this.bb.__vector(this.bb_pos+a)+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,a){let d=this.bb.__offset(this.bb_pos,14);return d?this.bb.__string(this.bb.__vector(this.bb_pos+d)+n*4,a):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,a){n.addFieldOffset(0,a,0)}static addDocString(n,a){n.addFieldOffset(1,a,0)}static addDims(n,a){n.addFieldOffset(2,a,0)}static createDimsVector(n,a){n.startVector(8,a.length,8);for(let d=a.length-1;d>=0;d--)n.addInt64(a[d]);return n.endVector()}static startDimsVector(n,a){n.startVector(8,a,8)}static addDataType(n,a){n.addFieldInt32(3,a,0)}static addRawData(n,a){n.addFieldOffset(4,a,0)}static createRawDataVector(n,a){n.startVector(1,a.length,1);for(let d=a.length-1;d>=0;d--)n.addInt8(a[d]);return n.endVector()}static startRawDataVector(n,a){n.startVector(1,a,1)}static addStringData(n,a){n.addFieldOffset(5,a,0)}static createStringDataVector(n,a){n.startVector(4,a.length,4);for(let d=a.length-1;d>=0;d--)n.addOffset(a[d]);return n.endVector()}static startStringDataVector(n,a){n.startVector(4,a,4)}static endTensor(n){return n.endObject()}static createTensor(n,a,d,c,e,l,s){return i.startTensor(n),i.addName(n,a),i.addDocString(n,d),i.addDims(n,c),i.addDataType(n,e),i.addRawData(n,l),i.addStringData(n,s),i.endTensor(n)}}o.Tensor=i})(r.fbs||(r.fbs={}))})(t.experimental||(t.experimental={}))})(F||(F={})),(t=>{(r=>{(o=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(n,a){return this.bb_pos=n,this.bb=a,this}static getRootAsSparseTensor(n,a){return(a||new i).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsSparseTensor(n,a){return n.setPosition(n.position()+w.SIZE_PREFIX_LENGTH),(a||new i).__init(n.readInt32(n.position())+n.position(),n)}values(n){let a=this.bb.__offset(this.bb_pos,4);return a?(n||new t.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+a),this.bb):null}indices(n){let a=this.bb.__offset(this.bb_pos,6);return a?(n||new t.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+a),this.bb):null}dims(n){let a=this.bb.__offset(this.bb_pos,8);return a?this.bb.readInt64(this.bb.__vector(this.bb_pos+a)+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,a){n.addFieldOffset(0,a,0)}static addIndices(n,a){n.addFieldOffset(1,a,0)}static addDims(n,a){n.addFieldOffset(2,a,0)}static createDimsVector(n,a){n.startVector(8,a.length,8);for(let d=a.length-1;d>=0;d--)n.addInt64(a[d]);return n.endVector()}static startDimsVector(n,a){n.startVector(8,a,8)}static endSparseTensor(n){return n.endObject()}static createSparseTensor(n,a,d,c){return i.startSparseTensor(n),i.addValues(n,a),i.addIndices(n,d),i.addDims(n,c),i.endSparseTensor(n)}}o.SparseTensor=i})(r.fbs||(r.fbs={}))})(t.experimental||(t.experimental={}))})(F||(F={})),(t=>{(r=>{(o=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(n,a){return this.bb_pos=n,this.bb=a,this}static getRootAsAttribute(n,a){return(a||new i).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsAttribute(n,a){return n.setPosition(n.position()+w.SIZE_PREFIX_LENGTH),(a||new i).__init(n.readInt32(n.position())+n.position(),n)}name(n){let a=this.bb.__offset(this.bb_pos,4);return a?this.bb.__string(this.bb_pos+a,n):null}docString(n){let a=this.bb.__offset(this.bb_pos,6);return a?this.bb.__string(this.bb_pos+a,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 a=this.bb.__offset(this.bb_pos,14);return a?this.bb.__string(this.bb_pos+a,n):null}t(n){let a=this.bb.__offset(this.bb_pos,16);return a?(n||new t.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+a),this.bb):null}g(n){let a=this.bb.__offset(this.bb_pos,18);return a?(n||new t.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb_pos+a),this.bb):null}floats(n){let a=this.bb.__offset(this.bb_pos,20);return a?this.bb.readFloat32(this.bb.__vector(this.bb_pos+a)+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 a=this.bb.__offset(this.bb_pos,22);return a?this.bb.readInt64(this.bb.__vector(this.bb_pos+a)+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,a){let d=this.bb.__offset(this.bb_pos,24);return d?this.bb.__string(this.bb.__vector(this.bb_pos+d)+n*4,a):null}stringsLength(){let n=this.bb.__offset(this.bb_pos,24);return n?this.bb.__vector_len(this.bb_pos+n):0}tensors(n,a){let d=this.bb.__offset(this.bb_pos,26);return d?(a||new t.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+d)+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,a){let d=this.bb.__offset(this.bb_pos,28);return d?(a||new t.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+d)+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,a){n.addFieldOffset(0,a,0)}static addDocString(n,a){n.addFieldOffset(1,a,0)}static addType(n,a){n.addFieldInt32(2,a,0)}static addF(n,a){n.addFieldFloat32(3,a,0)}static addI(n,a){n.addFieldInt64(4,a,n.createLong(0,0))}static addS(n,a){n.addFieldOffset(5,a,0)}static addT(n,a){n.addFieldOffset(6,a,0)}static addG(n,a){n.addFieldOffset(7,a,0)}static addFloats(n,a){n.addFieldOffset(8,a,0)}static createFloatsVector(n,a){n.startVector(4,a.length,4);for(let d=a.length-1;d>=0;d--)n.addFloat32(a[d]);return n.endVector()}static startFloatsVector(n,a){n.startVector(4,a,4)}static addInts(n,a){n.addFieldOffset(9,a,0)}static createIntsVector(n,a){n.startVector(8,a.length,8);for(let d=a.length-1;d>=0;d--)n.addInt64(a[d]);return n.endVector()}static startIntsVector(n,a){n.startVector(8,a,8)}static addStrings(n,a){n.addFieldOffset(10,a,0)}static createStringsVector(n,a){n.startVector(4,a.length,4);for(let d=a.length-1;d>=0;d--)n.addOffset(a[d]);return n.endVector()}static startStringsVector(n,a){n.startVector(4,a,4)}static addTensors(n,a){n.addFieldOffset(11,a,0)}static createTensorsVector(n,a){n.startVector(4,a.length,4);for(let d=a.length-1;d>=0;d--)n.addOffset(a[d]);return n.endVector()}static startTensorsVector(n,a){n.startVector(4,a,4)}static addGraphs(n,a){n.addFieldOffset(12,a,0)}static createGraphsVector(n,a){n.startVector(4,a.length,4);for(let d=a.length-1;d>=0;d--)n.addOffset(a[d]);return n.endVector()}static startGraphsVector(n,a){n.startVector(4,a,4)}static endAttribute(n){return n.endObject()}static createAttribute(n,a,d,c,e,l,s,h,f,m,v,_,I,T){return i.startAttribute(n),i.addName(n,a),i.addDocString(n,d),i.addType(n,c),i.addF(n,e),i.addI(n,l),i.addS(n,s),i.addT(n,h),i.addG(n,f),i.addFloats(n,m),i.addInts(n,v),i.addStrings(n,_),i.addTensors(n,I),i.addGraphs(n,T),i.endAttribute(n)}}o.Attribute=i})(r.fbs||(r.fbs={}))})(t.experimental||(t.experimental={}))})(F||(F={})),(t=>{(r=>{(o=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(n,a){return this.bb_pos=n,this.bb=a,this}static getRootAsGraph(n,a){return(a||new i).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsGraph(n,a){return n.setPosition(n.position()+w.SIZE_PREFIX_LENGTH),(a||new i).__init(n.readInt32(n.position())+n.position(),n)}initializers(n,a){let d=this.bb.__offset(this.bb_pos,4);return d?(a||new t.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+d)+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,a){let d=this.bb.__offset(this.bb_pos,6);return d?(a||new t.experimental.fbs.ValueInfo).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+d)+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,a){let d=this.bb.__offset(this.bb_pos,8);return d?(a||new t.experimental.fbs.Node).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+d)+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,a){let d=this.bb.__offset(this.bb_pos,12);return d?(a||new t.experimental.fbs.NodeEdge).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+d)+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,a){let d=this.bb.__offset(this.bb_pos,14);return d?this.bb.__string(this.bb.__vector(this.bb_pos+d)+n*4,a):null}inputsLength(){let n=this.bb.__offset(this.bb_pos,14);return n?this.bb.__vector_len(this.bb_pos+n):0}outputs(n,a){let d=this.bb.__offset(this.bb_pos,16);return d?this.bb.__string(this.bb.__vector(this.bb_pos+d)+n*4,a):null}outputsLength(){let n=this.bb.__offset(this.bb_pos,16);return n?this.bb.__vector_len(this.bb_pos+n):0}sparseInitializers(n,a){let d=this.bb.__offset(this.bb_pos,18);return d?(a||new t.experimental.fbs.SparseTensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+d)+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,a){n.addFieldOffset(0,a,0)}static createInitializersVector(n,a){n.startVector(4,a.length,4);for(let d=a.length-1;d>=0;d--)n.addOffset(a[d]);return n.endVector()}static startInitializersVector(n,a){n.startVector(4,a,4)}static addNodeArgs(n,a){n.addFieldOffset(1,a,0)}static createNodeArgsVector(n,a){n.startVector(4,a.length,4);for(let d=a.length-1;d>=0;d--)n.addOffset(a[d]);return n.endVector()}static startNodeArgsVector(n,a){n.startVector(4,a,4)}static addNodes(n,a){n.addFieldOffset(2,a,0)}static createNodesVector(n,a){n.startVector(4,a.length,4);for(let d=a.length-1;d>=0;d--)n.addOffset(a[d]);return n.endVector()}static startNodesVector(n,a){n.startVector(4,a,4)}static addMaxNodeIndex(n,a){n.addFieldInt32(3,a,0)}static addNodeEdges(n,a){n.addFieldOffset(4,a,0)}static createNodeEdgesVector(n,a){n.startVector(4,a.length,4);for(let d=a.length-1;d>=0;d--)n.addOffset(a[d]);return n.endVector()}static startNodeEdgesVector(n,a){n.startVector(4,a,4)}static addInputs(n,a){n.addFieldOffset(5,a,0)}static createInputsVector(n,a){n.startVector(4,a.length,4);for(let d=a.length-1;d>=0;d--)n.addOffset(a[d]);return n.endVector()}static startInputsVector(n,a){n.startVector(4,a,4)}static addOutputs(n,a){n.addFieldOffset(6,a,0)}static createOutputsVector(n,a){n.startVector(4,a.length,4);for(let d=a.length-1;d>=0;d--)n.addOffset(a[d]);return n.endVector()}static startOutputsVector(n,a){n.startVector(4,a,4)}static addSparseInitializers(n,a){n.addFieldOffset(7,a,0)}static createSparseInitializersVector(n,a){n.startVector(4,a.length,4);for(let d=a.length-1;d>=0;d--)n.addOffset(a[d]);return n.endVector()}static startSparseInitializersVector(n,a){n.startVector(4,a,4)}static endGraph(n){return n.endObject()}static createGraph(n,a,d,c,e,l,s,h,f){return i.startGraph(n),i.addInitializers(n,a),i.addNodeArgs(n,d),i.addNodes(n,c),i.addMaxNodeIndex(n,e),i.addNodeEdges(n,l),i.addInputs(n,s),i.addOutputs(n,h),i.addSparseInitializers(n,f),i.endGraph(n)}}o.Graph=i})(r.fbs||(r.fbs={}))})(t.experimental||(t.experimental={}))})(F||(F={})),(t=>{(r=>{(o=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(n,a){return this.bb_pos=n,this.bb=a,this}static getRootAsModel(n,a){return(a||new i).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsModel(n,a){return n.setPosition(n.position()+w.SIZE_PREFIX_LENGTH),(a||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,a){let d=this.bb.__offset(this.bb_pos,6);return d?(a||new t.experimental.fbs.OperatorSetId).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+d)+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 a=this.bb.__offset(this.bb_pos,8);return a?this.bb.__string(this.bb_pos+a,n):null}producerVersion(n){let a=this.bb.__offset(this.bb_pos,10);return a?this.bb.__string(this.bb_pos+a,n):null}domain(n){let a=this.bb.__offset(this.bb_pos,12);return a?this.bb.__string(this.bb_pos+a,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 a=this.bb.__offset(this.bb_pos,16);return a?this.bb.__string(this.bb_pos+a,n):null}graph(n){let a=this.bb.__offset(this.bb_pos,18);return a?(n||new t.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb_pos+a),this.bb):null}graphDocString(n){let a=this.bb.__offset(this.bb_pos,20);return a?this.bb.__string(this.bb_pos+a,n):null}static startModel(n){n.startObject(9)}static addIrVersion(n,a){n.addFieldInt64(0,a,n.createLong(0,0))}static addOpsetImport(n,a){n.addFieldOffset(1,a,0)}static createOpsetImportVector(n,a){n.startVector(4,a.length,4);for(let d=a.length-1;d>=0;d--)n.addOffset(a[d]);return n.endVector()}static startOpsetImportVector(n,a){n.startVector(4,a,4)}static addProducerName(n,a){n.addFieldOffset(2,a,0)}static addProducerVersion(n,a){n.addFieldOffset(3,a,0)}static addDomain(n,a){n.addFieldOffset(4,a,0)}static addModelVersion(n,a){n.addFieldInt64(5,a,n.createLong(0,0))}static addDocString(n,a){n.addFieldOffset(6,a,0)}static addGraph(n,a){n.addFieldOffset(7,a,0)}static addGraphDocString(n,a){n.addFieldOffset(8,a,0)}static endModel(n){return n.endObject()}static createModel(n,a,d,c,e,l,s,h,f,m){return i.startModel(n),i.addIrVersion(n,a),i.addOpsetImport(n,d),i.addProducerName(n,c),i.addProducerVersion(n,e),i.addDomain(n,l),i.addModelVersion(n,s),i.addDocString(n,h),i.addGraph(n,f),i.addGraphDocString(n,m),i.endModel(n)}}o.Model=i})(r.fbs||(r.fbs={}))})(t.experimental||(t.experimental={}))})(F||(F={})),(t=>{(r=>{(o=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(n,a){return this.bb_pos=n,this.bb=a,this}static getRootAsKernelCreateInfos(n,a){return(a||new i).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsKernelCreateInfos(n,a){return n.setPosition(n.position()+w.SIZE_PREFIX_LENGTH),(a||new i).__init(n.readInt32(n.position())+n.position(),n)}nodeIndices(n){let a=this.bb.__offset(this.bb_pos,4);return a?this.bb.readUint32(this.bb.__vector(this.bb_pos+a)+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 a=this.bb.__offset(this.bb_pos,6);return a?this.bb.readUint64(this.bb.__vector(this.bb_pos+a)+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,a){n.addFieldOffset(0,a,0)}static createNodeIndicesVector(n,a){n.startVector(4,a.length,4);for(let d=a.length-1;d>=0;d--)n.addInt32(a[d]);return n.endVector()}static startNodeIndicesVector(n,a){n.startVector(4,a,4)}static addKernelDefHashes(n,a){n.addFieldOffset(1,a,0)}static createKernelDefHashesVector(n,a){n.startVector(8,a.length,8);for(let d=a.length-1;d>=0;d--)n.addInt64(a[d]);return n.endVector()}static startKernelDefHashesVector(n,a){n.startVector(8,a,8)}static endKernelCreateInfos(n){return n.endObject()}static createKernelCreateInfos(n,a,d){return i.startKernelCreateInfos(n),i.addNodeIndices(n,a),i.addKernelDefHashes(n,d),i.endKernelCreateInfos(n)}}o.KernelCreateInfos=i})(r.fbs||(r.fbs={}))})(t.experimental||(t.experimental={}))})(F||(F={})),(t=>{(r=>{(o=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(n,a){return this.bb_pos=n,this.bb=a,this}static getRootAsSubGraphSessionState(n,a){return(a||new i).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsSubGraphSessionState(n,a){return n.setPosition(n.position()+w.SIZE_PREFIX_LENGTH),(a||new i).__init(n.readInt32(n.position())+n.position(),n)}graphId(n){let a=this.bb.__offset(this.bb_pos,4);return a?this.bb.__string(this.bb_pos+a,n):null}sessionState(n){let a=this.bb.__offset(this.bb_pos,6);return a?(n||new t.experimental.fbs.SessionState).__init(this.bb.__indirect(this.bb_pos+a),this.bb):null}static startSubGraphSessionState(n){n.startObject(2)}static addGraphId(n,a){n.addFieldOffset(0,a,0)}static addSessionState(n,a){n.addFieldOffset(1,a,0)}static endSubGraphSessionState(n){let a=n.endObject();return n.requiredField(a,4),a}static createSubGraphSessionState(n,a,d){return i.startSubGraphSessionState(n),i.addGraphId(n,a),i.addSessionState(n,d),i.endSubGraphSessionState(n)}}o.SubGraphSessionState=i})(r.fbs||(r.fbs={}))})(t.experimental||(t.experimental={}))})(F||(F={})),(t=>{(r=>{(o=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(n,a){return this.bb_pos=n,this.bb=a,this}static getRootAsSessionState(n,a){return(a||new i).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsSessionState(n,a){return n.setPosition(n.position()+w.SIZE_PREFIX_LENGTH),(a||new i).__init(n.readInt32(n.position())+n.position(),n)}kernels(n){let a=this.bb.__offset(this.bb_pos,4);return a?(n||new t.experimental.fbs.KernelCreateInfos).__init(this.bb.__indirect(this.bb_pos+a),this.bb):null}subGraphSessionStates(n,a){let d=this.bb.__offset(this.bb_pos,6);return d?(a||new t.experimental.fbs.SubGraphSessionState).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+d)+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,a){n.addFieldOffset(0,a,0)}static addSubGraphSessionStates(n,a){n.addFieldOffset(1,a,0)}static createSubGraphSessionStatesVector(n,a){n.startVector(4,a.length,4);for(let d=a.length-1;d>=0;d--)n.addOffset(a[d]);return n.endVector()}static startSubGraphSessionStatesVector(n,a){n.startVector(4,a,4)}static endSessionState(n){return n.endObject()}static createSessionState(n,a,d){return i.startSessionState(n),i.addKernels(n,a),i.addSubGraphSessionStates(n,d),i.endSessionState(n)}}o.SessionState=i})(r.fbs||(r.fbs={}))})(t.experimental||(t.experimental={}))})(F||(F={})),(t=>{(r=>{(o=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(n,a){return this.bb_pos=n,this.bb=a,this}static getRootAsInferenceSession(n,a){return(a||new i).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsInferenceSession(n,a){return n.setPosition(n.position()+w.SIZE_PREFIX_LENGTH),(a||new i).__init(n.readInt32(n.position())+n.position(),n)}static bufferHasIdentifier(n){return n.__has_identifier("ORTM")}ortVersion(n){let a=this.bb.__offset(this.bb_pos,4);return a?this.bb.__string(this.bb_pos+a,n):null}model(n){let a=this.bb.__offset(this.bb_pos,6);return a?(n||new t.experimental.fbs.Model).__init(this.bb.__indirect(this.bb_pos+a),this.bb):null}sessionState(n){let a=this.bb.__offset(this.bb_pos,8);return a?(n||new t.experimental.fbs.SessionState).__init(this.bb.__indirect(this.bb_pos+a),this.bb):null}static startInferenceSession(n){n.startObject(3)}static addOrtVersion(n,a){n.addFieldOffset(0,a,0)}static addModel(n,a){n.addFieldOffset(1,a,0)}static addSessionState(n,a){n.addFieldOffset(2,a,0)}static endInferenceSession(n){return n.endObject()}static finishInferenceSessionBuffer(n,a){n.finish(a,"ORTM")}static finishSizePrefixedInferenceSessionBuffer(n,a){n.finish(a,"ORTM",!0)}static createInferenceSession(n,a,d,c){return i.startInferenceSession(n),i.addOrtVersion(n,a),i.addModel(n,d),i.addSessionState(n,c),i.endInferenceSession(n)}}o.InferenceSession=i})(r.fbs||(r.fbs={}))})(t.experimental||(t.experimental={}))})(F||(F={}))}),js=mt((t,r)=>{r.exports=o;function o(i,u){for(var n=new Array(arguments.length-1),a=0,d=2,c=!0;d<arguments.length;)n[a++]=arguments[d++];return new Promise(function(e,l){n[a]=function(s){if(c)if(c=!1,s)l(s);else{for(var h=new Array(arguments.length-1),f=0;f<h.length;)h[f++]=arguments[f];e.apply(null,h)}};try{i.apply(u||null,n)}catch(s){c&&(c=!1,l(s))}})}}),Ys=mt(t=>{var r=t;r.length=function(a){var d=a.length;if(!d)return 0;for(var c=0;--d%4>1&&a.charAt(d)==="=";)++c;return Math.ceil(a.length*3)/4-c};var o=new Array(64),i=new Array(123);for(u=0;u<64;)i[o[u]=u<26?u+65:u<52?u+71:u<62?u-4:u-59|43]=u++;var u;r.encode=function(a,d,c){for(var e=null,l=[],s=0,h=0,f;d<c;){var m=a[d++];switch(h){case 0:l[s++]=o[m>>2],f=(m&3)<<4,h=1;break;case 1:l[s++]=o[f|m>>4],f=(m&15)<<2,h=2;break;case 2:l[s++]=o[f|m>>6],l[s++]=o[m&63],h=0;break}s>8191&&((e||(e=[])).push(String.fromCharCode.apply(String,l)),s=0)}return h&&(l[s++]=o[f],l[s++]=61,h===1&&(l[s++]=61)),e?(s&&e.push(String.fromCharCode.apply(String,l.slice(0,s))),e.join("")):String.fromCharCode.apply(String,l.slice(0,s))};var n="invalid encoding";r.decode=function(a,d,c){for(var e=c,l=0,s,h=0;h<a.length;){var f=a.charCodeAt(h++);if(f===61&&l>1)break;if((f=i[f])===void 0)throw Error(n);switch(l){case 0:s=f,l=1;break;case 1:d[c++]=s<<2|(f&48)>>4,s=f,l=2;break;case 2:d[c++]=(s&15)<<4|(f&60)>>2,s=f,l=3;break;case 3:d[c++]=(s&3)<<6|f,l=0;break}}if(l===1)throw Error(n);return c-e},r.test=function(a){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(a)}}),Qs=mt((t,r)=>{r.exports=o;function o(){this._listeners={}}o.prototype.on=function(i,u,n){return(this._listeners[i]||(this._listeners[i]=[])).push({fn:u,ctx:n||this}),this},o.prototype.off=function(i,u){if(i===void 0)this._listeners={};else if(u===void 0)this._listeners[i]=[];else for(var n=this._listeners[i],a=0;a<n.length;)n[a].fn===u?n.splice(a,1):++a;return this},o.prototype.emit=function(i){var u=this._listeners[i];if(u){for(var n=[],a=1;a<arguments.length;)n.push(arguments[a++]);for(a=0;a<u.length;)u[a].fn.apply(u[a++].ctx,n)}return this}}),au=mt((t,r)=>{r.exports=o(o);function o(d){return typeof Float32Array<"u"?function(){var c=new Float32Array([-0]),e=new Uint8Array(c.buffer),l=e[3]===128;function s(v,_,I){c[0]=v,_[I]=e[0],_[I+1]=e[1],_[I+2]=e[2],_[I+3]=e[3]}function h(v,_,I){c[0]=v,_[I]=e[3],_[I+1]=e[2],_[I+2]=e[1],_[I+3]=e[0]}d.writeFloatLE=l?s:h,d.writeFloatBE=l?h:s;function f(v,_){return e[0]=v[_],e[1]=v[_+1],e[2]=v[_+2],e[3]=v[_+3],c[0]}function m(v,_){return e[3]=v[_],e[2]=v[_+1],e[1]=v[_+2],e[0]=v[_+3],c[0]}d.readFloatLE=l?f:m,d.readFloatBE=l?m:f}():function(){function c(l,s,h,f){var m=s<0?1:0;if(m&&(s=-s),s===0)l(1/s>0?0:2147483648,h,f);else if(isNaN(s))l(2143289344,h,f);else if(s>34028234663852886e22)l((m<<31|2139095040)>>>0,h,f);else if(s<11754943508222875e-54)l((m<<31|Math.round(s/1401298464324817e-60))>>>0,h,f);else{var v=Math.floor(Math.log(s)/Math.LN2),_=Math.round(s*Math.pow(2,-v)*8388608)&8388607;l((m<<31|v+127<<23|_)>>>0,h,f)}}d.writeFloatLE=c.bind(null,i),d.writeFloatBE=c.bind(null,u);function e(l,s,h){var f=l(s,h),m=(f>>31)*2+1,v=f>>>23&255,_=f&8388607;return v===255?_?NaN:m*(1/0):v===0?m*1401298464324817e-60*_:m*Math.pow(2,v-150)*(_+8388608)}d.readFloatLE=e.bind(null,n),d.readFloatBE=e.bind(null,a)}(),typeof Float64Array<"u"?function(){var c=new Float64Array([-0]),e=new Uint8Array(c.buffer),l=e[7]===128;function s(v,_,I){c[0]=v,_[I]=e[0],_[I+1]=e[1],_[I+2]=e[2],_[I+3]=e[3],_[I+4]=e[4],_[I+5]=e[5],_[I+6]=e[6],_[I+7]=e[7]}function h(v,_,I){c[0]=v,_[I]=e[7],_[I+1]=e[6],_[I+2]=e[5],_[I+3]=e[4],_[I+4]=e[3],_[I+5]=e[2],_[I+6]=e[1],_[I+7]=e[0]}d.writeDoubleLE=l?s:h,d.writeDoubleBE=l?h:s;function f(v,_){return e[0]=v[_],e[1]=v[_+1],e[2]=v[_+2],e[3]=v[_+3],e[4]=v[_+4],e[5]=v[_+5],e[6]=v[_+6],e[7]=v[_+7],c[0]}function m(v,_){return e[7]=v[_],e[6]=v[_+1],e[5]=v[_+2],e[4]=v[_+3],e[3]=v[_+4],e[2]=v[_+5],e[1]=v[_+6],e[0]=v[_+7],c[0]}d.readDoubleLE=l?f:m,d.readDoubleBE=l?m:f}():function(){function c(l,s,h,f,m,v){var _=f<0?1:0;if(_&&(f=-f),f===0)l(0,m,v+s),l(1/f>0?0:2147483648,m,v+h);else if(isNaN(f))l(0,m,v+s),l(2146959360,m,v+h);else if(f>17976931348623157e292)l(0,m,v+s),l((_<<31|2146435072)>>>0,m,v+h);else{var I;if(f<22250738585072014e-324)I=f/5e-324,l(I>>>0,m,v+s),l((_<<31|I/4294967296)>>>0,m,v+h);else{var T=Math.floor(Math.log(f)/Math.LN2);T===1024&&(T=1023),I=f*Math.pow(2,-T),l(I*4503599627370496>>>0,m,v+s),l((_<<31|T+1023<<20|I*1048576&1048575)>>>0,m,v+h)}}}d.writeDoubleLE=c.bind(null,i,0,4),d.writeDoubleBE=c.bind(null,u,4,0);function e(l,s,h,f,m){var v=l(f,m+s),_=l(f,m+h),I=(_>>31)*2+1,T=_>>>20&2047,P=4294967296*(_&1048575)+v;return T===2047?P?NaN:I*(1/0):T===0?I*5e-324*P:I*Math.pow(2,T-1075)*(P+4503599627370496)}d.readDoubleLE=e.bind(null,n,0,4),d.readDoubleBE=e.bind(null,a,4,0)}(),d}function i(d,c,e){c[e]=d&255,c[e+1]=d>>>8&255,c[e+2]=d>>>16&255,c[e+3]=d>>>24}function u(d,c,e){c[e]=d>>>24,c[e+1]=d>>>16&255,c[e+2]=d>>>8&255,c[e+3]=d&255}function n(d,c){return(d[c]|d[c+1]<<8|d[c+2]<<16|d[c+3]<<24)>>>0}function a(d,c){return(d[c]<<24|d[c+1]<<16|d[c+2]<<8|d[c+3])>>>0}}),su=mt((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(t){}return null}}),lu=mt(t=>{var r=t;r.length=function(o){for(var i=0,u=0,n=0;n<o.length;++n)u=o.charCodeAt(n),u<128?i+=1:u<2048?i+=2:(u&64512)===55296&&(o.charCodeAt(n+1)&64512)===56320?(++n,i+=4):i+=3;return i},r.read=function(o,i,u){var n=u-i;if(n<1)return"";for(var a=null,d=[],c=0,e;i<u;)e=o[i++],e<128?d[c++]=e:e>191&&e<224?d[c++]=(e&31)<<6|o[i++]&63:e>239&&e<365?(e=((e&7)<<18|(o[i++]&63)<<12|(o[i++]&63)<<6|o[i++]&63)-65536,d[c++]=55296+(e>>10),d[c++]=56320+(e&1023)):d[c++]=(e&15)<<12|(o[i++]&63)<<6|o[i++]&63,c>8191&&((a||(a=[])).push(String.fromCharCode.apply(String,d)),c=0);return a?(c&&a.push(String.fromCharCode.apply(String,d.slice(0,c))),a.join("")):String.fromCharCode.apply(String,d.slice(0,c))},r.write=function(o,i,u){for(var n=u,a,d,c=0;c<o.length;++c)a=o.charCodeAt(c),a<128?i[u++]=a:a<2048?(i[u++]=a>>6|192,i[u++]=a&63|128):(a&64512)===55296&&((d=o.charCodeAt(c+1))&64512)===56320?(a=65536+((a&1023)<<10)+(d&1023),++c,i[u++]=a>>18|240,i[u++]=a>>12&63|128,i[u++]=a>>6&63|128,i[u++]=a&63|128):(i[u++]=a>>12|224,i[u++]=a>>6&63|128,i[u++]=a&63|128);return u-n}}),cu=mt((t,r)=>{r.exports=o;function o(i,u,n){var a=n||8192,d=a>>>1,c=null,e=a;return function(l){if(l<1||l>d)return i(l);e+l>a&&(c=i(a),e=0);var s=u.call(c,e,e+=l);return e&7&&(e=(e|7)+1),s}}}),du=mt((t,r)=>{r.exports=i;var o=Se();function i(d,c){this.lo=d>>>0,this.hi=c>>>0}var u=i.zero=new i(0,0);u.toNumber=function(){return 0},u.zzEncode=u.zzDecode=function(){return this},u.length=function(){return 1};var n=i.zeroHash="\0\0\0\0\0\0\0\0";i.fromNumber=function(d){if(d===0)return u;var c=d<0;c&&(d=-d);var e=d>>>0,l=(d-e)/4294967296>>>0;return c&&(l=~l>>>0,e=~e>>>0,++e>4294967295&&(e=0,++l>4294967295&&(l=0))),new i(e,l)},i.from=function(d){if(typeof d=="number")return i.fromNumber(d);if(o.isString(d))if(o.Long)d=o.Long.fromString(d);else return i.fromNumber(parseInt(d,10));return d.low||d.high?new i(d.low>>>0,d.high>>>0):u},i.prototype.toNumber=function(d){if(!d&&this.hi>>>31){var c=~this.lo+1>>>0,e=~this.hi>>>0;return c||(e=e+1>>>0),-(c+e*4294967296)}return this.lo+this.hi*4294967296},i.prototype.toLong=function(d){return o.Long?new o.Long(this.lo|0,this.hi|0,!!d):{low:this.lo|0,high:this.hi|0,unsigned:!!d}};var a=String.prototype.charCodeAt;i.fromHash=function(d){return d===n?u:new i((a.call(d,0)|a.call(d,1)<<8|a.call(d,2)<<16|a.call(d,3)<<24)>>>0,(a.call(d,4)|a.call(d,5)<<8|a.call(d,6)<<16|a.call(d,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 d=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^d)>>>0,this.lo=(this.lo<<1^d)>>>0,this},i.prototype.zzDecode=function(){var d=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^d)>>>0,this.hi=(this.hi>>>1^d)>>>0,this},i.prototype.length=function(){var d=this.lo,c=(this.lo>>>28|this.hi<<4)>>>0,e=this.hi>>>24;return e===0?c===0?d<16384?d<128?1:2:d<2097152?3:4:c<16384?c<128?5:6:c<2097152?7:8:e<128?9:10}}),Se=mt(t=>{var r=t;r.asPromise=js(),r.base64=Ys(),r.EventEmitter=Qs(),r.float=au(),r.inquire=su(),r.utf8=lu(),r.pool=cu(),r.LongBits=du(),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||t,r.emptyArray=Object.freeze?Object.freeze([]):[],r.emptyObject=Object.freeze?Object.freeze({}):{},r.isInteger=Number.isInteger||function(u){return typeof u=="number"&&isFinite(u)&&Math.floor(u)===u},r.isString=function(u){return typeof u=="string"||u instanceof String},r.isObject=function(u){return u&&typeof u=="object"},r.isset=r.isSet=function(u,n){var a=u[n];return a!=null&&u.hasOwnProperty(n)?typeof a!="object"||(Array.isArray(a)?a.length:Object.keys(a).length)>0:!1},r.Buffer=function(){try{var u=r.inquire("buffer").Buffer;return u.prototype.utf8Write?u:null}catch{return null}}(),r._Buffer_from=null,r._Buffer_allocUnsafe=null,r.newBuffer=function(u){return typeof u=="number"?r.Buffer?r._Buffer_allocUnsafe(u):new r.Array(u):r.Buffer?r._Buffer_from(u):typeof Uint8Array>"u"?u:new Uint8Array(u)},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(u){return u?r.LongBits.from(u).toHash():r.LongBits.zeroHash},r.longFromHash=function(u,n){var a=r.LongBits.fromHash(u);return r.Long?r.Long.fromBits(a.lo,a.hi,n):a.toNumber(!!n)};function o(u,n,a){for(var d=Object.keys(n),c=0;c<d.length;++c)(u[d[c]]===void 0||!a)&&(u[d[c]]=n[d[c]]);return u}r.merge=o,r.lcFirst=function(u){return u.charAt(0).toLowerCase()+u.substring(1)};function i(u){function n(a,d){if(!(this instanceof n))return new n(a,d);Object.defineProperty(this,"message",{get:function(){return a}}),Error.captureStackTrace?Error.captureStackTrace(this,n):Object.defineProperty(this,"stack",{value:new Error().stack||""}),d&&o(this,d)}return n.prototype=Object.create(Error.prototype,{constructor:{value:n,writable:!0,enumerable:!1,configurable:!0},name:{get:function(){return u},set:void 0,enumerable:!1,configurable:!0},toString:{value:function(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),n}r.newError=i,r.ProtocolError=i("ProtocolError"),r.oneOfGetter=function(u){for(var n={},a=0;a<u.length;++a)n[u[a]]=1;return function(){for(var d=Object.keys(this),c=d.length-1;c>-1;--c)if(n[d[c]]===1&&this[d[c]]!==void 0&&this[d[c]]!==null)return d[c]}},r.oneOfSetter=function(u){return function(n){for(var a=0;a<u.length;++a)u[a]!==n&&delete this[u[a]]}},r.toJSONOptions={longs:String,enums:String,bytes:String,json:!0},r._configure=function(){var u=r.Buffer;if(!u){r._Buffer_from=r._Buffer_allocUnsafe=null;return}r._Buffer_from=u.from!==Uint8Array.from&&u.from||function(n,a){return new u(n,a)},r._Buffer_allocUnsafe=u.allocUnsafe||function(n){return new u(n)}}}),ei=mt((t,r)=>{r.exports=l;var o=Se(),i,u=o.LongBits,n=o.base64,a=o.utf8;function d(T,P,C){this.fn=T,this.len=P,this.next=void 0,this.val=C}function c(){}function e(T){this.head=T.head,this.tail=T.tail,this.len=T.len,this.next=T.states}function l(){this.len=0,this.head=new d(c,0,0),this.tail=this.head,this.states=null}var s=function(){return o.Buffer?function(){return(l.create=function(){return new i})()}:function(){return new l}};l.create=s(),l.alloc=function(T){return new o.Array(T)},o.Array!==Array&&(l.alloc=o.pool(l.alloc,o.Array.prototype.subarray)),l.prototype._push=function(T,P,C){return this.tail=this.tail.next=new d(T,P,C),this.len+=P,this};function h(T,P,C){P[C]=T&255}function f(T,P,C){for(;T>127;)P[C++]=T&127|128,T>>>=7;P[C]=T}function m(T,P){this.len=T,this.next=void 0,this.val=P}m.prototype=Object.create(d.prototype),m.prototype.fn=f,l.prototype.uint32=function(T){return this.len+=(this.tail=this.tail.next=new m((T=T>>>0)<128?1:T<16384?2:T<2097152?3:T<268435456?4:5,T)).len,this},l.prototype.int32=function(T){return T<0?this._push(v,10,u.fromNumber(T)):this.uint32(T)},l.prototype.sint32=function(T){return this.uint32((T<<1^T>>31)>>>0)};function v(T,P,C){for(;T.hi;)P[C++]=T.lo&127|128,T.lo=(T.lo>>>7|T.hi<<25)>>>0,T.hi>>>=7;for(;T.lo>127;)P[C++]=T.lo&127|128,T.lo=T.lo>>>7;P[C++]=T.lo}l.prototype.uint64=function(T){var P=u.from(T);return this._push(v,P.length(),P)},l.prototype.int64=l.prototype.uint64,l.prototype.sint64=function(T){var P=u.from(T).zzEncode();return this._push(v,P.length(),P)},l.prototype.bool=function(T){return this._push(h,1,T?1:0)};function _(T,P,C){P[C]=T&255,P[C+1]=T>>>8&255,P[C+2]=T>>>16&255,P[C+3]=T>>>24}l.prototype.fixed32=function(T){return this._push(_,4,T>>>0)},l.prototype.sfixed32=l.prototype.fixed32,l.prototype.fixed64=function(T){var P=u.from(T);return this._push(_,4,P.lo)._push(_,4,P.hi)},l.prototype.sfixed64=l.prototype.fixed64,l.prototype.float=function(T){return this._push(o.float.writeFloatLE,4,T)},l.prototype.double=function(T){return this._push(o.float.writeDoubleLE,8,T)};var I=o.Array.prototype.set?function(T,P,C){P.set(T,C)}:function(T,P,C){for(var V=0;V<T.length;++V)P[C+V]=T[V]};l.prototype.bytes=function(T){var P=T.length>>>0;if(!P)return this._push(h,1,0);if(o.isString(T)){var C=l.alloc(P=n.length(T));n.decode(T,C,0),T=C}return this.uint32(P)._push(I,P,T)},l.prototype.string=function(T){var P=a.length(T);return P?this.uint32(P)._push(a.write,P,T):this._push(h,1,0)},l.prototype.fork=function(){return this.states=new e(this),this.head=this.tail=new d(c,0,0),this.len=0,this},l.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 d(c,0,0),this.len=0),this},l.prototype.ldelim=function(){var T=this.head,P=this.tail,C=this.len;return this.reset().uint32(C),C&&(this.tail.next=T.next,this.tail=P,this.len+=C),this},l.prototype.finish=function(){for(var T=this.head.next,P=this.constructor.alloc(this.len),C=0;T;)T.fn(T.val,P,C),C+=T.len,T=T.next;return P},l._configure=function(T){i=T,l.create=s(),i._configure()}}),vu=mt((t,r)=>{r.exports=u;var o=ei();(u.prototype=Object.create(o.prototype)).constructor=u;var i=Se();function u(){o.call(this)}u._configure=function(){u.alloc=i._Buffer_allocUnsafe,u.writeBytesBuffer=i.Buffer&&i.Buffer.prototype instanceof Uint8Array&&i.Buffer.prototype.set.name==="set"?function(a,d,c){d.set(a,c)}:function(a,d,c){if(a.copy)a.copy(d,c,0,a.length);else for(var e=0;e<a.length;)d[c++]=a[e++]}},u.prototype.bytes=function(a){i.isString(a)&&(a=i._Buffer_from(a,"base64"));var d=a.length>>>0;return this.uint32(d),d&&this._push(u.writeBytesBuffer,d,a),this};function n(a,d,c){a.length<40?i.utf8.write(a,d,c):d.utf8Write?d.utf8Write(a,c):d.write(a,c)}u.prototype.string=function(a){var d=i.Buffer.byteLength(a);return this.uint32(d),d&&this._push(n,d,a),this},u._configure()}),oi=mt((t,r)=>{r.exports=d;var o=Se(),i,u=o.LongBits,n=o.utf8;function a(f,m){return RangeError("index out of range: "+f.pos+" + "+(m||1)+" > "+f.len)}function d(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 d(f);throw Error("illegal buffer")}:function(f){if(Array.isArray(f))return new d(f);throw Error("illegal buffer")},e=function(){return o.Buffer?function(f){return(d.create=function(m){return o.Buffer.isBuffer(m)?new i(m):c(m)})(f)}:c};d.create=e(),d.prototype._slice=o.Array.prototype.subarray||o.Array.prototype.slice,d.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,a(this,10);return f}}(),d.prototype.int32=function(){return this.uint32()|0},d.prototype.sint32=function(){var f=this.uint32();return f>>>1^-(f&1)|0};function l(){var f=new u(0,0),m=0;if(this.len-this.pos>4){for(;m<4;++m)if(f.lo=(f.lo|(this.buf[this.pos]&127)<<m*7)>>>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;m=0}else{for(;m<3;++m){if(this.pos>=this.len)throw a(this);if(f.lo=(f.lo|(this.buf[this.pos]&127)<<m*7)>>>0,this.buf[this.pos++]<128)return f}return f.lo=(f.lo|(this.buf[this.pos++]&127)<<m*7)>>>0,f}if(this.len-this.pos>4){for(;m<5;++m)if(f.hi=(f.hi|(this.buf[this.pos]&127)<<m*7+3)>>>0,this.buf[this.pos++]<128)return f}else for(;m<5;++m){if(this.pos>=this.len)throw a(this);if(f.hi=(f.hi|(this.buf[this.pos]&127)<<m*7+3)>>>0,this.buf[this.pos++]<128)return f}throw Error("invalid varint encoding")}d.prototype.bool=function(){return this.uint32()!==0};function s(f,m){return(f[m-4]|f[m-3]<<8|f[m-2]<<16|f[m-1]<<24)>>>0}d.prototype.fixed32=function(){if(this.pos+4>this.len)throw a(this,4);return s(this.buf,this.pos+=4)},d.prototype.sfixed32=function(){if(this.pos+4>this.len)throw a(this,4);return s(this.buf,this.pos+=4)|0};function h(){if(this.pos+8>this.len)throw a(this,8);return new u(s(this.buf,this.pos+=4),s(this.buf,this.pos+=4))}d.prototype.float=function(){if(this.pos+4>this.len)throw a(this,4);var f=o.float.readFloatLE(this.buf,this.pos);return this.pos+=4,f},d.prototype.double=function(){if(this.pos+8>this.len)throw a(this,4);var f=o.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,f},d.prototype.bytes=function(){var f=this.uint32(),m=this.pos,v=this.pos+f;if(v>this.len)throw a(this,f);if(this.pos+=f,Array.isArray(this.buf))return this.buf.slice(m,v);if(m===v){var _=o.Buffer;return _?_.alloc(0):new this.buf.constructor(0)}return this._slice.call(this.buf,m,v)},d.prototype.string=function(){var f=this.bytes();return n.read(f,0,f.length)},d.prototype.skip=function(f){if(typeof f=="number"){if(this.pos+f>this.len)throw a(this,f);this.pos+=f}else do if(this.pos>=this.len)throw a(this);while(this.buf[this.pos++]&128);return this},d.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},d._configure=function(f){i=f,d.create=e(),i._configure();var m=o.Long?"toLong":"toNumber";o.merge(d.prototype,{int64:function(){return l.call(this)[m](!1)},uint64:function(){return l.call(this)[m](!0)},sint64:function(){return l.call(this).zzDecode()[m](!1)},fixed64:function(){return h.call(this)[m](!0)},sfixed64:function(){return h.call(this)[m](!1)}})}}),Lu=mt((t,r)=>{r.exports=u;var o=oi();(u.prototype=Object.create(o.prototype)).constructor=u;var i=Se();function u(n){o.call(this,n)}u._configure=function(){i.Buffer&&(u.prototype._slice=i.Buffer.prototype.slice)},u.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))},u._configure()}),ku=mt((t,r)=>{r.exports=i;var o=Se();(i.prototype=Object.create(o.EventEmitter.prototype)).constructor=i;function i(u,n,a){if(typeof u!="function")throw TypeError("rpcImpl must be a function");o.EventEmitter.call(this),this.rpcImpl=u,this.requestDelimited=!!n,this.responseDelimited=!!a}i.prototype.rpcCall=function u(n,a,d,c,e){if(!c)throw TypeError("request must be specified");var l=this;if(!e)return o.asPromise(u,l,n,a,d,c);if(!l.rpcImpl){setTimeout(function(){e(Error("already ended"))},0);return}try{return l.rpcImpl(n,a[l.requestDelimited?"encodeDelimited":"encode"](c).finish(),function(s,h){if(s)return l.emit("error",s,n),e(s);if(h===null){l.end(!0);return}if(!(h instanceof d))try{h=d[l.responseDelimited?"decodeDelimited":"decode"](h)}catch(f){return l.emit("error",f,n),e(f)}return l.emit("data",h,n),e(null,h)})}catch(s){l.emit("error",s,n),setTimeout(function(){e(s)},0);return}},i.prototype.end=function(u){return this.rpcImpl&&(u||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}}),Fu=mt(t=>{var r=t;r.Service=ku()}),Nu=mt((t,r)=>{r.exports={}}),Mu=mt(t=>{var r=t;r.build="minimal",r.Writer=ei(),r.BufferWriter=vu(),r.Reader=oi(),r.BufferReader=Lu(),r.util=Se(),r.rpc=Fu(),r.roots=Nu(),r.configure=o;function o(){r.util._configure(),r.Writer._configure(r.BufferWriter),r.Reader._configure(r.BufferReader)}o()}),Vu=mt((t,r)=>{r.exports=Mu()}),sr=mt((t,r)=>{var o=Vu(),i=o.Reader,u=o.Writer,n=o.util,a=o.roots.default||(o.roots.default={});a.onnx=function(){var d={};return d.Version=function(){var c={},e=Object.create(c);return e[c[0]="_START_VERSION"]=0,e[c[1]="IR_VERSION_2017_10_10"]=1,e[c[2]="IR_VERSION_2017_10_30"]=2,e[c[3]="IR_VERSION_2017_11_3"]=3,e[c[4]="IR_VERSION_2019_1_22"]=4,e[c[5]="IR_VERSION_2019_3_18"]=5,e[c[6]="IR_VERSION_2019_9_19"]=6,e[c[7]="IR_VERSION_2020_5_8"]=7,e[c[8]="IR_VERSION_2021_7_30"]=8,e[c[9]="IR_VERSION"]=9,e}(),d.AttributeProto=function(){function c(e){if(this.floats=[],this.ints=[],this.strings=[],this.tensors=[],this.graphs=[],this.sparseTensors=[],this.typeProtos=[],e)for(var l=Object.keys(e),s=0;s<l.length;++s)e[l[s]]!=null&&(this[l[s]]=e[l[s]])}return c.prototype.name="",c.prototype.refAttrName="",c.prototype.docString="",c.prototype.type=0,c.prototype.f=0,c.prototype.i=n.Long?n.Long.fromBits(0,0,!1):0,c.prototype.s=n.newBuffer([]),c.prototype.t=null,c.prototype.g=null,c.prototype.sparseTensor=null,c.prototype.tp=null,c.prototype.floats=n.emptyArray,c.prototype.ints=n.emptyArray,c.prototype.strings=n.emptyArray,c.prototype.tensors=n.emptyArray,c.prototype.graphs=n.emptyArray,c.prototype.sparseTensors=n.emptyArray,c.prototype.typeProtos=n.emptyArray,c.create=function(e){return new c(e)},c.encode=function(e,l){if(l||(l=u.create()),e.name!=null&&Object.hasOwnProperty.call(e,"name")&&l.uint32(10).string(e.name),e.f!=null&&Object.hasOwnProperty.call(e,"f")&&l.uint32(21).float(e.f),e.i!=null&&Object.hasOwnProperty.call(e,"i")&&l.uint32(24).int64(e.i),e.s!=null&&Object.hasOwnProperty.call(e,"s")&&l.uint32(34).bytes(e.s),e.t!=null&&Object.hasOwnProperty.call(e,"t")&&a.onnx.TensorProto.encode(e.t,l.uint32(42).fork()).ldelim(),e.g!=null&&Object.hasOwnProperty.call(e,"g")&&a.onnx.GraphProto.encode(e.g,l.uint32(50).fork()).ldelim(),e.floats!=null&&e.floats.length){l.uint32(58).fork();for(var s=0;s<e.floats.length;++s)l.float(e.floats[s]);l.ldelim()}if(e.ints!=null&&e.ints.length){l.uint32(66).fork();for(var s=0;s<e.ints.length;++s)l.int64(e.ints[s]);l.ldelim()}if(e.strings!=null&&e.strings.length)for(var s=0;s<e.strings.length;++s)l.uint32(74).bytes(e.strings[s]);if(e.tensors!=null&&e.tensors.length)for(var s=0;s<e.tensors.length;++s)a.onnx.TensorProto.encode(e.tensors[s],l.uint32(82).fork()).ldelim();if(e.graphs!=null&&e.graphs.length)for(var s=0;s<e.graphs.length;++s)a.onnx.GraphProto.encode(e.graphs[s],l.uint32(90).fork()).ldelim();if(e.docString!=null&&Object.hasOwnProperty.call(e,"docString")&&l.uint32(106).string(e.docString),e.tp!=null&&Object.hasOwnProperty.call(e,"tp")&&a.onnx.TypeProto.encode(e.tp,l.uint32(114).fork()).ldelim(),e.typeProtos!=null&&e.typeProtos.length)for(var s=0;s<e.typeProtos.length;++s)a.onnx.TypeProto.encode(e.typeProtos[s],l.uint32(122).fork()).ldelim();if(e.type!=null&&Object.hasOwnProperty.call(e,"type")&&l.uint32(160).int32(e.type),e.refAttrName!=null&&Object.hasOwnProperty.call(e,"refAttrName")&&l.uint32(170).string(e.refAttrName),e.sparseTensor!=null&&Object.hasOwnProperty.call(e,"sparseTensor")&&a.onnx.SparseTensorProto.encode(e.sparseTensor,l.uint32(178).fork()).ldelim(),e.sparseTensors!=null&&e.sparseTensors.length)for(var s=0;s<e.sparseTensors.length;++s)a.onnx.SparseTensorProto.encode(e.sparseTensors[s],l.uint32(186).fork()).ldelim();return l},c.encodeDelimited=function(e,l){return this.encode(e,l).ldelim()},c.decode=function(e,l){e instanceof i||(e=i.create(e));for(var s=l===void 0?e.len:e.pos+l,h=new a.onnx.AttributeProto;e.pos<s;){var f=e.uint32();switch(f>>>3){case 1:{h.name=e.string();break}case 21:{h.refAttrName=e.string();break}case 13:{h.docString=e.string();break}case 20:{h.type=e.int32();break}case 2:{h.f=e.float();break}case 3:{h.i=e.int64();break}case 4:{h.s=e.bytes();break}case 5:{h.t=a.onnx.TensorProto.decode(e,e.uint32());break}case 6:{h.g=a.onnx.GraphProto.decode(e,e.uint32());break}case 22:{h.sparseTensor=a.onnx.SparseTensorProto.decode(e,e.uint32());break}case 14:{h.tp=a.onnx.TypeProto.decode(e,e.uint32());break}case 7:{if(h.floats&&h.floats.length||(h.floats=[]),(f&7)===2)for(var m=e.uint32()+e.pos;e.pos<m;)h.floats.push(e.float());else h.floats.push(e.float());break}case 8:{if(h.ints&&h.ints.length||(h.ints=[]),(f&7)===2)for(var m=e.uint32()+e.pos;e.pos<m;)h.ints.push(e.int64());else h.ints.push(e.int64());break}case 9:{h.strings&&h.strings.length||(h.strings=[]),h.strings.push(e.bytes());break}case 10:{h.tensors&&h.tensors.length||(h.tensors=[]),h.tensors.push(a.onnx.TensorProto.decode(e,e.uint32()));break}case 11:{h.graphs&&h.graphs.length||(h.graphs=[]),h.graphs.push(a.onnx.GraphProto.decode(e,e.uint32()));break}case 23:{h.sparseTensors&&h.sparseTensors.length||(h.sparseTensors=[]),h.sparseTensors.push(a.onnx.SparseTensorProto.decode(e,e.uint32()));break}case 15:{h.typeProtos&&h.typeProtos.length||(h.typeProtos=[]),h.typeProtos.push(a.onnx.TypeProto.decode(e,e.uint32()));break}default:e.skipType(f&7);break}}return h},c.decodeDelimited=function(e){return e instanceof i||(e=new i(e)),this.decode(e,e.uint32())},c.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.name!=null&&e.hasOwnProperty("name")&&!n.isString(e.name))return"name: string expected";if(e.refAttrName!=null&&e.hasOwnProperty("refAttrName")&&!n.isString(e.refAttrName))return"refAttrName: string expected";if(e.docString!=null&&e.hasOwnProperty("docString")&&!n.isString(e.docString))return"docString: string expected";if(e.type!=null&&e.hasOwnProperty("type"))switch(e.type){default:return"type: enum value expected";case 0:case 1:case 2:case 3:case 4:case 5:case 11:case 13:case 6:case 7:case 8:case 9:case 10:case 12:case 14:break}if(e.f!=null&&e.hasOwnProperty("f")&&typeof e.f!="number")return"f: number expected";if(e.i!=null&&e.hasOwnProperty("i")&&!n.isInteger(e.i)&&!(e.i&&n.isInteger(e.i.low)&&n.isInteger(e.i.high)))return"i: integer|Long expected";if(e.s!=null&&e.hasOwnProperty("s")&&!(e.s&&typeof e.s.length=="number"||n.isString(e.s)))return"s: buffer expected";if(e.t!=null&&e.hasOwnProperty("t")){var l=a.onnx.TensorProto.verify(e.t);if(l)return"t."+l}if(e.g!=null&&e.hasOwnProperty("g")){var l=a.onnx.GraphProto.verify(e.g);if(l)return"g."+l}if(e.sparseTensor!=null&&e.hasOwnProperty("sparseTensor")){var l=a.onnx.SparseTensorProto.verify(e.sparseTensor);if(l)return"sparseTensor."+l}if(e.tp!=null&&e.hasOwnProperty("tp")){var l=a.onnx.TypeProto.verify(e.tp);if(l)return"tp."+l}if(e.floats!=null&&e.hasOwnProperty("floats")){if(!Array.isArray(e.floats))return"floats: array expected";for(var s=0;s<e.floats.length;++s)if(typeof e.floats[s]!="number")return"floats: number[] expected"}if(e.ints!=null&&e.hasOwnProperty("ints")){if(!Array.isArray(e.ints))return"ints: array expected";for(var s=0;s<e.ints.length;++s)if(!n.isInteger(e.ints[s])&&!(e.ints[s]&&n.isInteger(e.ints[s].low)&&n.isInteger(e.ints[s].high)))return"ints: integer|Long[] expected"}if(e.strings!=null&&e.hasOwnProperty("strings")){if(!Array.isArray(e.strings))return"strings: array expected";for(var s=0;s<e.strings.length;++s)if(!(e.strings[s]&&typeof e.strings[s].length=="number"||n.isString(e.strings[s])))return"strings: buffer[] expected"}if(e.tensors!=null&&e.hasOwnProperty("tensors")){if(!Array.isArray(e.tensors))return"tensors: array expected";for(var s=0;s<e.tensors.length;++s){var l=a.onnx.TensorProto.verify(e.tensors[s]);if(l)return"tensors."+l}}if(e.graphs!=null&&e.hasOwnProperty("graphs")){if(!Array.isArray(e.graphs))return"graphs: array expected";for(var s=0;s<e.graphs.length;++s){var l=a.onnx.GraphProto.verify(e.graphs[s]);if(l)return"graphs."+l}}if(e.sparseTensors!=null&&e.hasOwnProperty("sparseTensors")){if(!Array.isArray(e.sparseTensors))return"sparseTensors: array expected";for(var s=0;s<e.sparseTensors.length;++s){var l=a.onnx.SparseTensorProto.verify(e.sparseTensors[s]);if(l)return"sparseTensors."+l}}if(e.typeProtos!=null&&e.hasOwnProperty("typeProtos")){if(!Array.isArray(e.typeProtos))return"typeProtos: array expected";for(var s=0;s<e.typeProtos.length;++s){var l=a.onnx.TypeProto.verify(e.typeProtos[s]);if(l)return"typeProtos."+l}}return null},c.fromObject=function(e){if(e instanceof a.onnx.AttributeProto)return e;var l=new a.onnx.AttributeProto;switch(e.name!=null&&(l.name=String(e.name)),e.refAttrName!=null&&(l.refAttrName=String(e.refAttrName)),e.docString!=null&&(l.docString=String(e.docString)),e.type){default:if(typeof e.type=="number"){l.type=e.type;break}break;case"UNDEFINED":case 0:l.type=0;break;case"FLOAT":case 1:l.type=1;break;case"INT":case 2:l.type=2;break;case"STRING":case 3:l.type=3;break;case"TENSOR":case 4:l.type=4;break;case"GRAPH":case 5:l.type=5;break;case"SPARSE_TENSOR":case 11:l.type=11;break;case"TYPE_PROTO":case 13:l.type=13;break;case"FLOATS":case 6:l.type=6;break;case"INTS":case 7:l.type=7;break;case"STRINGS":case 8:l.type=8;break;case"TENSORS":case 9:l.type=9;break;case"GRAPHS":case 10:l.type=10;break;case"SPARSE_TENSORS":case 12:l.type=12;break;case"TYPE_PROTOS":case 14:l.type=14;break}if(e.f!=null&&(l.f=Number(e.f)),e.i!=null&&(n.Long?(l.i=n.Long.fromValue(e.i)).unsigned=!1:typeof e.i=="string"?l.i=parseInt(e.i,10):typeof e.i=="number"?l.i=e.i:typeof e.i=="object"&&(l.i=new n.LongBits(e.i.low>>>0,e.i.high>>>0).toNumber())),e.s!=null&&(typeof e.s=="string"?n.base64.decode(e.s,l.s=n.newBuffer(n.base64.length(e.s)),0):e.s.length>=0&&(l.s=e.s)),e.t!=null){if(typeof e.t!="object")throw TypeError(".onnx.AttributeProto.t: object expected");l.t=a.onnx.TensorProto.fromObject(e.t)}if(e.g!=null){if(typeof e.g!="object")throw TypeError(".onnx.AttributeProto.g: object expected");l.g=a.onnx.GraphProto.fromObject(e.g)}if(e.sparseTensor!=null){if(typeof e.sparseTensor!="object")throw TypeError(".onnx.AttributeProto.sparseTensor: object expected");l.sparseTensor=a.onnx.SparseTensorProto.fromObject(e.sparseTensor)}if(e.tp!=null){if(typeof e.tp!="object")throw TypeError(".onnx.AttributeProto.tp: object expected");l.tp=a.onnx.TypeProto.fromObject(e.tp)}if(e.floats){if(!Array.isArray(e.floats))throw TypeError(".onnx.AttributeProto.floats: array expected");l.floats=[];for(var s=0;s<e.floats.length;++s)l.floats[s]=Number(e.floats[s])}if(e.ints){if(!Array.isArray(e.ints))throw TypeError(".onnx.AttributeProto.ints: array expected");l.ints=[];for(var s=0;s<e.ints.length;++s)n.Long?(l.ints[s]=n.Long.fromValue(e.ints[s])).unsigned=!1:typeof e.ints[s]=="string"?l.ints[s]=parseInt(e.ints[s],10):typeof e.ints[s]=="number"?l.ints[s]=e.ints[s]:typeof e.ints[s]=="object"&&(l.ints[s]=new n.LongBits(e.ints[s].low>>>0,e.ints[s].high>>>0).toNumber())}if(e.strings){if(!Array.isArray(e.strings))throw TypeError(".onnx.AttributeProto.strings: array expected");l.strings=[];for(var s=0;s<e.strings.length;++s)typeof e.strings[s]=="string"?n.base64.decode(e.strings[s],l.strings[s]=n.newBuffer(n.base64.length(e.strings[s])),0):e.strings[s].length>=0&&(l.strings[s]=e.strings[s])}if(e.tensors){if(!Array.isArray(e.tensors))throw TypeError(".onnx.AttributeProto.tensors: array expected");l.tensors=[];for(var s=0;s<e.tensors.length;++s){if(typeof e.tensors[s]!="object")throw TypeError(".onnx.AttributeProto.tensors: object expected");l.tensors[s]=a.onnx.TensorProto.fromObject(e.tensors[s])}}if(e.graphs){if(!Array.isArray(e.graphs))throw TypeError(".onnx.AttributeProto.graphs: array expected");l.graphs=[];for(var s=0;s<e.graphs.length;++s){if(typeof e.graphs[s]!="object")throw TypeError(".onnx.AttributeProto.graphs: object expected");l.graphs[s]=a.onnx.GraphProto.fromObject(e.graphs[s])}}if(e.sparseTensors){if(!Array.isArray(e.sparseTensors))throw TypeError(".onnx.AttributeProto.sparseTensors: array expected");l.sparseTensors=[];for(var s=0;s<e.sparseTensors.length;++s){if(typeof e.sparseTensors[s]!="object")throw TypeError(".onnx.AttributeProto.sparseTensors: object expected");l.sparseTensors[s]=a.onnx.SparseTensorProto.fromObject(e.sparseTensors[s])}}if(e.typeProtos){if(!Array.isArray(e.typeProtos))throw TypeError(".onnx.AttributeProto.typeProtos: array expected");l.typeProtos=[];for(var s=0;s<e.typeProtos.length;++s){if(typeof e.typeProtos[s]!="object")throw TypeError(".onnx.AttributeProto.typeProtos: object expected");l.typeProtos[s]=a.onnx.TypeProto.fromObject(e.typeProtos[s])}}return l},c.toObject=function(e,l){l||(l={});var s={};if((l.arrays||l.defaults)&&(s.floats=[],s.ints=[],s.strings=[],s.tensors=[],s.graphs=[],s.typeProtos=[],s.sparseTensors=[]),l.defaults){if(s.name="",s.f=0,n.Long){var h=new n.Long(0,0,!1);s.i=l.longs===String?h.toString():l.longs===Number?h.toNumber():h}else s.i=l.longs===String?"0":0;l.bytes===String?s.s="":(s.s=[],l.bytes!==Array&&(s.s=n.newBuffer(s.s))),s.t=null,s.g=null,s.docString="",s.tp=null,s.type=l.enums===String?"UNDEFINED":0,s.refAttrName="",s.sparseTensor=null}if(e.name!=null&&e.hasOwnProperty("name")&&(s.name=e.name),e.f!=null&&e.hasOwnProperty("f")&&(s.f=l.json&&!isFinite(e.f)?String(e.f):e.f),e.i!=null&&e.hasOwnProperty("i")&&(typeof e.i=="number"?s.i=l.longs===String?String(e.i):e.i:s.i=l.longs===String?n.Long.prototype.toString.call(e.i):l.longs===Number?new n.LongBits(e.i.low>>>0,e.i.high>>>0).toNumber():e.i),e.s!=null&&e.hasOwnProperty("s")&&(s.s=l.bytes===String?n.base64.encode(e.s,0,e.s.length):l.bytes===Array?Array.prototype.slice.call(e.s):e.s),e.t!=null&&e.hasOwnProperty("t")&&(s.t=a.onnx.TensorProto.toObject(e.t,l)),e.g!=null&&e.hasOwnProperty("g")&&(s.g=a.onnx.GraphProto.toObject(e.g,l)),e.floats&&e.floats.length){s.floats=[];for(var f=0;f<e.floats.length;++f)s.floats[f]=l.json&&!isFinite(e.floats[f])?String(e.floats[f]):e.floats[f]}if(e.ints&&e.ints.length){s.ints=[];for(var f=0;f<e.ints.length;++f)typeof e.ints[f]=="number"?s.ints[f]=l.longs===String?String(e.ints[f]):e.ints[f]:s.ints[f]=l.longs===String?n.Long.prototype.toString.call(e.ints[f]):l.longs===Number?new n.LongBits(e.ints[f].low>>>0,e.ints[f].high>>>0).toNumber():e.ints[f]}if(e.strings&&e.strings.length){s.strings=[];for(var f=0;f<e.strings.length;++f)s.strings[f]=l.bytes===String?n.base64.encode(e.strings[f],0,e.strings[f].length):l.bytes===Array?Array.prototype.slice.call(e.strings[f]):e.strings[f]}if(e.tensors&&e.tensors.length){s.tensors=[];for(var f=0;f<e.tensors.length;++f)s.tensors[f]=a.onnx.TensorProto.toObject(e.tensors[f],l)}if(e.graphs&&e.graphs.length){s.graphs=[];for(var f=0;f<e.graphs.length;++f)s.graphs[f]=a.onnx.GraphProto.toObject(e.graphs[f],l)}if(e.docString!=null&&e.hasOwnProperty("docString")&&(s.docString=e.docString),e.tp!=null&&e.hasOwnProperty("tp")&&(s.tp=a.onnx.TypeProto.toObject(e.tp,l)),e.typeProtos&&e.typeProtos.length){s.typeProtos=[];for(var f=0;f<e.typeProtos.length;++f)s.typeProtos[f]=a.onnx.TypeProto.toObject(e.typeProtos[f],l)}if(e.type!=null&&e.hasOwnProperty("type")&&(s.type=l.enums===String?a.onnx.AttributeProto.AttributeType[e.type]===void 0?e.type:a.onnx.AttributeProto.AttributeType[e.type]:e.type),e.refAttrName!=null&&e.hasOwnProperty("refAttrName")&&(s.refAttrName=e.refAttrName),e.sparseTensor!=null&&e.hasOwnProperty("sparseTensor")&&(s.sparseTensor=a.onnx.SparseTensorProto.toObject(e.sparseTensor,l)),e.sparseTensors&&e.sparseTensors.length){s.sparseTensors=[];for(var f=0;f<e.sparseTensors.length;++f)s.sparseTensors[f]=a.onnx.SparseTensorProto.toObject(e.sparseTensors[f],l)}return s},c.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},c.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/onnx.AttributeProto"},c.AttributeType=function(){var e={},l=Object.create(e);return l[e[0]="UNDEFINED"]=0,l[e[1]="FLOAT"]=1,l[e[2]="INT"]=2,l[e[3]="STRING"]=3,l[e[4]="TENSOR"]=4,l[e[5]="GRAPH"]=5,l[e[11]="SPARSE_TENSOR"]=11,l[e[13]="TYPE_PROTO"]=13,l[e[6]="FLOATS"]=6,l[e[7]="INTS"]=7,l[e[8]="STRINGS"]=8,l[e[9]="TENSORS"]=9,l[e[10]="GRAPHS"]=10,l[e[12]="SPARSE_TENSORS"]=12,l[e[14]="TYPE_PROTOS"]=14,l}(),c}(),d.ValueInfoProto=function(){function c(e){if(e)for(var l=Object.keys(e),s=0;s<l.length;++s)e[l[s]]!=null&&(this[l[s]]=e[l[s]])}return c.prototype.name="",c.prototype.type=null,c.prototype.docString="",c.create=function(e){return new c(e)},c.encode=function(e,l){return l||(l=u.create()),e.name!=null&&Object.hasOwnProperty.call(e,"name")&&l.uint32(10).string(e.name),e.type!=null&&Object.hasOwnProperty.call(e,"type")&&a.onnx.TypeProto.encode(e.type,l.uint32(18).fork()).ldelim(),e.docString!=null&&Object.hasOwnProperty.call(e,"docString")&&l.uint32(26).string(e.docString),l},c.encodeDelimited=function(e,l){return this.encode(e,l).ldelim()},c.decode=function(e,l){e instanceof i||(e=i.create(e));for(var s=l===void 0?e.len:e.pos+l,h=new a.onnx.ValueInfoProto;e.pos<s;){var f=e.uint32();switch(f>>>3){case 1:{h.name=e.string();break}case 2:{h.type=a.onnx.TypeProto.decode(e,e.uint32());break}case 3:{h.docString=e.string();break}default:e.skipType(f&7);break}}return h},c.decodeDelimited=function(e){return e instanceof i||(e=new i(e)),this.decode(e,e.uint32())},c.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.name!=null&&e.hasOwnProperty("name")&&!n.isString(e.name))return"name: string expected";if(e.type!=null&&e.hasOwnProperty("type")){var l=a.onnx.TypeProto.verify(e.type);if(l)return"type."+l}return e.docString!=null&&e.hasOwnProperty("docString")&&!n.isString(e.docString)?"docString: string expected":null},c.fromObject=function(e){if(e instanceof a.onnx.ValueInfoProto)return e;var l=new a.onnx.ValueInfoProto;if(e.name!=null&&(l.name=String(e.name)),e.type!=null){if(typeof e.type!="object")throw TypeError(".onnx.ValueInfoProto.type: object expected");l.type=a.onnx.TypeProto.fromObject(e.type)}return e.docString!=null&&(l.docString=String(e.docString)),l},c.toObject=function(e,l){l||(l={});var s={};return l.defaults&&(s.name="",s.type=null,s.docString=""),e.name!=null&&e.hasOwnProperty("name")&&(s.name=e.name),e.type!=null&&e.hasOwnProperty("type")&&(s.type=a.onnx.TypeProto.toObject(e.type,l)),e.docString!=null&&e.hasOwnProperty("docString")&&(s.docString=e.docString),s},c.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},c.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/onnx.ValueInfoProto"},c}(),d.NodeProto=function(){function c(e){if(this.input=[],this.output=[],this.attribute=[],e)for(var l=Object.keys(e),s=0;s<l.length;++s)e[l[s]]!=null&&(this[l[s]]=e[l[s]])}return c.prototype.input=n.emptyArray,c.prototype.output=n.emptyArray,c.prototype.name="",c.prototype.opType="",c.prototype.domain="",c.prototype.attribute=n.emptyArray,c.prototype.docString="",c.create=function(e){return new c(e)},c.encode=function(e,l){if(l||(l=u.create()),e.input!=null&&e.input.length)for(var s=0;s<e.input.length;++s)l.uint32(10).string(e.input[s]);if(e.output!=null&&e.output.length)for(var s=0;s<e.output.length;++s)l.uint32(18).string(e.output[s]);if(e.name!=null&&Object.hasOwnProperty.call(e,"name")&&l.uint32(26).string(e.name),e.opType!=null&&Object.hasOwnProperty.call(e,"opType")&&l.uint32(34).string(e.opType),e.attribute!=null&&e.attribute.length)for(var s=0;s<e.attribute.length;++s)a.onnx.AttributeProto.encode(e.attribute[s],l.uint32(42).fork()).ldelim();return e.docString!=null&&Object.hasOwnProperty.call(e,"docString")&&l.uint32(50).string(e.docString),e.domain!=null&&Object.hasOwnProperty.call(e,"domain")&&l.uint32(58).string(e.domain),l},c.encodeDelimited=function(e,l){return this.encode(e,l).ldelim()},c.decode=function(e,l){e instanceof i||(e=i.create(e));for(var s=l===void 0?e.len:e.pos+l,h=new a.onnx.NodeProto;e.pos<s;){var f=e.uint32();switch(f>>>3){case 1:{h.input&&h.input.length||(h.input=[]),h.input.push(e.string());break}case 2:{h.output&&h.output.length||(h.output=[]),h.output.push(e.string());break}case 3:{h.name=e.string();break}case 4:{h.opType=e.string();break}case 7:{h.domain=e.string();break}case 5:{h.attribute&&h.attribute.length||(h.attribute=[]),h.attribute.push(a.onnx.AttributeProto.decode(e,e.uint32()));break}case 6:{h.docString=e.string();break}default:e.skipType(f&7);break}}return h},c.decodeDelimited=function(e){return e instanceof i||(e=new i(e)),this.decode(e,e.uint32())},c.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.input!=null&&e.hasOwnProperty("input")){if(!Array.isArray(e.input))return"input: array expected";for(var l=0;l<e.input.length;++l)if(!n.isString(e.input[l]))return"input: string[] expected"}if(e.output!=null&&e.hasOwnProperty("output")){if(!Array.isArray(e.output))return"output: array expected";for(var l=0;l<e.output.length;++l)if(!n.isString(e.output[l]))return"output: string[] expected"}if(e.name!=null&&e.hasOwnProperty("name")&&!n.isString(e.name))return"name: string expected";if(e.opType!=null&&e.hasOwnProperty("opType")&&!n.isString(e.opType))return"opType: string expected";if(e.domain!=null&&e.hasOwnProperty("domain")&&!n.isString(e.domain))return"domain: string expected";if(e.attribute!=null&&e.hasOwnProperty("attribute")){if(!Array.isArray(e.attribute))return"attribute: array expected";for(var l=0;l<e.attribute.length;++l){var s=a.onnx.AttributeProto.verify(e.attribute[l]);if(s)return"attribute."+s}}return e.docString!=null&&e.hasOwnProperty("docString")&&!n.isString(e.docString)?"docString: string expected":null},c.fromObject=function(e){if(e instanceof a.onnx.NodeProto)return e;var l=new a.onnx.NodeProto;if(e.input){if(!Array.isArray(e.input))throw TypeError(".onnx.NodeProto.input: array expected");l.input=[];for(var s=0;s<e.input.length;++s)l.input[s]=String(e.input[s])}if(e.output){if(!Array.isArray(e.output))throw TypeError(".onnx.NodeProto.output: array expected");l.output=[];for(var s=0;s<e.output.length;++s)l.output[s]=String(e.output[s])}if(e.name!=null&&(l.name=String(e.name)),e.opType!=null&&(l.opType=String(e.opType)),e.domain!=null&&(l.domain=String(e.domain)),e.attribute){if(!Array.isArray(e.attribute))throw TypeError(".onnx.NodeProto.attribute: array expected");l.attribute=[];for(var s=0;s<e.attribute.length;++s){if(typeof e.attribute[s]!="object")throw TypeError(".onnx.NodeProto.attribute: object expected");l.attribute[s]=a.onnx.AttributeProto.fromObject(e.attribute[s])}}return e.docString!=null&&(l.docString=String(e.docString)),l},c.toObject=function(e,l){l||(l={});var s={};if((l.arrays||l.defaults)&&(s.input=[],s.output=[],s.attribute=[]),l.defaults&&(s.name="",s.opType="",s.docString="",s.domain=""),e.input&&e.input.length){s.input=[];for(var h=0;h<e.input.length;++h)s.input[h]=e.input[h]}if(e.output&&e.output.length){s.output=[];for(var h=0;h<e.output.length;++h)s.output[h]=e.output[h]}if(e.name!=null&&e.hasOwnProperty("name")&&(s.name=e.name),e.opType!=null&&e.hasOwnProperty("opType")&&(s.opType=e.opType),e.attribute&&e.attribute.length){s.attribute=[];for(var h=0;h<e.attribute.length;++h)s.attribute[h]=a.onnx.AttributeProto.toObject(e.attribute[h],l)}return e.docString!=null&&e.hasOwnProperty("docString")&&(s.docString=e.docString),e.domain!=null&&e.hasOwnProperty("domain")&&(s.domain=e.domain),s},c.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},c.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/onnx.NodeProto"},c}(),d.TrainingInfoProto=function(){function c(e){if(this.initializationBinding=[],this.updateBinding=[],e)for(var l=Object.keys(e),s=0;s<l.length;++s)e[l[s]]!=null&&(this[l[s]]=e[l[s]])}return c.prototype.initialization=null,c.prototype.algorithm=null,c.prototype.initializationBinding=n.emptyArray,c.prototype.updateBinding=n.emptyArray,c.create=function(e){return new c(e)},c.encode=function(e,l){if(l||(l=u.create()),e.initialization!=null&&Object.hasOwnProperty.call(e,"initialization")&&a.onnx.GraphProto.encode(e.initialization,l.uint32(10).fork()).ldelim(),e.algorithm!=null&&Object.hasOwnProperty.call(e,"algorithm")&&a.onnx.GraphProto.encode(e.algorithm,l.uint32(18).fork()).ldelim(),e.initializationBinding!=null&&e.initializationBinding.length)for(var s=0;s<e.initializationBinding.length;++s)a.onnx.StringStringEntryProto.encode(e.initializationBinding[s],l.uint32(26).fork()).ldelim();if(e.updateBinding!=null&&e.updateBinding.length)for(var s=0;s<e.updateBinding.length;++s)a.onnx.StringStringEntryProto.encode(e.updateBinding[s],l.uint32(34).fork()).ldelim();return l},c.encodeDelimited=function(e,l){return this.encode(e,l).ldelim()},c.decode=function(e,l){e instanceof i||(e=i.create(e));for(var s=l===void 0?e.len:e.pos+l,h=new a.onnx.TrainingInfoProto;e.pos<s;){var f=e.uint32();switch(f>>>3){case 1:{h.initialization=a.onnx.GraphProto.decode(e,e.uint32());break}case 2:{h.algorithm=a.onnx.GraphProto.decode(e,e.uint32());break}case 3:{h.initializationBinding&&h.initializationBinding.length||(h.initializationBinding=[]),h.initializationBinding.push(a.onnx.StringStringEntryProto.decode(e,e.uint32()));break}case 4:{h.updateBinding&&h.updateBinding.length||(h.updateBinding=[]),h.updateBinding.push(a.onnx.StringStringEntryProto.decode(e,e.uint32()));break}default:e.skipType(f&7);break}}return h},c.decodeDelimited=function(e){return e instanceof i||(e=new i(e)),this.decode(e,e.uint32())},c.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.initialization!=null&&e.hasOwnProperty("initialization")){var l=a.onnx.GraphProto.verify(e.initialization);if(l)return"initialization."+l}if(e.algorithm!=null&&e.hasOwnProperty("algorithm")){var l=a.onnx.GraphProto.verify(e.algorithm);if(l)return"algorithm."+l}if(e.initializationBinding!=null&&e.hasOwnProperty("initializationBinding")){if(!Array.isArray(e.initializationBinding))return"initializationBinding: array expected";for(var s=0;s<e.initializationBinding.length;++s){var l=a.onnx.StringStringEntryProto.verify(e.initializationBinding[s]);if(l)return"initializationBinding."+l}}if(e.updateBinding!=null&&e.hasOwnProperty("updateBinding")){if(!Array.isArray(e.updateBinding))return"updateBinding: array expected";for(var s=0;s<e.updateBinding.length;++s){var l=a.onnx.StringStringEntryProto.verify(e.updateBinding[s]);if(l)return"updateBinding."+l}}return null},c.fromObject=function(e){if(e instanceof a.onnx.TrainingInfoProto)return e;var l=new a.onnx.TrainingInfoProto;if(e.initialization!=null){if(typeof e.initialization!="object")throw TypeError(".onnx.TrainingInfoProto.initialization: object expected");l.initialization=a.onnx.GraphProto.fromObject(e.initialization)}if(e.algorithm!=null){if(typeof e.algorithm!="object")throw TypeError(".onnx.TrainingInfoProto.algorithm: object expected");l.algorithm=a.onnx.GraphProto.fromObject(e.algorithm)}if(e.initializationBinding){if(!Array.isArray(e.initializationBinding))throw TypeError(".onnx.TrainingInfoProto.initializationBinding: array expected");l.initializationBinding=[];for(var s=0;s<e.initializationBinding.length;++s){if(typeof e.initializationBinding[s]!="object")throw TypeError(".onnx.TrainingInfoProto.initializationBinding: object expected");l.initializationBinding[s]=a.onnx.StringStringEntryProto.fromObject(e.initializationBinding[s])}}if(e.updateBinding){if(!Array.isArray(e.updateBinding))throw TypeError(".onnx.TrainingInfoProto.updateBinding: array expected");l.updateBinding=[];for(var s=0;s<e.updateBinding.length;++s){if(typeof e.updateBinding[s]!="object")throw TypeError(".onnx.TrainingInfoProto.updateBinding: object expected");l.updateBinding[s]=a.onnx.StringStringEntryProto.fromObject(e.updateBinding[s])}}return l},c.toObject=function(e,l){l||(l={});var s={};if((l.arrays||l.defaults)&&(s.initializationBinding=[],s.updateBinding=[]),l.defaults&&(s.initialization=null,s.algorithm=null),e.initialization!=null&&e.hasOwnProperty("initialization")&&(s.initialization=a.onnx.GraphProto.toObject(e.initialization,l)),e.algorithm!=null&&e.hasOwnProperty("algorithm")&&(s.algorithm=a.onnx.GraphProto.toObject(e.algorithm,l)),e.initializationBinding&&e.initializationBinding.length){s.initializationBinding=[];for(var h=0;h<e.initializationBinding.length;++h)s.initializationBinding[h]=a.onnx.StringStringEntryProto.toObject(e.initializationBinding[h],l)}if(e.updateBinding&&e.updateBinding.length){s.updateBinding=[];for(var h=0;h<e.updateBinding.length;++h)s.updateBinding[h]=a.onnx.StringStringEntryProto.toObject(e.updateBinding[h],l)}return s},c.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},c.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/onnx.TrainingInfoProto"},c}(),d.ModelProto=function(){function c(e){if(this.opsetImport=[],this.metadataProps=[],this.trainingInfo=[],this.functions=[],e)for(var l=Object.keys(e),s=0;s<l.length;++s)e[l[s]]!=null&&(this[l[s]]=e[l[s]])}return c.prototype.irVersion=n.Long?n.Long.fromBits(0,0,!1):0,c.prototype.opsetImport=n.emptyArray,c.prototype.producerName="",c.prototype.producerVersion="",c.prototype.domain="",c.prototype.modelVersion=n.Long?n.Long.fromBits(0,0,!1):0,c.prototype.docString="",c.prototype.graph=null,c.prototype.metadataProps=n.emptyArray,c.prototype.trainingInfo=n.emptyArray,c.prototype.functions=n.emptyArray,c.create=function(e){return new c(e)},c.encode=function(e,l){if(l||(l=u.create()),e.irVersion!=null&&Object.hasOwnProperty.call(e,"irVersion")&&l.uint32(8).int64(e.irVersion),e.producerName!=null&&Object.hasOwnProperty.call(e,"producerName")&&l.uint32(18).string(e.producerName),e.producerVersion!=null&&Object.hasOwnProperty.call(e,"producerVersion")&&l.uint32(26).string(e.producerVersion),e.domain!=null&&Object.hasOwnProperty.call(e,"domain")&&l.uint32(34).string(e.domain),e.modelVersion!=null&&Object.hasOwnProperty.call(e,"modelVersion")&&l.uint32(40).int64(e.modelVersion),e.docString!=null&&Object.hasOwnProperty.call(e,"docString")&&l.uint32(50).string(e.docString),e.graph!=null&&Object.hasOwnProperty.call(e,"graph")&&a.onnx.GraphProto.encode(e.graph,l.uint32(58).fork()).ldelim(),e.opsetImport!=null&&e.opsetImport.length)for(var s=0;s<e.opsetImport.length;++s)a.onnx.OperatorSetIdProto.encode(e.opsetImport[s],l.uint32(66).fork()).ldelim();if(e.metadataProps!=null&&e.metadataProps.length)for(var s=0;s<e.metadataProps.length;++s)a.onnx.StringStringEntryProto.encode(e.metadataProps[s],l.uint32(114).fork()).ldelim();if(e.trainingInfo!=null&&e.trainingInfo.length)for(var s=0;s<e.trainingInfo.length;++s)a.onnx.TrainingInfoProto.encode(e.trainingInfo[s],l.uint32(162).fork()).ldelim();if(e.functions!=null&&e.functions.length)for(var s=0;s<e.functions.length;++s)a.onnx.FunctionProto.encode(e.functions[s],l.uint32(202).fork()).ldelim();return l},c.encodeDelimited=function(e,l){return this.encode(e,l).ldelim()},c.decode=function(e,l){e instanceof i||(e=i.create(e));for(var s=l===void 0?e.len:e.pos+l,h=new a.onnx.ModelProto;e.pos<s;){var f=e.uint32();switch(f>>>3){case 1:{h.irVersion=e.int64();break}case 8:{h.opsetImport&&h.opsetImport.length||(h.opsetImport=[]),h.opsetImport.push(a.onnx.OperatorSetIdProto.decode(e,e.uint32()));break}case 2:{h.producerName=e.string();break}case 3:{h.producerVersion=e.string();break}case 4:{h.domain=e.string();break}case 5:{h.modelVersion=e.int64();break}case 6:{h.docString=e.string();break}case 7:{h.graph=a.onnx.GraphProto.decode(e,e.uint32());break}case 14:{h.metadataProps&&h.metadataProps.length||(h.metadataProps=[]),h.metadataProps.push(a.onnx.StringStringEntryProto.decode(e,e.uint32()));break}case 20:{h.trainingInfo&&h.trainingInfo.length||(h.trainingInfo=[]),h.trainingInfo.push(a.onnx.TrainingInfoProto.decode(e,e.uint32()));break}case 25:{h.functions&&h.functions.length||(h.functions=[]),h.functions.push(a.onnx.FunctionProto.decode(e,e.uint32()));break}default:e.skipType(f&7);break}}return h},c.decodeDelimited=function(e){return e instanceof i||(e=new i(e)),this.decode(e,e.uint32())},c.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.irVersion!=null&&e.hasOwnProperty("irVersion")&&!n.isInteger(e.irVersion)&&!(e.irVersion&&n.isInteger(e.irVersion.low)&&n.isInteger(e.irVersion.high)))return"irVersion: integer|Long expected";if(e.opsetImport!=null&&e.hasOwnProperty("opsetImport")){if(!Array.isArray(e.opsetImport))return"opsetImport: array expected";for(var l=0;l<e.opsetImport.length;++l){var s=a.onnx.OperatorSetIdProto.verify(e.opsetImport[l]);if(s)return"opsetImport."+s}}if(e.producerName!=null&&e.hasOwnProperty("producerName")&&!n.isString(e.producerName))return"producerName: string expected";if(e.producerVersion!=null&&e.hasOwnProperty("producerVersion")&&!n.isString(e.producerVersion))return"producerVersion: string expected";if(e.domain!=null&&e.hasOwnProperty("domain")&&!n.isString(e.domain))return"domain: string expected";if(e.modelVersion!=null&&e.hasOwnProperty("modelVersion")&&!n.isInteger(e.modelVersion)&&!(e.modelVersion&&n.isInteger(e.modelVersion.low)&&n.isInteger(e.modelVersion.high)))return"modelVersion: integer|Long expected";if(e.docString!=null&&e.hasOwnProperty("docString")&&!n.isString(e.docString))return"docString: string expected";if(e.graph!=null&&e.hasOwnProperty("graph")){var s=a.onnx.GraphProto.verify(e.graph);if(s)return"graph."+s}if(e.metadataProps!=null&&e.hasOwnProperty("metadataProps")){if(!Array.isArray(e.metadataProps))return"metadataProps: array expected";for(var l=0;l<e.metadataProps.length;++l){var s=a.onnx.StringStringEntryProto.verify(e.metadataProps[l]);if(s)return"metadataProps."+s}}if(e.trainingInfo!=null&&e.hasOwnProperty("trainingInfo")){if(!Array.isArray(e.trainingInfo))return"trainingInfo: array expected";for(var l=0;l<e.trainingInfo.length;++l){var s=a.onnx.TrainingInfoProto.verify(e.trainingInfo[l]);if(s)return"trainingInfo."+s}}if(e.functions!=null&&e.hasOwnProperty("functions")){if(!Array.isArray(e.functions))return"functions: array expected";for(var l=0;l<e.functions.length;++l){var s=a.onnx.FunctionProto.verify(e.functions[l]);if(s)return"functions."+s}}return null},c.fromObject=function(e){if(e instanceof a.onnx.ModelProto)return e;var l=new a.onnx.ModelProto;if(e.irVersion!=null&&(n.Long?(l.irVersion=n.Long.fromValue(e.irVersion)).unsigned=!1:typeof e.irVersion=="string"?l.irVersion=parseInt(e.irVersion,10):typeof e.irVersion=="number"?l.irVersion=e.irVersion:typeof e.irVersion=="object"&&(l.irVersion=new n.LongBits(e.irVersion.low>>>0,e.irVersion.high>>>0).toNumber())),e.opsetImport){if(!Array.isArray(e.opsetImport))throw TypeError(".onnx.ModelProto.opsetImport: array expected");l.opsetImport=[];for(var s=0;s<e.opsetImport.length;++s){if(typeof e.opsetImport[s]!="object")throw TypeError(".onnx.ModelProto.opsetImport: object expected");l.opsetImport[s]=a.onnx.OperatorSetIdProto.fromObject(e.opsetImport[s])}}if(e.producerName!=null&&(l.producerName=String(e.producerName)),e.producerVersion!=null&&(l.producerVersion=String(e.producerVersion)),e.domain!=null&&(l.domain=String(e.domain)),e.modelVersion!=null&&(n.Long?(l.modelVersion=n.Long.fromValue(e.modelVersion)).unsigned=!1:typeof e.modelVersion=="string"?l.modelVersion=parseInt(e.modelVersion,10):typeof e.modelVersion=="number"?l.modelVersion=e.modelVersion:typeof e.modelVersion=="object"&&(l.modelVersion=new n.LongBits(e.modelVersion.low>>>0,e.modelVersion.high>>>0).toNumber())),e.docString!=null&&(l.docString=String(e.docString)),e.graph!=null){if(typeof e.graph!="object")throw TypeError(".onnx.ModelProto.graph: object expected");l.graph=a.onnx.GraphProto.fromObject(e.graph)}if(e.metadataProps){if(!Array.isArray(e.metadataProps))throw TypeError(".onnx.ModelProto.metadataProps: array expected");l.metadataProps=[];for(var s=0;s<e.metadataProps.length;++s){if(typeof e.metadataProps[s]!="object")throw TypeError(".onnx.ModelProto.metadataProps: object expected");l.metadataProps[s]=a.onnx.StringStringEntryProto.fromObject(e.metadataProps[s])}}if(e.trainingInfo){if(!Array.isArray(e.trainingInfo))throw TypeError(".onnx.ModelProto.trainingInfo: array expected");l.trainingInfo=[];for(var s=0;s<e.trainingInfo.length;++s){if(typeof e.trainingInfo[s]!="object")throw TypeError(".onnx.ModelProto.trainingInfo: object expected");l.trainingInfo[s]=a.onnx.TrainingInfoProto.fromObject(e.trainingInfo[s])}}if(e.functions){if(!Array.isArray(e.functions))throw TypeError(".onnx.ModelProto.functions: array expected");l.functions=[];for(var s=0;s<e.functions.length;++s){if(typeof e.functions[s]!="object")throw TypeError(".onnx.ModelProto.functions: object expected");l.functions[s]=a.onnx.FunctionProto.fromObject(e.functions[s])}}return l},c.toObject=function(e,l){l||(l={});var s={};if((l.arrays||l.defaults)&&(s.opsetImport=[],s.metadataProps=[],s.trainingInfo=[],s.functions=[]),l.defaults){if(n.Long){var h=new n.Long(0,0,!1);s.irVersion=l.longs===String?h.toString():l.longs===Number?h.toNumber():h}else s.irVersion=l.longs===String?"0":0;if(s.producerName="",s.producerVersion="",s.domain="",n.Long){var h=new n.Long(0,0,!1);s.modelVersion=l.longs===String?h.toString():l.longs===Number?h.toNumber():h}else s.modelVersion=l.longs===String?"0":0;s.docString="",s.graph=null}if(e.irVersion!=null&&e.hasOwnProperty("irVersion")&&(typeof e.irVersion=="number"?s.irVersion=l.longs===String?String(e.irVersion):e.irVersion:s.irVersion=l.longs===String?n.Long.prototype.toString.call(e.irVersion):l.longs===Number?new n.LongBits(e.irVersion.low>>>0,e.irVersion.high>>>0).toNumber():e.irVersion),e.producerName!=null&&e.hasOwnProperty("producerName")&&(s.producerName=e.producerName),e.producerVersion!=null&&e.hasOwnProperty("producerVersion")&&(s.producerVersion=e.producerVersion),e.domain!=null&&e.hasOwnProperty("domain")&&(s.domain=e.domain),e.modelVersion!=null&&e.hasOwnProperty("modelVersion")&&(typeof e.modelVersion=="number"?s.modelVersion=l.longs===String?String(e.modelVersion):e.modelVersion:s.modelVersion=l.longs===String?n.Long.prototype.toString.call(e.modelVersion):l.longs===Number?new n.LongBits(e.modelVersion.low>>>0,e.modelVersion.high>>>0).toNumber():e.modelVersion),e.docString!=null&&e.hasOwnProperty("docString")&&(s.docString=e.docString),e.graph!=null&&e.hasOwnProperty("graph")&&(s.graph=a.onnx.GraphProto.toObject(e.graph,l)),e.opsetImport&&e.opsetImport.length){s.opsetImport=[];for(var f=0;f<e.opsetImport.length;++f)s.opsetImport[f]=a.onnx.OperatorSetIdProto.toObject(e.opsetImport[f],l)}if(e.metadataProps&&e.metadataProps.length){s.metadataProps=[];for(var f=0;f<e.metadataProps.length;++f)s.metadataProps[f]=a.onnx.StringStringEntryProto.toObject(e.metadataProps[f],l)}if(e.trainingInfo&&e.trainingInfo.length){s.trainingInfo=[];for(var f=0;f<e.trainingInfo.length;++f)s.trainingInfo[f]=a.onnx.TrainingInfoProto.toObject(e.trainingInfo[f],l)}if(e.functions&&e.functions.length){s.functions=[];for(var f=0;f<e.functions.length;++f)s.functions[f]=a.onnx.FunctionProto.toObject(e.functions[f],l)}return s},c.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},c.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/onnx.ModelProto"},c}(),d.StringStringEntryProto=function(){function c(e){if(e)for(var l=Object.keys(e),s=0;s<l.length;++s)e[l[s]]!=null&&(this[l[s]]=e[l[s]])}return c.prototype.key="",c.prototype.value="",c.create=function(e){return new c(e)},c.encode=function(e,l){return l||(l=u.create()),e.key!=null&&Object.hasOwnProperty.call(e,"key")&&l.uint32(10).string(e.key),e.value!=null&&Object.hasOwnProperty.call(e,"value")&&l.uint32(18).string(e.value),l},c.encodeDelimited=function(e,l){return this.encode(e,l).ldelim()},c.decode=function(e,l){e instanceof i||(e=i.create(e));for(var s=l===void 0?e.len:e.pos+l,h=new a.onnx.StringStringEntryProto;e.pos<s;){var f=e.uint32();switch(f>>>3){case 1:{h.key=e.string();break}case 2:{h.value=e.string();break}default:e.skipType(f&7);break}}return h},c.decodeDelimited=function(e){return e instanceof i||(e=new i(e)),this.decode(e,e.uint32())},c.verify=function(e){return typeof e!="object"||e===null?"object expected":e.key!=null&&e.hasOwnProperty("key")&&!n.isString(e.key)?"key: string expected":e.value!=null&&e.hasOwnProperty("value")&&!n.isString(e.value)?"value: string expected":null},c.fromObject=function(e){if(e instanceof a.onnx.StringStringEntryProto)return e;var l=new a.onnx.StringStringEntryProto;return e.key!=null&&(l.key=String(e.key)),e.value!=null&&(l.value=String(e.value)),l},c.toObject=function(e,l){l||(l={});var s={};return l.defaults&&(s.key="",s.value=""),e.key!=null&&e.hasOwnProperty("key")&&(s.key=e.key),e.value!=null&&e.hasOwnProperty("value")&&(s.value=e.value),s},c.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},c.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/onnx.StringStringEntryProto"},c}(),d.TensorAnnotation=function(){function c(e){if(this.quantParameterTensorNames=[],e)for(var l=Object.keys(e),s=0;s<l.length;++s)e[l[s]]!=null&&(this[l[s]]=e[l[s]])}return c.prototype.tensorName="",c.prototype.quantParameterTensorNames=n.emptyArray,c.create=function(e){return new c(e)},c.encode=function(e,l){if(l||(l=u.create()),e.tensorName!=null&&Object.hasOwnProperty.call(e,"tensorName")&&l.uint32(10).string(e.tensorName),e.quantParameterTensorNames!=null&&e.quantParameterTensorNames.length)for(var s=0;s<e.quantParameterTensorNames.length;++s)a.onnx.StringStringEntryProto.encode(e.quantParameterTensorNames[s],l.uint32(18).fork()).ldelim();return l},c.encodeDelimited=function(e,l){return this.encode(e,l).ldelim()},c.decode=function(e,l){e instanceof i||(e=i.create(e));for(var s=l===void 0?e.len:e.pos+l,h=new a.onnx.TensorAnnotation;e.pos<s;){var f=e.uint32();switch(f>>>3){case 1:{h.tensorName=e.string();break}case 2:{h.quantParameterTensorNames&&h.quantParameterTensorNames.length||(h.quantParameterTensorNames=[]),h.quantParameterTensorNames.push(a.onnx.StringStringEntryProto.decode(e,e.uint32()));break}default:e.skipType(f&7);break}}return h},c.decodeDelimited=function(e){return e instanceof i||(e=new i(e)),this.decode(e,e.uint32())},c.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.tensorName!=null&&e.hasOwnProperty("tensorName")&&!n.isString(e.tensorName))return"tensorName: string expected";if(e.quantParameterTensorNames!=null&&e.hasOwnProperty("quantParameterTensorNames")){if(!Array.isArray(e.quantParameterTensorNames))return"quantParameterTensorNames: array expected";for(var l=0;l<e.quantParameterTensorNames.length;++l){var s=a.onnx.StringStringEntryProto.verify(e.quantParameterTensorNames[l]);if(s)return"quantParameterTensorNames."+s}}return null},c.fromObject=function(e){if(e instanceof a.onnx.TensorAnnotation)return e;var l=new a.onnx.TensorAnnotation;if(e.tensorName!=null&&(l.tensorName=String(e.tensorName)),e.quantParameterTensorNames){if(!Array.isArray(e.quantParameterTensorNames))throw TypeError(".onnx.TensorAnnotation.quantParameterTensorNames: array expected");l.quantParameterTensorNames=[];for(var s=0;s<e.quantParameterTensorNames.length;++s){if(typeof e.quantParameterTensorNames[s]!="object")throw TypeError(".onnx.TensorAnnotation.quantParameterTensorNames: object expected");l.quantParameterTensorNames[s]=a.onnx.StringStringEntryProto.fromObject(e.quantParameterTensorNames[s])}}return l},c.toObject=function(e,l){l||(l={});var s={};if((l.arrays||l.defaults)&&(s.quantParameterTensorNames=[]),l.defaults&&(s.tensorName=""),e.tensorName!=null&&e.hasOwnProperty("tensorName")&&(s.tensorName=e.tensorName),e.quantParameterTensorNames&&e.quantParameterTensorNames.length){s.quantParameterTensorNames=[];for(var h=0;h<e.quantParameterTensorNames.length;++h)s.quantParameterTensorNames[h]=a.onnx.StringStringEntryProto.toObject(e.quantParameterTensorNames[h],l)}return s},c.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},c.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/onnx.TensorAnnotation"},c}(),d.GraphProto=function(){function c(e){if(this.node=[],this.initializer=[],this.sparseInitializer=[],this.input=[],this.output=[],this.valueInfo=[],this.quantizationAnnotation=[],e)for(var l=Object.keys(e),s=0;s<l.length;++s)e[l[s]]!=null&&(this[l[s]]=e[l[s]])}return c.prototype.node=n.emptyArray,c.prototype.name="",c.prototype.initializer=n.emptyArray,c.prototype.sparseInitializer=n.emptyArray,c.prototype.docString="",c.prototype.input=n.emptyArray,c.prototype.output=n.emptyArray,c.prototype.valueInfo=n.emptyArray,c.prototype.quantizationAnnotation=n.emptyArray,c.create=function(e){return new c(e)},c.encode=function(e,l){if(l||(l=u.create()),e.node!=null&&e.node.length)for(var s=0;s<e.node.length;++s)a.onnx.NodeProto.encode(e.node[s],l.uint32(10).fork()).ldelim();if(e.name!=null&&Object.hasOwnProperty.call(e,"name")&&l.uint32(18).string(e.name),e.initializer!=null&&e.initializer.length)for(var s=0;s<e.initializer.length;++s)a.onnx.TensorProto.encode(e.initializer[s],l.uint32(42).fork()).ldelim();if(e.docString!=null&&Object.hasOwnProperty.call(e,"docString")&&l.uint32(82).string(e.docString),e.input!=null&&e.input.length)for(var s=0;s<e.input.length;++s)a.onnx.ValueInfoProto.encode(e.input[s],l.uint32(90).fork()).ldelim();if(e.output!=null&&e.output.length)for(var s=0;s<e.output.length;++s)a.onnx.ValueInfoProto.encode(e.output[s],l.uint32(98).fork()).ldelim();if(e.valueInfo!=null&&e.valueInfo.length)for(var s=0;s<e.valueInfo.length;++s)a.onnx.ValueInfoProto.encode(e.valueInfo[s],l.uint32(106).fork()).ldelim();if(e.quantizationAnnotation!=null&&e.quantizationAnnotation.length)for(var s=0;s<e.quantizationAnnotation.length;++s)a.onnx.TensorAnnotation.encode(e.quantizationAnnotation[s],l.uint32(114).fork()).ldelim();if(e.sparseInitializer!=null&&e.sparseInitializer.length)for(var s=0;s<e.sparseInitializer.length;++s)a.onnx.SparseTensorProto.encode(e.sparseInitializer[s],l.uint32(122).fork()).ldelim();return l},c.encodeDelimited=function(e,l){return this.encode(e,l).ldelim()},c.decode=function(e,l){e instanceof i||(e=i.create(e));for(var s=l===void 0?e.len:e.pos+l,h=new a.onnx.GraphProto;e.pos<s;){var f=e.uint32();switch(f>>>3){case 1:{h.node&&h.node.length||(h.node=[]),h.node.push(a.onnx.NodeProto.decode(e,e.uint32()));break}case 2:{h.name=e.string();break}case 5:{h.initializer&&h.initializer.length||(h.initializer=[]),h.initializer.push(a.onnx.TensorProto.decode(e,e.uint32()));break}case 15:{h.sparseInitializer&&h.sparseInitializer.length||(h.sparseInitializer=[]),h.sparseInitializer.push(a.onnx.SparseTensorProto.decode(e,e.uint32()));break}case 10:{h.docString=e.string();break}case 11:{h.input&&h.input.length||(h.input=[]),h.input.push(a.onnx.ValueInfoProto.decode(e,e.uint32()));break}case 12:{h.output&&h.output.length||(h.output=[]),h.output.push(a.onnx.ValueInfoProto.decode(e,e.uint32()));break}case 13:{h.valueInfo&&h.valueInfo.length||(h.valueInfo=[]),h.valueInfo.push(a.onnx.ValueInfoProto.decode(e,e.uint32()));break}case 14:{h.quantizationAnnotation&&h.quantizationAnnotation.length||(h.quantizationAnnotation=[]),h.quantizationAnnotation.push(a.onnx.TensorAnnotation.decode(e,e.uint32()));break}default:e.skipType(f&7);break}}return h},c.decodeDelimited=function(e){return e instanceof i||(e=new i(e)),this.decode(e,e.uint32())},c.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.node!=null&&e.hasOwnProperty("node")){if(!Array.isArray(e.node))return"node: array expected";for(var l=0;l<e.node.length;++l){var s=a.onnx.NodeProto.verify(e.node[l]);if(s)return"node."+s}}if(e.name!=null&&e.hasOwnProperty("name")&&!n.isString(e.name))return"name: string expected";if(e.initializer!=null&&e.hasOwnProperty("initializer")){if(!Array.isArray(e.initializer))return"initializer: array expected";for(var l=0;l<e.initializer.length;++l){var s=a.onnx.TensorProto.verify(e.initializer[l]);if(s)return"initializer."+s}}if(e.sparseInitializer!=null&&e.hasOwnProperty("sparseInitializer")){if(!Array.isArray(e.sparseInitializer))return"sparseInitializer: array expected";for(var l=0;l<e.sparseInitializer.length;++l){var s=a.onnx.SparseTensorProto.verify(e.sparseInitializer[l]);if(s)return"sparseInitializer."+s}}if(e.docString!=null&&e.hasOwnProperty("docString")&&!n.isString(e.docString))return"docString: string expected";if(e.input!=null&&e.hasOwnProperty("input")){if(!Array.isArray(e.input))return"input: array expected";for(var l=0;l<e.input.length;++l){var s=a.onnx.ValueInfoProto.verify(e.input[l]);if(s)return"input."+s}}if(e.output!=null&&e.hasOwnProperty("output")){if(!Array.isArray(e.output))return"output: array expected";for(var l=0;l<e.output.length;++l){var s=a.onnx.ValueInfoProto.verify(e.output[l]);if(s)return"output."+s}}if(e.valueInfo!=null&&e.hasOwnProperty("valueInfo")){if(!Array.isArray(e.valueInfo))return"valueInfo: array expected";for(var l=0;l<e.valueInfo.length;++l){var s=a.onnx.ValueInfoProto.verify(e.valueInfo[l]);if(s)return"valueInfo."+s}}if(e.quantizationAnnotation!=null&&e.hasOwnProperty("quantizationAnnotation")){if(!Array.isArray(e.quantizationAnnotation))return"quantizationAnnotation: array expected";for(var l=0;l<e.quantizationAnnotation.length;++l){var s=a.onnx.TensorAnnotation.verify(e.quantizationAnnotation[l]);if(s)return"quantizationAnnotation."+s}}return null},c.fromObject=function(e){if(e instanceof a.onnx.GraphProto)return e;var l=new a.onnx.GraphProto;if(e.node){if(!Array.isArray(e.node))throw TypeError(".onnx.GraphProto.node: array expected");l.node=[];for(var s=0;s<e.node.length;++s){if(typeof e.node[s]!="object")throw TypeError(".onnx.GraphProto.node: object expected");l.node[s]=a.onnx.NodeProto.fromObject(e.node[s])}}if(e.name!=null&&(l.name=String(e.name)),e.initializer){if(!Array.isArray(e.initializer))throw TypeError(".onnx.GraphProto.initializer: array expected");l.initializer=[];for(var s=0;s<e.initializer.length;++s){if(typeof e.initializer[s]!="object")throw TypeError(".onnx.GraphProto.initializer: object expected");l.initializer[s]=a.onnx.TensorProto.fromObject(e.initializer[s])}}if(e.sparseInitializer){if(!Array.isArray(e.sparseInitializer))throw TypeError(".onnx.GraphProto.sparseInitializer: array expected");l.sparseInitializer=[];for(var s=0;s<e.sparseInitializer.length;++s){if(typeof e.sparseInitializer[s]!="object")throw TypeError(".onnx.GraphProto.sparseInitializer: object expected");l.sparseInitializer[s]=a.onnx.SparseTensorProto.fromObject(e.sparseInitializer[s])}}if(e.docString!=null&&(l.docString=String(e.docString)),e.input){if(!Array.isArray(e.input))throw TypeError(".onnx.GraphProto.input: array expected");l.input=[];for(var s=0;s<e.input.length;++s){if(typeof e.input[s]!="object")throw TypeError(".onnx.GraphProto.input: object expected");l.input[s]=a.onnx.ValueInfoProto.fromObject(e.input[s])}}if(e.output){if(!Array.isArray(e.output))throw TypeError(".onnx.GraphProto.output: array expected");l.output=[];for(var s=0;s<e.output.length;++s){if(typeof e.output[s]!="object")throw TypeError(".onnx.GraphProto.output: object expected");l.output[s]=a.onnx.ValueInfoProto.fromObject(e.output[s])}}if(e.valueInfo){if(!Array.isArray(e.valueInfo))throw TypeError(".onnx.GraphProto.valueInfo: array expected");l.valueInfo=[];for(var s=0;s<e.valueInfo.length;++s){if(typeof e.valueInfo[s]!="object")throw TypeError(".onnx.GraphProto.valueInfo: object expected");l.valueInfo[s]=a.onnx.ValueInfoProto.fromObject(e.valueInfo[s])}}if(e.quantizationAnnotation){if(!Array.isArray(e.quantizationAnnotation))throw TypeError(".onnx.GraphProto.quantizationAnnotation: array expected");l.quantizationAnnotation=[];for(var s=0;s<e.quantizationAnnotation.length;++s){if(typeof e.quantizationAnnotation[s]!="object")throw TypeError(".onnx.GraphProto.quantizationAnnotation: object expected");l.quantizationAnnotation[s]=a.onnx.TensorAnnotation.fromObject(e.quantizationAnnotation[s])}}return l},c.toObject=function(e,l){l||(l={});var s={};if((l.arrays||l.defaults)&&(s.node=[],s.initializer=[],s.input=[],s.output=[],s.valueInfo=[],s.quantizationAnnotation=[],s.sparseInitializer=[]),l.defaults&&(s.name="",s.docString=""),e.node&&e.node.length){s.node=[];for(var h=0;h<e.node.length;++h)s.node[h]=a.onnx.NodeProto.toObject(e.node[h],l)}if(e.name!=null&&e.hasOwnProperty("name")&&(s.name=e.name),e.initializer&&e.initializer.length){s.initializer=[];for(var h=0;h<e.initializer.length;++h)s.initializer[h]=a.onnx.TensorProto.toObject(e.initializer[h],l)}if(e.docString!=null&&e.hasOwnProperty("docString")&&(s.docString=e.docString),e.input&&e.input.length){s.input=[];for(var h=0;h<e.input.length;++h)s.input[h]=a.onnx.ValueInfoProto.toObject(e.input[h],l)}if(e.output&&e.output.length){s.output=[];for(var h=0;h<e.output.length;++h)s.output[h]=a.onnx.ValueInfoProto.toObject(e.output[h],l)}if(e.valueInfo&&e.valueInfo.length){s.valueInfo=[];for(var h=0;h<e.valueInfo.length;++h)s.valueInfo[h]=a.onnx.ValueInfoProto.toObject(e.valueInfo[h],l)}if(e.quantizationAnnotation&&e.quantizationAnnotation.length){s.quantizationAnnotation=[];for(var h=0;h<e.quantizationAnnotation.length;++h)s.quantizationAnnotation[h]=a.onnx.TensorAnnotation.toObject(e.quantizationAnnotation[h],l)}if(e.sparseInitializer&&e.sparseInitializer.length){s.sparseInitializer=[];for(var h=0;h<e.sparseInitializer.length;++h)s.sparseInitializer[h]=a.onnx.SparseTensorProto.toObject(e.sparseInitializer[h],l)}return s},c.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},c.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/onnx.GraphProto"},c}(),d.TensorProto=function(){function c(e){if(this.dims=[],this.floatData=[],this.int32Data=[],this.stringData=[],this.int64Data=[],this.externalData=[],this.doubleData=[],this.uint64Data=[],e)for(var l=Object.keys(e),s=0;s<l.length;++s)e[l[s]]!=null&&(this[l[s]]=e[l[s]])}return c.prototype.dims=n.emptyArray,c.prototype.dataType=0,c.prototype.segment=null,c.prototype.floatData=n.emptyArray,c.prototype.int32Data=n.emptyArray,c.prototype.stringData=n.emptyArray,c.prototype.int64Data=n.emptyArray,c.prototype.name="",c.prototype.docString="",c.prototype.rawData=n.newBuffer([]),c.prototype.externalData=n.emptyArray,c.prototype.dataLocation=0,c.prototype.doubleData=n.emptyArray,c.prototype.uint64Data=n.emptyArray,c.create=function(e){return new c(e)},c.encode=function(e,l){if(l||(l=u.create()),e.dims!=null&&e.dims.length){l.uint32(10).fork();for(var s=0;s<e.dims.length;++s)l.int64(e.dims[s]);l.ldelim()}if(e.dataType!=null&&Object.hasOwnProperty.call(e,"dataType")&&l.uint32(16).int32(e.dataType),e.segment!=null&&Object.hasOwnProperty.call(e,"segment")&&a.onnx.TensorProto.Segment.encode(e.segment,l.uint32(26).fork()).ldelim(),e.floatData!=null&&e.floatData.length){l.uint32(34).fork();for(var s=0;s<e.floatData.length;++s)l.float(e.floatData[s]);l.ldelim()}if(e.int32Data!=null&&e.int32Data.length){l.uint32(42).fork();for(var s=0;s<e.int32Data.length;++s)l.int32(e.int32Data[s]);l.ldelim()}if(e.stringData!=null&&e.stringData.length)for(var s=0;s<e.stringData.length;++s)l.uint32(50).bytes(e.stringData[s]);if(e.int64Data!=null&&e.int64Data.length){l.uint32(58).fork();for(var s=0;s<e.int64Data.length;++s)l.int64(e.int64Data[s]);l.ldelim()}if(e.name!=null&&Object.hasOwnProperty.call(e,"name")&&l.uint32(66).string(e.name),e.rawData!=null&&Object.hasOwnProperty.call(e,"rawData")&&l.uint32(74).bytes(e.rawData),e.doubleData!=null&&e.doubleData.length){l.uint32(82).fork();for(var s=0;s<e.doubleData.length;++s)l.double(e.doubleData[s]);l.ldelim()}if(e.uint64Data!=null&&e.uint64Data.length){l.uint32(90).fork();for(var s=0;s<e.uint64Data.length;++s)l.uint64(e.uint64Data[s]);l.ldelim()}if(e.docString!=null&&Object.hasOwnProperty.call(e,"docString")&&l.uint32(98).string(e.docString),e.externalData!=null&&e.externalData.length)for(var s=0;s<e.externalData.length;++s)a.onnx.StringStringEntryProto.encode(e.externalData[s],l.uint32(106).fork()).ldelim();return e.dataLocation!=null&&Object.hasOwnProperty.call(e,"dataLocation")&&l.uint32(112).int32(e.dataLocation),l},c.encodeDelimited=function(e,l){return this.encode(e,l).ldelim()},c.decode=function(e,l){e instanceof i||(e=i.create(e));for(var s=l===void 0?e.len:e.pos+l,h=new a.onnx.TensorProto;e.pos<s;){var f=e.uint32();switch(f>>>3){case 1:{if(h.dims&&h.dims.length||(h.dims=[]),(f&7)===2)for(var m=e.uint32()+e.pos;e.pos<m;)h.dims.push(e.int64());else h.dims.push(e.int64());break}case 2:{h.dataType=e.int32();break}case 3:{h.segment=a.onnx.TensorProto.Segment.decode(e,e.uint32());break}case 4:{if(h.floatData&&h.floatData.length||(h.floatData=[]),(f&7)===2)for(var m=e.uint32()+e.pos;e.pos<m;)h.floatData.push(e.float());else h.floatData.push(e.float());break}case 5:{if(h.int32Data&&h.int32Data.length||(h.int32Data=[]),(f&7)===2)for(var m=e.uint32()+e.pos;e.pos<m;)h.int32Data.push(e.int32());else h.int32Data.push(e.int32());break}case 6:{h.stringData&&h.stringData.length||(h.stringData=[]),h.stringData.push(e.bytes());break}case 7:{if(h.int64Data&&h.int64Data.length||(h.int64Data=[]),(f&7)===2)for(var m=e.uint32()+e.pos;e.pos<m;)h.int64Data.push(e.int64());else h.int64Data.push(e.int64());break}case 8:{h.name=e.string();break}case 12:{h.docString=e.string();break}case 9:{h.rawData=e.bytes();break}case 13:{h.externalData&&h.externalData.length||(h.externalData=[]),h.externalData.push(a.onnx.StringStringEntryProto.decode(e,e.uint32()));break}case 14:{h.dataLocation=e.int32();break}case 10:{if(h.doubleData&&h.doubleData.length||(h.doubleData=[]),(f&7)===2)for(var m=e.uint32()+e.pos;e.pos<m;)h.doubleData.push(e.double());else h.doubleData.push(e.double());break}case 11:{if(h.uint64Data&&h.uint64Data.length||(h.uint64Data=[]),(f&7)===2)for(var m=e.uint32()+e.pos;e.pos<m;)h.uint64Data.push(e.uint64());else h.uint64Data.push(e.uint64());break}default:e.skipType(f&7);break}}return h},c.decodeDelimited=function(e){return e instanceof i||(e=new i(e)),this.decode(e,e.uint32())},c.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.dims!=null&&e.hasOwnProperty("dims")){if(!Array.isArray(e.dims))return"dims: array expected";for(var l=0;l<e.dims.length;++l)if(!n.isInteger(e.dims[l])&&!(e.dims[l]&&n.isInteger(e.dims[l].low)&&n.isInteger(e.dims[l].high)))return"dims: integer|Long[] expected"}if(e.dataType!=null&&e.hasOwnProperty("dataType")&&!n.isInteger(e.dataType))return"dataType: integer expected";if(e.segment!=null&&e.hasOwnProperty("segment")){var s=a.onnx.TensorProto.Segment.verify(e.segment);if(s)return"segment."+s}if(e.floatData!=null&&e.hasOwnProperty("floatData")){if(!Array.isArray(e.floatData))return"floatData: array expected";for(var l=0;l<e.floatData.length;++l)if(typeof e.floatData[l]!="number")return"floatData: number[] expected"}if(e.int32Data!=null&&e.hasOwnProperty("int32Data")){if(!Array.isArray(e.int32Data))return"int32Data: array expected";for(var l=0;l<e.int32Data.length;++l)if(!n.isInteger(e.int32Data[l]))return"int32Data: integer[] expected"}if(e.stringData!=null&&e.hasOwnProperty("stringData")){if(!Array.isArray(e.stringData))return"stringData: array expected";for(var l=0;l<e.stringData.length;++l)if(!(e.stringData[l]&&typeof e.stringData[l].length=="number"||n.isString(e.stringData[l])))return"stringData: buffer[] expected"}if(e.int64Data!=null&&e.hasOwnProperty("int64Data")){if(!Array.isArray(e.int64Data))return"int64Data: array expected";for(var l=0;l<e.int64Data.length;++l)if(!n.isInteger(e.int64Data[l])&&!(e.int64Data[l]&&n.isInteger(e.int64Data[l].low)&&n.isInteger(e.int64Data[l].high)))return"int64Data: integer|Long[] expected"}if(e.name!=null&&e.hasOwnProperty("name")&&!n.isString(e.name))return"name: string expected";if(e.docString!=null&&e.hasOwnProperty("docString")&&!n.isString(e.docString))return"docString: string expected";if(e.rawData!=null&&e.hasOwnProperty("rawData")&&!(e.rawData&&typeof e.rawData.length=="number"||n.isString(e.rawData)))return"rawData: buffer expected";if(e.externalData!=null&&e.hasOwnProperty("externalData")){if(!Array.isArray(e.externalData))return"externalData: array expected";for(var l=0;l<e.externalData.length;++l){var s=a.onnx.StringStringEntryProto.verify(e.externalData[l]);if(s)return"externalData."+s}}if(e.dataLocation!=null&&e.hasOwnProperty("dataLocation"))switch(e.dataLocation){default:return"dataLocation: enum value expected";case 0:case 1:break}if(e.doubleData!=null&&e.hasOwnProperty("doubleData")){if(!Array.isArray(e.doubleData))return"doubleData: array expected";for(var l=0;l<e.doubleData.length;++l)if(typeof e.doubleData[l]!="number")return"doubleData: number[] expected"}if(e.uint64Data!=null&&e.hasOwnProperty("uint64Data")){if(!Array.isArray(e.uint64Data))return"uint64Data: array expected";for(var l=0;l<e.uint64Data.length;++l)if(!n.isInteger(e.uint64Data[l])&&!(e.uint64Data[l]&&n.isInteger(e.uint64Data[l].low)&&n.isInteger(e.uint64Data[l].high)))return"uint64Data: integer|Long[] expected"}return null},c.fromObject=function(e){if(e instanceof a.onnx.TensorProto)return e;var l=new a.onnx.TensorProto;if(e.dims){if(!Array.isArray(e.dims))throw TypeError(".onnx.TensorProto.dims: array expected");l.dims=[];for(var s=0;s<e.dims.length;++s)n.Long?(l.dims[s]=n.Long.fromValue(e.dims[s])).unsigned=!1:typeof e.dims[s]=="string"?l.dims[s]=parseInt(e.dims[s],10):typeof e.dims[s]=="number"?l.dims[s]=e.dims[s]:typeof e.dims[s]=="object"&&(l.dims[s]=new n.LongBits(e.dims[s].low>>>0,e.dims[s].high>>>0).toNumber())}if(e.dataType!=null&&(l.dataType=e.dataType|0),e.segment!=null){if(typeof e.segment!="object")throw TypeError(".onnx.TensorProto.segment: object expected");l.segment=a.onnx.TensorProto.Segment.fromObject(e.segment)}if(e.floatData){if(!Array.isArray(e.floatData))throw TypeError(".onnx.TensorProto.floatData: array expected");l.floatData=[];for(var s=0;s<e.floatData.length;++s)l.floatData[s]=Number(e.floatData[s])}if(e.int32Data){if(!Array.isArray(e.int32Data))throw TypeError(".onnx.TensorProto.int32Data: array expected");l.int32Data=[];for(var s=0;s<e.int32Data.length;++s)l.int32Data[s]=e.int32Data[s]|0}if(e.stringData){if(!Array.isArray(e.stringData))throw TypeError(".onnx.TensorProto.stringData: array expected");l.stringData=[];for(var s=0;s<e.stringData.length;++s)typeof e.stringData[s]=="string"?n.base64.decode(e.stringData[s],l.stringData[s]=n.newBuffer(n.base64.length(e.stringData[s])),0):e.stringData[s].length>=0&&(l.stringData[s]=e.stringData[s])}if(e.int64Data){if(!Array.isArray(e.int64Data))throw TypeError(".onnx.TensorProto.int64Data: array expected");l.int64Data=[];for(var s=0;s<e.int64Data.length;++s)n.Long?(l.int64Data[s]=n.Long.fromValue(e.int64Data[s])).unsigned=!1:typeof e.int64Data[s]=="string"?l.int64Data[s]=parseInt(e.int64Data[s],10):typeof e.int64Data[s]=="number"?l.int64Data[s]=e.int64Data[s]:typeof e.int64Data[s]=="object"&&(l.int64Data[s]=new n.LongBits(e.int64Data[s].low>>>0,e.int64Data[s].high>>>0).toNumber())}if(e.name!=null&&(l.name=String(e.name)),e.docString!=null&&(l.docString=String(e.docString)),e.rawData!=null&&(typeof e.rawData=="string"?n.base64.decode(e.rawData,l.rawData=n.newBuffer(n.base64.length(e.rawData)),0):e.rawData.length>=0&&(l.rawData=e.rawData)),e.externalData){if(!Array.isArray(e.externalData))throw TypeError(".onnx.TensorProto.externalData: array expected");l.externalData=[];for(var s=0;s<e.externalData.length;++s){if(typeof e.externalData[s]!="object")throw TypeError(".onnx.TensorProto.externalData: object expected");l.externalData[s]=a.onnx.StringStringEntryProto.fromObject(e.externalData[s])}}switch(e.dataLocation){default:if(typeof e.dataLocation=="number"){l.dataLocation=e.dataLocation;break}break;case"DEFAULT":case 0:l.dataLocation=0;break;case"EXTERNAL":case 1:l.dataLocation=1;break}if(e.doubleData){if(!Array.isArray(e.doubleData))throw TypeError(".onnx.TensorProto.doubleData: array expected");l.doubleData=[];for(var s=0;s<e.doubleData.length;++s)l.doubleData[s]=Number(e.doubleData[s])}if(e.uint64Data){if(!Array.isArray(e.uint64Data))throw TypeError(".onnx.TensorProto.uint64Data: array expected");l.uint64Data=[];for(var s=0;s<e.uint64Data.length;++s)n.Long?(l.uint64Data[s]=n.Long.fromValue(e.uint64Data[s])).unsigned=!0:typeof e.uint64Data[s]=="string"?l.uint64Data[s]=parseInt(e.uint64Data[s],10):typeof e.uint64Data[s]=="number"?l.uint64Data[s]=e.uint64Data[s]:typeof e.uint64Data[s]=="object"&&(l.uint64Data[s]=new n.LongBits(e.uint64Data[s].low>>>0,e.uint64Data[s].high>>>0).toNumber(!0))}return l},c.toObject=function(e,l){l||(l={});var s={};if((l.arrays||l.defaults)&&(s.dims=[],s.floatData=[],s.int32Data=[],s.stringData=[],s.int64Data=[],s.doubleData=[],s.uint64Data=[],s.externalData=[]),l.defaults&&(s.dataType=0,s.segment=null,s.name="",l.bytes===String?s.rawData="":(s.rawData=[],l.bytes!==Array&&(s.rawData=n.newBuffer(s.rawData))),s.docString="",s.dataLocation=l.enums===String?"DEFAULT":0),e.dims&&e.dims.length){s.dims=[];for(var h=0;h<e.dims.length;++h)typeof e.dims[h]=="number"?s.dims[h]=l.longs===String?String(e.dims[h]):e.dims[h]:s.dims[h]=l.longs===String?n.Long.prototype.toString.call(e.dims[h]):l.longs===Number?new n.LongBits(e.dims[h].low>>>0,e.dims[h].high>>>0).toNumber():e.dims[h]}if(e.dataType!=null&&e.hasOwnProperty("dataType")&&(s.dataType=e.dataType),e.segment!=null&&e.hasOwnProperty("segment")&&(s.segment=a.onnx.TensorProto.Segment.toObject(e.segment,l)),e.floatData&&e.floatData.length){s.floatData=[];for(var h=0;h<e.floatData.length;++h)s.floatData[h]=l.json&&!isFinite(e.floatData[h])?String(e.floatData[h]):e.floatData[h]}if(e.int32Data&&e.int32Data.length){s.int32Data=[];for(var h=0;h<e.int32Data.length;++h)s.int32Data[h]=e.int32Data[h]}if(e.stringData&&e.stringData.length){s.stringData=[];for(var h=0;h<e.stringData.length;++h)s.stringData[h]=l.bytes===String?n.base64.encode(e.stringData[h],0,e.stringData[h].length):l.bytes===Array?Array.prototype.slice.call(e.stringData[h]):e.stringData[h]}if(e.int64Data&&e.int64Data.length){s.int64Data=[];for(var h=0;h<e.int64Data.length;++h)typeof e.int64Data[h]=="number"?s.int64Data[h]=l.longs===String?String(e.int64Data[h]):e.int64Data[h]:s.int64Data[h]=l.longs===String?n.Long.prototype.toString.call(e.int64Data[h]):l.longs===Number?new n.LongBits(e.int64Data[h].low>>>0,e.int64Data[h].high>>>0).toNumber():e.int64Data[h]}if(e.name!=null&&e.hasOwnProperty("name")&&(s.name=e.name),e.rawData!=null&&e.hasOwnProperty("rawData")&&(s.rawData=l.bytes===String?n.base64.encode(e.rawData,0,e.rawData.length):l.bytes===Array?Array.prototype.slice.call(e.rawData):e.rawData),e.doubleData&&e.doubleData.length){s.doubleData=[];for(var h=0;h<e.doubleData.length;++h)s.doubleData[h]=l.json&&!isFinite(e.doubleData[h])?String(e.doubleData[h]):e.doubleData[h]}if(e.uint64Data&&e.uint64Data.length){s.uint64Data=[];for(var h=0;h<e.uint64Data.length;++h)typeof e.uint64Data[h]=="number"?s.uint64Data[h]=l.longs===String?String(e.uint64Data[h]):e.uint64Data[h]:s.uint64Data[h]=l.longs===String?n.Long.prototype.toString.call(e.uint64Data[h]):l.longs===Number?new n.LongBits(e.uint64Data[h].low>>>0,e.uint64Data[h].high>>>0).toNumber(!0):e.uint64Data[h]}if(e.docString!=null&&e.hasOwnProperty("docString")&&(s.docString=e.docString),e.externalData&&e.externalData.length){s.externalData=[];for(var h=0;h<e.externalData.length;++h)s.externalData[h]=a.onnx.StringStringEntryProto.toObject(e.externalData[h],l)}return e.dataLocation!=null&&e.hasOwnProperty("dataLocation")&&(s.dataLocation=l.enums===String?a.onnx.TensorProto.DataLocation[e.dataLocation]===void 0?e.dataLocation:a.onnx.TensorProto.DataLocation[e.dataLocation]:e.dataLocation),s},c.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},c.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/onnx.TensorProto"},c.DataType=function(){var e={},l=Object.create(e);return l[e[0]="UNDEFINED"]=0,l[e[1]="FLOAT"]=1,l[e[2]="UINT8"]=2,l[e[3]="INT8"]=3,l[e[4]="UINT16"]=4,l[e[5]="INT16"]=5,l[e[6]="INT32"]=6,l[e[7]="INT64"]=7,l[e[8]="STRING"]=8,l[e[9]="BOOL"]=9,l[e[10]="FLOAT16"]=10,l[e[11]="DOUBLE"]=11,l[e[12]="UINT32"]=12,l[e[13]="UINT64"]=13,l[e[14]="COMPLEX64"]=14,l[e[15]="COMPLEX128"]=15,l[e[16]="BFLOAT16"]=16,l[e[17]="FLOAT8E4M3FN"]=17,l[e[18]="FLOAT8E4M3FNUZ"]=18,l[e[19]="FLOAT8E5M2"]=19,l[e[20]="FLOAT8E5M2FNUZ"]=20,l}(),c.Segment=function(){function e(l){if(l)for(var s=Object.keys(l),h=0;h<s.length;++h)l[s[h]]!=null&&(this[s[h]]=l[s[h]])}return e.prototype.begin=n.Long?n.Long.fromBits(0,0,!1):0,e.prototype.end=n.Long?n.Long.fromBits(0,0,!1):0,e.create=function(l){return new e(l)},e.encode=function(l,s){return s||(s=u.create()),l.begin!=null&&Object.hasOwnProperty.call(l,"begin")&&s.uint32(8).int64(l.begin),l.end!=null&&Object.hasOwnProperty.call(l,"end")&&s.uint32(16).int64(l.end),s},e.encodeDelimited=function(l,s){return this.encode(l,s).ldelim()},e.decode=function(l,s){l instanceof i||(l=i.create(l));for(var h=s===void 0?l.len:l.pos+s,f=new a.onnx.TensorProto.Segment;l.pos<h;){var m=l.uint32();switch(m>>>3){case 1:{f.begin=l.int64();break}case 2:{f.end=l.int64();break}default:l.skipType(m&7);break}}return f},e.decodeDelimited=function(l){return l instanceof i||(l=new i(l)),this.decode(l,l.uint32())},e.verify=function(l){return typeof l!="object"||l===null?"object expected":l.begin!=null&&l.hasOwnProperty("begin")&&!n.isInteger(l.begin)&&!(l.begin&&n.isInteger(l.begin.low)&&n.isInteger(l.begin.high))?"begin: integer|Long expected":l.end!=null&&l.hasOwnProperty("end")&&!n.isInteger(l.end)&&!(l.end&&n.isInteger(l.end.low)&&n.isInteger(l.end.high))?"end: integer|Long expected":null},e.fromObject=function(l){if(l instanceof a.onnx.TensorProto.Segment)return l;var s=new a.onnx.TensorProto.Segment;return l.begin!=null&&(n.Long?(s.begin=n.Long.fromValue(l.begin)).unsigned=!1:typeof l.begin=="string"?s.begin=parseInt(l.begin,10):typeof l.begin=="number"?s.begin=l.begin:typeof l.begin=="object"&&(s.begin=new n.LongBits(l.begin.low>>>0,l.begin.high>>>0).toNumber())),l.end!=null&&(n.Long?(s.end=n.Long.fromValue(l.end)).unsigned=!1:typeof l.end=="string"?s.end=parseInt(l.end,10):typeof l.end=="number"?s.end=l.end:typeof l.end=="object"&&(s.end=new n.LongBits(l.end.low>>>0,l.end.high>>>0).toNumber())),s},e.toObject=function(l,s){s||(s={});var h={};if(s.defaults){if(n.Long){var f=new n.Long(0,0,!1);h.begin=s.longs===String?f.toString():s.longs===Number?f.toNumber():f}else h.begin=s.longs===String?"0":0;if(n.Long){var f=new n.Long(0,0,!1);h.end=s.longs===String?f.toString():s.longs===Number?f.toNumber():f}else h.end=s.longs===String?"0":0}return l.begin!=null&&l.hasOwnProperty("begin")&&(typeof l.begin=="number"?h.begin=s.longs===String?String(l.begin):l.begin:h.begin=s.longs===String?n.Long.prototype.toString.call(l.begin):s.longs===Number?new n.LongBits(l.begin.low>>>0,l.begin.high>>>0).toNumber():l.begin),l.end!=null&&l.hasOwnProperty("end")&&(typeof l.end=="number"?h.end=s.longs===String?String(l.end):l.end:h.end=s.longs===String?n.Long.prototype.toString.call(l.end):s.longs===Number?new n.LongBits(l.end.low>>>0,l.end.high>>>0).toNumber():l.end),h},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},e.getTypeUrl=function(l){return l===void 0&&(l="type.googleapis.com"),l+"/onnx.TensorProto.Segment"},e}(),c.DataLocation=function(){var e={},l=Object.create(e);return l[e[0]="DEFAULT"]=0,l[e[1]="EXTERNAL"]=1,l}(),c}(),d.SparseTensorProto=function(){function c(e){if(this.dims=[],e)for(var l=Object.keys(e),s=0;s<l.length;++s)e[l[s]]!=null&&(this[l[s]]=e[l[s]])}return c.prototype.values=null,c.prototype.indices=null,c.prototype.dims=n.emptyArray,c.create=function(e){return new c(e)},c.encode=function(e,l){if(l||(l=u.create()),e.values!=null&&Object.hasOwnProperty.call(e,"values")&&a.onnx.TensorProto.encode(e.values,l.uint32(10).fork()).ldelim(),e.indices!=null&&Object.hasOwnProperty.call(e,"indices")&&a.onnx.TensorProto.encode(e.indices,l.uint32(18).fork()).ldelim(),e.dims!=null&&e.dims.length){l.uint32(26).fork();for(var s=0;s<e.dims.length;++s)l.int64(e.dims[s]);l.ldelim()}return l},c.encodeDelimited=function(e,l){return this.encode(e,l).ldelim()},c.decode=function(e,l){e instanceof i||(e=i.create(e));for(var s=l===void 0?e.len:e.pos+l,h=new a.onnx.SparseTensorProto;e.pos<s;){var f=e.uint32();switch(f>>>3){case 1:{h.values=a.onnx.TensorProto.decode(e,e.uint32());break}case 2:{h.indices=a.onnx.TensorProto.decode(e,e.uint32());break}case 3:{if(h.dims&&h.dims.length||(h.dims=[]),(f&7)===2)for(var m=e.uint32()+e.pos;e.pos<m;)h.dims.push(e.int64());else h.dims.push(e.int64());break}default:e.skipType(f&7);break}}return h},c.decodeDelimited=function(e){return e instanceof i||(e=new i(e)),this.decode(e,e.uint32())},c.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.values!=null&&e.hasOwnProperty("values")){var l=a.onnx.TensorProto.verify(e.values);if(l)return"values."+l}if(e.indices!=null&&e.hasOwnProperty("indices")){var l=a.onnx.TensorProto.verify(e.indices);if(l)return"indices."+l}if(e.dims!=null&&e.hasOwnProperty("dims")){if(!Array.isArray(e.dims))return"dims: array expected";for(var s=0;s<e.dims.length;++s)if(!n.isInteger(e.dims[s])&&!(e.dims[s]&&n.isInteger(e.dims[s].low)&&n.isInteger(e.dims[s].high)))return"dims: integer|Long[] expected"}return null},c.fromObject=function(e){if(e instanceof a.onnx.SparseTensorProto)return e;var l=new a.onnx.SparseTensorProto;if(e.values!=null){if(typeof e.values!="object")throw TypeError(".onnx.SparseTensorProto.values: object expected");l.values=a.onnx.TensorProto.fromObject(e.values)}if(e.indices!=null){if(typeof e.indices!="object")throw TypeError(".onnx.SparseTensorProto.indices: object expected");l.indices=a.onnx.TensorProto.fromObject(e.indices)}if(e.dims){if(!Array.isArray(e.dims))throw TypeError(".onnx.SparseTensorProto.dims: array expected");l.dims=[];for(var s=0;s<e.dims.length;++s)n.Long?(l.dims[s]=n.Long.fromValue(e.dims[s])).unsigned=!1:typeof e.dims[s]=="string"?l.dims[s]=parseInt(e.dims[s],10):typeof e.dims[s]=="number"?l.dims[s]=e.dims[s]:typeof e.dims[s]=="object"&&(l.dims[s]=new n.LongBits(e.dims[s].low>>>0,e.dims[s].high>>>0).toNumber())}return l},c.toObject=function(e,l){l||(l={});var s={};if((l.arrays||l.defaults)&&(s.dims=[]),l.defaults&&(s.values=null,s.indices=null),e.values!=null&&e.hasOwnProperty("values")&&(s.values=a.onnx.TensorProto.toObject(e.values,l)),e.indices!=null&&e.hasOwnProperty("indices")&&(s.indices=a.onnx.TensorProto.toObject(e.indices,l)),e.dims&&e.dims.length){s.dims=[];for(var h=0;h<e.dims.length;++h)typeof e.dims[h]=="number"?s.dims[h]=l.longs===String?String(e.dims[h]):e.dims[h]:s.dims[h]=l.longs===String?n.Long.prototype.toString.call(e.dims[h]):l.longs===Number?new n.LongBits(e.dims[h].low>>>0,e.dims[h].high>>>0).toNumber():e.dims[h]}return s},c.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},c.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/onnx.SparseTensorProto"},c}(),d.TensorShapeProto=function(){function c(e){if(this.dim=[],e)for(var l=Object.keys(e),s=0;s<l.length;++s)e[l[s]]!=null&&(this[l[s]]=e[l[s]])}return c.prototype.dim=n.emptyArray,c.create=function(e){return new c(e)},c.encode=function(e,l){if(l||(l=u.create()),e.dim!=null&&e.dim.length)for(var s=0;s<e.dim.length;++s)a.onnx.TensorShapeProto.Dimension.encode(e.dim[s],l.uint32(10).fork()).ldelim();return l},c.encodeDelimited=function(e,l){return this.encode(e,l).ldelim()},c.decode=function(e,l){e instanceof i||(e=i.create(e));for(var s=l===void 0?e.len:e.pos+l,h=new a.onnx.TensorShapeProto;e.pos<s;){var f=e.uint32();switch(f>>>3){case 1:{h.dim&&h.dim.length||(h.dim=[]),h.dim.push(a.onnx.TensorShapeProto.Dimension.decode(e,e.uint32()));break}default:e.skipType(f&7);break}}return h},c.decodeDelimited=function(e){return e instanceof i||(e=new i(e)),this.decode(e,e.uint32())},c.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.dim!=null&&e.hasOwnProperty("dim")){if(!Array.isArray(e.dim))return"dim: array expected";for(var l=0;l<e.dim.length;++l){var s=a.onnx.TensorShapeProto.Dimension.verify(e.dim[l]);if(s)return"dim."+s}}return null},c.fromObject=function(e){if(e instanceof a.onnx.TensorShapeProto)return e;var l=new a.onnx.TensorShapeProto;if(e.dim){if(!Array.isArray(e.dim))throw TypeError(".onnx.TensorShapeProto.dim: array expected");l.dim=[];for(var s=0;s<e.dim.length;++s){if(typeof e.dim[s]!="object")throw TypeError(".onnx.TensorShapeProto.dim: object expected");l.dim[s]=a.onnx.TensorShapeProto.Dimension.fromObject(e.dim[s])}}return l},c.toObject=function(e,l){l||(l={});var s={};if((l.arrays||l.defaults)&&(s.dim=[]),e.dim&&e.dim.length){s.dim=[];for(var h=0;h<e.dim.length;++h)s.dim[h]=a.onnx.TensorShapeProto.Dimension.toObject(e.dim[h],l)}return s},c.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},c.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/onnx.TensorShapeProto"},c.Dimension=function(){function e(s){if(s)for(var h=Object.keys(s),f=0;f<h.length;++f)s[h[f]]!=null&&(this[h[f]]=s[h[f]])}e.prototype.dimValue=null,e.prototype.dimParam=null,e.prototype.denotation="";var l;return Object.defineProperty(e.prototype,"value",{get:n.oneOfGetter(l=["dimValue","dimParam"]),set:n.oneOfSetter(l)}),e.create=function(s){return new e(s)},e.encode=function(s,h){return h||(h=u.create()),s.dimValue!=null&&Object.hasOwnProperty.call(s,"dimValue")&&h.uint32(8).int64(s.dimValue),s.dimParam!=null&&Object.hasOwnProperty.call(s,"dimParam")&&h.uint32(18).string(s.dimParam),s.denotation!=null&&Object.hasOwnProperty.call(s,"denotation")&&h.uint32(26).string(s.denotation),h},e.encodeDelimited=function(s,h){return this.encode(s,h).ldelim()},e.decode=function(s,h){s instanceof i||(s=i.create(s));for(var f=h===void 0?s.len:s.pos+h,m=new a.onnx.TensorShapeProto.Dimension;s.pos<f;){var v=s.uint32();switch(v>>>3){case 1:{m.dimValue=s.int64();break}case 2:{m.dimParam=s.string();break}case 3:{m.denotation=s.string();break}default:s.skipType(v&7);break}}return m},e.decodeDelimited=function(s){return s instanceof i||(s=new i(s)),this.decode(s,s.uint32())},e.verify=function(s){if(typeof s!="object"||s===null)return"object expected";var h={};if(s.dimValue!=null&&s.hasOwnProperty("dimValue")&&(h.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(h.value===1)return"value: multiple values";if(h.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},e.fromObject=function(s){if(s instanceof a.onnx.TensorShapeProto.Dimension)return s;var h=new a.onnx.TensorShapeProto.Dimension;return s.dimValue!=null&&(n.Long?(h.dimValue=n.Long.fromValue(s.dimValue)).unsigned=!1:typeof s.dimValue=="string"?h.dimValue=parseInt(s.dimValue,10):typeof s.dimValue=="number"?h.dimValue=s.dimValue:typeof s.dimValue=="object"&&(h.dimValue=new n.LongBits(s.dimValue.low>>>0,s.dimValue.high>>>0).toNumber())),s.dimParam!=null&&(h.dimParam=String(s.dimParam)),s.denotation!=null&&(h.denotation=String(s.denotation)),h},e.toObject=function(s,h){h||(h={});var f={};return h.defaults&&(f.denotation=""),s.dimValue!=null&&s.hasOwnProperty("dimValue")&&(typeof s.dimValue=="number"?f.dimValue=h.longs===String?String(s.dimValue):s.dimValue:f.dimValue=h.longs===String?n.Long.prototype.toString.call(s.dimValue):h.longs===Number?new n.LongBits(s.dimValue.low>>>0,s.dimValue.high>>>0).toNumber():s.dimValue,h.oneofs&&(f.value="dimValue")),s.dimParam!=null&&s.hasOwnProperty("dimParam")&&(f.dimParam=s.dimParam,h.oneofs&&(f.value="dimParam")),s.denotation!=null&&s.hasOwnProperty("denotation")&&(f.denotation=s.denotation),f},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},e.getTypeUrl=function(s){return s===void 0&&(s="type.googleapis.com"),s+"/onnx.TensorShapeProto.Dimension"},e}(),c}(),d.TypeProto=function(){function c(l){if(l)for(var s=Object.keys(l),h=0;h<s.length;++h)l[s[h]]!=null&&(this[s[h]]=l[s[h]])}c.prototype.tensorType=null,c.prototype.sequenceType=null,c.prototype.mapType=null,c.prototype.optionalType=null,c.prototype.sparseTensorType=null,c.prototype.denotation="";var e;return Object.defineProperty(c.prototype,"value",{get:n.oneOfGetter(e=["tensorType","sequenceType","mapType","optionalType","sparseTensorType"]),set:n.oneOfSetter(e)}),c.create=function(l){return new c(l)},c.encode=function(l,s){return s||(s=u.create()),l.tensorType!=null&&Object.hasOwnProperty.call(l,"tensorType")&&a.onnx.TypeProto.Tensor.encode(l.tensorType,s.uint32(10).fork()).ldelim(),l.sequenceType!=null&&Object.hasOwnProperty.call(l,"sequenceType")&&a.onnx.TypeProto.Sequence.encode(l.sequenceType,s.uint32(34).fork()).ldelim(),l.mapType!=null&&Object.hasOwnProperty.call(l,"mapType")&&a.onnx.TypeProto.Map.encode(l.mapType,s.uint32(42).fork()).ldelim(),l.denotation!=null&&Object.hasOwnProperty.call(l,"denotation")&&s.uint32(50).string(l.denotation),l.sparseTensorType!=null&&Object.hasOwnProperty.call(l,"sparseTensorType")&&a.onnx.TypeProto.SparseTensor.encode(l.sparseTensorType,s.uint32(66).fork()).ldelim(),l.optionalType!=null&&Object.hasOwnProperty.call(l,"optionalType")&&a.onnx.TypeProto.Optional.encode(l.optionalType,s.uint32(74).fork()).ldelim(),s},c.encodeDelimited=function(l,s){return this.encode(l,s).ldelim()},c.decode=function(l,s){l instanceof i||(l=i.create(l));for(var h=s===void 0?l.len:l.pos+s,f=new a.onnx.TypeProto;l.pos<h;){var m=l.uint32();switch(m>>>3){case 1:{f.tensorType=a.onnx.TypeProto.Tensor.decode(l,l.uint32());break}case 4:{f.sequenceType=a.onnx.TypeProto.Sequence.decode(l,l.uint32());break}case 5:{f.mapType=a.onnx.TypeProto.Map.decode(l,l.uint32());break}case 9:{f.optionalType=a.onnx.TypeProto.Optional.decode(l,l.uint32());break}case 8:{f.sparseTensorType=a.onnx.TypeProto.SparseTensor.decode(l,l.uint32());break}case 6:{f.denotation=l.string();break}default:l.skipType(m&7);break}}return f},c.decodeDelimited=function(l){return l instanceof i||(l=new i(l)),this.decode(l,l.uint32())},c.verify=function(l){if(typeof l!="object"||l===null)return"object expected";var s={};if(l.tensorType!=null&&l.hasOwnProperty("tensorType")){s.value=1;{var h=a.onnx.TypeProto.Tensor.verify(l.tensorType);if(h)return"tensorType."+h}}if(l.sequenceType!=null&&l.hasOwnProperty("sequenceType")){if(s.value===1)return"value: multiple values";s.value=1;{var h=a.onnx.TypeProto.Sequence.verify(l.sequenceType);if(h)return"sequenceType."+h}}if(l.mapType!=null&&l.hasOwnProperty("mapType")){if(s.value===1)return"value: multiple values";s.value=1;{var h=a.onnx.TypeProto.Map.verify(l.mapType);if(h)return"mapType."+h}}if(l.optionalType!=null&&l.hasOwnProperty("optionalType")){if(s.value===1)return"value: multiple values";s.value=1;{var h=a.onnx.TypeProto.Optional.verify(l.optionalType);if(h)return"optionalType."+h}}if(l.sparseTensorType!=null&&l.hasOwnProperty("sparseTensorType")){if(s.value===1)return"value: multiple values";s.value=1;{var h=a.onnx.TypeProto.SparseTensor.verify(l.sparseTensorType);if(h)return"sparseTensorType."+h}}return l.denotation!=null&&l.hasOwnProperty("denotation")&&!n.isString(l.denotation)?"denotation: string expected":null},c.fromObject=function(l){if(l instanceof a.onnx.TypeProto)return l;var s=new a.onnx.TypeProto;if(l.tensorType!=null){if(typeof l.tensorType!="object")throw TypeError(".onnx.TypeProto.tensorType: object expected");s.tensorType=a.onnx.TypeProto.Tensor.fromObject(l.tensorType)}if(l.sequenceType!=null){if(typeof l.sequenceType!="object")throw TypeError(".onnx.TypeProto.sequenceType: object expected");s.sequenceType=a.onnx.TypeProto.Sequence.fromObject(l.sequenceType)}if(l.mapType!=null){if(typeof l.mapType!="object")throw TypeError(".onnx.TypeProto.mapType: object expected");s.mapType=a.onnx.TypeProto.Map.fromObject(l.mapType)}if(l.optionalType!=null){if(typeof l.optionalType!="object")throw TypeError(".onnx.TypeProto.optionalType: object expected");s.optionalType=a.onnx.TypeProto.Optional.fromObject(l.optionalType)}if(l.sparseTensorType!=null){if(typeof l.sparseTensorType!="object")throw TypeError(".onnx.TypeProto.sparseTensorType: object expected");s.sparseTensorType=a.onnx.TypeProto.SparseTensor.fromObject(l.sparseTensorType)}return l.denotation!=null&&(s.denotation=String(l.denotation)),s},c.toObject=function(l,s){s||(s={});var h={};return s.defaults&&(h.denotation=""),l.tensorType!=null&&l.hasOwnProperty("tensorType")&&(h.tensorType=a.onnx.TypeProto.Tensor.toObject(l.tensorType,s),s.oneofs&&(h.value="tensorType")),l.sequenceType!=null&&l.hasOwnProperty("sequenceType")&&(h.sequenceType=a.onnx.TypeProto.Sequence.toObject(l.sequenceType,s),s.oneofs&&(h.value="sequenceType")),l.mapType!=null&&l.hasOwnProperty("mapType")&&(h.mapType=a.onnx.TypeProto.Map.toObject(l.mapType,s),s.oneofs&&(h.value="mapType")),l.denotation!=null&&l.hasOwnProperty("denotation")&&(h.denotation=l.denotation),l.sparseTensorType!=null&&l.hasOwnProperty("sparseTensorType")&&(h.sparseTensorType=a.onnx.TypeProto.SparseTensor.toObject(l.sparseTensorType,s),s.oneofs&&(h.value="sparseTensorType")),l.optionalType!=null&&l.hasOwnProperty("optionalType")&&(h.optionalType=a.onnx.TypeProto.Optional.toObject(l.optionalType,s),s.oneofs&&(h.value="optionalType")),h},c.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},c.getTypeUrl=function(l){return l===void 0&&(l="type.googleapis.com"),l+"/onnx.TypeProto"},c.Tensor=function(){function l(s){if(s)for(var h=Object.keys(s),f=0;f<h.length;++f)s[h[f]]!=null&&(this[h[f]]=s[h[f]])}return l.prototype.elemType=0,l.prototype.shape=null,l.create=function(s){return new l(s)},l.encode=function(s,h){return h||(h=u.create()),s.elemType!=null&&Object.hasOwnProperty.call(s,"elemType")&&h.uint32(8).int32(s.elemType),s.shape!=null&&Object.hasOwnProperty.call(s,"shape")&&a.onnx.TensorShapeProto.encode(s.shape,h.uint32(18).fork()).ldelim(),h},l.encodeDelimited=function(s,h){return this.encode(s,h).ldelim()},l.decode=function(s,h){s instanceof i||(s=i.create(s));for(var f=h===void 0?s.len:s.pos+h,m=new a.onnx.TypeProto.Tensor;s.pos<f;){var v=s.uint32();switch(v>>>3){case 1:{m.elemType=s.int32();break}case 2:{m.shape=a.onnx.TensorShapeProto.decode(s,s.uint32());break}default:s.skipType(v&7);break}}return m},l.decodeDelimited=function(s){return s instanceof i||(s=new i(s)),this.decode(s,s.uint32())},l.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 h=a.onnx.TensorShapeProto.verify(s.shape);if(h)return"shape."+h}return null},l.fromObject=function(s){if(s instanceof a.onnx.TypeProto.Tensor)return s;var h=new a.onnx.TypeProto.Tensor;if(s.elemType!=null&&(h.elemType=s.elemType|0),s.shape!=null){if(typeof s.shape!="object")throw TypeError(".onnx.TypeProto.Tensor.shape: object expected");h.shape=a.onnx.TensorShapeProto.fromObject(s.shape)}return h},l.toObject=function(s,h){h||(h={});var f={};return h.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=a.onnx.TensorShapeProto.toObject(s.shape,h)),f},l.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},l.getTypeUrl=function(s){return s===void 0&&(s="type.googleapis.com"),s+"/onnx.TypeProto.Tensor"},l}(),c.Sequence=function(){function l(s){if(s)for(var h=Object.keys(s),f=0;f<h.length;++f)s[h[f]]!=null&&(this[h[f]]=s[h[f]])}return l.prototype.elemType=null,l.create=function(s){return new l(s)},l.encode=function(s,h){return h||(h=u.create()),s.elemType!=null&&Object.hasOwnProperty.call(s,"elemType")&&a.onnx.TypeProto.encode(s.elemType,h.uint32(10).fork()).ldelim(),h},l.encodeDelimited=function(s,h){return this.encode(s,h).ldelim()},l.decode=function(s,h){s instanceof i||(s=i.create(s));for(var f=h===void 0?s.len:s.pos+h,m=new a.onnx.TypeProto.Sequence;s.pos<f;){var v=s.uint32();switch(v>>>3){case 1:{m.elemType=a.onnx.TypeProto.decode(s,s.uint32());break}default:s.skipType(v&7);break}}return m},l.decodeDelimited=function(s){return s instanceof i||(s=new i(s)),this.decode(s,s.uint32())},l.verify=function(s){if(typeof s!="object"||s===null)return"object expected";if(s.elemType!=null&&s.hasOwnProperty("elemType")){var h=a.onnx.TypeProto.verify(s.elemType);if(h)return"elemType."+h}return null},l.fromObject=function(s){if(s instanceof a.onnx.TypeProto.Sequence)return s;var h=new a.onnx.TypeProto.Sequence;if(s.elemType!=null){if(typeof s.elemType!="object")throw TypeError(".onnx.TypeProto.Sequence.elemType: object expected");h.elemType=a.onnx.TypeProto.fromObject(s.elemType)}return h},l.toObject=function(s,h){h||(h={});var f={};return h.defaults&&(f.elemType=null),s.elemType!=null&&s.hasOwnProperty("elemType")&&(f.elemType=a.onnx.TypeProto.toObject(s.elemType,h)),f},l.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},l.getTypeUrl=function(s){return s===void 0&&(s="type.googleapis.com"),s+"/onnx.TypeProto.Sequence"},l}(),c.Map=function(){function l(s){if(s)for(var h=Object.keys(s),f=0;f<h.length;++f)s[h[f]]!=null&&(this[h[f]]=s[h[f]])}return l.prototype.keyType=0,l.prototype.valueType=null,l.create=function(s){return new l(s)},l.encode=function(s,h){return h||(h=u.create()),s.keyType!=null&&Object.hasOwnProperty.call(s,"keyType")&&h.uint32(8).int32(s.keyType),s.valueType!=null&&Object.hasOwnProperty.call(s,"valueType")&&a.onnx.TypeProto.encode(s.valueType,h.uint32(18).fork()).ldelim(),h},l.encodeDelimited=function(s,h){return this.encode(s,h).ldelim()},l.decode=function(s,h){s instanceof i||(s=i.create(s));for(var f=h===void 0?s.len:s.pos+h,m=new a.onnx.TypeProto.Map;s.pos<f;){var v=s.uint32();switch(v>>>3){case 1:{m.keyType=s.int32();break}case 2:{m.valueType=a.onnx.TypeProto.decode(s,s.uint32());break}default:s.skipType(v&7);break}}return m},l.decodeDelimited=function(s){return s instanceof i||(s=new i(s)),this.decode(s,s.uint32())},l.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 h=a.onnx.TypeProto.verify(s.valueType);if(h)return"valueType."+h}return null},l.fromObject=function(s){if(s instanceof a.onnx.TypeProto.Map)return s;var h=new a.onnx.TypeProto.Map;if(s.keyType!=null&&(h.keyType=s.keyType|0),s.valueType!=null){if(typeof s.valueType!="object")throw TypeError(".onnx.TypeProto.Map.valueType: object expected");h.valueType=a.onnx.TypeProto.fromObject(s.valueType)}return h},l.toObject=function(s,h){h||(h={});var f={};return h.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=a.onnx.TypeProto.toObject(s.valueType,h)),f},l.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},l.getTypeUrl=function(s){return s===void 0&&(s="type.googleapis.com"),s+"/onnx.TypeProto.Map"},l}(),c.Optional=function(){function l(s){if(s)for(var h=Object.keys(s),f=0;f<h.length;++f)s[h[f]]!=null&&(this[h[f]]=s[h[f]])}return l.prototype.elemType=null,l.create=function(s){return new l(s)},l.encode=function(s,h){return h||(h=u.create()),s.elemType!=null&&Object.hasOwnProperty.call(s,"elemType")&&a.onnx.TypeProto.encode(s.elemType,h.uint32(10).fork()).ldelim(),h},l.encodeDelimited=function(s,h){return this.encode(s,h).ldelim()},l.decode=function(s,h){s instanceof i||(s=i.create(s));for(var f=h===void 0?s.len:s.pos+h,m=new a.onnx.TypeProto.Optional;s.pos<f;){var v=s.uint32();switch(v>>>3){case 1:{m.elemType=a.onnx.TypeProto.decode(s,s.uint32());break}default:s.skipType(v&7);break}}return m},l.decodeDelimited=function(s){return s instanceof i||(s=new i(s)),this.decode(s,s.uint32())},l.verify=function(s){if(typeof s!="object"||s===null)return"object expected";if(s.elemType!=null&&s.hasOwnProperty("elemType")){var h=a.onnx.TypeProto.verify(s.elemType);if(h)return"elemType."+h}return null},l.fromObject=function(s){if(s instanceof a.onnx.TypeProto.Optional)return s;var h=new a.onnx.TypeProto.Optional;if(s.elemType!=null){if(typeof s.elemType!="object")throw TypeError(".onnx.TypeProto.Optional.elemType: object expected");h.elemType=a.onnx.TypeProto.fromObject(s.elemType)}return h},l.toObject=function(s,h){h||(h={});var f={};return h.defaults&&(f.elemType=null),s.elemType!=null&&s.hasOwnProperty("elemType")&&(f.elemType=a.onnx.TypeProto.toObject(s.elemType,h)),f},l.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},l.getTypeUrl=function(s){return s===void 0&&(s="type.googleapis.com"),s+"/onnx.TypeProto.Optional"},l}(),c.SparseTensor=function(){function l(s){if(s)for(var h=Object.keys(s),f=0;f<h.length;++f)s[h[f]]!=null&&(this[h[f]]=s[h[f]])}return l.prototype.elemType=0,l.prototype.shape=null,l.create=function(s){return new l(s)},l.encode=function(s,h){return h||(h=u.create()),s.elemType!=null&&Object.hasOwnProperty.call(s,"elemType")&&h.uint32(8).int32(s.elemType),s.shape!=null&&Object.hasOwnProperty.call(s,"shape")&&a.onnx.TensorShapeProto.encode(s.shape,h.uint32(18).fork()).ldelim(),h},l.encodeDelimited=function(s,h){return this.encode(s,h).ldelim()},l.decode=function(s,h){s instanceof i||(s=i.create(s));for(var f=h===void 0?s.len:s.pos+h,m=new a.onnx.TypeProto.SparseTensor;s.pos<f;){var v=s.uint32();switch(v>>>3){case 1:{m.elemType=s.int32();break}case 2:{m.shape=a.onnx.TensorShapeProto.decode(s,s.uint32());break}default:s.skipType(v&7);break}}return m},l.decodeDelimited=function(s){return s instanceof i||(s=new i(s)),this.decode(s,s.uint32())},l.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 h=a.onnx.TensorShapeProto.verify(s.shape);if(h)return"shape."+h}return null},l.fromObject=function(s){if(s instanceof a.onnx.TypeProto.SparseTensor)return s;var h=new a.onnx.TypeProto.SparseTensor;if(s.elemType!=null&&(h.elemType=s.elemType|0),s.shape!=null){if(typeof s.shape!="object")throw TypeError(".onnx.TypeProto.SparseTensor.shape: object expected");h.shape=a.onnx.TensorShapeProto.fromObject(s.shape)}return h},l.toObject=function(s,h){h||(h={});var f={};return h.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=a.onnx.TensorShapeProto.toObject(s.shape,h)),f},l.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},l.getTypeUrl=function(s){return s===void 0&&(s="type.googleapis.com"),s+"/onnx.TypeProto.SparseTensor"},l}(),c}(),d.OperatorSetIdProto=function(){function c(e){if(e)for(var l=Object.keys(e),s=0;s<l.length;++s)e[l[s]]!=null&&(this[l[s]]=e[l[s]])}return c.prototype.domain="",c.prototype.version=n.Long?n.Long.fromBits(0,0,!1):0,c.create=function(e){return new c(e)},c.encode=function(e,l){return l||(l=u.create()),e.domain!=null&&Object.hasOwnProperty.call(e,"domain")&&l.uint32(10).string(e.domain),e.version!=null&&Object.hasOwnProperty.call(e,"version")&&l.uint32(16).int64(e.version),l},c.encodeDelimited=function(e,l){return this.encode(e,l).ldelim()},c.decode=function(e,l){e instanceof i||(e=i.create(e));for(var s=l===void 0?e.len:e.pos+l,h=new a.onnx.OperatorSetIdProto;e.pos<s;){var f=e.uint32();switch(f>>>3){case 1:{h.domain=e.string();break}case 2:{h.version=e.int64();break}default:e.skipType(f&7);break}}return h},c.decodeDelimited=function(e){return e instanceof i||(e=new i(e)),this.decode(e,e.uint32())},c.verify=function(e){return typeof e!="object"||e===null?"object expected":e.domain!=null&&e.hasOwnProperty("domain")&&!n.isString(e.domain)?"domain: string expected":e.version!=null&&e.hasOwnProperty("version")&&!n.isInteger(e.version)&&!(e.version&&n.isInteger(e.version.low)&&n.isInteger(e.version.high))?"version: integer|Long expected":null},c.fromObject=function(e){if(e instanceof a.onnx.OperatorSetIdProto)return e;var l=new a.onnx.OperatorSetIdProto;return e.domain!=null&&(l.domain=String(e.domain)),e.version!=null&&(n.Long?(l.version=n.Long.fromValue(e.version)).unsigned=!1:typeof e.version=="string"?l.version=parseInt(e.version,10):typeof e.version=="number"?l.version=e.version:typeof e.version=="object"&&(l.version=new n.LongBits(e.version.low>>>0,e.version.high>>>0).toNumber())),l},c.toObject=function(e,l){l||(l={});var s={};if(l.defaults)if(s.domain="",n.Long){var h=new n.Long(0,0,!1);s.version=l.longs===String?h.toString():l.longs===Number?h.toNumber():h}else s.version=l.longs===String?"0":0;return e.domain!=null&&e.hasOwnProperty("domain")&&(s.domain=e.domain),e.version!=null&&e.hasOwnProperty("version")&&(typeof e.version=="number"?s.version=l.longs===String?String(e.version):e.version:s.version=l.longs===String?n.Long.prototype.toString.call(e.version):l.longs===Number?new n.LongBits(e.version.low>>>0,e.version.high>>>0).toNumber():e.version),s},c.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},c.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/onnx.OperatorSetIdProto"},c}(),d.OperatorStatus=function(){var c={},e=Object.create(c);return e[c[0]="EXPERIMENTAL"]=0,e[c[1]="STABLE"]=1,e}(),d.FunctionProto=function(){function c(e){if(this.input=[],this.output=[],this.attribute=[],this.attributeProto=[],this.node=[],this.opsetImport=[],e)for(var l=Object.keys(e),s=0;s<l.length;++s)e[l[s]]!=null&&(this[l[s]]=e[l[s]])}return c.prototype.name="",c.prototype.input=n.emptyArray,c.prototype.output=n.emptyArray,c.prototype.attribute=n.emptyArray,c.prototype.attributeProto=n.emptyArray,c.prototype.node=n.emptyArray,c.prototype.docString="",c.prototype.opsetImport=n.emptyArray,c.prototype.domain="",c.create=function(e){return new c(e)},c.encode=function(e,l){if(l||(l=u.create()),e.name!=null&&Object.hasOwnProperty.call(e,"name")&&l.uint32(10).string(e.name),e.input!=null&&e.input.length)for(var s=0;s<e.input.length;++s)l.uint32(34).string(e.input[s]);if(e.output!=null&&e.output.length)for(var s=0;s<e.output.length;++s)l.uint32(42).string(e.output[s]);if(e.attribute!=null&&e.attribute.length)for(var s=0;s<e.attribute.length;++s)l.uint32(50).string(e.attribute[s]);if(e.node!=null&&e.node.length)for(var s=0;s<e.node.length;++s)a.onnx.NodeProto.encode(e.node[s],l.uint32(58).fork()).ldelim();if(e.docString!=null&&Object.hasOwnProperty.call(e,"docString")&&l.uint32(66).string(e.docString),e.opsetImport!=null&&e.opsetImport.length)for(var s=0;s<e.opsetImport.length;++s)a.onnx.OperatorSetIdProto.encode(e.opsetImport[s],l.uint32(74).fork()).ldelim();if(e.domain!=null&&Object.hasOwnProperty.call(e,"domain")&&l.uint32(82).string(e.domain),e.attributeProto!=null&&e.attributeProto.length)for(var s=0;s<e.attributeProto.length;++s)a.onnx.AttributeProto.encode(e.attributeProto[s],l.uint32(90).fork()).ldelim();return l},c.encodeDelimited=function(e,l){return this.encode(e,l).ldelim()},c.decode=function(e,l){e instanceof i||(e=i.create(e));for(var s=l===void 0?e.len:e.pos+l,h=new a.onnx.FunctionProto;e.pos<s;){var f=e.uint32();switch(f>>>3){case 1:{h.name=e.string();break}case 4:{h.input&&h.input.length||(h.input=[]),h.input.push(e.string());break}case 5:{h.output&&h.output.length||(h.output=[]),h.output.push(e.string());break}case 6:{h.attribute&&h.attribute.length||(h.attribute=[]),h.attribute.push(e.string());break}case 11:{h.attributeProto&&h.attributeProto.length||(h.attributeProto=[]),h.attributeProto.push(a.onnx.AttributeProto.decode(e,e.uint32()));break}case 7:{h.node&&h.node.length||(h.node=[]),h.node.push(a.onnx.NodeProto.decode(e,e.uint32()));break}case 8:{h.docString=e.string();break}case 9:{h.opsetImport&&h.opsetImport.length||(h.opsetImport=[]),h.opsetImport.push(a.onnx.OperatorSetIdProto.decode(e,e.uint32()));break}case 10:{h.domain=e.string();break}default:e.skipType(f&7);break}}return h},c.decodeDelimited=function(e){return e instanceof i||(e=new i(e)),this.decode(e,e.uint32())},c.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.name!=null&&e.hasOwnProperty("name")&&!n.isString(e.name))return"name: string expected";if(e.input!=null&&e.hasOwnProperty("input")){if(!Array.isArray(e.input))return"input: array expected";for(var l=0;l<e.input.length;++l)if(!n.isString(e.input[l]))return"input: string[] expected"}if(e.output!=null&&e.hasOwnProperty("output")){if(!Array.isArray(e.output))return"output: array expected";for(var l=0;l<e.output.length;++l)if(!n.isString(e.output[l]))return"output: string[] expected"}if(e.attribute!=null&&e.hasOwnProperty("attribute")){if(!Array.isArray(e.attribute))return"attribute: array expected";for(var l=0;l<e.attribute.length;++l)if(!n.isString(e.attribute[l]))return"attribute: string[] expected"}if(e.attributeProto!=null&&e.hasOwnProperty("attributeProto")){if(!Array.isArray(e.attributeProto))return"attributeProto: array expected";for(var l=0;l<e.attributeProto.length;++l){var s=a.onnx.AttributeProto.verify(e.attributeProto[l]);if(s)return"attributeProto."+s}}if(e.node!=null&&e.hasOwnProperty("node")){if(!Array.isArray(e.node))return"node: array expected";for(var l=0;l<e.node.length;++l){var s=a.onnx.NodeProto.verify(e.node[l]);if(s)return"node."+s}}if(e.docString!=null&&e.hasOwnProperty("docString")&&!n.isString(e.docString))return"docString: string expected";if(e.opsetImport!=null&&e.hasOwnProperty("opsetImport")){if(!Array.isArray(e.opsetImport))return"opsetImport: array expected";for(var l=0;l<e.opsetImport.length;++l){var s=a.onnx.OperatorSetIdProto.verify(e.opsetImport[l]);if(s)return"opsetImport."+s}}return e.domain!=null&&e.hasOwnProperty("domain")&&!n.isString(e.domain)?"domain: string expected":null},c.fromObject=function(e){if(e instanceof a.onnx.FunctionProto)return e;var l=new a.onnx.FunctionProto;if(e.name!=null&&(l.name=String(e.name)),e.input){if(!Array.isArray(e.input))throw TypeError(".onnx.FunctionProto.input: array expected");l.input=[];for(var s=0;s<e.input.length;++s)l.input[s]=String(e.input[s])}if(e.output){if(!Array.isArray(e.output))throw TypeError(".onnx.FunctionProto.output: array expected");l.output=[];for(var s=0;s<e.output.length;++s)l.output[s]=String(e.output[s])}if(e.attribute){if(!Array.isArray(e.attribute))throw TypeError(".onnx.FunctionProto.attribute: array expected");l.attribute=[];for(var s=0;s<e.attribute.length;++s)l.attribute[s]=String(e.attribute[s])}if(e.attributeProto){if(!Array.isArray(e.attributeProto))throw TypeError(".onnx.FunctionProto.attributeProto: array expected");l.attributeProto=[];for(var s=0;s<e.attributeProto.length;++s){if(typeof e.attributeProto[s]!="object")throw TypeError(".onnx.FunctionProto.attributeProto: object expected");l.attributeProto[s]=a.onnx.AttributeProto.fromObject(e.attributeProto[s])}}if(e.node){if(!Array.isArray(e.node))throw TypeError(".onnx.FunctionProto.node: array expected");l.node=[];for(var s=0;s<e.node.length;++s){if(typeof e.node[s]!="object")throw TypeError(".onnx.FunctionProto.node: object expected");l.node[s]=a.onnx.NodeProto.fromObject(e.node[s])}}if(e.docString!=null&&(l.docString=String(e.docString)),e.opsetImport){if(!Array.isArray(e.opsetImport))throw TypeError(".onnx.FunctionProto.opsetImport: array expected");l.opsetImport=[];for(var s=0;s<e.opsetImport.length;++s){if(typeof e.opsetImport[s]!="object")throw TypeError(".onnx.FunctionProto.opsetImport: object expected");l.opsetImport[s]=a.onnx.OperatorSetIdProto.fromObject(e.opsetImport[s])}}return e.domain!=null&&(l.domain=String(e.domain)),l},c.toObject=function(e,l){l||(l={});var s={};if((l.arrays||l.defaults)&&(s.input=[],s.output=[],s.attribute=[],s.node=[],s.opsetImport=[],s.attributeProto=[]),l.defaults&&(s.name="",s.docString="",s.domain=""),e.name!=null&&e.hasOwnProperty("name")&&(s.name=e.name),e.input&&e.input.length){s.input=[];for(var h=0;h<e.input.length;++h)s.input[h]=e.input[h]}if(e.output&&e.output.length){s.output=[];for(var h=0;h<e.output.length;++h)s.output[h]=e.output[h]}if(e.attribute&&e.attribute.length){s.attribute=[];for(var h=0;h<e.attribute.length;++h)s.attribute[h]=e.attribute[h]}if(e.node&&e.node.length){s.node=[];for(var h=0;h<e.node.length;++h)s.node[h]=a.onnx.NodeProto.toObject(e.node[h],l)}if(e.docString!=null&&e.hasOwnProperty("docString")&&(s.docString=e.docString),e.opsetImport&&e.opsetImport.length){s.opsetImport=[];for(var h=0;h<e.opsetImport.length;++h)s.opsetImport[h]=a.onnx.OperatorSetIdProto.toObject(e.opsetImport[h],l)}if(e.domain!=null&&e.hasOwnProperty("domain")&&(s.domain=e.domain),e.attributeProto&&e.attributeProto.length){s.attributeProto=[];for(var h=0;h<e.attributeProto.length;++h)s.attributeProto[h]=a.onnx.AttributeProto.toObject(e.attributeProto[h],l)}return s},c.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},c.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/onnx.FunctionProto"},c}(),d}(),r.exports=a});function ur(t,r){if(!t)throw new Error(typeof r=="string"?r:r())}function kr(t){return new TextDecoder().decode(t)}var ot,Me,ai,kt,Sn,At,Rt,B,$r,Ue,Ve,ze,Y=O(()=>{wn(),qo(),ot=rr(sr()),We(),Me=class{static arraysEqual(t,r){if(t.length!==r.length)return!1;for(let o=0;o<t.length;o++)if(t[o]!==r[o])return!1;return!0}},ai=class{static preprocessInputShapes(t,r){let o=t.length===1?[1,t[0]]:t,i=r.length===1?[r[0],1]:r;return[o,i]}static postprocessOutputShape(t,r,o){r===1&&t.splice(t.length-2,1),o===1&&t.pop()}static calcMatMulShape(t,r){return t[1]!==r[0]?void 0:[t[0],r[1]]}},kt=class Oe{static calcShape(r,o,i=!1){let u=r.length,n=o.length;if(u===0)return o;if(n===0)return r;let a=Math.max(r.length,o.length),d=new Array(a);if(i){if(u<2||n<2)return;let c=ai.calcMatMulShape([r[u-2],r[u-1]],[o[n-2],o[n-1]]);if(c===void 0)return;[d[a-2],d[a-1]]=c}for(let c=i?3:1;c<=a;c++){let e=u-c<0?1:r[u-c],l=n-c<0?1:o[n-c];if(e!==l&&e>1&&l>1)return;d[a-c]=Math.max(e,l)}return d}static index(r,o){let i=new Array(o.length);return Oe.fillIndex(r,o,i),i}static fillIndex(r,o,i){let u=r.length-o.length;for(let n=0;n<o.length;n++)i[n]=r[u+n]%o[n]}static calc(r,o,i,u,n){let a=Oe.calcShape(r.dims,o.dims);if(a){if(u&&!B.areEqual(a,r.dims))return;let d=B.size(a),c=u?r:new bt(a,n||r.type);if(a.length===0)c.set([],i(r.get([]),o.get([])));else{let e=new Array(a.length),l=new Array(r.dims.length),s=new Array(o.dims.length),h=0,f=0,m=!1,v=!1;r.dims.length===0&&(h=r.get([]),m=!0),o.dims.length===0&&(f=o.get([]),v=!0);let _;for(let I=0;I<d;I++){_=I;for(let T=a.length-1;T>=0;T--)e[T]=_%a[T],_=Math.floor(_/a[T]);m||(Oe.fillIndex(e,r.dims,l),h=r.get(l)),v||(Oe.fillIndex(e,o.dims,s),f=o.get(s)),c.set(e,i(h,f))}}return c}}static isValidBroadcast(r,o){let i=r.length,u=o.length;if(i>u)return!1;for(let n=1;n<=i;n++)if(r[i-n]!==1&&r[i-n]!==o[u-n])return!1;return!0}static getBroadcastDims(r,o){let i=r.length,u=[];for(let n=0;n<i;n++){let a=i-1-n,d=r[a]||1;(o[o.length-1-n]||1)>1&&d===1&&u.unshift(a)}return u}},Sn=class{static getShapeOfGemmResult(t,r,o,i,u){if(t.length!==2||o.length!==2)throw new Error("shape need to be of size 2");let n,a,d;r?(n=t[1],a=t[0]):(n=t[0],a=t[1]);let c=-1;if(i?(d=o[0],c=1):(d=o[1],c=0),o[c]!==a)throw new Error("dimension mismatch");if(n<=0||d<=0||a<=0)throw new Error("invalid shape specified");if(u&&!kt.isValidBroadcast(u,[n,d]))throw new Error("gemm: invalid bias shape for broadcast");return[n,d,a]}},At=class nn{static tensorDataTypeFromProto(r){switch(r){case ot.onnx.TensorProto.DataType.INT8:return"int8";case ot.onnx.TensorProto.DataType.UINT8:return"uint8";case ot.onnx.TensorProto.DataType.BOOL:return"bool";case ot.onnx.TensorProto.DataType.INT16:return"int16";case ot.onnx.TensorProto.DataType.UINT16:return"uint16";case ot.onnx.TensorProto.DataType.INT32:return"int32";case ot.onnx.TensorProto.DataType.UINT32:return"uint32";case ot.onnx.TensorProto.DataType.FLOAT:return"float32";case ot.onnx.TensorProto.DataType.DOUBLE:return"float64";case ot.onnx.TensorProto.DataType.STRING:return"string";case ot.onnx.TensorProto.DataType.INT64:return"int32";case ot.onnx.TensorProto.DataType.UINT64:return"uint32";default:throw new Error(`unsupported data type: ${ot.onnx.TensorProto.DataType[r]}`)}}static tensorDataTypeStringToEnum(r){switch(r){case"int8":return ot.onnx.TensorProto.DataType.INT8;case"uint8":return ot.onnx.TensorProto.DataType.UINT8;case"bool":return ot.onnx.TensorProto.DataType.BOOL;case"int16":return ot.onnx.TensorProto.DataType.INT16;case"uint16":return ot.onnx.TensorProto.DataType.UINT16;case"int32":return ot.onnx.TensorProto.DataType.INT32;case"uint32":return ot.onnx.TensorProto.DataType.UINT32;case"float32":return ot.onnx.TensorProto.DataType.FLOAT;case"float64":return ot.onnx.TensorProto.DataType.DOUBLE;case"string":return ot.onnx.TensorProto.DataType.STRING;case"int64":return ot.onnx.TensorProto.DataType.INT64;case"uint64":return ot.onnx.TensorProto.DataType.UINT64;default:throw new Error(`unsupported data type: ${r}`)}}static tensorDimsFromProto(r){return r.map(o=>xe.isLong(o)?o.toNumber():o)}static tensorValueTypeFromProto(r){return{tensorType:nn.tensorDataTypeFromProto(r.elemType),shape:{dims:nn.tensorDimsFromProto(r.shape.dim.map(o=>o.dimValue))}}}static tensorDimsFromORTFormat(r){let o=[];for(let i=0;i<r.dimsLength();i++)o.push(Rt.longToNumber(r.dims(i)));return o}static tensorAttributesFromORTFormat(r){let o=[];for(let i=0;i<r.attributesLength();i++)o.push(r.attributes(i));return o}},Rt=class{static longToNumber(t,r){return xe.isLong(t)?t.toNumber():t instanceof w.Long?xe.fromValue({low:t.low,high:t.high,unsigned:r??!1}).toNumber():t}static isLong(t){return xe.isLong(t)||t instanceof w.Long}},B=class re{static size(r){return re.getSizeFromDimensionRange(r,0,r.length)}static sizeFromDimension(r,o){if(o<0||o>r.length)throw new Error(`invalid dimension of ${o} for sizeFromDimension as Tensor has ${r.length} dimensions.`);return re.getSizeFromDimensionRange(r,o,r.length)}static sizeToDimension(r,o){if(o<0||o>r.length)throw new Error(`invalid dimension of ${o} for sizeToDimension as Tensor has ${r.length} dimensions.`);return re.getSizeFromDimensionRange(r,0,o)}static getSizeFromDimensionRange(r,o,i){let u=1;for(let n=o;n<i;n++){if(r[n]<=0)throw new Error("cannot get valid size from specified dimension range. Most likely the range contains 0 or negative values in them.");u*=r[n]}return u}static computeStrides(r){let o=r.length;if(o===0)return[];if(o===1)return[1];let i=new Array(o);i[o-1]=1,i[o-2]=r[o-1];for(let u=o-3;u>=0;--u)i[u]=i[u+1]*r[u+1];return i}static transpose(r){return r.slice().reverse()}static indicesToOffset(r,o,i){i===void 0&&(i=r.length);let u=0;for(let n=0;n<i;++n)u+=o[n]*r[n];return u}static offsetToIndices(r,o){let i=o.length;if(i===0)return[];if(i===1)return[r*o[0]];let u=new Array(o.length);for(let n=0;n<u.length-1;++n)u[n]=Math.floor(r/o[n]),r-=u[n]*o[n];return u[u.length-1]=r,u}static normalizeAxis(r,o){if(r<-o&&r>=o)throw new Error("unsupported axis for this operation.");return r<0?r+o:r}static normalizeAxes(r,o){return r.map(i=>this.normalizeAxis(i,o))}static incrementIndex(r,o,i){if(o.length===0||r.length===0)throw new Error("Index incrementing unsupported for scalar Tensor");if(i===void 0)i=o.length;else if(i<=0||i>o.length)throw new Error("Incorrect axis to increment on");for(let u=i-1;u>=0&&(r[u]++,!(r[u]<o[u]));--u)r[u]=0}static calculateReshapedDims(r,o){if(o.length===0){if(r.length===0||re.size(r)===1)return[];throw new Error("cannot reshape to a scalar Tensor")}let i=o.length,u=new Array(i),n=-1,a=1;for(let c=0;c<i;c++){if(o[c]<-1)throw new Error("a dimension in shape hints cannot be less than -1");if(o[c]===-1){if(n!==-1)throw new Error("at most one dimension in shape hints can be -1");n=c}else{if(o[c]===0){if(c>=r.length)throw new Error("the dimension with value zero exceeds the dimension size of the input tensor");u[c]=r[c]}else u[c]=o[c];a*=u[c]}}let d=re.size(r);if(n!==-1){if(d%a!==0)throw new Error(`the input tensor cannot be reshaped to the requested shape. Input shape: [${r}] Output shape: [${o}]`);u[n]=d/a}else if(a!==d)throw new Error("reshapedDims and originalDims don't have matching sizes");return u}static sortBasedOnPerm(r,o){return o?o.map(i=>r[i]):r.slice().reverse()}static padShape(r,o){let i=r.length;return r.map((u,n)=>u+o[n]+o[n+i])}static areEqual(r,o){return r.length!==o.length?!1:r.every((i,u)=>i===o[u])}static validateDimsAndCalcSize(r){if(r.length>6)throw new TypeError("Only rank 0 to 6 is supported for tensor shape.");let o=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`);o*=i}return o}static flattenShape(r,o){o<0&&(o+=r.length);let i=r.reduce((n,a)=>n*a,1),u=r.slice(o).reduce((n,a)=>n*a,1);return[i/u,u]}static squeezeShape(r,o){let i=new Array;o=re.normalizeAxes(o,r.length);for(let u=0;u<r.length;u++){let n=o.indexOf(u)>=0;if(n&&r[u]!==1)throw new Error("squeeze an axis of size different than 1");(o.length===0&&r[u]>1||o.length>0&&!n)&&i.push(r[u])}return i}static unsqueezeShape(r,o){let i=new Array(r.length+o.length);i.fill(0);for(let n=0;n<o.length;n++){let a=re.normalizeAxis(o[n],i.length);if(a>=i.length)throw new Error("'axes' has an out of range axis");if(i[a]!==0)throw new Error("'axes' has a duplicate axis");i[a]=1}let u=0;for(let n=0;n<i.length;n++)i[n]===0&&(i[n]=r[u++]);if(u!==r.length)throw new Error("the unsqueezed dimension could not be established");return i}},$r=class Ia{static splitShape(r,o,i,u){if(i.length===0){if(!u)throw new Error("need to know number of outputs when the 'split' attribute is not specified");Ia.determineSplit(r[o],u,i)}let n=[],a=[0];for(let d=0;d<i.length;++d){d!==0&&a.push(a[d-1]+i[d-1]);let c=r.slice();c[o]=i[d],n.push(c)}return[n,a]}static determineSplit(r,o,i){if(r%o!==0)throw new Error("cannot split tensor to equal sized parts");for(let u=0;u<o;++u)i.push(r/o)}},Ue=class Ie{static adjustPoolAttributes(r,o,i,u,n,a){if(!r&&i.length!==o.length-2)throw new Error("length of specified kernel shapes should be 2 less than length of input dimensions");if(r)for(let d=0;d<o.length-2;d++)d>=i.length?i.push(o[d+2]):i[d]=o[d+2];for(let d=0;d<i.length;d++)if(d<u.length){if(u[d]<0)throw new Error("strides should be greater than or equal to 1")}else u.push(1);for(let d=0;d<i.length;d++)if(d<n.length){if(n[d]<0)throw new Error("dilations should be greater than or equal to 1")}else n.push(1);for(let d=0;d<i.length*2;d++)if(d<a.length){if(a[d]<0)throw new Error("pad should be greater than or equal to 1")}else a.push(0);for(let d=0;d<i.length;d++){if(i[d]<=0)throw new Error("kernel shapes need to be greater than 0");if(a[d]>=i[d]||a[d+i.length]>=i[d])throw new Error("pads should be smaller than kernel")}}static adjustPadsBasedOnAutoPad(r,o,i,u,n,a){if(a){if(n.length!==2*(r.length-2))throw new Error("length of pads should be twice the length of data dimensions");if(o.length!==r.length-2)throw new Error("length of strides should be the length of data dimensions");if(u.length!==r.length-2)throw new Error("length of kernel shapes should be the length of data dimensions");for(let d=0;d<r.length-2;d++)Ie.adjustPadAndReturnShape(r[d+2],o[d],i[d],u[d],n,d,d+r.length-2,a)}}static computePoolOutputShape(r,o,i,u,n,a,d){if(o.length<=0)throw new Error("input shape must be of size greater than 0");let c=[o[0],o[1]];return Ie.computeShapeHelper(r,o,c,i,u,n,a,d),c}static computeConvOutputShape(r,o,i,u,n,a,d){if(r.length<=0||o.length<=0)throw new Error("invalid input tensor dims or invalid filter tensor dims");let c=[r[0],o[0]];return Ie.computeShapeHelper(!1,r,c,i,u,n,a,d),c}static computeShapeHelper(r,o,i,u,n,a,d,c){if(r)for(let e=0;e<o.length-2;e++)i.push(1);else for(let e=0;e<o.length-2;e++)i.push(Ie.adjustPadAndReturnShape(o[e+2],u[e],n[e],a[e],d,e,e+o.length-2,c))}static adjustPadAndReturnShape(r,o,i,u,n,a,d,c){let e=i*(u-1)+1;if(c&&c!=="NOTSET")switch(c){case"VALID":return n[a]=0,n[d]=0,Math.floor((r-e)/o+1);case"SAME_LOWER":case"SAME_UPPER":if(i!==1)throw new Error("Dilation not supported for SAME_UPPER or SAME_LOWER");{let l=((r+o-1)/o-1)*o+u-r;return n[a]=Math.floor(c==="SAME_LOWER"?(l+1)/2:l/2),n[d]=l-n[a],Math.floor((r+l-u)/o+1)}default:throw new Error("Unsupported AutoPad type")}else return Math.floor((r+n[a]+n[d]-e)/o+1)}},Ve=-34028234663852886e22,ze=34028234663852886e22});function hh(t){switch(t){case"bool":case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;case"float64":return 8;default:throw new Error(`cannot calculate sizeof() on type ${t}`)}}function Wu(t){switch(t){case H.onnx.TensorProto.DataType.UINT8:case H.onnx.TensorProto.DataType.INT8:case H.onnx.TensorProto.DataType.BOOL:return 1;case H.onnx.TensorProto.DataType.UINT16:case H.onnx.TensorProto.DataType.INT16:return 2;case H.onnx.TensorProto.DataType.FLOAT:case H.onnx.TensorProto.DataType.INT32:case H.onnx.TensorProto.DataType.UINT32:return 4;case H.onnx.TensorProto.DataType.INT64:case H.onnx.TensorProto.DataType.DOUBLE:case H.onnx.TensorProto.DataType.UINT64:return 8;default:throw new Error(`cannot calculate sizeof() on type ${H.onnx.TensorProto.DataType[t]}`)}}function mh(t,r){return new(ju(r))(t)}function ju(t){switch(t){case"bool":case"uint8":return Uint8Array;case"int8":return Int8Array;case"int16":return Int16Array;case"uint16":return Uint16Array;case"int32":return Int32Array;case"uint32":return Uint32Array;case"int64":return BigInt64Array;case"float32":return Float32Array;case"float64":return Float64Array;default:throw new Error("unspecified error")}}function ui(t,r){if(r===H.onnx.TensorProto.DataType.INT64||r===si.TensorDataType.INT64){if(t.greaterThanOrEqual(2147483648)||t.lessThan(-2147483648))throw new TypeError("int64 is not supported")}else if(r===H.onnx.TensorProto.DataType.UINT32||r===si.TensorDataType.UINT32||r===H.onnx.TensorProto.DataType.UINT64||r===si.TensorDataType.UINT64){if(t.greaterThanOrEqual(4294967296)||t.lessThan(0))throw new TypeError("uint64 is not supported")}else throw new TypeError(`not a LONG type: ${H.onnx.TensorProto.DataType[r]}`);return t.toNumber()}function Hu(t,r,o){switch(r){case H.onnx.TensorProto.DataType.BOOL:case H.onnx.TensorProto.DataType.UINT8:return t.getUint8(o);case H.onnx.TensorProto.DataType.INT8:return t.getInt8(o);case H.onnx.TensorProto.DataType.UINT16:return t.getUint16(o,!0);case H.onnx.TensorProto.DataType.INT16:return t.getInt16(o,!0);case H.onnx.TensorProto.DataType.FLOAT:return t.getFloat32(o,!0);case H.onnx.TensorProto.DataType.INT32:return t.getInt32(o,!0);case H.onnx.TensorProto.DataType.UINT32:return t.getUint32(o,!0);case H.onnx.TensorProto.DataType.INT64:return ui(xe.fromBits(t.getUint32(o,!0),t.getUint32(o+4,!0),!1),r);case H.onnx.TensorProto.DataType.DOUBLE:return t.getFloat64(o,!0);case H.onnx.TensorProto.DataType.UINT64:return ui(xe.fromBits(t.getUint32(o,!0),t.getUint32(o+4,!0),!0),r);default:throw new Error(`cannot read from DataView for type ${H.onnx.TensorProto.DataType[r]}`)}}var qu,H,si,bt,We=O(()=>{qu=rr(Fs()),qo(),Pr(),H=rr(sr()),Y(),si=F.experimental.fbs,bt=class vr{constructor(r,o,i,u,n,a=qu.Guid.create()){this.dims=r,this.type=o,this.dataProvider=i,this.asyncDataProvider=u,this.cache=n,this.dataId=a,this.size=B.validateDimsAndCalcSize(r);let d=this.size,c=i===void 0&&u===void 0&&n===void 0;if(n!==void 0&&n.length!==d)throw new RangeError("Input dims doesn't match data length.");if(o==="string"){if(n!==void 0&&(!Array.isArray(n)||!n.every(e=>typeof e=="string")))throw new TypeError("cache should be a string array");c&&(this.cache=new Array(d))}else{if(n!==void 0){let e=ju(o);if(!(n instanceof e))throw new TypeError(`cache should be type ${e.name}`)}if(c){let e=new ArrayBuffer(d*hh(o));this.cache=mh(e,o)}}}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[B.indicesToOffset(r,this.strides)]}set(r,o){this.data[B.indicesToOffset(r,this.strides)]=o}async getData(){return this.cache===void 0&&(this.cache=await this.asyncDataProvider(this.dataId)),this.cache}get strides(){return this._strides||(this._strides=B.computeStrides(this.dims)),this._strides}static fromProto(r){if(!r)throw new Error("cannot construct Value from an empty tensor");let o=At.tensorDataTypeFromProto(r.dataType),i=At.tensorDimsFromProto(r.dims),u=new vr(i,o);if(o==="string")r.stringData.forEach((n,a)=>{u.data[a]=kr(n)});else if(r.rawData&&typeof r.rawData.byteLength=="number"&&r.rawData.byteLength>0){let n=u.data,a=new DataView(r.rawData.buffer,r.rawData.byteOffset,r.rawData.byteLength),d=Wu(r.dataType),c=r.rawData.byteLength/d;if(r.rawData.byteLength%d!==0)throw new Error("invalid buffer length");if(n.length!==c)throw new Error("buffer length mismatch");for(let e=0;e<c;e++){let l=Hu(a,r.dataType,e*d);n[e]=l}}else{let n;switch(r.dataType){case H.onnx.TensorProto.DataType.FLOAT:n=r.floatData;break;case H.onnx.TensorProto.DataType.INT32:case H.onnx.TensorProto.DataType.INT16:case H.onnx.TensorProto.DataType.UINT16:case H.onnx.TensorProto.DataType.INT8:case H.onnx.TensorProto.DataType.UINT8:case H.onnx.TensorProto.DataType.BOOL:n=r.int32Data;break;case H.onnx.TensorProto.DataType.INT64:n=r.int64Data;break;case H.onnx.TensorProto.DataType.DOUBLE:n=r.doubleData;break;case H.onnx.TensorProto.DataType.UINT32:case H.onnx.TensorProto.DataType.UINT64:n=r.uint64Data;break;default:throw new Error("unspecific error")}if(n==null)throw new Error("failed to populate data from a tensorproto value");let a=u.data;if(a.length!==n.length)throw new Error("array length mismatch");for(let d=0;d<n.length;d++){let c=n[d];xe.isLong(c)?a[d]=ui(c,r.dataType):a[d]=c}}return u}static fromData(r,o,i){return new vr(o,i,void 0,void 0,r)}static fromOrtTensor(r){if(!r)throw new Error("cannot construct Value from an empty tensor");let o=At.tensorDimsFromORTFormat(r),i=At.tensorDataTypeFromProto(r.dataType()),u=new vr(o,i);if(i==="string")for(let n=0;n<r.stringDataLength();n++)u.data[n]=r.stringData(n);else if(r.rawDataArray()&&typeof r.rawDataLength()=="number"&&r.rawDataLength()>0){let n=u.data,a=new DataView(r.rawDataArray().buffer,r.rawDataArray().byteOffset,r.rawDataLength()),d=Wu(r.dataType()),c=r.rawDataLength()/d;if(r.rawDataLength()%d!==0)throw new Error("invalid buffer length");if(n.length!==c)throw new Error("buffer length mismatch");for(let e=0;e<c;e++){let l=Hu(a,r.dataType(),e*d);n[e]=l}}return u}}});function G(t){return t===1?bh:gh}function Xu(t){let r=G(t);return`${r.version}
10
+ */var Hd=Object.create,an=Object.defineProperty,qd=Object.getOwnPropertyDescriptor,jd=Object.getOwnPropertyNames,Xd=Object.getPrototypeOf,Kd=Object.prototype.hasOwnProperty,Co=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(n,a)=>(typeof require<"u"?require:n)[a]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),O=(e,n)=>()=>(e&&(n=e(e=0)),n),mt=(e,n)=>()=>(n||e((n={exports:{}}).exports,n),n.exports),Or=(e,n)=>{for(var a in n)an(e,a,{get:n[a],enumerable:!0})},Qa=(e,n,a,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let p of jd(n))!Kd.call(e,p)&&p!==a&&an(e,p,{get:()=>n[p],enumerable:!(i=qd(n,p))||i.enumerable});return e},rr=(e,n,a)=>(a=e!=null?Hd(Xd(e)):{},Qa(!e||!e.__esModule?an(a,"default",{value:e,enumerable:!0}):a,e)),sn=e=>Qa(an({},"__esModule",{value:!0}),e),un,ke,nr,Jd,ln,fn=O(()=>{un=new Map,ke=[],nr=(e,n,a)=>{if(n&&typeof n.init=="function"&&typeof n.createInferenceSessionHandler=="function"){let i=un.get(e);if(i===void 0)un.set(e,{backend:n,priority:a});else{if(i.priority>a)return;if(i.priority===a&&i.backend!==n)throw new Error(`cannot register backend "${e}" using priority ${a}`)}if(a>=0){let p=ke.indexOf(e);p!==-1&&ke.splice(p,1);for(let o=0;o<ke.length;o++)if(un.get(ke[o]).priority<=a){ke.splice(o,0,e);return}ke.push(e)}return}throw new TypeError("not a valid backend")},Jd=async e=>{let n=un.get(e);if(!n)return"backend not found.";if(n.initialized)return n.backend;if(n.aborted)return n.error;{let a=!!n.initPromise;try{return a||(n.initPromise=n.backend.init(e)),await n.initPromise,n.initialized=!0,n.backend}catch(i){return a||(n.error=`${i}`,n.aborted=!0),n.error}finally{delete n.initPromise}}},ln=async e=>{let n=e.executionProviders||[],a=n.map(h=>typeof h=="string"?h:h.name),i=a.length===0?ke:a,p,o=[],s=new Set;for(let h of i){let r=await Jd(h);typeof r=="string"?o.push({name:h,err:r}):(p||(p=r),p===r&&s.add(h))}if(!p)throw new Error(`no available backend found. ERR: ${o.map(h=>`[${h.name}] ${h.err}`).join(", ")}`);for(let{name:h,err:r}of o)a.includes(h)&&console.warn(`removing requested execution provider "${h}" from session options because it is not available: ${r}`);let c=n.filter(h=>s.has(typeof h=="string"?h:h.name));return[p,new Proxy(e,{get:(h,r)=>r==="executionProviders"?c:Reflect.get(h,r)})]}}),ts=O(()=>{fn()}),es,rs=O(()=>{es="1.20.1"}),ns,Gt,No=O(()=>{rs(),ns="warning",Gt={wasm:{},webgl:{},webgpu:{},versions:{common:es},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}`);ns=e}},get logLevel(){return ns}},Object.defineProperty(Gt,"logLevel",{enumerable:!0})}),z,os=O(()=>{No(),z=Gt}),is,as,ss=O(()=>{is=(e,n)=>{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 p,o;(n==null?void 0:n.tensorLayout)!==void 0&&n.tensorLayout==="NHWC"?(p=e.dims[2],o=e.dims[3]):(p=e.dims[3],o=e.dims[2]);let s=(n==null?void 0:n.format)!==void 0?n.format:"RGB",c=n==null?void 0:n.norm,h,r;c===void 0||c.mean===void 0?h=[255,255,255,255]:typeof c.mean=="number"?h=[c.mean,c.mean,c.mean,c.mean]:(h=[c.mean[0],c.mean[1],c.mean[2],0],c.mean[3]!==void 0&&(h[3]=c.mean[3])),c===void 0||c.bias===void 0?r=[0,0,0,0]:typeof c.bias=="number"?r=[c.bias,c.bias,c.bias,c.bias]:(r=[c.bias[0],c.bias[1],c.bias[2],0],c.bias[3]!==void 0&&(r[3]=c.bias[3]));let u=o*p,l=0,f=u,g=u*2,b=-1;s==="RGBA"?(l=0,f=u,g=u*2,b=u*3):s==="RGB"?(l=0,f=u,g=u*2):s==="RBG"&&(l=0,g=u,f=u*2);for(let v=0;v<o;v++)for(let S=0;S<p;S++){let P=(e.data[l++]-r[0])*h[0],_=(e.data[f++]-r[1])*h[1],A=(e.data[g++]-r[2])*h[2],L=b===-1?255:(e.data[b++]-r[3])*h[3];i.fillStyle="rgba("+P+","+_+","+A+","+L+")",i.fillRect(S,v,1,1)}if("toDataURL"in a)return a.toDataURL();throw new Error("toDataURL is not supported")}else throw new Error("Can not access image data")},as=(e,n)=>{let a=typeof document<"u"?document.createElement("canvas").getContext("2d"):new OffscreenCanvas(1,1).getContext("2d"),i;if(a!=null){let p,o,s;(n==null?void 0:n.tensorLayout)!==void 0&&n.tensorLayout==="NHWC"?(p=e.dims[2],o=e.dims[1],s=e.dims[3]):(p=e.dims[3],o=e.dims[2],s=e.dims[1]);let c=n!==void 0&&n.format!==void 0?n.format:"RGB",h=n==null?void 0:n.norm,r,u;h===void 0||h.mean===void 0?r=[255,255,255,255]:typeof h.mean=="number"?r=[h.mean,h.mean,h.mean,h.mean]:(r=[h.mean[0],h.mean[1],h.mean[2],255],h.mean[3]!==void 0&&(r[3]=h.mean[3])),h===void 0||h.bias===void 0?u=[0,0,0,0]:typeof h.bias=="number"?u=[h.bias,h.bias,h.bias,h.bias]:(u=[h.bias[0],h.bias[1],h.bias[2],0],h.bias[3]!==void 0&&(u[3]=h.bias[3]));let l=o*p;if(n!==void 0&&(n.format!==void 0&&s===4&&n.format!=="RGBA"||s===3&&n.format!=="RGB"&&n.format!=="BGR"))throw new Error("Tensor format doesn't match input tensor dims");let f=4,g=0,b=1,v=2,S=3,P=0,_=l,A=l*2,L=-1;c==="RGBA"?(P=0,_=l,A=l*2,L=l*3):c==="RGB"?(P=0,_=l,A=l*2):c==="RBG"&&(P=0,A=l,_=l*2),i=a.createImageData(p,o);for(let V=0;V<o*p;g+=f,b+=f,v+=f,S+=f,V++)i.data[g]=(e.data[P++]-u[0])*r[0],i.data[b]=(e.data[_++]-u[1])*r[1],i.data[v]=(e.data[A++]-u[2])*r[2],i.data[S]=L===-1?255:(e.data[L++]-u[3])*r[3]}else throw new Error("Can not access image data");return i}}),Ro,us,ls,fs,cs,ps,ds=O(()=>{cn(),Ro=(e,n)=>{if(e===void 0)throw new Error("Image buffer must be defined");if(n.height===void 0||n.width===void 0)throw new Error("Image height and width must be defined");if(n.tensorLayout==="NHWC")throw new Error("NHWC Tensor layout is not supported yet");let{height:a,width:i}=n,p=n.norm??{mean:255,bias:0},o,s;typeof p.mean=="number"?o=[p.mean,p.mean,p.mean,p.mean]:o=[p.mean[0],p.mean[1],p.mean[2],p.mean[3]??255],typeof p.bias=="number"?s=[p.bias,p.bias,p.bias,p.bias]:s=[p.bias[0],p.bias[1],p.bias[2],p.bias[3]??0];let c=n.format!==void 0?n.format:"RGBA",h=n.tensorFormat!==void 0&&n.tensorFormat!==void 0?n.tensorFormat:"RGB",r=a*i,u=h==="RGBA"?new Float32Array(r*4):new Float32Array(r*3),l=4,f=0,g=1,b=2,v=3,S=0,P=r,_=r*2,A=-1;c==="RGB"&&(l=3,f=0,g=1,b=2,v=-1),h==="RGBA"?A=r*3:h==="RBG"?(S=0,_=r,P=r*2):h==="BGR"&&(_=0,P=r,S=r*2);for(let L=0;L<r;L++,f+=l,b+=l,g+=l,v+=l)u[S++]=(e[f]+s[0])/o[0],u[P++]=(e[g]+s[1])/o[1],u[_++]=(e[b]+s[2])/o[2],A!==-1&&v!==-1&&(u[A++]=(e[v]+s[3])/o[3]);return h==="RGBA"?new St("float32",u,[1,4,a,i]):new St("float32",u,[1,3,a,i])},us=async(e,n)=>{let a=typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement,i=typeof ImageData<"u"&&e instanceof ImageData,p=typeof ImageBitmap<"u"&&e instanceof ImageBitmap,o=typeof e=="string",s,c=n??{},h=()=>{if(typeof document<"u")return document.createElement("canvas");if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(1,1);throw new Error("Canvas is not supported")},r=u=>typeof HTMLCanvasElement<"u"&&u instanceof HTMLCanvasElement||u instanceof OffscreenCanvas?u.getContext("2d"):null;if(a){let u=h();u.width=e.width,u.height=e.height;let l=r(u);if(l!=null){let f=e.height,g=e.width;if(n!==void 0&&n.resizedHeight!==void 0&&n.resizedWidth!==void 0&&(f=n.resizedHeight,g=n.resizedWidth),n!==void 0){if(c=n,n.tensorFormat!==void 0)throw new Error("Image input config format must be RGBA for HTMLImageElement");c.tensorFormat="RGBA",c.height=f,c.width=g}else c.tensorFormat="RGBA",c.height=f,c.width=g;l.drawImage(e,0,0),s=l.getImageData(0,0,g,f).data}else throw new Error("Can not access image data")}else if(i){let u,l;if(n!==void 0&&n.resizedWidth!==void 0&&n.resizedHeight!==void 0?(u=n.resizedHeight,l=n.resizedWidth):(u=e.height,l=e.width),n!==void 0&&(c=n),c.format="RGBA",c.height=u,c.width=l,n!==void 0){let f=h();f.width=l,f.height=u;let g=r(f);if(g!=null)g.putImageData(e,0,0),s=g.getImageData(0,0,l,u).data;else throw new Error("Can not access image data")}else s=e.data}else if(p){if(n===void 0)throw new Error("Please provide image config with format for Imagebitmap");let u=h();u.width=e.width,u.height=e.height;let l=r(u);if(l!=null){let f=e.height,g=e.width;return l.drawImage(e,0,0,g,f),s=l.getImageData(0,0,g,f).data,c.height=f,c.width=g,Ro(s,c)}else throw new Error("Can not access image data")}else{if(o)return new Promise((u,l)=>{let f=h(),g=r(f);if(!e||!g)return l();let b=new Image;b.crossOrigin="Anonymous",b.src=e,b.onload=()=>{f.width=b.width,f.height=b.height,g.drawImage(b,0,0,f.width,f.height);let v=g.getImageData(0,0,f.width,f.height);c.height=f.height,c.width=f.width,u(Ro(v.data,c))}});throw new Error("Input data provided is not supported - aborted tensor creation")}if(s!==void 0)return Ro(s,c);throw new Error("Input data provided is not supported - aborted tensor creation")},ls=(e,n)=>{let{width:a,height:i,download:p,dispose:o}=n,s=[1,i,a,4];return new St({location:"texture",type:"float32",texture:e,dims:s,download:p,dispose:o})},fs=(e,n)=>{let{dataType:a,dims:i,download:p,dispose:o}=n;return new St({location:"gpu-buffer",type:a??"float32",gpuBuffer:e,dims:i,download:p,dispose:o})},cs=(e,n)=>{let{dataType:a,dims:i,download:p,dispose:o}=n;return new St({location:"ml-tensor",type:a??"float32",mlTensor:e,dims:i,download:p,dispose:o})},ps=(e,n,a)=>new St({location:"cpu-pinned",type:e,data:n,dims:a??[n.length]})}),Be,Sr,hs,ms,bs=O(()=>{Be=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array],["int4",Uint8Array],["uint4",Uint8Array]]),Sr=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]),hs=!1,ms=()=>{if(!hs){hs=!0;let e=typeof BigInt64Array<"u"&&BigInt64Array.from,n=typeof BigUint64Array<"u"&&BigUint64Array.from,a=typeof Float16Array<"u"&&Float16Array.from;e&&(Be.set("int64",BigInt64Array),Sr.set(BigInt64Array,"int64")),n&&(Be.set("uint64",BigUint64Array),Sr.set(BigUint64Array,"uint64")),a?(Be.set("float16",Float16Array),Sr.set(Float16Array,"float16")):Be.set("float16",Uint16Array)}}}),gs,ys,xs=O(()=>{cn(),gs=e=>{let n=1;for(let a=0;a<e.length;a++){let i=e[a];if(typeof i!="number"||!Number.isSafeInteger(i))throw new TypeError(`dims[${a}] must be an integer, got: ${i}`);if(i<0)throw new RangeError(`dims[${a}] must be a non-negative integer, got: ${i}`);n*=i}return n},ys=(e,n)=>{switch(e.location){case"cpu":return new St(e.type,e.data,n);case"cpu-pinned":return new St({location:"cpu-pinned",data:e.data,type:e.type,dims:n});case"texture":return new St({location:"texture",texture:e.texture,type:e.type,dims:n});case"gpu-buffer":return new St({location:"gpu-buffer",gpuBuffer:e.gpuBuffer,type:e.type,dims:n});case"ml-tensor":return new St({location:"ml-tensor",mlTensor:e.mlTensor,type:e.type,dims:n});default:throw new Error(`tensorReshape: tensor location ${e.location} is not supported`)}}}),St,cn=O(()=>{ss(),ds(),bs(),xs(),St=class{constructor(e,n,a){ms();let i,p;if(typeof e=="object"&&"location"in e)switch(this.dataLocation=e.location,i=e.type,p=e.dims,e.location){case"cpu-pinned":{let s=Be.get(i);if(!s)throw new TypeError(`unsupported type "${i}" to create tensor from pinned buffer`);if(!(e.data instanceof s))throw new TypeError(`buffer should be of type ${s.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"&&i!=="uint4"&&i!=="int4")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}case"ml-tensor":{if(i!=="float32"&&i!=="float16"&&i!=="int32"&&i!=="int64"&&i!=="uint32"&&i!=="uint64"&&i!=="int8"&&i!=="uint8"&&i!=="bool")throw new TypeError(`unsupported type "${i}" to create tensor from MLTensor`);this.mlTensorData=e.mlTensor,this.downloader=e.download,this.disposer=e.dispose;break}default:throw new Error(`Tensor constructor: unsupported location '${this.dataLocation}'`)}else{let s,c;if(typeof e=="string")if(i=e,c=a,e==="string"){if(!Array.isArray(n))throw new TypeError("A string tensor's data must be a string array.");s=n}else{let h=Be.get(e);if(h===void 0)throw new TypeError(`Unsupported tensor type: ${e}.`);if(Array.isArray(n)){if(e==="float16"&&h===Uint16Array||e==="uint4"||e==="int4")throw new TypeError(`Creating a ${e} tensor from number array is not supported. Please use ${h.name} as data.`);e==="uint64"||e==="int64"?s=h.from(n,BigInt):s=h.from(n)}else if(n instanceof h)s=n;else if(n instanceof Uint8ClampedArray)if(e==="uint8")s=Uint8Array.from(n);else throw new TypeError("A Uint8ClampedArray tensor's data must be type of uint8");else throw new TypeError(`A ${i} tensor's data must be type of ${h}`)}else if(c=n,Array.isArray(e)){if(e.length===0)throw new TypeError("Tensor type cannot be inferred from an empty array.");let h=typeof e[0];if(h==="string")i="string",s=e;else if(h==="boolean")i="bool",s=Uint8Array.from(e);else throw new TypeError(`Invalid element type of data array: ${h}.`)}else if(e instanceof Uint8ClampedArray)i="uint8",s=Uint8Array.from(e);else{let h=Sr.get(e.constructor);if(h===void 0)throw new TypeError(`Unsupported type for tensor data: ${e.constructor}.`);i=h,s=e}if(c===void 0)c=[s.length];else if(!Array.isArray(c))throw new TypeError("A tensor's dims must be a number array");p=c,this.cpuData=s,this.dataLocation="cpu"}let o=gs(p);if(this.cpuData&&o!==this.cpuData.length&&!((i==="uint4"||i==="int4")&&Math.ceil(o/2)===this.cpuData.length))throw new Error(`Tensor's size(${o}) does not match data length(${this.cpuData.length}).`);this.type=i,this.dims=p,this.size=o}static async fromImage(e,n){return us(e,n)}static fromTexture(e,n){return ls(e,n)}static fromGpuBuffer(e,n){return fs(e,n)}static fromMLTensor(e,n){return cs(e,n)}static fromPinnedBuffer(e,n,a){return ps(e,n,a)}toDataURL(e){return is(this,e)}toImageData(e){return as(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}get mlTensor(){if(this.ensureValid(),!this.mlTensorData)throw new Error("The data is not stored as a WebNN MLTensor.");return this.mlTensorData}async getData(e){switch(this.ensureValid(),this.dataLocation){case"cpu":case"cpu-pinned":return this.data;case"texture":case"gpu-buffer":case"ml-tensor":{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 n=await this.downloader();return this.downloader=void 0,this.dataLocation="cpu",this.cpuData=n,e&&this.disposer&&(this.disposer(),this.disposer=void 0),n}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.mlTensorData=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 ys(this,e)}}}),yt,pn=O(()=>{cn(),yt=St}),Ts,ws,Fe,Ce,Go=O(()=>{No(),Ts=(e,n)=>{(typeof Gt.trace>"u"?!Gt.wasm.trace:!Gt.trace)||console.timeStamp(`${e}::ORT::${n}`)},ws=(e,n)=>{var p;let a=((p=new Error().stack)==null?void 0:p.split(/\r\n|\r|\n/g))||[],i=!1;for(let o=0;o<a.length;o++){if(i&&!a[o].includes("TRACE_FUNC")){let s=`FUNC_${e}::${a[o].trim().split(" ")[1]}`;n&&(s+=`::${n}`),Ts("CPU",s);return}a[o].includes("TRACE_FUNC")&&(i=!0)}},Fe=e=>{(typeof Gt.trace>"u"?!Gt.wasm.trace:!Gt.trace)||ws("BEGIN",e)},Ce=e=>{(typeof Gt.trace>"u"?!Gt.wasm.trace:!Gt.trace)||ws("END",e)}}),dn,vs=O(()=>{fn(),pn(),Go(),dn=class Oa{constructor(n){this.handler=n}async run(n,a,i){Fe();let p={},o={};if(typeof n!="object"||n===null||n instanceof yt||Array.isArray(n))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let s=!0;if(typeof a=="object"){if(a===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(a instanceof yt)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.");s=!1;for(let r of a){if(typeof r!="string")throw new TypeError("'fetches' must be a string array or an object.");if(this.outputNames.indexOf(r)===-1)throw new RangeError(`'fetches' contains invalid output name: ${r}.`);p[r]=null}if(typeof i=="object"&&i!==null)o=i;else if(typeof i<"u")throw new TypeError("'options' must be an object.")}else{let r=!1,u=Object.getOwnPropertyNames(a);for(let l of this.outputNames)if(u.indexOf(l)!==-1){let f=a[l];(f===null||f instanceof yt)&&(r=!0,s=!1,p[l]=f)}if(r){if(typeof i=="object"&&i!==null)o=i;else if(typeof i<"u")throw new TypeError("'options' must be an object.")}else o=a}}else if(typeof a<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let r of this.inputNames)if(typeof n[r]>"u")throw new Error(`input '${r}' is missing in 'feeds'.`);if(s)for(let r of this.outputNames)p[r]=null;let c=await this.handler.run(n,p,o),h={};for(let r in c)if(Object.hasOwnProperty.call(c,r)){let u=c[r];u instanceof yt?h[r]=u:h[r]=new yt(u.type,u.data,u.dims)}return Ce(),h}async release(){return this.handler.dispose()}static async create(n,a,i,p){Fe();let o,s={};if(typeof n=="string"){if(o=n,typeof a=="object"&&a!==null)s=a;else if(typeof a<"u")throw new TypeError("'options' must be an object.")}else if(n instanceof Uint8Array){if(o=n,typeof a=="object"&&a!==null)s=a;else if(typeof a<"u")throw new TypeError("'options' must be an object.")}else if(n instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&n instanceof SharedArrayBuffer){let u=n,l=0,f=n.byteLength;if(typeof a=="object"&&a!==null)s=a;else if(typeof a=="number"){if(l=a,!Number.isSafeInteger(l))throw new RangeError("'byteOffset' must be an integer.");if(l<0||l>=u.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${u.byteLength}).`);if(f=n.byteLength-l,typeof i=="number"){if(f=i,!Number.isSafeInteger(f))throw new RangeError("'byteLength' must be an integer.");if(f<=0||l+f>u.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${u.byteLength-l}].`);if(typeof p=="object"&&p!==null)s=p;else if(typeof p<"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.");o=new Uint8Array(u,l,f)}else throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");let[c,h]=await ln(s),r=await c.createInferenceSessionHandler(o,h);return Ce(),new Oa(r)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}}}),Yd,Is=O(()=>{vs(),Yd=dn}),_s=O(()=>{}),Os=O(()=>{}),Ss=O(()=>{}),As=O(()=>{}),Zd,hn,Ps=O(()=>{fn(),pn(),Zd="Training backend could not be resolved. Make sure you're using the correct configuration & WebAssembly files.",hn=class Sa{constructor(n,a,i){this.handler=n,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(n,a){let i=n.evalModel||"",p=n.optimizerModel||"",o=a||{},[s,c]=await ln(o);if(s.createTrainingSessionHandler){let h=await s.createTrainingSessionHandler(n.checkpointState,n.trainModel,i,p,c);return new Sa(h,!!n.optimizerModel,!!n.evalModel)}else throw new Error(Zd)}typeNarrowingForRunStep(n,a,i,p,o){let s={},c={};if(typeof i!="object"||i===null||i instanceof yt||Array.isArray(i))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let h=!0;if(typeof p=="object"){if(p===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(p instanceof yt)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(p)){if(p.length===0)throw new TypeError("'fetches' cannot be an empty array.");h=!1;for(let r of p){if(typeof r!="string")throw new TypeError("'fetches' must be a string array or an object.");if(a.indexOf(r)===-1)throw new RangeError(`'fetches' contains invalid output name: ${r}.`);s[r]=null}if(typeof o=="object"&&o!==null)c=o;else if(typeof o<"u")throw new TypeError("'options' must be an object.")}else{let r=!1,u=Object.getOwnPropertyNames(p);for(let l of a)if(u.indexOf(l)!==-1){let f=p[l];(f===null||f instanceof yt)&&(r=!0,h=!1,s[l]=f)}if(r){if(typeof o=="object"&&o!==null)c=o;else if(typeof o<"u")throw new TypeError("'options' must be an object.")}else c=p}}else if(typeof p<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let r of n)if(typeof i[r]>"u")throw new Error(`input '${r}' is missing in 'feeds'.`);if(h)for(let r of a)s[r]=null;return[s,c]}convertHandlerReturnTypeToMapOfTensors(n){let a={};for(let i in n)if(Object.hasOwnProperty.call(n,i)){let p=n[i];p instanceof yt?a[i]=p:a[i]=new yt(p.type,p.data,p.dims)}return a}async lazyResetGrad(){await this.handler.lazyResetGrad()}async runTrainStep(n,a,i){let[p,o]=this.typeNarrowingForRunStep(this.trainingInputNames,this.trainingOutputNames,n,a,i),s=await this.handler.runTrainStep(n,p,o);return this.convertHandlerReturnTypeToMapOfTensors(s)}async runOptimizerStep(n){if(this.hasOptimizerModel)await this.handler.runOptimizerStep(n||{});else throw new Error("This TrainingSession has no OptimizerModel loaded.")}async runEvalStep(n,a,i){if(this.hasEvalModel){let[p,o]=this.typeNarrowingForRunStep(this.evalInputNames,this.evalOutputNames,n,a,i),s=await this.handler.runEvalStep(n,p,o);return this.convertHandlerReturnTypeToMapOfTensors(s)}else throw new Error("This TrainingSession has no EvalModel loaded.")}async getParametersSize(n=!0){return this.handler.getParametersSize(n)}async loadParametersBuffer(n,a=!0){let i=await this.getParametersSize(a);if(n.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(n,a)}async getContiguousParameters(n=!0){return this.handler.getContiguousParameters(n)}async release(){return this.handler.dispose()}}}),Qd,Es=O(()=>{Ps(),Qd=hn}),Mo={};Or(Mo,{InferenceSession:()=>Yd,TRACE:()=>Ts,TRACE_FUNC_BEGIN:()=>Fe,TRACE_FUNC_END:()=>Ce,Tensor:()=>yt,TrainingSession:()=>Qd,env:()=>z,registerBackend:()=>nr});var Yt=O(()=>{ts(),os(),Is(),pn(),_s(),Os(),Go(),Ss(),As(),Es()});function _e(e,n,a,i){if(n===void 0)return eh(e);if(a===void 0)mn(e,n);else if(typeof a=="number"&&i===void 0)mn(e,n);else if(typeof a=="string"&&i===void 0)mn(e,a,1,n);else if(typeof a=="string"&&typeof i=="number")mn(e,a,i,n);else throw new TypeError("input is valid")}function eh(e){return{verbose:_e.verbose.bind(null,e),info:_e.info.bind(null,e),warning:_e.warning.bind(null,e),error:_e.error.bind(null,e),fatal:_e.fatal.bind(null,e)}}function mn(e,n,a,i){let p=Ar[i||""]||Ar[""];Ls[e]<Ls[p.minimalSeverity]||(p.logDateTime&&(n=`${new Date().toISOString()}|${n}`),p.logSourceLocation,th[p.provider].log(e,n,i))}var Uo,Vo,Ls,th,$s,Ar,tt,gn,yn,xn,bn,Ut=O(()=>{Uo=class{log(e,n,a){}},Vo=class{log(e,n,a){console.log(`${this.color(e)} ${a?"\x1B[35m"+a+"\x1B[0m ":""}${n}`)}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}`)}}},Ls={verbose:1e3,info:2e3,warning:4e3,error:5e3,fatal:6e3},th={none:new Uo,console:new Vo},$s={provider:"console",minimalSeverity:"warning",logDateTime:!0,logSourceLocation:!1},Ar={"":$s},(e=>{function n(r,u){e("verbose",r,u)}e.verbose=n;function a(r,u){e("info",r,u)}e.info=a;function i(r,u){e("warning",r,u)}e.warning=i;function p(r,u){e("error",r,u)}e.error=p;function o(r,u){e("fatal",r,u)}e.fatal=o;function s(r){Ar={},c("",r||{})}e.reset=s;function c(r,u){if(r==="*")s(u);else{let l=Ar[r]||$s;Ar[r]={provider:u.provider||l.provider,minimalSeverity:u.minimalSeverity||l.minimalSeverity,logDateTime:u.logDateTime===void 0?l.logDateTime:u.logDateTime,logSourceLocation:u.logSourceLocation===void 0?l.logSourceLocation:u.logSourceLocation}}}e.set=c;function h(r){let u={};r.logLevel&&(u.minimalSeverity=r.logLevel),c("",u)}e.setWithEnv=h})(_e||(_e={})),tt=_e,gn=class{constructor(e,n,a,i,p,o){this.category=e,this.name=n,this.startTime=a,this.endCallback=i,this.timer=p,this.ctx=o}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)}},yn=class{constructor(e,n,a,i){this.category=e,this.name=n,this.startTime=a,this.endTime=i}},xn=class{constructor(e,n,a){this._started=!1,this._flushPointer=0,this._started=!1,this._maxNumberEvents=e===void 0?1e4:e,this._flushBatchSize=n===void 0?10:n,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=bn(),this._flushPointer=0}stop(){for(this._started=!1;this._flushPointer<this._timingEvents.length;this._flushPointer++)this.logOneEvent(this._timingEvents[this._flushPointer])}event(e,n,a,i){let p=this._started?this.begin(e,n,i):void 0,o=!1,s=a();if(s&&typeof s.then=="function")return o=!0,new Promise((c,h)=>{s.then(async r=>{p&&await p.end(),c(r)},async r=>{p&&await p.end(),h(r)})});if(!o&&p){let c=p.end();if(c&&typeof c.then=="function")return new Promise((h,r)=>{c.then(()=>{h(s)},u=>{r(u)})})}return s}begin(e,n,a){if(!this._started)throw new Error("profiler is not started yet");if(a===void 0){let i=bn();return this.flush(i),new gn(e,n,i,p=>this.endSync(p))}else{let i=a.beginTimer();return new gn(e,n,0,async p=>this.end(p),i,a)}}async end(e){let n=await e.checkTimer();this._timingEvents.length<this._maxNumberEvents&&(this._timingEvents.push(new yn(e.category,e.name,e.startTime,n)),this.flush(n))}endSync(e){let n=bn();this._timingEvents.length<this._maxNumberEvents&&(this._timingEvents.push(new yn(e.category,e.name,e.startTime,n)),this.flush(n))}logOneEvent(e){tt.verbose(`Profiler.${e.category}`,`${(e.endTime-e.startTime).toFixed(2)}ms on event '${e.name}' at ${e.endTime.toFixed(2)}`)}flush(e){if(this._timingEvents.length-this._flushPointer>=this._flushBatchSize||e-this._flushTime>=this._flushIntervalInMilliseconds){for(let n=this._flushPointer;this._flushPointer<n+this._flushBatchSize&&this._flushPointer<this._timingEvents.length;this._flushPointer++)this.logOneEvent(this._timingEvents[this._flushPointer]);this._flushTime=bn()}}get started(){return this._started}},bn=typeof performance<"u"&&performance.now?()=>performance.now():Date.now});function ks(e,n,a){for(let i of a){let p=i[0],o=i[1],s=i[2],c=i[3],h=i[4];if(e.opType===p){for(let r of n)if((r.domain===o||r.domain==="ai.onnx"&&o==="")&&rh(r.version,s))return{opImpl:c,opInit:h}}}throw new TypeError(`cannot resolve operator '${e.opType}' with opsets: ${n.map(i=>`${i.domain||"ai.onnx"} v${i.version}`).join(", ")}`)}function rh(e,n){if(n.endsWith("+")){let a=Number.parseInt(n.substring(0,n.length-1),10);return!isNaN(a)&&a<=e}else if(n.split("-").length===2){let a=n.split("-"),i=Number.parseInt(a[0],10),p=Number.parseInt(a[1],10);return!isNaN(i)&&!isNaN(p)&&i<=e&&e<=p}else return Number.parseInt(n,10)===e}var Bs=O(()=>{}),Fs=mt(e=>{e.__esModule=!0;var n=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 p=i.toString();return i&&(i instanceof a||a.validator.test(p))},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 p="",o=0;o<i;o++)p+=((1+Math.random())*65536|0).toString(16).substring(1);return p},a.prototype.equals=function(i){return a.isGuid(i)&&this.value===i.toString()},a.prototype.isEmpty=function(){return this.value===a.EMPTY},a.prototype.toString=function(){return this.value},a.prototype.toJSON=function(){return{value:this.value}},a.validator=new RegExp("^[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$","i"),a.EMPTY="00000000-0000-0000-0000-000000000000",a}();e.Guid=n});function rt(e,n,a){this.low=e|0,this.high=n|0,this.unsigned=!!a}function Et(e){return(e&&e.__isLong__)===!0}function Cs(e){var n=Math.clz32(e&-e);return e?31-n:n}function Ne(e,n){var a,i,p;return n?(e>>>=0,(p=0<=e&&e<256)&&(i=Rs[e],i)?i:(a=J(e,0,!0),p&&(Rs[e]=a),a)):(e|=0,(p=-128<=e&&e<128)&&(i=Ns[e],i)?i:(a=J(e,e<0?-1:0,!1),p&&(Ns[e]=a),a))}function zt(e,n){if(isNaN(e))return n?ye:Zt;if(n){if(e<0)return ye;if(e>=Vs)return Hs}else{if(e<=-Ms)return Ct;if(e+1>=Ms)return Ws}return e<0?zt(-e,n).neg():J(e%ir|0,e/ir|0,n)}function J(e,n,a){return new rt(e,n,a)}function Ho(e,n,a){if(e.length===0)throw Error("empty string");if(typeof n=="number"?(a=n,n=!1):n=!!n,e==="NaN"||e==="Infinity"||e==="+Infinity"||e==="-Infinity")return n?ye:Zt;if(a=a||10,a<2||36<a)throw RangeError("radix");var i;if((i=e.indexOf("-"))>0)throw Error("interior hyphen");if(i===0)return Ho(e.substring(1),n,a).neg();for(var p=zt(Tn(a,8)),o=Zt,s=0;s<e.length;s+=8){var c=Math.min(8,e.length-s),h=parseInt(e.substring(s,s+c),a);if(c<8){var r=zt(Tn(a,c));o=o.mul(r).add(zt(h))}else o=o.mul(p),o=o.add(zt(h))}return o.unsigned=n,o}function Qt(e,n){return typeof e=="number"?zt(e,n):typeof e=="string"?Ho(e,n):J(e.low,e.high,typeof n=="boolean"?n:e.unsigned)}var Vt,Ns,Rs,Tn,Gs,oh,ir,Vs,Ms,Us,Zt,ye,or,zs,Wo,Ws,Hs,Ct,D,xe,qo=O(()=>{Vt=null;try{Vt=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{}rt.prototype.__isLong__,Object.defineProperty(rt.prototype,"__isLong__",{value:!0}),rt.isLong=Et,Ns={},Rs={},rt.fromInt=Ne,rt.fromNumber=zt,rt.fromBits=J,Tn=Math.pow,rt.fromString=Ho,rt.fromValue=Qt,Gs=65536,oh=1<<24,ir=Gs*Gs,Vs=ir*ir,Ms=Vs/2,Us=Ne(oh),Zt=Ne(0),rt.ZERO=Zt,ye=Ne(0,!0),rt.UZERO=ye,or=Ne(1),rt.ONE=or,zs=Ne(1,!0),rt.UONE=zs,Wo=Ne(-1),rt.NEG_ONE=Wo,Ws=J(-1,2147483647,!1),rt.MAX_VALUE=Ws,Hs=J(-1,-1,!0),rt.MAX_UNSIGNED_VALUE=Hs,Ct=J(0,-2147483648,!1),rt.MIN_VALUE=Ct,D=rt.prototype,D.toInt=function(){return this.unsigned?this.low>>>0:this.low},D.toNumber=function(){return this.unsigned?(this.high>>>0)*ir+(this.low>>>0):this.high*ir+(this.low>>>0)},D.toString=function(e){if(e=e||10,e<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(Ct)){var n=zt(e),a=this.div(n),i=a.mul(n).sub(this);return a.toString(e)+i.toInt().toString(e)}else return"-"+this.neg().toString(e);for(var p=zt(Tn(e,6),this.unsigned),o=this,s="";;){var c=o.div(p),h=o.sub(c.mul(p)).toInt()>>>0,r=h.toString(e);if(o=c,o.isZero())return r+s;for(;r.length<6;)r="0"+r;s=""+r+s}},D.getHighBits=function(){return this.high},D.getHighBitsUnsigned=function(){return this.high>>>0},D.getLowBits=function(){return this.low},D.getLowBitsUnsigned=function(){return this.low>>>0},D.getNumBitsAbs=function(){if(this.isNegative())return this.eq(Ct)?64:this.neg().getNumBitsAbs();for(var e=this.high!=0?this.high:this.low,n=31;n>0&&!(e&1<<n);n--);return this.high!=0?n+33:n+1},D.isZero=function(){return this.high===0&&this.low===0},D.eqz=D.isZero,D.isNegative=function(){return!this.unsigned&&this.high<0},D.isPositive=function(){return this.unsigned||this.high>=0},D.isOdd=function(){return(this.low&1)===1},D.isEven=function(){return(this.low&1)===0},D.equals=function(e){return Et(e)||(e=Qt(e)),this.unsigned!==e.unsigned&&this.high>>>31===1&&e.high>>>31===1?!1:this.high===e.high&&this.low===e.low},D.eq=D.equals,D.notEquals=function(e){return!this.eq(e)},D.neq=D.notEquals,D.ne=D.notEquals,D.lessThan=function(e){return this.comp(e)<0},D.lt=D.lessThan,D.lessThanOrEqual=function(e){return this.comp(e)<=0},D.lte=D.lessThanOrEqual,D.le=D.lessThanOrEqual,D.greaterThan=function(e){return this.comp(e)>0},D.gt=D.greaterThan,D.greaterThanOrEqual=function(e){return this.comp(e)>=0},D.gte=D.greaterThanOrEqual,D.ge=D.greaterThanOrEqual,D.compare=function(e){if(Et(e)||(e=Qt(e)),this.eq(e))return 0;var n=this.isNegative(),a=e.isNegative();return n&&!a?-1:!n&&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},D.comp=D.compare,D.negate=function(){return!this.unsigned&&this.eq(Ct)?Ct:this.not().add(or)},D.neg=D.negate,D.add=function(e){Et(e)||(e=Qt(e));var n=this.high>>>16,a=this.high&65535,i=this.low>>>16,p=this.low&65535,o=e.high>>>16,s=e.high&65535,c=e.low>>>16,h=e.low&65535,r=0,u=0,l=0,f=0;return f+=p+h,l+=f>>>16,f&=65535,l+=i+c,u+=l>>>16,l&=65535,u+=a+s,r+=u>>>16,u&=65535,r+=n+o,r&=65535,J(l<<16|f,r<<16|u,this.unsigned)},D.subtract=function(e){return Et(e)||(e=Qt(e)),this.add(e.neg())},D.sub=D.subtract,D.multiply=function(e){if(this.isZero())return this;if(Et(e)||(e=Qt(e)),Vt){var n=Vt.mul(this.low,this.high,e.low,e.high);return J(n,Vt.get_high(),this.unsigned)}if(e.isZero())return this.unsigned?ye:Zt;if(this.eq(Ct))return e.isOdd()?Ct:Zt;if(e.eq(Ct))return this.isOdd()?Ct:Zt;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(Us)&&e.lt(Us))return zt(this.toNumber()*e.toNumber(),this.unsigned);var a=this.high>>>16,i=this.high&65535,p=this.low>>>16,o=this.low&65535,s=e.high>>>16,c=e.high&65535,h=e.low>>>16,r=e.low&65535,u=0,l=0,f=0,g=0;return g+=o*r,f+=g>>>16,g&=65535,f+=p*r,l+=f>>>16,f&=65535,f+=o*h,l+=f>>>16,f&=65535,l+=i*r,u+=l>>>16,l&=65535,l+=p*h,u+=l>>>16,l&=65535,l+=o*c,u+=l>>>16,l&=65535,u+=a*r+i*h+p*c+o*s,u&=65535,J(f<<16|g,u<<16|l,this.unsigned)},D.mul=D.multiply,D.divide=function(e){if(Et(e)||(e=Qt(e)),e.isZero())throw Error("division by zero");if(Vt){if(!this.unsigned&&this.high===-2147483648&&e.low===-1&&e.high===-1)return this;var n=(this.unsigned?Vt.div_u:Vt.div_s)(this.low,this.high,e.low,e.high);return J(n,Vt.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?ye:Zt;var a,i,p;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return ye;if(e.gt(this.shru(1)))return zs;p=ye}else{if(this.eq(Ct)){if(e.eq(or)||e.eq(Wo))return Ct;if(e.eq(Ct))return or;var o=this.shr(1);return a=o.div(e).shl(1),a.eq(Zt)?e.isNegative()?or:Wo:(i=this.sub(e.mul(a)),p=a.add(i.div(e)),p)}else if(e.eq(Ct))return this.unsigned?ye:Zt;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();p=Zt}for(i=this;i.gte(e);){a=Math.max(1,Math.floor(i.toNumber()/e.toNumber()));for(var s=Math.ceil(Math.log(a)/Math.LN2),c=s<=48?1:Tn(2,s-48),h=zt(a),r=h.mul(e);r.isNegative()||r.gt(i);)a-=c,h=zt(a,this.unsigned),r=h.mul(e);h.isZero()&&(h=or),p=p.add(h),i=i.sub(r)}return p},D.div=D.divide,D.modulo=function(e){if(Et(e)||(e=Qt(e)),Vt){var n=(this.unsigned?Vt.rem_u:Vt.rem_s)(this.low,this.high,e.low,e.high);return J(n,Vt.get_high(),this.unsigned)}return this.sub(this.div(e).mul(e))},D.mod=D.modulo,D.rem=D.modulo,D.not=function(){return J(~this.low,~this.high,this.unsigned)},D.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32},D.clz=D.countLeadingZeros,D.countTrailingZeros=function(){return this.low?Cs(this.low):Cs(this.high)+32},D.ctz=D.countTrailingZeros,D.and=function(e){return Et(e)||(e=Qt(e)),J(this.low&e.low,this.high&e.high,this.unsigned)},D.or=function(e){return Et(e)||(e=Qt(e)),J(this.low|e.low,this.high|e.high,this.unsigned)},D.xor=function(e){return Et(e)||(e=Qt(e)),J(this.low^e.low,this.high^e.high,this.unsigned)},D.shiftLeft=function(e){return Et(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?J(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):J(0,this.low<<e-32,this.unsigned)},D.shl=D.shiftLeft,D.shiftRight=function(e){return Et(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?J(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):J(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},D.shr=D.shiftRight,D.shiftRightUnsigned=function(e){return Et(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?J(this.low>>>e|this.high<<32-e,this.high>>>e,this.unsigned):e===32?J(this.high,0,this.unsigned):J(this.high>>>e-32,0,this.unsigned)},D.shru=D.shiftRightUnsigned,D.shr_u=D.shiftRightUnsigned,D.rotateLeft=function(e){var n;return Et(e)&&(e=e.toInt()),(e&=63)===0?this:e===32?J(this.high,this.low,this.unsigned):e<32?(n=32-e,J(this.low<<e|this.high>>>n,this.high<<e|this.low>>>n,this.unsigned)):(e-=32,n=32-e,J(this.high<<e|this.low>>>n,this.low<<e|this.high>>>n,this.unsigned))},D.rotl=D.rotateLeft,D.rotateRight=function(e){var n;return Et(e)&&(e=e.toInt()),(e&=63)===0?this:e===32?J(this.high,this.low,this.unsigned):e<32?(n=32-e,J(this.high<<n|this.low>>>e,this.low<<n|this.high>>>e,this.unsigned)):(e-=32,n=32-e,J(this.low<<n|this.high>>>e,this.high<<n|this.low>>>e,this.unsigned))},D.rotr=D.rotateRight,D.toSigned=function(){return this.unsigned?J(this.low,this.high,!1):this},D.toUnsigned=function(){return this.unsigned?this:J(this.low,this.high,!0)},D.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},D.toBytesLE=function(){var e=this.high,n=this.low;return[n&255,n>>>8&255,n>>>16&255,n>>>24,e&255,e>>>8&255,e>>>16&255,e>>>24]},D.toBytesBE=function(){var e=this.high,n=this.low;return[e>>>24,e>>>16&255,e>>>8&255,e&255,n>>>24,n>>>16&255,n>>>8&255,n&255]},rt.fromBytes=function(e,n,a){return a?rt.fromBytesLE(e,n):rt.fromBytesBE(e,n)},rt.fromBytesLE=function(e,n){return new rt(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,n)},rt.fromBytesBE=function(e,n){return new rt(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],n)},xe=rt}),w,wn=O(()=>{w={},w.Offset,w.Table,w.SIZEOF_SHORT=2,w.SIZEOF_INT=4,w.FILE_IDENTIFIER_LENGTH=4,w.SIZE_PREFIX_LENGTH=4,w.Encoding={UTF8_BYTES:1,UTF16_STRING:2},w.int32=new Int32Array(2),w.float32=new Float32Array(w.int32.buffer),w.float64=new Float64Array(w.int32.buffer),w.isLittleEndian=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1,w.Long=function(e,n){this.low=e|0,this.high=n|0},w.Long.create=function(e,n){return e==0&&n==0?w.Long.ZERO:new w.Long(e,n)},w.Long.prototype.toFloat64=function(){return(this.low>>>0)+this.high*4294967296},w.Long.prototype.equals=function(e){return this.low==e.low&&this.high==e.high},w.Long.ZERO=new w.Long(0,0),w.Builder=function(e){if(e)var n=e;else var n=1024;this.bb=w.ByteBuffer.allocate(n),this.space=n,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},w.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},w.Builder.prototype.forceDefaults=function(e){this.force_defaults=e},w.Builder.prototype.dataBuffer=function(){return this.bb},w.Builder.prototype.asUint8Array=function(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())},w.Builder.prototype.prep=function(e,n){e>this.minalign&&(this.minalign=e);for(var a=~(this.bb.capacity()-this.space+n)+1&e-1;this.space<a+e+n;){var i=this.bb.capacity();this.bb=w.Builder.growByteBuffer(this.bb),this.space+=this.bb.capacity()-i}this.pad(a)},w.Builder.prototype.pad=function(e){for(var n=0;n<e;n++)this.bb.writeInt8(--this.space,0)},w.Builder.prototype.writeInt8=function(e){this.bb.writeInt8(this.space-=1,e)},w.Builder.prototype.writeInt16=function(e){this.bb.writeInt16(this.space-=2,e)},w.Builder.prototype.writeInt32=function(e){this.bb.writeInt32(this.space-=4,e)},w.Builder.prototype.writeInt64=function(e){this.bb.writeInt64(this.space-=8,e)},w.Builder.prototype.writeFloat32=function(e){this.bb.writeFloat32(this.space-=4,e)},w.Builder.prototype.writeFloat64=function(e){this.bb.writeFloat64(this.space-=8,e)},w.Builder.prototype.addInt8=function(e){this.prep(1,0),this.writeInt8(e)},w.Builder.prototype.addInt16=function(e){this.prep(2,0),this.writeInt16(e)},w.Builder.prototype.addInt32=function(e){this.prep(4,0),this.writeInt32(e)},w.Builder.prototype.addInt64=function(e){this.prep(8,0),this.writeInt64(e)},w.Builder.prototype.addFloat32=function(e){this.prep(4,0),this.writeFloat32(e)},w.Builder.prototype.addFloat64=function(e){this.prep(8,0),this.writeFloat64(e)},w.Builder.prototype.addFieldInt8=function(e,n,a){(this.force_defaults||n!=a)&&(this.addInt8(n),this.slot(e))},w.Builder.prototype.addFieldInt16=function(e,n,a){(this.force_defaults||n!=a)&&(this.addInt16(n),this.slot(e))},w.Builder.prototype.addFieldInt32=function(e,n,a){(this.force_defaults||n!=a)&&(this.addInt32(n),this.slot(e))},w.Builder.prototype.addFieldInt64=function(e,n,a){(this.force_defaults||!n.equals(a))&&(this.addInt64(n),this.slot(e))},w.Builder.prototype.addFieldFloat32=function(e,n,a){(this.force_defaults||n!=a)&&(this.addFloat32(n),this.slot(e))},w.Builder.prototype.addFieldFloat64=function(e,n,a){(this.force_defaults||n!=a)&&(this.addFloat64(n),this.slot(e))},w.Builder.prototype.addFieldOffset=function(e,n,a){(this.force_defaults||n!=a)&&(this.addOffset(n),this.slot(e))},w.Builder.prototype.addFieldStruct=function(e,n,a){n!=a&&(this.nested(n),this.slot(e))},w.Builder.prototype.nested=function(e){if(e!=this.offset())throw new Error("FlatBuffers: struct must be serialized inline.")},w.Builder.prototype.notNested=function(){if(this.isNested)throw new Error("FlatBuffers: object serialization must not be nested.")},w.Builder.prototype.slot=function(e){this.vtable[e]=this.offset()},w.Builder.prototype.offset=function(){return this.bb.capacity()-this.space},w.Builder.growByteBuffer=function(e){var n=e.capacity();if(n&3221225472)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");var a=n<<1,i=w.ByteBuffer.allocate(a);return i.setPosition(a-n),i.bytes().set(e.bytes(),a-n),i},w.Builder.prototype.addOffset=function(e){this.prep(w.SIZEOF_INT,0),this.writeInt32(this.offset()-e+w.SIZEOF_INT)},w.Builder.prototype.startObject=function(e){this.notNested(),this.vtable==null&&(this.vtable=[]),this.vtable_in_use=e;for(var n=0;n<e;n++)this.vtable[n]=0;this.isNested=!0,this.object_start=this.offset()},w.Builder.prototype.endObject=function(){if(this.vtable==null||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);for(var e=this.offset(),n=this.vtable_in_use-1;n>=0&&this.vtable[n]==0;n--);for(var a=n+1;n>=0;n--)this.addInt16(this.vtable[n]!=0?e-this.vtable[n]:0);var i=2;this.addInt16(e-this.object_start);var p=(a+i)*w.SIZEOF_SHORT;this.addInt16(p);var o=0,s=this.space;t:for(n=0;n<this.vtables.length;n++){var c=this.bb.capacity()-this.vtables[n];if(p==this.bb.readInt16(c)){for(var h=w.SIZEOF_SHORT;h<p;h+=w.SIZEOF_SHORT)if(this.bb.readInt16(s+h)!=this.bb.readInt16(c+h))continue t;o=this.vtables[n];break}}return o?(this.space=this.bb.capacity()-e,this.bb.writeInt32(this.space,o-e)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-e,this.offset()-e)),this.isNested=!1,e},w.Builder.prototype.finish=function(e,n,a){var i=a?w.SIZE_PREFIX_LENGTH:0;if(n){var p=n;if(this.prep(this.minalign,w.SIZEOF_INT+w.FILE_IDENTIFIER_LENGTH+i),p.length!=w.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+w.FILE_IDENTIFIER_LENGTH);for(var o=w.FILE_IDENTIFIER_LENGTH-1;o>=0;o--)this.writeInt8(p.charCodeAt(o))}this.prep(this.minalign,w.SIZEOF_INT+i),this.addOffset(e),i&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)},w.Builder.prototype.finishSizePrefixed=function(e,n){this.finish(e,n,!0)},w.Builder.prototype.requiredField=function(e,n){var a=this.bb.capacity()-e,i=a-this.bb.readInt32(a),p=this.bb.readInt16(i+n)!=0;if(!p)throw new Error("FlatBuffers: field "+n+" must be set")},w.Builder.prototype.startVector=function(e,n,a){this.notNested(),this.vector_num_elems=n,this.prep(w.SIZEOF_INT,e*n),this.prep(a,e*n)},w.Builder.prototype.endVector=function(){return this.writeInt32(this.vector_num_elems),this.offset()},w.Builder.prototype.createString=function(e){if(e instanceof Uint8Array)var n=e;else for(var n=[],a=0;a<e.length;){var i,p=e.charCodeAt(a++);if(p<55296||p>=56320)i=p;else{var o=e.charCodeAt(a++);i=(p<<10)+o+-56613888}i<128?n.push(i):(i<2048?n.push(i>>6&31|192):(i<65536?n.push(i>>12&15|224):n.push(i>>18&7|240,i>>12&63|128),n.push(i>>6&63|128)),n.push(i&63|128))}this.addInt8(0),this.startVector(1,n.length,1),this.bb.setPosition(this.space-=n.length);for(var a=0,s=this.space,c=this.bb.bytes();a<n.length;a++)c[s++]=n[a];return this.endVector()},w.Builder.prototype.createLong=function(e,n){return w.Long.create(e,n)},w.ByteBuffer=function(e){this.bytes_=e,this.position_=0},w.ByteBuffer.allocate=function(e){return new w.ByteBuffer(new Uint8Array(e))},w.ByteBuffer.prototype.clear=function(){this.position_=0},w.ByteBuffer.prototype.bytes=function(){return this.bytes_},w.ByteBuffer.prototype.position=function(){return this.position_},w.ByteBuffer.prototype.setPosition=function(e){this.position_=e},w.ByteBuffer.prototype.capacity=function(){return this.bytes_.length},w.ByteBuffer.prototype.readInt8=function(e){return this.readUint8(e)<<24>>24},w.ByteBuffer.prototype.readUint8=function(e){return this.bytes_[e]},w.ByteBuffer.prototype.readInt16=function(e){return this.readUint16(e)<<16>>16},w.ByteBuffer.prototype.readUint16=function(e){return this.bytes_[e]|this.bytes_[e+1]<<8},w.ByteBuffer.prototype.readInt32=function(e){return this.bytes_[e]|this.bytes_[e+1]<<8|this.bytes_[e+2]<<16|this.bytes_[e+3]<<24},w.ByteBuffer.prototype.readUint32=function(e){return this.readInt32(e)>>>0},w.ByteBuffer.prototype.readInt64=function(e){return new w.Long(this.readInt32(e),this.readInt32(e+4))},w.ByteBuffer.prototype.readUint64=function(e){return new w.Long(this.readUint32(e),this.readUint32(e+4))},w.ByteBuffer.prototype.readFloat32=function(e){return w.int32[0]=this.readInt32(e),w.float32[0]},w.ByteBuffer.prototype.readFloat64=function(e){return w.int32[w.isLittleEndian?0:1]=this.readInt32(e),w.int32[w.isLittleEndian?1:0]=this.readInt32(e+4),w.float64[0]},w.ByteBuffer.prototype.writeInt8=function(e,n){this.bytes_[e]=n},w.ByteBuffer.prototype.writeUint8=function(e,n){this.bytes_[e]=n},w.ByteBuffer.prototype.writeInt16=function(e,n){this.bytes_[e]=n,this.bytes_[e+1]=n>>8},w.ByteBuffer.prototype.writeUint16=function(e,n){this.bytes_[e]=n,this.bytes_[e+1]=n>>8},w.ByteBuffer.prototype.writeInt32=function(e,n){this.bytes_[e]=n,this.bytes_[e+1]=n>>8,this.bytes_[e+2]=n>>16,this.bytes_[e+3]=n>>24},w.ByteBuffer.prototype.writeUint32=function(e,n){this.bytes_[e]=n,this.bytes_[e+1]=n>>8,this.bytes_[e+2]=n>>16,this.bytes_[e+3]=n>>24},w.ByteBuffer.prototype.writeInt64=function(e,n){this.writeInt32(e,n.low),this.writeInt32(e+4,n.high)},w.ByteBuffer.prototype.writeUint64=function(e,n){this.writeUint32(e,n.low),this.writeUint32(e+4,n.high)},w.ByteBuffer.prototype.writeFloat32=function(e,n){w.float32[0]=n,this.writeInt32(e,w.int32[0])},w.ByteBuffer.prototype.writeFloat64=function(e,n){w.float64[0]=n,this.writeInt32(e,w.int32[w.isLittleEndian?0:1]),this.writeInt32(e+4,w.int32[w.isLittleEndian?1:0])},w.ByteBuffer.prototype.getBufferIdentifier=function(){if(this.bytes_.length<this.position_+w.SIZEOF_INT+w.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");for(var e="",n=0;n<w.FILE_IDENTIFIER_LENGTH;n++)e+=String.fromCharCode(this.readInt8(this.position_+w.SIZEOF_INT+n));return e},w.ByteBuffer.prototype.__offset=function(e,n){var a=e-this.readInt32(e);return n<this.readInt16(a)?this.readInt16(a+n):0},w.ByteBuffer.prototype.__union=function(e,n){return e.bb_pos=n+this.readInt32(n),e.bb=this,e},w.ByteBuffer.prototype.__string=function(e,n){e+=this.readInt32(e);var a=this.readInt32(e),i="",p=0;if(e+=w.SIZEOF_INT,n===w.Encoding.UTF8_BYTES)return this.bytes_.subarray(e,e+a);for(;p<a;){var o,s=this.readUint8(e+p++);if(s<192)o=s;else{var c=this.readUint8(e+p++);if(s<224)o=(s&31)<<6|c&63;else{var h=this.readUint8(e+p++);if(s<240)o=(s&15)<<12|(c&63)<<6|h&63;else{var r=this.readUint8(e+p++);o=(s&7)<<18|(c&63)<<12|(h&63)<<6|r&63}}}o<65536?i+=String.fromCharCode(o):(o-=65536,i+=String.fromCharCode((o>>10)+55296,(o&1023)+56320))}return i},w.ByteBuffer.prototype.__indirect=function(e){return e+this.readInt32(e)},w.ByteBuffer.prototype.__vector=function(e){return e+this.readInt32(e)+w.SIZEOF_INT},w.ByteBuffer.prototype.__vector_len=function(e){return this.readInt32(e+this.readInt32(e))},w.ByteBuffer.prototype.__has_identifier=function(e){if(e.length!=w.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+w.FILE_IDENTIFIER_LENGTH);for(var n=0;n<w.FILE_IDENTIFIER_LENGTH;n++)if(e.charCodeAt(n)!=this.readInt8(this.position_+w.SIZEOF_INT+n))return!1;return!0},w.ByteBuffer.prototype.createLong=function(e,n){return w.Long.create(e,n)}}),F,Pr=O(()=>{wn(),(e=>{(n=>{(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={}))})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(a=>{(i=>(i[i.UNKNOWN=0]="UNKNOWN",i[i.VALUE=1]="VALUE",i[i.PARAM=2]="PARAM"))(a.DimensionValueType||(a.DimensionValueType={}))})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(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={}))})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(a=>{(i=>(i[i.Primitive=0]="Primitive",i[i.Fused=1]="Fused"))(a.NodeType||(a.NodeType={}))})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(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={}))})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsShape(o,s){return(s||new i).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsShape(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new i).__init(o.readInt32(o.position())+o.position(),o)}dim(o,s){let c=this.bb.__offset(this.bb_pos,4);return c?(s||new e.experimental.fbs.Dimension).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+c)+o*4),this.bb):null}dimLength(){let o=this.bb.__offset(this.bb_pos,4);return o?this.bb.__vector_len(this.bb_pos+o):0}static startShape(o){o.startObject(1)}static addDim(o,s){o.addFieldOffset(0,s,0)}static createDimVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addOffset(s[c]);return o.endVector()}static startDimVector(o,s){o.startVector(4,s,4)}static endShape(o){return o.endObject()}static createShape(o,s){return i.startShape(o),i.addDim(o,s),i.endShape(o)}}a.Shape=i})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsDimension(o,s){return(s||new i).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsDimension(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new i).__init(o.readInt32(o.position())+o.position(),o)}value(o){let s=this.bb.__offset(this.bb_pos,4);return s?(o||new e.experimental.fbs.DimensionValue).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}denotation(o){let s=this.bb.__offset(this.bb_pos,6);return s?this.bb.__string(this.bb_pos+s,o):null}static startDimension(o){o.startObject(2)}static addValue(o,s){o.addFieldOffset(0,s,0)}static addDenotation(o,s){o.addFieldOffset(1,s,0)}static endDimension(o){return o.endObject()}static createDimension(o,s,c){return i.startDimension(o),i.addValue(o,s),i.addDenotation(o,c),i.endDimension(o)}}a.Dimension=i})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsDimensionValue(o,s){return(s||new i).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsDimensionValue(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new i).__init(o.readInt32(o.position())+o.position(),o)}dimType(){let o=this.bb.__offset(this.bb_pos,4);return o?this.bb.readInt8(this.bb_pos+o):0}dimValue(){let o=this.bb.__offset(this.bb_pos,6);return o?this.bb.readInt64(this.bb_pos+o):this.bb.createLong(0,0)}dimParam(o){let s=this.bb.__offset(this.bb_pos,8);return s?this.bb.__string(this.bb_pos+s,o):null}static startDimensionValue(o){o.startObject(3)}static addDimType(o,s){o.addFieldInt8(0,s,0)}static addDimValue(o,s){o.addFieldInt64(1,s,o.createLong(0,0))}static addDimParam(o,s){o.addFieldOffset(2,s,0)}static endDimensionValue(o){return o.endObject()}static createDimensionValue(o,s,c,h){return i.startDimensionValue(o),i.addDimType(o,s),i.addDimValue(o,c),i.addDimParam(o,h),i.endDimensionValue(o)}}a.DimensionValue=i})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsTensorTypeAndShape(o,s){return(s||new i).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsTensorTypeAndShape(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new i).__init(o.readInt32(o.position())+o.position(),o)}elemType(){let o=this.bb.__offset(this.bb_pos,4);return o?this.bb.readInt32(this.bb_pos+o):0}shape(o){let s=this.bb.__offset(this.bb_pos,6);return s?(o||new e.experimental.fbs.Shape).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}static startTensorTypeAndShape(o){o.startObject(2)}static addElemType(o,s){o.addFieldInt32(0,s,0)}static addShape(o,s){o.addFieldOffset(1,s,0)}static endTensorTypeAndShape(o){return o.endObject()}static createTensorTypeAndShape(o,s,c){return i.startTensorTypeAndShape(o),i.addElemType(o,s),i.addShape(o,c),i.endTensorTypeAndShape(o)}}a.TensorTypeAndShape=i})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsMapType(o,s){return(s||new i).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsMapType(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new i).__init(o.readInt32(o.position())+o.position(),o)}keyType(){let o=this.bb.__offset(this.bb_pos,4);return o?this.bb.readInt32(this.bb_pos+o):0}valueType(o){let s=this.bb.__offset(this.bb_pos,6);return s?(o||new e.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}static startMapType(o){o.startObject(2)}static addKeyType(o,s){o.addFieldInt32(0,s,0)}static addValueType(o,s){o.addFieldOffset(1,s,0)}static endMapType(o){return o.endObject()}static createMapType(o,s,c){return i.startMapType(o),i.addKeyType(o,s),i.addValueType(o,c),i.endMapType(o)}}a.MapType=i})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsSequenceType(o,s){return(s||new i).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsSequenceType(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new i).__init(o.readInt32(o.position())+o.position(),o)}elemType(o){let s=this.bb.__offset(this.bb_pos,4);return s?(o||new e.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}static startSequenceType(o){o.startObject(1)}static addElemType(o,s){o.addFieldOffset(0,s,0)}static endSequenceType(o){return o.endObject()}static createSequenceType(o,s){return i.startSequenceType(o),i.addElemType(o,s),i.endSequenceType(o)}}a.SequenceType=i})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,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(o,s,c,h){return o.prep(4,12),o.writeInt32(h),o.writeInt32(c),o.writeInt32(s),o.offset()}}a.EdgeEnd=i})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsNodeEdge(o,s){return(s||new i).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsNodeEdge(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new i).__init(o.readInt32(o.position())+o.position(),o)}nodeIndex(){let o=this.bb.__offset(this.bb_pos,4);return o?this.bb.readUint32(this.bb_pos+o):0}inputEdges(o,s){let c=this.bb.__offset(this.bb_pos,6);return c?(s||new e.experimental.fbs.EdgeEnd).__init(this.bb.__vector(this.bb_pos+c)+o*12,this.bb):null}inputEdgesLength(){let o=this.bb.__offset(this.bb_pos,6);return o?this.bb.__vector_len(this.bb_pos+o):0}outputEdges(o,s){let c=this.bb.__offset(this.bb_pos,8);return c?(s||new e.experimental.fbs.EdgeEnd).__init(this.bb.__vector(this.bb_pos+c)+o*12,this.bb):null}outputEdgesLength(){let o=this.bb.__offset(this.bb_pos,8);return o?this.bb.__vector_len(this.bb_pos+o):0}static startNodeEdge(o){o.startObject(3)}static addNodeIndex(o,s){o.addFieldInt32(0,s,0)}static addInputEdges(o,s){o.addFieldOffset(1,s,0)}static startInputEdgesVector(o,s){o.startVector(12,s,4)}static addOutputEdges(o,s){o.addFieldOffset(2,s,0)}static startOutputEdgesVector(o,s){o.startVector(12,s,4)}static endNodeEdge(o){return o.endObject()}static createNodeEdge(o,s,c,h){return i.startNodeEdge(o),i.addNodeIndex(o,s),i.addInputEdges(o,c),i.addOutputEdges(o,h),i.endNodeEdge(o)}}a.NodeEdge=i})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsNode(o,s){return(s||new i).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsNode(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new i).__init(o.readInt32(o.position())+o.position(),o)}name(o){let s=this.bb.__offset(this.bb_pos,4);return s?this.bb.__string(this.bb_pos+s,o):null}docString(o){let s=this.bb.__offset(this.bb_pos,6);return s?this.bb.__string(this.bb_pos+s,o):null}domain(o){let s=this.bb.__offset(this.bb_pos,8);return s?this.bb.__string(this.bb_pos+s,o):null}sinceVersion(){let o=this.bb.__offset(this.bb_pos,10);return o?this.bb.readInt32(this.bb_pos+o):0}index(){let o=this.bb.__offset(this.bb_pos,12);return o?this.bb.readUint32(this.bb_pos+o):0}opType(o){let s=this.bb.__offset(this.bb_pos,14);return s?this.bb.__string(this.bb_pos+s,o):null}type(){let o=this.bb.__offset(this.bb_pos,16);return o?this.bb.readInt32(this.bb_pos+o):0}executionProviderType(o){let s=this.bb.__offset(this.bb_pos,18);return s?this.bb.__string(this.bb_pos+s,o):null}inputs(o,s){let c=this.bb.__offset(this.bb_pos,20);return c?this.bb.__string(this.bb.__vector(this.bb_pos+c)+o*4,s):null}inputsLength(){let o=this.bb.__offset(this.bb_pos,20);return o?this.bb.__vector_len(this.bb_pos+o):0}outputs(o,s){let c=this.bb.__offset(this.bb_pos,22);return c?this.bb.__string(this.bb.__vector(this.bb_pos+c)+o*4,s):null}outputsLength(){let o=this.bb.__offset(this.bb_pos,22);return o?this.bb.__vector_len(this.bb_pos+o):0}attributes(o,s){let c=this.bb.__offset(this.bb_pos,24);return c?(s||new e.experimental.fbs.Attribute).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+c)+o*4),this.bb):null}attributesLength(){let o=this.bb.__offset(this.bb_pos,24);return o?this.bb.__vector_len(this.bb_pos+o):0}inputArgCounts(o){let s=this.bb.__offset(this.bb_pos,26);return s?this.bb.readInt32(this.bb.__vector(this.bb_pos+s)+o*4):0}inputArgCountsLength(){let o=this.bb.__offset(this.bb_pos,26);return o?this.bb.__vector_len(this.bb_pos+o):0}inputArgCountsArray(){let o=this.bb.__offset(this.bb_pos,26);return o?new Int32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+o),this.bb.__vector_len(this.bb_pos+o)):null}implicitInputs(o,s){let c=this.bb.__offset(this.bb_pos,28);return c?this.bb.__string(this.bb.__vector(this.bb_pos+c)+o*4,s):null}implicitInputsLength(){let o=this.bb.__offset(this.bb_pos,28);return o?this.bb.__vector_len(this.bb_pos+o):0}static startNode(o){o.startObject(13)}static addName(o,s){o.addFieldOffset(0,s,0)}static addDocString(o,s){o.addFieldOffset(1,s,0)}static addDomain(o,s){o.addFieldOffset(2,s,0)}static addSinceVersion(o,s){o.addFieldInt32(3,s,0)}static addIndex(o,s){o.addFieldInt32(4,s,0)}static addOpType(o,s){o.addFieldOffset(5,s,0)}static addType(o,s){o.addFieldInt32(6,s,0)}static addExecutionProviderType(o,s){o.addFieldOffset(7,s,0)}static addInputs(o,s){o.addFieldOffset(8,s,0)}static createInputsVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addOffset(s[c]);return o.endVector()}static startInputsVector(o,s){o.startVector(4,s,4)}static addOutputs(o,s){o.addFieldOffset(9,s,0)}static createOutputsVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addOffset(s[c]);return o.endVector()}static startOutputsVector(o,s){o.startVector(4,s,4)}static addAttributes(o,s){o.addFieldOffset(10,s,0)}static createAttributesVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addOffset(s[c]);return o.endVector()}static startAttributesVector(o,s){o.startVector(4,s,4)}static addInputArgCounts(o,s){o.addFieldOffset(11,s,0)}static createInputArgCountsVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addInt32(s[c]);return o.endVector()}static startInputArgCountsVector(o,s){o.startVector(4,s,4)}static addImplicitInputs(o,s){o.addFieldOffset(12,s,0)}static createImplicitInputsVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addOffset(s[c]);return o.endVector()}static startImplicitInputsVector(o,s){o.startVector(4,s,4)}static endNode(o){return o.endObject()}static createNode(o,s,c,h,r,u,l,f,g,b,v,S,P,_){return i.startNode(o),i.addName(o,s),i.addDocString(o,c),i.addDomain(o,h),i.addSinceVersion(o,r),i.addIndex(o,u),i.addOpType(o,l),i.addType(o,f),i.addExecutionProviderType(o,g),i.addInputs(o,b),i.addOutputs(o,v),i.addAttributes(o,S),i.addInputArgCounts(o,P),i.addImplicitInputs(o,_),i.endNode(o)}}a.Node=i})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsValueInfo(o,s){return(s||new i).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsValueInfo(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new i).__init(o.readInt32(o.position())+o.position(),o)}name(o){let s=this.bb.__offset(this.bb_pos,4);return s?this.bb.__string(this.bb_pos+s,o):null}docString(o){let s=this.bb.__offset(this.bb_pos,6);return s?this.bb.__string(this.bb_pos+s,o):null}type(o){let s=this.bb.__offset(this.bb_pos,8);return s?(o||new e.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}static startValueInfo(o){o.startObject(3)}static addName(o,s){o.addFieldOffset(0,s,0)}static addDocString(o,s){o.addFieldOffset(1,s,0)}static addType(o,s){o.addFieldOffset(2,s,0)}static endValueInfo(o){return o.endObject()}static createValueInfo(o,s,c,h){return i.startValueInfo(o),i.addName(o,s),i.addDocString(o,c),i.addType(o,h),i.endValueInfo(o)}}a.ValueInfo=i})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsTypeInfo(o,s){return(s||new i).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsTypeInfo(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new i).__init(o.readInt32(o.position())+o.position(),o)}denotation(o){let s=this.bb.__offset(this.bb_pos,4);return s?this.bb.__string(this.bb_pos+s,o):null}valueType(){let o=this.bb.__offset(this.bb_pos,6);return o?this.bb.readUint8(this.bb_pos+o):0}value(o){let s=this.bb.__offset(this.bb_pos,8);return s?this.bb.__union(o,this.bb_pos+s):null}static startTypeInfo(o){o.startObject(3)}static addDenotation(o,s){o.addFieldOffset(0,s,0)}static addValueType(o,s){o.addFieldInt8(1,s,0)}static addValue(o,s){o.addFieldOffset(2,s,0)}static endTypeInfo(o){return o.endObject()}static createTypeInfo(o,s,c,h){return i.startTypeInfo(o),i.addDenotation(o,s),i.addValueType(o,c),i.addValue(o,h),i.endTypeInfo(o)}}a.TypeInfo=i})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsOperatorSetId(o,s){return(s||new i).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsOperatorSetId(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new i).__init(o.readInt32(o.position())+o.position(),o)}domain(o){let s=this.bb.__offset(this.bb_pos,4);return s?this.bb.__string(this.bb_pos+s,o):null}version(){let o=this.bb.__offset(this.bb_pos,6);return o?this.bb.readInt64(this.bb_pos+o):this.bb.createLong(0,0)}static startOperatorSetId(o){o.startObject(2)}static addDomain(o,s){o.addFieldOffset(0,s,0)}static addVersion(o,s){o.addFieldInt64(1,s,o.createLong(0,0))}static endOperatorSetId(o){return o.endObject()}static createOperatorSetId(o,s,c){return i.startOperatorSetId(o),i.addDomain(o,s),i.addVersion(o,c),i.endOperatorSetId(o)}}a.OperatorSetId=i})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsTensor(o,s){return(s||new i).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsTensor(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new i).__init(o.readInt32(o.position())+o.position(),o)}name(o){let s=this.bb.__offset(this.bb_pos,4);return s?this.bb.__string(this.bb_pos+s,o):null}docString(o){let s=this.bb.__offset(this.bb_pos,6);return s?this.bb.__string(this.bb_pos+s,o):null}dims(o){let s=this.bb.__offset(this.bb_pos,8);return s?this.bb.readInt64(this.bb.__vector(this.bb_pos+s)+o*8):this.bb.createLong(0,0)}dimsLength(){let o=this.bb.__offset(this.bb_pos,8);return o?this.bb.__vector_len(this.bb_pos+o):0}dataType(){let o=this.bb.__offset(this.bb_pos,10);return o?this.bb.readInt32(this.bb_pos+o):0}rawData(o){let s=this.bb.__offset(this.bb_pos,12);return s?this.bb.readUint8(this.bb.__vector(this.bb_pos+s)+o):0}rawDataLength(){let o=this.bb.__offset(this.bb_pos,12);return o?this.bb.__vector_len(this.bb_pos+o):0}rawDataArray(){let o=this.bb.__offset(this.bb_pos,12);return o?new Uint8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+o),this.bb.__vector_len(this.bb_pos+o)):null}stringData(o,s){let c=this.bb.__offset(this.bb_pos,14);return c?this.bb.__string(this.bb.__vector(this.bb_pos+c)+o*4,s):null}stringDataLength(){let o=this.bb.__offset(this.bb_pos,14);return o?this.bb.__vector_len(this.bb_pos+o):0}static startTensor(o){o.startObject(6)}static addName(o,s){o.addFieldOffset(0,s,0)}static addDocString(o,s){o.addFieldOffset(1,s,0)}static addDims(o,s){o.addFieldOffset(2,s,0)}static createDimsVector(o,s){o.startVector(8,s.length,8);for(let c=s.length-1;c>=0;c--)o.addInt64(s[c]);return o.endVector()}static startDimsVector(o,s){o.startVector(8,s,8)}static addDataType(o,s){o.addFieldInt32(3,s,0)}static addRawData(o,s){o.addFieldOffset(4,s,0)}static createRawDataVector(o,s){o.startVector(1,s.length,1);for(let c=s.length-1;c>=0;c--)o.addInt8(s[c]);return o.endVector()}static startRawDataVector(o,s){o.startVector(1,s,1)}static addStringData(o,s){o.addFieldOffset(5,s,0)}static createStringDataVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addOffset(s[c]);return o.endVector()}static startStringDataVector(o,s){o.startVector(4,s,4)}static endTensor(o){return o.endObject()}static createTensor(o,s,c,h,r,u,l){return i.startTensor(o),i.addName(o,s),i.addDocString(o,c),i.addDims(o,h),i.addDataType(o,r),i.addRawData(o,u),i.addStringData(o,l),i.endTensor(o)}}a.Tensor=i})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsSparseTensor(o,s){return(s||new i).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsSparseTensor(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new i).__init(o.readInt32(o.position())+o.position(),o)}values(o){let s=this.bb.__offset(this.bb_pos,4);return s?(o||new e.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}indices(o){let s=this.bb.__offset(this.bb_pos,6);return s?(o||new e.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}dims(o){let s=this.bb.__offset(this.bb_pos,8);return s?this.bb.readInt64(this.bb.__vector(this.bb_pos+s)+o*8):this.bb.createLong(0,0)}dimsLength(){let o=this.bb.__offset(this.bb_pos,8);return o?this.bb.__vector_len(this.bb_pos+o):0}static startSparseTensor(o){o.startObject(3)}static addValues(o,s){o.addFieldOffset(0,s,0)}static addIndices(o,s){o.addFieldOffset(1,s,0)}static addDims(o,s){o.addFieldOffset(2,s,0)}static createDimsVector(o,s){o.startVector(8,s.length,8);for(let c=s.length-1;c>=0;c--)o.addInt64(s[c]);return o.endVector()}static startDimsVector(o,s){o.startVector(8,s,8)}static endSparseTensor(o){return o.endObject()}static createSparseTensor(o,s,c,h){return i.startSparseTensor(o),i.addValues(o,s),i.addIndices(o,c),i.addDims(o,h),i.endSparseTensor(o)}}a.SparseTensor=i})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsAttribute(o,s){return(s||new i).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsAttribute(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new i).__init(o.readInt32(o.position())+o.position(),o)}name(o){let s=this.bb.__offset(this.bb_pos,4);return s?this.bb.__string(this.bb_pos+s,o):null}docString(o){let s=this.bb.__offset(this.bb_pos,6);return s?this.bb.__string(this.bb_pos+s,o):null}type(){let o=this.bb.__offset(this.bb_pos,8);return o?this.bb.readInt32(this.bb_pos+o):0}f(){let o=this.bb.__offset(this.bb_pos,10);return o?this.bb.readFloat32(this.bb_pos+o):0}i(){let o=this.bb.__offset(this.bb_pos,12);return o?this.bb.readInt64(this.bb_pos+o):this.bb.createLong(0,0)}s(o){let s=this.bb.__offset(this.bb_pos,14);return s?this.bb.__string(this.bb_pos+s,o):null}t(o){let s=this.bb.__offset(this.bb_pos,16);return s?(o||new e.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}g(o){let s=this.bb.__offset(this.bb_pos,18);return s?(o||new e.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}floats(o){let s=this.bb.__offset(this.bb_pos,20);return s?this.bb.readFloat32(this.bb.__vector(this.bb_pos+s)+o*4):0}floatsLength(){let o=this.bb.__offset(this.bb_pos,20);return o?this.bb.__vector_len(this.bb_pos+o):0}floatsArray(){let o=this.bb.__offset(this.bb_pos,20);return o?new Float32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+o),this.bb.__vector_len(this.bb_pos+o)):null}ints(o){let s=this.bb.__offset(this.bb_pos,22);return s?this.bb.readInt64(this.bb.__vector(this.bb_pos+s)+o*8):this.bb.createLong(0,0)}intsLength(){let o=this.bb.__offset(this.bb_pos,22);return o?this.bb.__vector_len(this.bb_pos+o):0}strings(o,s){let c=this.bb.__offset(this.bb_pos,24);return c?this.bb.__string(this.bb.__vector(this.bb_pos+c)+o*4,s):null}stringsLength(){let o=this.bb.__offset(this.bb_pos,24);return o?this.bb.__vector_len(this.bb_pos+o):0}tensors(o,s){let c=this.bb.__offset(this.bb_pos,26);return c?(s||new e.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+c)+o*4),this.bb):null}tensorsLength(){let o=this.bb.__offset(this.bb_pos,26);return o?this.bb.__vector_len(this.bb_pos+o):0}graphs(o,s){let c=this.bb.__offset(this.bb_pos,28);return c?(s||new e.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+c)+o*4),this.bb):null}graphsLength(){let o=this.bb.__offset(this.bb_pos,28);return o?this.bb.__vector_len(this.bb_pos+o):0}static startAttribute(o){o.startObject(13)}static addName(o,s){o.addFieldOffset(0,s,0)}static addDocString(o,s){o.addFieldOffset(1,s,0)}static addType(o,s){o.addFieldInt32(2,s,0)}static addF(o,s){o.addFieldFloat32(3,s,0)}static addI(o,s){o.addFieldInt64(4,s,o.createLong(0,0))}static addS(o,s){o.addFieldOffset(5,s,0)}static addT(o,s){o.addFieldOffset(6,s,0)}static addG(o,s){o.addFieldOffset(7,s,0)}static addFloats(o,s){o.addFieldOffset(8,s,0)}static createFloatsVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addFloat32(s[c]);return o.endVector()}static startFloatsVector(o,s){o.startVector(4,s,4)}static addInts(o,s){o.addFieldOffset(9,s,0)}static createIntsVector(o,s){o.startVector(8,s.length,8);for(let c=s.length-1;c>=0;c--)o.addInt64(s[c]);return o.endVector()}static startIntsVector(o,s){o.startVector(8,s,8)}static addStrings(o,s){o.addFieldOffset(10,s,0)}static createStringsVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addOffset(s[c]);return o.endVector()}static startStringsVector(o,s){o.startVector(4,s,4)}static addTensors(o,s){o.addFieldOffset(11,s,0)}static createTensorsVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addOffset(s[c]);return o.endVector()}static startTensorsVector(o,s){o.startVector(4,s,4)}static addGraphs(o,s){o.addFieldOffset(12,s,0)}static createGraphsVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addOffset(s[c]);return o.endVector()}static startGraphsVector(o,s){o.startVector(4,s,4)}static endAttribute(o){return o.endObject()}static createAttribute(o,s,c,h,r,u,l,f,g,b,v,S,P,_){return i.startAttribute(o),i.addName(o,s),i.addDocString(o,c),i.addType(o,h),i.addF(o,r),i.addI(o,u),i.addS(o,l),i.addT(o,f),i.addG(o,g),i.addFloats(o,b),i.addInts(o,v),i.addStrings(o,S),i.addTensors(o,P),i.addGraphs(o,_),i.endAttribute(o)}}a.Attribute=i})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsGraph(o,s){return(s||new i).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsGraph(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new i).__init(o.readInt32(o.position())+o.position(),o)}initializers(o,s){let c=this.bb.__offset(this.bb_pos,4);return c?(s||new e.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+c)+o*4),this.bb):null}initializersLength(){let o=this.bb.__offset(this.bb_pos,4);return o?this.bb.__vector_len(this.bb_pos+o):0}nodeArgs(o,s){let c=this.bb.__offset(this.bb_pos,6);return c?(s||new e.experimental.fbs.ValueInfo).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+c)+o*4),this.bb):null}nodeArgsLength(){let o=this.bb.__offset(this.bb_pos,6);return o?this.bb.__vector_len(this.bb_pos+o):0}nodes(o,s){let c=this.bb.__offset(this.bb_pos,8);return c?(s||new e.experimental.fbs.Node).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+c)+o*4),this.bb):null}nodesLength(){let o=this.bb.__offset(this.bb_pos,8);return o?this.bb.__vector_len(this.bb_pos+o):0}maxNodeIndex(){let o=this.bb.__offset(this.bb_pos,10);return o?this.bb.readUint32(this.bb_pos+o):0}nodeEdges(o,s){let c=this.bb.__offset(this.bb_pos,12);return c?(s||new e.experimental.fbs.NodeEdge).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+c)+o*4),this.bb):null}nodeEdgesLength(){let o=this.bb.__offset(this.bb_pos,12);return o?this.bb.__vector_len(this.bb_pos+o):0}inputs(o,s){let c=this.bb.__offset(this.bb_pos,14);return c?this.bb.__string(this.bb.__vector(this.bb_pos+c)+o*4,s):null}inputsLength(){let o=this.bb.__offset(this.bb_pos,14);return o?this.bb.__vector_len(this.bb_pos+o):0}outputs(o,s){let c=this.bb.__offset(this.bb_pos,16);return c?this.bb.__string(this.bb.__vector(this.bb_pos+c)+o*4,s):null}outputsLength(){let o=this.bb.__offset(this.bb_pos,16);return o?this.bb.__vector_len(this.bb_pos+o):0}sparseInitializers(o,s){let c=this.bb.__offset(this.bb_pos,18);return c?(s||new e.experimental.fbs.SparseTensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+c)+o*4),this.bb):null}sparseInitializersLength(){let o=this.bb.__offset(this.bb_pos,18);return o?this.bb.__vector_len(this.bb_pos+o):0}static startGraph(o){o.startObject(8)}static addInitializers(o,s){o.addFieldOffset(0,s,0)}static createInitializersVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addOffset(s[c]);return o.endVector()}static startInitializersVector(o,s){o.startVector(4,s,4)}static addNodeArgs(o,s){o.addFieldOffset(1,s,0)}static createNodeArgsVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addOffset(s[c]);return o.endVector()}static startNodeArgsVector(o,s){o.startVector(4,s,4)}static addNodes(o,s){o.addFieldOffset(2,s,0)}static createNodesVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addOffset(s[c]);return o.endVector()}static startNodesVector(o,s){o.startVector(4,s,4)}static addMaxNodeIndex(o,s){o.addFieldInt32(3,s,0)}static addNodeEdges(o,s){o.addFieldOffset(4,s,0)}static createNodeEdgesVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addOffset(s[c]);return o.endVector()}static startNodeEdgesVector(o,s){o.startVector(4,s,4)}static addInputs(o,s){o.addFieldOffset(5,s,0)}static createInputsVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addOffset(s[c]);return o.endVector()}static startInputsVector(o,s){o.startVector(4,s,4)}static addOutputs(o,s){o.addFieldOffset(6,s,0)}static createOutputsVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addOffset(s[c]);return o.endVector()}static startOutputsVector(o,s){o.startVector(4,s,4)}static addSparseInitializers(o,s){o.addFieldOffset(7,s,0)}static createSparseInitializersVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addOffset(s[c]);return o.endVector()}static startSparseInitializersVector(o,s){o.startVector(4,s,4)}static endGraph(o){return o.endObject()}static createGraph(o,s,c,h,r,u,l,f,g){return i.startGraph(o),i.addInitializers(o,s),i.addNodeArgs(o,c),i.addNodes(o,h),i.addMaxNodeIndex(o,r),i.addNodeEdges(o,u),i.addInputs(o,l),i.addOutputs(o,f),i.addSparseInitializers(o,g),i.endGraph(o)}}a.Graph=i})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsModel(o,s){return(s||new i).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsModel(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new i).__init(o.readInt32(o.position())+o.position(),o)}irVersion(){let o=this.bb.__offset(this.bb_pos,4);return o?this.bb.readInt64(this.bb_pos+o):this.bb.createLong(0,0)}opsetImport(o,s){let c=this.bb.__offset(this.bb_pos,6);return c?(s||new e.experimental.fbs.OperatorSetId).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+c)+o*4),this.bb):null}opsetImportLength(){let o=this.bb.__offset(this.bb_pos,6);return o?this.bb.__vector_len(this.bb_pos+o):0}producerName(o){let s=this.bb.__offset(this.bb_pos,8);return s?this.bb.__string(this.bb_pos+s,o):null}producerVersion(o){let s=this.bb.__offset(this.bb_pos,10);return s?this.bb.__string(this.bb_pos+s,o):null}domain(o){let s=this.bb.__offset(this.bb_pos,12);return s?this.bb.__string(this.bb_pos+s,o):null}modelVersion(){let o=this.bb.__offset(this.bb_pos,14);return o?this.bb.readInt64(this.bb_pos+o):this.bb.createLong(0,0)}docString(o){let s=this.bb.__offset(this.bb_pos,16);return s?this.bb.__string(this.bb_pos+s,o):null}graph(o){let s=this.bb.__offset(this.bb_pos,18);return s?(o||new e.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}graphDocString(o){let s=this.bb.__offset(this.bb_pos,20);return s?this.bb.__string(this.bb_pos+s,o):null}static startModel(o){o.startObject(9)}static addIrVersion(o,s){o.addFieldInt64(0,s,o.createLong(0,0))}static addOpsetImport(o,s){o.addFieldOffset(1,s,0)}static createOpsetImportVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addOffset(s[c]);return o.endVector()}static startOpsetImportVector(o,s){o.startVector(4,s,4)}static addProducerName(o,s){o.addFieldOffset(2,s,0)}static addProducerVersion(o,s){o.addFieldOffset(3,s,0)}static addDomain(o,s){o.addFieldOffset(4,s,0)}static addModelVersion(o,s){o.addFieldInt64(5,s,o.createLong(0,0))}static addDocString(o,s){o.addFieldOffset(6,s,0)}static addGraph(o,s){o.addFieldOffset(7,s,0)}static addGraphDocString(o,s){o.addFieldOffset(8,s,0)}static endModel(o){return o.endObject()}static createModel(o,s,c,h,r,u,l,f,g,b){return i.startModel(o),i.addIrVersion(o,s),i.addOpsetImport(o,c),i.addProducerName(o,h),i.addProducerVersion(o,r),i.addDomain(o,u),i.addModelVersion(o,l),i.addDocString(o,f),i.addGraph(o,g),i.addGraphDocString(o,b),i.endModel(o)}}a.Model=i})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsKernelCreateInfos(o,s){return(s||new i).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsKernelCreateInfos(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new i).__init(o.readInt32(o.position())+o.position(),o)}nodeIndices(o){let s=this.bb.__offset(this.bb_pos,4);return s?this.bb.readUint32(this.bb.__vector(this.bb_pos+s)+o*4):0}nodeIndicesLength(){let o=this.bb.__offset(this.bb_pos,4);return o?this.bb.__vector_len(this.bb_pos+o):0}nodeIndicesArray(){let o=this.bb.__offset(this.bb_pos,4);return o?new Uint32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+o),this.bb.__vector_len(this.bb_pos+o)):null}kernelDefHashes(o){let s=this.bb.__offset(this.bb_pos,6);return s?this.bb.readUint64(this.bb.__vector(this.bb_pos+s)+o*8):this.bb.createLong(0,0)}kernelDefHashesLength(){let o=this.bb.__offset(this.bb_pos,6);return o?this.bb.__vector_len(this.bb_pos+o):0}static startKernelCreateInfos(o){o.startObject(2)}static addNodeIndices(o,s){o.addFieldOffset(0,s,0)}static createNodeIndicesVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addInt32(s[c]);return o.endVector()}static startNodeIndicesVector(o,s){o.startVector(4,s,4)}static addKernelDefHashes(o,s){o.addFieldOffset(1,s,0)}static createKernelDefHashesVector(o,s){o.startVector(8,s.length,8);for(let c=s.length-1;c>=0;c--)o.addInt64(s[c]);return o.endVector()}static startKernelDefHashesVector(o,s){o.startVector(8,s,8)}static endKernelCreateInfos(o){return o.endObject()}static createKernelCreateInfos(o,s,c){return i.startKernelCreateInfos(o),i.addNodeIndices(o,s),i.addKernelDefHashes(o,c),i.endKernelCreateInfos(o)}}a.KernelCreateInfos=i})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsSubGraphSessionState(o,s){return(s||new i).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsSubGraphSessionState(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new i).__init(o.readInt32(o.position())+o.position(),o)}graphId(o){let s=this.bb.__offset(this.bb_pos,4);return s?this.bb.__string(this.bb_pos+s,o):null}sessionState(o){let s=this.bb.__offset(this.bb_pos,6);return s?(o||new e.experimental.fbs.SessionState).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}static startSubGraphSessionState(o){o.startObject(2)}static addGraphId(o,s){o.addFieldOffset(0,s,0)}static addSessionState(o,s){o.addFieldOffset(1,s,0)}static endSubGraphSessionState(o){let s=o.endObject();return o.requiredField(s,4),s}static createSubGraphSessionState(o,s,c){return i.startSubGraphSessionState(o),i.addGraphId(o,s),i.addSessionState(o,c),i.endSubGraphSessionState(o)}}a.SubGraphSessionState=i})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsSessionState(o,s){return(s||new i).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsSessionState(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new i).__init(o.readInt32(o.position())+o.position(),o)}kernels(o){let s=this.bb.__offset(this.bb_pos,4);return s?(o||new e.experimental.fbs.KernelCreateInfos).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}subGraphSessionStates(o,s){let c=this.bb.__offset(this.bb_pos,6);return c?(s||new e.experimental.fbs.SubGraphSessionState).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+c)+o*4),this.bb):null}subGraphSessionStatesLength(){let o=this.bb.__offset(this.bb_pos,6);return o?this.bb.__vector_len(this.bb_pos+o):0}static startSessionState(o){o.startObject(2)}static addKernels(o,s){o.addFieldOffset(0,s,0)}static addSubGraphSessionStates(o,s){o.addFieldOffset(1,s,0)}static createSubGraphSessionStatesVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addOffset(s[c]);return o.endVector()}static startSubGraphSessionStatesVector(o,s){o.startVector(4,s,4)}static endSessionState(o){return o.endObject()}static createSessionState(o,s,c){return i.startSessionState(o),i.addKernels(o,s),i.addSubGraphSessionStates(o,c),i.endSessionState(o)}}a.SessionState=i})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsInferenceSession(o,s){return(s||new i).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsInferenceSession(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new i).__init(o.readInt32(o.position())+o.position(),o)}static bufferHasIdentifier(o){return o.__has_identifier("ORTM")}ortVersion(o){let s=this.bb.__offset(this.bb_pos,4);return s?this.bb.__string(this.bb_pos+s,o):null}model(o){let s=this.bb.__offset(this.bb_pos,6);return s?(o||new e.experimental.fbs.Model).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}sessionState(o){let s=this.bb.__offset(this.bb_pos,8);return s?(o||new e.experimental.fbs.SessionState).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}static startInferenceSession(o){o.startObject(3)}static addOrtVersion(o,s){o.addFieldOffset(0,s,0)}static addModel(o,s){o.addFieldOffset(1,s,0)}static addSessionState(o,s){o.addFieldOffset(2,s,0)}static endInferenceSession(o){return o.endObject()}static finishInferenceSessionBuffer(o,s){o.finish(s,"ORTM")}static finishSizePrefixedInferenceSessionBuffer(o,s){o.finish(s,"ORTM",!0)}static createInferenceSession(o,s,c,h){return i.startInferenceSession(o),i.addOrtVersion(o,s),i.addModel(o,c),i.addSessionState(o,h),i.endInferenceSession(o)}}a.InferenceSession=i})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={}))}),js=mt((e,n)=>{n.exports=a;function a(i,p){for(var o=new Array(arguments.length-1),s=0,c=2,h=!0;c<arguments.length;)o[s++]=arguments[c++];return new Promise(function(r,u){o[s]=function(l){if(h)if(h=!1,l)u(l);else{for(var f=new Array(arguments.length-1),g=0;g<f.length;)f[g++]=arguments[g];r.apply(null,f)}};try{i.apply(p||null,o)}catch(l){h&&(h=!1,u(l))}})}}),Ys=mt(e=>{var n=e;n.length=function(s){var c=s.length;if(!c)return 0;for(var h=0;--c%4>1&&s.charAt(c)==="=";)++h;return Math.ceil(s.length*3)/4-h};var a=new Array(64),i=new Array(123);for(p=0;p<64;)i[a[p]=p<26?p+65:p<52?p+71:p<62?p-4:p-59|43]=p++;var p;n.encode=function(s,c,h){for(var r=null,u=[],l=0,f=0,g;c<h;){var b=s[c++];switch(f){case 0:u[l++]=a[b>>2],g=(b&3)<<4,f=1;break;case 1:u[l++]=a[g|b>>4],g=(b&15)<<2,f=2;break;case 2:u[l++]=a[g|b>>6],u[l++]=a[b&63],f=0;break}l>8191&&((r||(r=[])).push(String.fromCharCode.apply(String,u)),l=0)}return f&&(u[l++]=a[g],u[l++]=61,f===1&&(u[l++]=61)),r?(l&&r.push(String.fromCharCode.apply(String,u.slice(0,l))),r.join("")):String.fromCharCode.apply(String,u.slice(0,l))};var o="invalid encoding";n.decode=function(s,c,h){for(var r=h,u=0,l,f=0;f<s.length;){var g=s.charCodeAt(f++);if(g===61&&u>1)break;if((g=i[g])===void 0)throw Error(o);switch(u){case 0:l=g,u=1;break;case 1:c[h++]=l<<2|(g&48)>>4,l=g,u=2;break;case 2:c[h++]=(l&15)<<4|(g&60)>>2,l=g,u=3;break;case 3:c[h++]=(l&3)<<6|g,u=0;break}}if(u===1)throw Error(o);return h-r},n.test=function(s){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(s)}}),Qs=mt((e,n)=>{n.exports=a;function a(){this._listeners={}}a.prototype.on=function(i,p,o){return(this._listeners[i]||(this._listeners[i]=[])).push({fn:p,ctx:o||this}),this},a.prototype.off=function(i,p){if(i===void 0)this._listeners={};else if(p===void 0)this._listeners[i]=[];else for(var o=this._listeners[i],s=0;s<o.length;)o[s].fn===p?o.splice(s,1):++s;return this},a.prototype.emit=function(i){var p=this._listeners[i];if(p){for(var o=[],s=1;s<arguments.length;)o.push(arguments[s++]);for(s=0;s<p.length;)p[s].fn.apply(p[s++].ctx,o)}return this}}),au=mt((e,n)=>{n.exports=a(a);function a(c){return typeof Float32Array<"u"?function(){var h=new Float32Array([-0]),r=new Uint8Array(h.buffer),u=r[3]===128;function l(v,S,P){h[0]=v,S[P]=r[0],S[P+1]=r[1],S[P+2]=r[2],S[P+3]=r[3]}function f(v,S,P){h[0]=v,S[P]=r[3],S[P+1]=r[2],S[P+2]=r[1],S[P+3]=r[0]}c.writeFloatLE=u?l:f,c.writeFloatBE=u?f:l;function g(v,S){return r[0]=v[S],r[1]=v[S+1],r[2]=v[S+2],r[3]=v[S+3],h[0]}function b(v,S){return r[3]=v[S],r[2]=v[S+1],r[1]=v[S+2],r[0]=v[S+3],h[0]}c.readFloatLE=u?g:b,c.readFloatBE=u?b:g}():function(){function h(u,l,f,g){var b=l<0?1:0;if(b&&(l=-l),l===0)u(1/l>0?0:2147483648,f,g);else if(isNaN(l))u(2143289344,f,g);else if(l>34028234663852886e22)u((b<<31|2139095040)>>>0,f,g);else if(l<11754943508222875e-54)u((b<<31|Math.round(l/1401298464324817e-60))>>>0,f,g);else{var v=Math.floor(Math.log(l)/Math.LN2),S=Math.round(l*Math.pow(2,-v)*8388608)&8388607;u((b<<31|v+127<<23|S)>>>0,f,g)}}c.writeFloatLE=h.bind(null,i),c.writeFloatBE=h.bind(null,p);function r(u,l,f){var g=u(l,f),b=(g>>31)*2+1,v=g>>>23&255,S=g&8388607;return v===255?S?NaN:b*(1/0):v===0?b*1401298464324817e-60*S:b*Math.pow(2,v-150)*(S+8388608)}c.readFloatLE=r.bind(null,o),c.readFloatBE=r.bind(null,s)}(),typeof Float64Array<"u"?function(){var h=new Float64Array([-0]),r=new Uint8Array(h.buffer),u=r[7]===128;function l(v,S,P){h[0]=v,S[P]=r[0],S[P+1]=r[1],S[P+2]=r[2],S[P+3]=r[3],S[P+4]=r[4],S[P+5]=r[5],S[P+6]=r[6],S[P+7]=r[7]}function f(v,S,P){h[0]=v,S[P]=r[7],S[P+1]=r[6],S[P+2]=r[5],S[P+3]=r[4],S[P+4]=r[3],S[P+5]=r[2],S[P+6]=r[1],S[P+7]=r[0]}c.writeDoubleLE=u?l:f,c.writeDoubleBE=u?f:l;function g(v,S){return r[0]=v[S],r[1]=v[S+1],r[2]=v[S+2],r[3]=v[S+3],r[4]=v[S+4],r[5]=v[S+5],r[6]=v[S+6],r[7]=v[S+7],h[0]}function b(v,S){return r[7]=v[S],r[6]=v[S+1],r[5]=v[S+2],r[4]=v[S+3],r[3]=v[S+4],r[2]=v[S+5],r[1]=v[S+6],r[0]=v[S+7],h[0]}c.readDoubleLE=u?g:b,c.readDoubleBE=u?b:g}():function(){function h(u,l,f,g,b,v){var S=g<0?1:0;if(S&&(g=-g),g===0)u(0,b,v+l),u(1/g>0?0:2147483648,b,v+f);else if(isNaN(g))u(0,b,v+l),u(2146959360,b,v+f);else if(g>17976931348623157e292)u(0,b,v+l),u((S<<31|2146435072)>>>0,b,v+f);else{var P;if(g<22250738585072014e-324)P=g/5e-324,u(P>>>0,b,v+l),u((S<<31|P/4294967296)>>>0,b,v+f);else{var _=Math.floor(Math.log(g)/Math.LN2);_===1024&&(_=1023),P=g*Math.pow(2,-_),u(P*4503599627370496>>>0,b,v+l),u((S<<31|_+1023<<20|P*1048576&1048575)>>>0,b,v+f)}}}c.writeDoubleLE=h.bind(null,i,0,4),c.writeDoubleBE=h.bind(null,p,4,0);function r(u,l,f,g,b){var v=u(g,b+l),S=u(g,b+f),P=(S>>31)*2+1,_=S>>>20&2047,A=4294967296*(S&1048575)+v;return _===2047?A?NaN:P*(1/0):_===0?P*5e-324*A:P*Math.pow(2,_-1075)*(A+4503599627370496)}c.readDoubleLE=r.bind(null,o,0,4),c.readDoubleBE=r.bind(null,s,4,0)}(),c}function i(c,h,r){h[r]=c&255,h[r+1]=c>>>8&255,h[r+2]=c>>>16&255,h[r+3]=c>>>24}function p(c,h,r){h[r]=c>>>24,h[r+1]=c>>>16&255,h[r+2]=c>>>8&255,h[r+3]=c&255}function o(c,h){return(c[h]|c[h+1]<<8|c[h+2]<<16|c[h+3]<<24)>>>0}function s(c,h){return(c[h]<<24|c[h+1]<<16|c[h+2]<<8|c[h+3])>>>0}}),su=mt((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}}),lu=mt(e=>{var n=e;n.length=function(a){for(var i=0,p=0,o=0;o<a.length;++o)p=a.charCodeAt(o),p<128?i+=1:p<2048?i+=2:(p&64512)===55296&&(a.charCodeAt(o+1)&64512)===56320?(++o,i+=4):i+=3;return i},n.read=function(a,i,p){var o=p-i;if(o<1)return"";for(var s=null,c=[],h=0,r;i<p;)r=a[i++],r<128?c[h++]=r:r>191&&r<224?c[h++]=(r&31)<<6|a[i++]&63:r>239&&r<365?(r=((r&7)<<18|(a[i++]&63)<<12|(a[i++]&63)<<6|a[i++]&63)-65536,c[h++]=55296+(r>>10),c[h++]=56320+(r&1023)):c[h++]=(r&15)<<12|(a[i++]&63)<<6|a[i++]&63,h>8191&&((s||(s=[])).push(String.fromCharCode.apply(String,c)),h=0);return s?(h&&s.push(String.fromCharCode.apply(String,c.slice(0,h))),s.join("")):String.fromCharCode.apply(String,c.slice(0,h))},n.write=function(a,i,p){for(var o=p,s,c,h=0;h<a.length;++h)s=a.charCodeAt(h),s<128?i[p++]=s:s<2048?(i[p++]=s>>6|192,i[p++]=s&63|128):(s&64512)===55296&&((c=a.charCodeAt(h+1))&64512)===56320?(s=65536+((s&1023)<<10)+(c&1023),++h,i[p++]=s>>18|240,i[p++]=s>>12&63|128,i[p++]=s>>6&63|128,i[p++]=s&63|128):(i[p++]=s>>12|224,i[p++]=s>>6&63|128,i[p++]=s&63|128);return p-o}}),cu=mt((e,n)=>{n.exports=a;function a(i,p,o){var s=o||8192,c=s>>>1,h=null,r=s;return function(u){if(u<1||u>c)return i(u);r+u>s&&(h=i(s),r=0);var l=p.call(h,r,r+=u);return r&7&&(r=(r|7)+1),l}}}),du=mt((e,n)=>{n.exports=i;var a=Se();function i(c,h){this.lo=c>>>0,this.hi=h>>>0}var p=i.zero=new i(0,0);p.toNumber=function(){return 0},p.zzEncode=p.zzDecode=function(){return this},p.length=function(){return 1};var o=i.zeroHash="\0\0\0\0\0\0\0\0";i.fromNumber=function(c){if(c===0)return p;var h=c<0;h&&(c=-c);var r=c>>>0,u=(c-r)/4294967296>>>0;return h&&(u=~u>>>0,r=~r>>>0,++r>4294967295&&(r=0,++u>4294967295&&(u=0))),new i(r,u)},i.from=function(c){if(typeof c=="number")return i.fromNumber(c);if(a.isString(c))if(a.Long)c=a.Long.fromString(c);else return i.fromNumber(parseInt(c,10));return c.low||c.high?new i(c.low>>>0,c.high>>>0):p},i.prototype.toNumber=function(c){if(!c&&this.hi>>>31){var h=~this.lo+1>>>0,r=~this.hi>>>0;return h||(r=r+1>>>0),-(h+r*4294967296)}return this.lo+this.hi*4294967296},i.prototype.toLong=function(c){return a.Long?new a.Long(this.lo|0,this.hi|0,!!c):{low:this.lo|0,high:this.hi|0,unsigned:!!c}};var s=String.prototype.charCodeAt;i.fromHash=function(c){return c===o?p:new i((s.call(c,0)|s.call(c,1)<<8|s.call(c,2)<<16|s.call(c,3)<<24)>>>0,(s.call(c,4)|s.call(c,5)<<8|s.call(c,6)<<16|s.call(c,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 c=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^c)>>>0,this.lo=(this.lo<<1^c)>>>0,this},i.prototype.zzDecode=function(){var c=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^c)>>>0,this.hi=(this.hi>>>1^c)>>>0,this},i.prototype.length=function(){var c=this.lo,h=(this.lo>>>28|this.hi<<4)>>>0,r=this.hi>>>24;return r===0?h===0?c<16384?c<128?1:2:c<2097152?3:4:h<16384?h<128?5:6:h<2097152?7:8:r<128?9:10}}),Se=mt(e=>{var n=e;n.asPromise=js(),n.base64=Ys(),n.EventEmitter=Qs(),n.float=au(),n.inquire=su(),n.utf8=lu(),n.pool=cu(),n.LongBits=du(),n.isNode=!!(typeof global<"u"&&global&&global.process&&global.process.versions&&global.process.versions.node),n.global=n.isNode&&global||typeof window<"u"&&window||typeof self<"u"&&self||e,n.emptyArray=Object.freeze?Object.freeze([]):[],n.emptyObject=Object.freeze?Object.freeze({}):{},n.isInteger=Number.isInteger||function(p){return typeof p=="number"&&isFinite(p)&&Math.floor(p)===p},n.isString=function(p){return typeof p=="string"||p instanceof String},n.isObject=function(p){return p&&typeof p=="object"},n.isset=n.isSet=function(p,o){var s=p[o];return s!=null&&p.hasOwnProperty(o)?typeof s!="object"||(Array.isArray(s)?s.length:Object.keys(s).length)>0:!1},n.Buffer=function(){try{var p=n.inquire("buffer").Buffer;return p.prototype.utf8Write?p:null}catch{return null}}(),n._Buffer_from=null,n._Buffer_allocUnsafe=null,n.newBuffer=function(p){return typeof p=="number"?n.Buffer?n._Buffer_allocUnsafe(p):new n.Array(p):n.Buffer?n._Buffer_from(p):typeof Uint8Array>"u"?p:new Uint8Array(p)},n.Array=typeof Uint8Array<"u"?Uint8Array:Array,n.Long=n.global.dcodeIO&&n.global.dcodeIO.Long||n.global.Long||n.inquire("long"),n.key2Re=/^true|false|0|1$/,n.key32Re=/^-?(?:0|[1-9][0-9]*)$/,n.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,n.longToHash=function(p){return p?n.LongBits.from(p).toHash():n.LongBits.zeroHash},n.longFromHash=function(p,o){var s=n.LongBits.fromHash(p);return n.Long?n.Long.fromBits(s.lo,s.hi,o):s.toNumber(!!o)};function a(p,o,s){for(var c=Object.keys(o),h=0;h<c.length;++h)(p[c[h]]===void 0||!s)&&(p[c[h]]=o[c[h]]);return p}n.merge=a,n.lcFirst=function(p){return p.charAt(0).toLowerCase()+p.substring(1)};function i(p){function o(s,c){if(!(this instanceof o))return new o(s,c);Object.defineProperty(this,"message",{get:function(){return s}}),Error.captureStackTrace?Error.captureStackTrace(this,o):Object.defineProperty(this,"stack",{value:new Error().stack||""}),c&&a(this,c)}return o.prototype=Object.create(Error.prototype,{constructor:{value:o,writable:!0,enumerable:!1,configurable:!0},name:{get:function(){return p},set:void 0,enumerable:!1,configurable:!0},toString:{value:function(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),o}n.newError=i,n.ProtocolError=i("ProtocolError"),n.oneOfGetter=function(p){for(var o={},s=0;s<p.length;++s)o[p[s]]=1;return function(){for(var c=Object.keys(this),h=c.length-1;h>-1;--h)if(o[c[h]]===1&&this[c[h]]!==void 0&&this[c[h]]!==null)return c[h]}},n.oneOfSetter=function(p){return function(o){for(var s=0;s<p.length;++s)p[s]!==o&&delete this[p[s]]}},n.toJSONOptions={longs:String,enums:String,bytes:String,json:!0},n._configure=function(){var p=n.Buffer;if(!p){n._Buffer_from=n._Buffer_allocUnsafe=null;return}n._Buffer_from=p.from!==Uint8Array.from&&p.from||function(o,s){return new p(o,s)},n._Buffer_allocUnsafe=p.allocUnsafe||function(o){return new p(o)}}}),ei=mt((e,n)=>{n.exports=u;var a=Se(),i,p=a.LongBits,o=a.base64,s=a.utf8;function c(_,A,L){this.fn=_,this.len=A,this.next=void 0,this.val=L}function h(){}function r(_){this.head=_.head,this.tail=_.tail,this.len=_.len,this.next=_.states}function u(){this.len=0,this.head=new c(h,0,0),this.tail=this.head,this.states=null}var l=function(){return a.Buffer?function(){return(u.create=function(){return new i})()}:function(){return new u}};u.create=l(),u.alloc=function(_){return new a.Array(_)},a.Array!==Array&&(u.alloc=a.pool(u.alloc,a.Array.prototype.subarray)),u.prototype._push=function(_,A,L){return this.tail=this.tail.next=new c(_,A,L),this.len+=A,this};function f(_,A,L){A[L]=_&255}function g(_,A,L){for(;_>127;)A[L++]=_&127|128,_>>>=7;A[L]=_}function b(_,A){this.len=_,this.next=void 0,this.val=A}b.prototype=Object.create(c.prototype),b.prototype.fn=g,u.prototype.uint32=function(_){return this.len+=(this.tail=this.tail.next=new b((_=_>>>0)<128?1:_<16384?2:_<2097152?3:_<268435456?4:5,_)).len,this},u.prototype.int32=function(_){return _<0?this._push(v,10,p.fromNumber(_)):this.uint32(_)},u.prototype.sint32=function(_){return this.uint32((_<<1^_>>31)>>>0)};function v(_,A,L){for(;_.hi;)A[L++]=_.lo&127|128,_.lo=(_.lo>>>7|_.hi<<25)>>>0,_.hi>>>=7;for(;_.lo>127;)A[L++]=_.lo&127|128,_.lo=_.lo>>>7;A[L++]=_.lo}u.prototype.uint64=function(_){var A=p.from(_);return this._push(v,A.length(),A)},u.prototype.int64=u.prototype.uint64,u.prototype.sint64=function(_){var A=p.from(_).zzEncode();return this._push(v,A.length(),A)},u.prototype.bool=function(_){return this._push(f,1,_?1:0)};function S(_,A,L){A[L]=_&255,A[L+1]=_>>>8&255,A[L+2]=_>>>16&255,A[L+3]=_>>>24}u.prototype.fixed32=function(_){return this._push(S,4,_>>>0)},u.prototype.sfixed32=u.prototype.fixed32,u.prototype.fixed64=function(_){var A=p.from(_);return this._push(S,4,A.lo)._push(S,4,A.hi)},u.prototype.sfixed64=u.prototype.fixed64,u.prototype.float=function(_){return this._push(a.float.writeFloatLE,4,_)},u.prototype.double=function(_){return this._push(a.float.writeDoubleLE,8,_)};var P=a.Array.prototype.set?function(_,A,L){A.set(_,L)}:function(_,A,L){for(var V=0;V<_.length;++V)A[L+V]=_[V]};u.prototype.bytes=function(_){var A=_.length>>>0;if(!A)return this._push(f,1,0);if(a.isString(_)){var L=u.alloc(A=o.length(_));o.decode(_,L,0),_=L}return this.uint32(A)._push(P,A,_)},u.prototype.string=function(_){var A=s.length(_);return A?this.uint32(A)._push(s.write,A,_):this._push(f,1,0)},u.prototype.fork=function(){return this.states=new r(this),this.head=this.tail=new c(h,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 c(h,0,0),this.len=0),this},u.prototype.ldelim=function(){var _=this.head,A=this.tail,L=this.len;return this.reset().uint32(L),L&&(this.tail.next=_.next,this.tail=A,this.len+=L),this},u.prototype.finish=function(){for(var _=this.head.next,A=this.constructor.alloc(this.len),L=0;_;)_.fn(_.val,A,L),L+=_.len,_=_.next;return A},u._configure=function(_){i=_,u.create=l(),i._configure()}}),vu=mt((e,n)=>{n.exports=p;var a=ei();(p.prototype=Object.create(a.prototype)).constructor=p;var i=Se();function p(){a.call(this)}p._configure=function(){p.alloc=i._Buffer_allocUnsafe,p.writeBytesBuffer=i.Buffer&&i.Buffer.prototype instanceof Uint8Array&&i.Buffer.prototype.set.name==="set"?function(s,c,h){c.set(s,h)}:function(s,c,h){if(s.copy)s.copy(c,h,0,s.length);else for(var r=0;r<s.length;)c[h++]=s[r++]}},p.prototype.bytes=function(s){i.isString(s)&&(s=i._Buffer_from(s,"base64"));var c=s.length>>>0;return this.uint32(c),c&&this._push(p.writeBytesBuffer,c,s),this};function o(s,c,h){s.length<40?i.utf8.write(s,c,h):c.utf8Write?c.utf8Write(s,h):c.write(s,h)}p.prototype.string=function(s){var c=i.Buffer.byteLength(s);return this.uint32(c),c&&this._push(o,c,s),this},p._configure()}),oi=mt((e,n)=>{n.exports=c;var a=Se(),i,p=a.LongBits,o=a.utf8;function s(g,b){return RangeError("index out of range: "+g.pos+" + "+(b||1)+" > "+g.len)}function c(g){this.buf=g,this.pos=0,this.len=g.length}var h=typeof Uint8Array<"u"?function(g){if(g instanceof Uint8Array||Array.isArray(g))return new c(g);throw Error("illegal buffer")}:function(g){if(Array.isArray(g))return new c(g);throw Error("illegal buffer")},r=function(){return a.Buffer?function(g){return(c.create=function(b){return a.Buffer.isBuffer(b)?new i(b):h(b)})(g)}:h};c.create=r(),c.prototype._slice=a.Array.prototype.subarray||a.Array.prototype.slice,c.prototype.uint32=function(){var g=4294967295;return function(){if(g=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(g=(g|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(g=(g|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(g=(g|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(g=(g|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return g;if((this.pos+=5)>this.len)throw this.pos=this.len,s(this,10);return g}}(),c.prototype.int32=function(){return this.uint32()|0},c.prototype.sint32=function(){var g=this.uint32();return g>>>1^-(g&1)|0};function u(){var g=new p(0,0),b=0;if(this.len-this.pos>4){for(;b<4;++b)if(g.lo=(g.lo|(this.buf[this.pos]&127)<<b*7)>>>0,this.buf[this.pos++]<128)return g;if(g.lo=(g.lo|(this.buf[this.pos]&127)<<28)>>>0,g.hi=(g.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return g;b=0}else{for(;b<3;++b){if(this.pos>=this.len)throw s(this);if(g.lo=(g.lo|(this.buf[this.pos]&127)<<b*7)>>>0,this.buf[this.pos++]<128)return g}return g.lo=(g.lo|(this.buf[this.pos++]&127)<<b*7)>>>0,g}if(this.len-this.pos>4){for(;b<5;++b)if(g.hi=(g.hi|(this.buf[this.pos]&127)<<b*7+3)>>>0,this.buf[this.pos++]<128)return g}else for(;b<5;++b){if(this.pos>=this.len)throw s(this);if(g.hi=(g.hi|(this.buf[this.pos]&127)<<b*7+3)>>>0,this.buf[this.pos++]<128)return g}throw Error("invalid varint encoding")}c.prototype.bool=function(){return this.uint32()!==0};function l(g,b){return(g[b-4]|g[b-3]<<8|g[b-2]<<16|g[b-1]<<24)>>>0}c.prototype.fixed32=function(){if(this.pos+4>this.len)throw s(this,4);return l(this.buf,this.pos+=4)},c.prototype.sfixed32=function(){if(this.pos+4>this.len)throw s(this,4);return l(this.buf,this.pos+=4)|0};function f(){if(this.pos+8>this.len)throw s(this,8);return new p(l(this.buf,this.pos+=4),l(this.buf,this.pos+=4))}c.prototype.float=function(){if(this.pos+4>this.len)throw s(this,4);var g=a.float.readFloatLE(this.buf,this.pos);return this.pos+=4,g},c.prototype.double=function(){if(this.pos+8>this.len)throw s(this,4);var g=a.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,g},c.prototype.bytes=function(){var g=this.uint32(),b=this.pos,v=this.pos+g;if(v>this.len)throw s(this,g);if(this.pos+=g,Array.isArray(this.buf))return this.buf.slice(b,v);if(b===v){var S=a.Buffer;return S?S.alloc(0):new this.buf.constructor(0)}return this._slice.call(this.buf,b,v)},c.prototype.string=function(){var g=this.bytes();return o.read(g,0,g.length)},c.prototype.skip=function(g){if(typeof g=="number"){if(this.pos+g>this.len)throw s(this,g);this.pos+=g}else do if(this.pos>=this.len)throw s(this);while(this.buf[this.pos++]&128);return this},c.prototype.skipType=function(g){switch(g){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(g=this.uint32()&7)!==4;)this.skipType(g);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+g+" at offset "+this.pos)}return this},c._configure=function(g){i=g,c.create=r(),i._configure();var b=a.Long?"toLong":"toNumber";a.merge(c.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 f.call(this)[b](!0)},sfixed64:function(){return f.call(this)[b](!1)}})}}),Lu=mt((e,n)=>{n.exports=p;var a=oi();(p.prototype=Object.create(a.prototype)).constructor=p;var i=Se();function p(o){a.call(this,o)}p._configure=function(){i.Buffer&&(p.prototype._slice=i.Buffer.prototype.slice)},p.prototype.string=function(){var o=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+o,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+o,this.len))},p._configure()}),ku=mt((e,n)=>{n.exports=i;var a=Se();(i.prototype=Object.create(a.EventEmitter.prototype)).constructor=i;function i(p,o,s){if(typeof p!="function")throw TypeError("rpcImpl must be a function");a.EventEmitter.call(this),this.rpcImpl=p,this.requestDelimited=!!o,this.responseDelimited=!!s}i.prototype.rpcCall=function p(o,s,c,h,r){if(!h)throw TypeError("request must be specified");var u=this;if(!r)return a.asPromise(p,u,o,s,c,h);if(!u.rpcImpl){setTimeout(function(){r(Error("already ended"))},0);return}try{return u.rpcImpl(o,s[u.requestDelimited?"encodeDelimited":"encode"](h).finish(),function(l,f){if(l)return u.emit("error",l,o),r(l);if(f===null){u.end(!0);return}if(!(f instanceof c))try{f=c[u.responseDelimited?"decodeDelimited":"decode"](f)}catch(g){return u.emit("error",g,o),r(g)}return u.emit("data",f,o),r(null,f)})}catch(l){u.emit("error",l,o),setTimeout(function(){r(l)},0);return}},i.prototype.end=function(p){return this.rpcImpl&&(p||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}}),Fu=mt(e=>{var n=e;n.Service=ku()}),Nu=mt((e,n)=>{n.exports={}}),Mu=mt(e=>{var n=e;n.build="minimal",n.Writer=ei(),n.BufferWriter=vu(),n.Reader=oi(),n.BufferReader=Lu(),n.util=Se(),n.rpc=Fu(),n.roots=Nu(),n.configure=a;function a(){n.util._configure(),n.Writer._configure(n.BufferWriter),n.Reader._configure(n.BufferReader)}a()}),Vu=mt((e,n)=>{n.exports=Mu()}),sr=mt((e,n)=>{var a=Vu(),i=a.Reader,p=a.Writer,o=a.util,s=a.roots.default||(a.roots.default={});s.onnx=function(){var c={};return c.Version=function(){var h={},r=Object.create(h);return r[h[0]="_START_VERSION"]=0,r[h[1]="IR_VERSION_2017_10_10"]=1,r[h[2]="IR_VERSION_2017_10_30"]=2,r[h[3]="IR_VERSION_2017_11_3"]=3,r[h[4]="IR_VERSION_2019_1_22"]=4,r[h[5]="IR_VERSION_2019_3_18"]=5,r[h[6]="IR_VERSION_2019_9_19"]=6,r[h[7]="IR_VERSION_2020_5_8"]=7,r[h[8]="IR_VERSION_2021_7_30"]=8,r[h[9]="IR_VERSION"]=9,r}(),c.AttributeProto=function(){function h(r){if(this.floats=[],this.ints=[],this.strings=[],this.tensors=[],this.graphs=[],this.sparseTensors=[],this.typeProtos=[],r)for(var u=Object.keys(r),l=0;l<u.length;++l)r[u[l]]!=null&&(this[u[l]]=r[u[l]])}return h.prototype.name="",h.prototype.refAttrName="",h.prototype.docString="",h.prototype.type=0,h.prototype.f=0,h.prototype.i=o.Long?o.Long.fromBits(0,0,!1):0,h.prototype.s=o.newBuffer([]),h.prototype.t=null,h.prototype.g=null,h.prototype.sparseTensor=null,h.prototype.tp=null,h.prototype.floats=o.emptyArray,h.prototype.ints=o.emptyArray,h.prototype.strings=o.emptyArray,h.prototype.tensors=o.emptyArray,h.prototype.graphs=o.emptyArray,h.prototype.sparseTensors=o.emptyArray,h.prototype.typeProtos=o.emptyArray,h.create=function(r){return new h(r)},h.encode=function(r,u){if(u||(u=p.create()),r.name!=null&&Object.hasOwnProperty.call(r,"name")&&u.uint32(10).string(r.name),r.f!=null&&Object.hasOwnProperty.call(r,"f")&&u.uint32(21).float(r.f),r.i!=null&&Object.hasOwnProperty.call(r,"i")&&u.uint32(24).int64(r.i),r.s!=null&&Object.hasOwnProperty.call(r,"s")&&u.uint32(34).bytes(r.s),r.t!=null&&Object.hasOwnProperty.call(r,"t")&&s.onnx.TensorProto.encode(r.t,u.uint32(42).fork()).ldelim(),r.g!=null&&Object.hasOwnProperty.call(r,"g")&&s.onnx.GraphProto.encode(r.g,u.uint32(50).fork()).ldelim(),r.floats!=null&&r.floats.length){u.uint32(58).fork();for(var l=0;l<r.floats.length;++l)u.float(r.floats[l]);u.ldelim()}if(r.ints!=null&&r.ints.length){u.uint32(66).fork();for(var l=0;l<r.ints.length;++l)u.int64(r.ints[l]);u.ldelim()}if(r.strings!=null&&r.strings.length)for(var l=0;l<r.strings.length;++l)u.uint32(74).bytes(r.strings[l]);if(r.tensors!=null&&r.tensors.length)for(var l=0;l<r.tensors.length;++l)s.onnx.TensorProto.encode(r.tensors[l],u.uint32(82).fork()).ldelim();if(r.graphs!=null&&r.graphs.length)for(var l=0;l<r.graphs.length;++l)s.onnx.GraphProto.encode(r.graphs[l],u.uint32(90).fork()).ldelim();if(r.docString!=null&&Object.hasOwnProperty.call(r,"docString")&&u.uint32(106).string(r.docString),r.tp!=null&&Object.hasOwnProperty.call(r,"tp")&&s.onnx.TypeProto.encode(r.tp,u.uint32(114).fork()).ldelim(),r.typeProtos!=null&&r.typeProtos.length)for(var l=0;l<r.typeProtos.length;++l)s.onnx.TypeProto.encode(r.typeProtos[l],u.uint32(122).fork()).ldelim();if(r.type!=null&&Object.hasOwnProperty.call(r,"type")&&u.uint32(160).int32(r.type),r.refAttrName!=null&&Object.hasOwnProperty.call(r,"refAttrName")&&u.uint32(170).string(r.refAttrName),r.sparseTensor!=null&&Object.hasOwnProperty.call(r,"sparseTensor")&&s.onnx.SparseTensorProto.encode(r.sparseTensor,u.uint32(178).fork()).ldelim(),r.sparseTensors!=null&&r.sparseTensors.length)for(var l=0;l<r.sparseTensors.length;++l)s.onnx.SparseTensorProto.encode(r.sparseTensors[l],u.uint32(186).fork()).ldelim();return u},h.encodeDelimited=function(r,u){return this.encode(r,u).ldelim()},h.decode=function(r,u){r instanceof i||(r=i.create(r));for(var l=u===void 0?r.len:r.pos+u,f=new s.onnx.AttributeProto;r.pos<l;){var g=r.uint32();switch(g>>>3){case 1:{f.name=r.string();break}case 21:{f.refAttrName=r.string();break}case 13:{f.docString=r.string();break}case 20:{f.type=r.int32();break}case 2:{f.f=r.float();break}case 3:{f.i=r.int64();break}case 4:{f.s=r.bytes();break}case 5:{f.t=s.onnx.TensorProto.decode(r,r.uint32());break}case 6:{f.g=s.onnx.GraphProto.decode(r,r.uint32());break}case 22:{f.sparseTensor=s.onnx.SparseTensorProto.decode(r,r.uint32());break}case 14:{f.tp=s.onnx.TypeProto.decode(r,r.uint32());break}case 7:{if(f.floats&&f.floats.length||(f.floats=[]),(g&7)===2)for(var b=r.uint32()+r.pos;r.pos<b;)f.floats.push(r.float());else f.floats.push(r.float());break}case 8:{if(f.ints&&f.ints.length||(f.ints=[]),(g&7)===2)for(var b=r.uint32()+r.pos;r.pos<b;)f.ints.push(r.int64());else f.ints.push(r.int64());break}case 9:{f.strings&&f.strings.length||(f.strings=[]),f.strings.push(r.bytes());break}case 10:{f.tensors&&f.tensors.length||(f.tensors=[]),f.tensors.push(s.onnx.TensorProto.decode(r,r.uint32()));break}case 11:{f.graphs&&f.graphs.length||(f.graphs=[]),f.graphs.push(s.onnx.GraphProto.decode(r,r.uint32()));break}case 23:{f.sparseTensors&&f.sparseTensors.length||(f.sparseTensors=[]),f.sparseTensors.push(s.onnx.SparseTensorProto.decode(r,r.uint32()));break}case 15:{f.typeProtos&&f.typeProtos.length||(f.typeProtos=[]),f.typeProtos.push(s.onnx.TypeProto.decode(r,r.uint32()));break}default:r.skipType(g&7);break}}return f},h.decodeDelimited=function(r){return r instanceof i||(r=new i(r)),this.decode(r,r.uint32())},h.verify=function(r){if(typeof r!="object"||r===null)return"object expected";if(r.name!=null&&r.hasOwnProperty("name")&&!o.isString(r.name))return"name: string expected";if(r.refAttrName!=null&&r.hasOwnProperty("refAttrName")&&!o.isString(r.refAttrName))return"refAttrName: string expected";if(r.docString!=null&&r.hasOwnProperty("docString")&&!o.isString(r.docString))return"docString: string expected";if(r.type!=null&&r.hasOwnProperty("type"))switch(r.type){default:return"type: enum value expected";case 0:case 1:case 2:case 3:case 4:case 5:case 11:case 13:case 6:case 7:case 8:case 9:case 10:case 12:case 14:break}if(r.f!=null&&r.hasOwnProperty("f")&&typeof r.f!="number")return"f: number expected";if(r.i!=null&&r.hasOwnProperty("i")&&!o.isInteger(r.i)&&!(r.i&&o.isInteger(r.i.low)&&o.isInteger(r.i.high)))return"i: integer|Long expected";if(r.s!=null&&r.hasOwnProperty("s")&&!(r.s&&typeof r.s.length=="number"||o.isString(r.s)))return"s: buffer expected";if(r.t!=null&&r.hasOwnProperty("t")){var u=s.onnx.TensorProto.verify(r.t);if(u)return"t."+u}if(r.g!=null&&r.hasOwnProperty("g")){var u=s.onnx.GraphProto.verify(r.g);if(u)return"g."+u}if(r.sparseTensor!=null&&r.hasOwnProperty("sparseTensor")){var u=s.onnx.SparseTensorProto.verify(r.sparseTensor);if(u)return"sparseTensor."+u}if(r.tp!=null&&r.hasOwnProperty("tp")){var u=s.onnx.TypeProto.verify(r.tp);if(u)return"tp."+u}if(r.floats!=null&&r.hasOwnProperty("floats")){if(!Array.isArray(r.floats))return"floats: array expected";for(var l=0;l<r.floats.length;++l)if(typeof r.floats[l]!="number")return"floats: number[] expected"}if(r.ints!=null&&r.hasOwnProperty("ints")){if(!Array.isArray(r.ints))return"ints: array expected";for(var l=0;l<r.ints.length;++l)if(!o.isInteger(r.ints[l])&&!(r.ints[l]&&o.isInteger(r.ints[l].low)&&o.isInteger(r.ints[l].high)))return"ints: integer|Long[] expected"}if(r.strings!=null&&r.hasOwnProperty("strings")){if(!Array.isArray(r.strings))return"strings: array expected";for(var l=0;l<r.strings.length;++l)if(!(r.strings[l]&&typeof r.strings[l].length=="number"||o.isString(r.strings[l])))return"strings: buffer[] expected"}if(r.tensors!=null&&r.hasOwnProperty("tensors")){if(!Array.isArray(r.tensors))return"tensors: array expected";for(var l=0;l<r.tensors.length;++l){var u=s.onnx.TensorProto.verify(r.tensors[l]);if(u)return"tensors."+u}}if(r.graphs!=null&&r.hasOwnProperty("graphs")){if(!Array.isArray(r.graphs))return"graphs: array expected";for(var l=0;l<r.graphs.length;++l){var u=s.onnx.GraphProto.verify(r.graphs[l]);if(u)return"graphs."+u}}if(r.sparseTensors!=null&&r.hasOwnProperty("sparseTensors")){if(!Array.isArray(r.sparseTensors))return"sparseTensors: array expected";for(var l=0;l<r.sparseTensors.length;++l){var u=s.onnx.SparseTensorProto.verify(r.sparseTensors[l]);if(u)return"sparseTensors."+u}}if(r.typeProtos!=null&&r.hasOwnProperty("typeProtos")){if(!Array.isArray(r.typeProtos))return"typeProtos: array expected";for(var l=0;l<r.typeProtos.length;++l){var u=s.onnx.TypeProto.verify(r.typeProtos[l]);if(u)return"typeProtos."+u}}return null},h.fromObject=function(r){if(r instanceof s.onnx.AttributeProto)return r;var u=new s.onnx.AttributeProto;switch(r.name!=null&&(u.name=String(r.name)),r.refAttrName!=null&&(u.refAttrName=String(r.refAttrName)),r.docString!=null&&(u.docString=String(r.docString)),r.type){default:if(typeof r.type=="number"){u.type=r.type;break}break;case"UNDEFINED":case 0:u.type=0;break;case"FLOAT":case 1:u.type=1;break;case"INT":case 2:u.type=2;break;case"STRING":case 3:u.type=3;break;case"TENSOR":case 4:u.type=4;break;case"GRAPH":case 5:u.type=5;break;case"SPARSE_TENSOR":case 11:u.type=11;break;case"TYPE_PROTO":case 13:u.type=13;break;case"FLOATS":case 6:u.type=6;break;case"INTS":case 7:u.type=7;break;case"STRINGS":case 8:u.type=8;break;case"TENSORS":case 9:u.type=9;break;case"GRAPHS":case 10:u.type=10;break;case"SPARSE_TENSORS":case 12:u.type=12;break;case"TYPE_PROTOS":case 14:u.type=14;break}if(r.f!=null&&(u.f=Number(r.f)),r.i!=null&&(o.Long?(u.i=o.Long.fromValue(r.i)).unsigned=!1:typeof r.i=="string"?u.i=parseInt(r.i,10):typeof r.i=="number"?u.i=r.i:typeof r.i=="object"&&(u.i=new o.LongBits(r.i.low>>>0,r.i.high>>>0).toNumber())),r.s!=null&&(typeof r.s=="string"?o.base64.decode(r.s,u.s=o.newBuffer(o.base64.length(r.s)),0):r.s.length>=0&&(u.s=r.s)),r.t!=null){if(typeof r.t!="object")throw TypeError(".onnx.AttributeProto.t: object expected");u.t=s.onnx.TensorProto.fromObject(r.t)}if(r.g!=null){if(typeof r.g!="object")throw TypeError(".onnx.AttributeProto.g: object expected");u.g=s.onnx.GraphProto.fromObject(r.g)}if(r.sparseTensor!=null){if(typeof r.sparseTensor!="object")throw TypeError(".onnx.AttributeProto.sparseTensor: object expected");u.sparseTensor=s.onnx.SparseTensorProto.fromObject(r.sparseTensor)}if(r.tp!=null){if(typeof r.tp!="object")throw TypeError(".onnx.AttributeProto.tp: object expected");u.tp=s.onnx.TypeProto.fromObject(r.tp)}if(r.floats){if(!Array.isArray(r.floats))throw TypeError(".onnx.AttributeProto.floats: array expected");u.floats=[];for(var l=0;l<r.floats.length;++l)u.floats[l]=Number(r.floats[l])}if(r.ints){if(!Array.isArray(r.ints))throw TypeError(".onnx.AttributeProto.ints: array expected");u.ints=[];for(var l=0;l<r.ints.length;++l)o.Long?(u.ints[l]=o.Long.fromValue(r.ints[l])).unsigned=!1:typeof r.ints[l]=="string"?u.ints[l]=parseInt(r.ints[l],10):typeof r.ints[l]=="number"?u.ints[l]=r.ints[l]:typeof r.ints[l]=="object"&&(u.ints[l]=new o.LongBits(r.ints[l].low>>>0,r.ints[l].high>>>0).toNumber())}if(r.strings){if(!Array.isArray(r.strings))throw TypeError(".onnx.AttributeProto.strings: array expected");u.strings=[];for(var l=0;l<r.strings.length;++l)typeof r.strings[l]=="string"?o.base64.decode(r.strings[l],u.strings[l]=o.newBuffer(o.base64.length(r.strings[l])),0):r.strings[l].length>=0&&(u.strings[l]=r.strings[l])}if(r.tensors){if(!Array.isArray(r.tensors))throw TypeError(".onnx.AttributeProto.tensors: array expected");u.tensors=[];for(var l=0;l<r.tensors.length;++l){if(typeof r.tensors[l]!="object")throw TypeError(".onnx.AttributeProto.tensors: object expected");u.tensors[l]=s.onnx.TensorProto.fromObject(r.tensors[l])}}if(r.graphs){if(!Array.isArray(r.graphs))throw TypeError(".onnx.AttributeProto.graphs: array expected");u.graphs=[];for(var l=0;l<r.graphs.length;++l){if(typeof r.graphs[l]!="object")throw TypeError(".onnx.AttributeProto.graphs: object expected");u.graphs[l]=s.onnx.GraphProto.fromObject(r.graphs[l])}}if(r.sparseTensors){if(!Array.isArray(r.sparseTensors))throw TypeError(".onnx.AttributeProto.sparseTensors: array expected");u.sparseTensors=[];for(var l=0;l<r.sparseTensors.length;++l){if(typeof r.sparseTensors[l]!="object")throw TypeError(".onnx.AttributeProto.sparseTensors: object expected");u.sparseTensors[l]=s.onnx.SparseTensorProto.fromObject(r.sparseTensors[l])}}if(r.typeProtos){if(!Array.isArray(r.typeProtos))throw TypeError(".onnx.AttributeProto.typeProtos: array expected");u.typeProtos=[];for(var l=0;l<r.typeProtos.length;++l){if(typeof r.typeProtos[l]!="object")throw TypeError(".onnx.AttributeProto.typeProtos: object expected");u.typeProtos[l]=s.onnx.TypeProto.fromObject(r.typeProtos[l])}}return u},h.toObject=function(r,u){u||(u={});var l={};if((u.arrays||u.defaults)&&(l.floats=[],l.ints=[],l.strings=[],l.tensors=[],l.graphs=[],l.typeProtos=[],l.sparseTensors=[]),u.defaults){if(l.name="",l.f=0,o.Long){var f=new o.Long(0,0,!1);l.i=u.longs===String?f.toString():u.longs===Number?f.toNumber():f}else l.i=u.longs===String?"0":0;u.bytes===String?l.s="":(l.s=[],u.bytes!==Array&&(l.s=o.newBuffer(l.s))),l.t=null,l.g=null,l.docString="",l.tp=null,l.type=u.enums===String?"UNDEFINED":0,l.refAttrName="",l.sparseTensor=null}if(r.name!=null&&r.hasOwnProperty("name")&&(l.name=r.name),r.f!=null&&r.hasOwnProperty("f")&&(l.f=u.json&&!isFinite(r.f)?String(r.f):r.f),r.i!=null&&r.hasOwnProperty("i")&&(typeof r.i=="number"?l.i=u.longs===String?String(r.i):r.i:l.i=u.longs===String?o.Long.prototype.toString.call(r.i):u.longs===Number?new o.LongBits(r.i.low>>>0,r.i.high>>>0).toNumber():r.i),r.s!=null&&r.hasOwnProperty("s")&&(l.s=u.bytes===String?o.base64.encode(r.s,0,r.s.length):u.bytes===Array?Array.prototype.slice.call(r.s):r.s),r.t!=null&&r.hasOwnProperty("t")&&(l.t=s.onnx.TensorProto.toObject(r.t,u)),r.g!=null&&r.hasOwnProperty("g")&&(l.g=s.onnx.GraphProto.toObject(r.g,u)),r.floats&&r.floats.length){l.floats=[];for(var g=0;g<r.floats.length;++g)l.floats[g]=u.json&&!isFinite(r.floats[g])?String(r.floats[g]):r.floats[g]}if(r.ints&&r.ints.length){l.ints=[];for(var g=0;g<r.ints.length;++g)typeof r.ints[g]=="number"?l.ints[g]=u.longs===String?String(r.ints[g]):r.ints[g]:l.ints[g]=u.longs===String?o.Long.prototype.toString.call(r.ints[g]):u.longs===Number?new o.LongBits(r.ints[g].low>>>0,r.ints[g].high>>>0).toNumber():r.ints[g]}if(r.strings&&r.strings.length){l.strings=[];for(var g=0;g<r.strings.length;++g)l.strings[g]=u.bytes===String?o.base64.encode(r.strings[g],0,r.strings[g].length):u.bytes===Array?Array.prototype.slice.call(r.strings[g]):r.strings[g]}if(r.tensors&&r.tensors.length){l.tensors=[];for(var g=0;g<r.tensors.length;++g)l.tensors[g]=s.onnx.TensorProto.toObject(r.tensors[g],u)}if(r.graphs&&r.graphs.length){l.graphs=[];for(var g=0;g<r.graphs.length;++g)l.graphs[g]=s.onnx.GraphProto.toObject(r.graphs[g],u)}if(r.docString!=null&&r.hasOwnProperty("docString")&&(l.docString=r.docString),r.tp!=null&&r.hasOwnProperty("tp")&&(l.tp=s.onnx.TypeProto.toObject(r.tp,u)),r.typeProtos&&r.typeProtos.length){l.typeProtos=[];for(var g=0;g<r.typeProtos.length;++g)l.typeProtos[g]=s.onnx.TypeProto.toObject(r.typeProtos[g],u)}if(r.type!=null&&r.hasOwnProperty("type")&&(l.type=u.enums===String?s.onnx.AttributeProto.AttributeType[r.type]===void 0?r.type:s.onnx.AttributeProto.AttributeType[r.type]:r.type),r.refAttrName!=null&&r.hasOwnProperty("refAttrName")&&(l.refAttrName=r.refAttrName),r.sparseTensor!=null&&r.hasOwnProperty("sparseTensor")&&(l.sparseTensor=s.onnx.SparseTensorProto.toObject(r.sparseTensor,u)),r.sparseTensors&&r.sparseTensors.length){l.sparseTensors=[];for(var g=0;g<r.sparseTensors.length;++g)l.sparseTensors[g]=s.onnx.SparseTensorProto.toObject(r.sparseTensors[g],u)}return l},h.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},h.getTypeUrl=function(r){return r===void 0&&(r="type.googleapis.com"),r+"/onnx.AttributeProto"},h.AttributeType=function(){var r={},u=Object.create(r);return u[r[0]="UNDEFINED"]=0,u[r[1]="FLOAT"]=1,u[r[2]="INT"]=2,u[r[3]="STRING"]=3,u[r[4]="TENSOR"]=4,u[r[5]="GRAPH"]=5,u[r[11]="SPARSE_TENSOR"]=11,u[r[13]="TYPE_PROTO"]=13,u[r[6]="FLOATS"]=6,u[r[7]="INTS"]=7,u[r[8]="STRINGS"]=8,u[r[9]="TENSORS"]=9,u[r[10]="GRAPHS"]=10,u[r[12]="SPARSE_TENSORS"]=12,u[r[14]="TYPE_PROTOS"]=14,u}(),h}(),c.ValueInfoProto=function(){function h(r){if(r)for(var u=Object.keys(r),l=0;l<u.length;++l)r[u[l]]!=null&&(this[u[l]]=r[u[l]])}return h.prototype.name="",h.prototype.type=null,h.prototype.docString="",h.create=function(r){return new h(r)},h.encode=function(r,u){return u||(u=p.create()),r.name!=null&&Object.hasOwnProperty.call(r,"name")&&u.uint32(10).string(r.name),r.type!=null&&Object.hasOwnProperty.call(r,"type")&&s.onnx.TypeProto.encode(r.type,u.uint32(18).fork()).ldelim(),r.docString!=null&&Object.hasOwnProperty.call(r,"docString")&&u.uint32(26).string(r.docString),u},h.encodeDelimited=function(r,u){return this.encode(r,u).ldelim()},h.decode=function(r,u){r instanceof i||(r=i.create(r));for(var l=u===void 0?r.len:r.pos+u,f=new s.onnx.ValueInfoProto;r.pos<l;){var g=r.uint32();switch(g>>>3){case 1:{f.name=r.string();break}case 2:{f.type=s.onnx.TypeProto.decode(r,r.uint32());break}case 3:{f.docString=r.string();break}default:r.skipType(g&7);break}}return f},h.decodeDelimited=function(r){return r instanceof i||(r=new i(r)),this.decode(r,r.uint32())},h.verify=function(r){if(typeof r!="object"||r===null)return"object expected";if(r.name!=null&&r.hasOwnProperty("name")&&!o.isString(r.name))return"name: string expected";if(r.type!=null&&r.hasOwnProperty("type")){var u=s.onnx.TypeProto.verify(r.type);if(u)return"type."+u}return r.docString!=null&&r.hasOwnProperty("docString")&&!o.isString(r.docString)?"docString: string expected":null},h.fromObject=function(r){if(r instanceof s.onnx.ValueInfoProto)return r;var u=new s.onnx.ValueInfoProto;if(r.name!=null&&(u.name=String(r.name)),r.type!=null){if(typeof r.type!="object")throw TypeError(".onnx.ValueInfoProto.type: object expected");u.type=s.onnx.TypeProto.fromObject(r.type)}return r.docString!=null&&(u.docString=String(r.docString)),u},h.toObject=function(r,u){u||(u={});var l={};return u.defaults&&(l.name="",l.type=null,l.docString=""),r.name!=null&&r.hasOwnProperty("name")&&(l.name=r.name),r.type!=null&&r.hasOwnProperty("type")&&(l.type=s.onnx.TypeProto.toObject(r.type,u)),r.docString!=null&&r.hasOwnProperty("docString")&&(l.docString=r.docString),l},h.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},h.getTypeUrl=function(r){return r===void 0&&(r="type.googleapis.com"),r+"/onnx.ValueInfoProto"},h}(),c.NodeProto=function(){function h(r){if(this.input=[],this.output=[],this.attribute=[],r)for(var u=Object.keys(r),l=0;l<u.length;++l)r[u[l]]!=null&&(this[u[l]]=r[u[l]])}return h.prototype.input=o.emptyArray,h.prototype.output=o.emptyArray,h.prototype.name="",h.prototype.opType="",h.prototype.domain="",h.prototype.attribute=o.emptyArray,h.prototype.docString="",h.create=function(r){return new h(r)},h.encode=function(r,u){if(u||(u=p.create()),r.input!=null&&r.input.length)for(var l=0;l<r.input.length;++l)u.uint32(10).string(r.input[l]);if(r.output!=null&&r.output.length)for(var l=0;l<r.output.length;++l)u.uint32(18).string(r.output[l]);if(r.name!=null&&Object.hasOwnProperty.call(r,"name")&&u.uint32(26).string(r.name),r.opType!=null&&Object.hasOwnProperty.call(r,"opType")&&u.uint32(34).string(r.opType),r.attribute!=null&&r.attribute.length)for(var l=0;l<r.attribute.length;++l)s.onnx.AttributeProto.encode(r.attribute[l],u.uint32(42).fork()).ldelim();return r.docString!=null&&Object.hasOwnProperty.call(r,"docString")&&u.uint32(50).string(r.docString),r.domain!=null&&Object.hasOwnProperty.call(r,"domain")&&u.uint32(58).string(r.domain),u},h.encodeDelimited=function(r,u){return this.encode(r,u).ldelim()},h.decode=function(r,u){r instanceof i||(r=i.create(r));for(var l=u===void 0?r.len:r.pos+u,f=new s.onnx.NodeProto;r.pos<l;){var g=r.uint32();switch(g>>>3){case 1:{f.input&&f.input.length||(f.input=[]),f.input.push(r.string());break}case 2:{f.output&&f.output.length||(f.output=[]),f.output.push(r.string());break}case 3:{f.name=r.string();break}case 4:{f.opType=r.string();break}case 7:{f.domain=r.string();break}case 5:{f.attribute&&f.attribute.length||(f.attribute=[]),f.attribute.push(s.onnx.AttributeProto.decode(r,r.uint32()));break}case 6:{f.docString=r.string();break}default:r.skipType(g&7);break}}return f},h.decodeDelimited=function(r){return r instanceof i||(r=new i(r)),this.decode(r,r.uint32())},h.verify=function(r){if(typeof r!="object"||r===null)return"object expected";if(r.input!=null&&r.hasOwnProperty("input")){if(!Array.isArray(r.input))return"input: array expected";for(var u=0;u<r.input.length;++u)if(!o.isString(r.input[u]))return"input: string[] expected"}if(r.output!=null&&r.hasOwnProperty("output")){if(!Array.isArray(r.output))return"output: array expected";for(var u=0;u<r.output.length;++u)if(!o.isString(r.output[u]))return"output: string[] expected"}if(r.name!=null&&r.hasOwnProperty("name")&&!o.isString(r.name))return"name: string expected";if(r.opType!=null&&r.hasOwnProperty("opType")&&!o.isString(r.opType))return"opType: string expected";if(r.domain!=null&&r.hasOwnProperty("domain")&&!o.isString(r.domain))return"domain: string expected";if(r.attribute!=null&&r.hasOwnProperty("attribute")){if(!Array.isArray(r.attribute))return"attribute: array expected";for(var u=0;u<r.attribute.length;++u){var l=s.onnx.AttributeProto.verify(r.attribute[u]);if(l)return"attribute."+l}}return r.docString!=null&&r.hasOwnProperty("docString")&&!o.isString(r.docString)?"docString: string expected":null},h.fromObject=function(r){if(r instanceof s.onnx.NodeProto)return r;var u=new s.onnx.NodeProto;if(r.input){if(!Array.isArray(r.input))throw TypeError(".onnx.NodeProto.input: array expected");u.input=[];for(var l=0;l<r.input.length;++l)u.input[l]=String(r.input[l])}if(r.output){if(!Array.isArray(r.output))throw TypeError(".onnx.NodeProto.output: array expected");u.output=[];for(var l=0;l<r.output.length;++l)u.output[l]=String(r.output[l])}if(r.name!=null&&(u.name=String(r.name)),r.opType!=null&&(u.opType=String(r.opType)),r.domain!=null&&(u.domain=String(r.domain)),r.attribute){if(!Array.isArray(r.attribute))throw TypeError(".onnx.NodeProto.attribute: array expected");u.attribute=[];for(var l=0;l<r.attribute.length;++l){if(typeof r.attribute[l]!="object")throw TypeError(".onnx.NodeProto.attribute: object expected");u.attribute[l]=s.onnx.AttributeProto.fromObject(r.attribute[l])}}return r.docString!=null&&(u.docString=String(r.docString)),u},h.toObject=function(r,u){u||(u={});var l={};if((u.arrays||u.defaults)&&(l.input=[],l.output=[],l.attribute=[]),u.defaults&&(l.name="",l.opType="",l.docString="",l.domain=""),r.input&&r.input.length){l.input=[];for(var f=0;f<r.input.length;++f)l.input[f]=r.input[f]}if(r.output&&r.output.length){l.output=[];for(var f=0;f<r.output.length;++f)l.output[f]=r.output[f]}if(r.name!=null&&r.hasOwnProperty("name")&&(l.name=r.name),r.opType!=null&&r.hasOwnProperty("opType")&&(l.opType=r.opType),r.attribute&&r.attribute.length){l.attribute=[];for(var f=0;f<r.attribute.length;++f)l.attribute[f]=s.onnx.AttributeProto.toObject(r.attribute[f],u)}return r.docString!=null&&r.hasOwnProperty("docString")&&(l.docString=r.docString),r.domain!=null&&r.hasOwnProperty("domain")&&(l.domain=r.domain),l},h.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},h.getTypeUrl=function(r){return r===void 0&&(r="type.googleapis.com"),r+"/onnx.NodeProto"},h}(),c.TrainingInfoProto=function(){function h(r){if(this.initializationBinding=[],this.updateBinding=[],r)for(var u=Object.keys(r),l=0;l<u.length;++l)r[u[l]]!=null&&(this[u[l]]=r[u[l]])}return h.prototype.initialization=null,h.prototype.algorithm=null,h.prototype.initializationBinding=o.emptyArray,h.prototype.updateBinding=o.emptyArray,h.create=function(r){return new h(r)},h.encode=function(r,u){if(u||(u=p.create()),r.initialization!=null&&Object.hasOwnProperty.call(r,"initialization")&&s.onnx.GraphProto.encode(r.initialization,u.uint32(10).fork()).ldelim(),r.algorithm!=null&&Object.hasOwnProperty.call(r,"algorithm")&&s.onnx.GraphProto.encode(r.algorithm,u.uint32(18).fork()).ldelim(),r.initializationBinding!=null&&r.initializationBinding.length)for(var l=0;l<r.initializationBinding.length;++l)s.onnx.StringStringEntryProto.encode(r.initializationBinding[l],u.uint32(26).fork()).ldelim();if(r.updateBinding!=null&&r.updateBinding.length)for(var l=0;l<r.updateBinding.length;++l)s.onnx.StringStringEntryProto.encode(r.updateBinding[l],u.uint32(34).fork()).ldelim();return u},h.encodeDelimited=function(r,u){return this.encode(r,u).ldelim()},h.decode=function(r,u){r instanceof i||(r=i.create(r));for(var l=u===void 0?r.len:r.pos+u,f=new s.onnx.TrainingInfoProto;r.pos<l;){var g=r.uint32();switch(g>>>3){case 1:{f.initialization=s.onnx.GraphProto.decode(r,r.uint32());break}case 2:{f.algorithm=s.onnx.GraphProto.decode(r,r.uint32());break}case 3:{f.initializationBinding&&f.initializationBinding.length||(f.initializationBinding=[]),f.initializationBinding.push(s.onnx.StringStringEntryProto.decode(r,r.uint32()));break}case 4:{f.updateBinding&&f.updateBinding.length||(f.updateBinding=[]),f.updateBinding.push(s.onnx.StringStringEntryProto.decode(r,r.uint32()));break}default:r.skipType(g&7);break}}return f},h.decodeDelimited=function(r){return r instanceof i||(r=new i(r)),this.decode(r,r.uint32())},h.verify=function(r){if(typeof r!="object"||r===null)return"object expected";if(r.initialization!=null&&r.hasOwnProperty("initialization")){var u=s.onnx.GraphProto.verify(r.initialization);if(u)return"initialization."+u}if(r.algorithm!=null&&r.hasOwnProperty("algorithm")){var u=s.onnx.GraphProto.verify(r.algorithm);if(u)return"algorithm."+u}if(r.initializationBinding!=null&&r.hasOwnProperty("initializationBinding")){if(!Array.isArray(r.initializationBinding))return"initializationBinding: array expected";for(var l=0;l<r.initializationBinding.length;++l){var u=s.onnx.StringStringEntryProto.verify(r.initializationBinding[l]);if(u)return"initializationBinding."+u}}if(r.updateBinding!=null&&r.hasOwnProperty("updateBinding")){if(!Array.isArray(r.updateBinding))return"updateBinding: array expected";for(var l=0;l<r.updateBinding.length;++l){var u=s.onnx.StringStringEntryProto.verify(r.updateBinding[l]);if(u)return"updateBinding."+u}}return null},h.fromObject=function(r){if(r instanceof s.onnx.TrainingInfoProto)return r;var u=new s.onnx.TrainingInfoProto;if(r.initialization!=null){if(typeof r.initialization!="object")throw TypeError(".onnx.TrainingInfoProto.initialization: object expected");u.initialization=s.onnx.GraphProto.fromObject(r.initialization)}if(r.algorithm!=null){if(typeof r.algorithm!="object")throw TypeError(".onnx.TrainingInfoProto.algorithm: object expected");u.algorithm=s.onnx.GraphProto.fromObject(r.algorithm)}if(r.initializationBinding){if(!Array.isArray(r.initializationBinding))throw TypeError(".onnx.TrainingInfoProto.initializationBinding: array expected");u.initializationBinding=[];for(var l=0;l<r.initializationBinding.length;++l){if(typeof r.initializationBinding[l]!="object")throw TypeError(".onnx.TrainingInfoProto.initializationBinding: object expected");u.initializationBinding[l]=s.onnx.StringStringEntryProto.fromObject(r.initializationBinding[l])}}if(r.updateBinding){if(!Array.isArray(r.updateBinding))throw TypeError(".onnx.TrainingInfoProto.updateBinding: array expected");u.updateBinding=[];for(var l=0;l<r.updateBinding.length;++l){if(typeof r.updateBinding[l]!="object")throw TypeError(".onnx.TrainingInfoProto.updateBinding: object expected");u.updateBinding[l]=s.onnx.StringStringEntryProto.fromObject(r.updateBinding[l])}}return u},h.toObject=function(r,u){u||(u={});var l={};if((u.arrays||u.defaults)&&(l.initializationBinding=[],l.updateBinding=[]),u.defaults&&(l.initialization=null,l.algorithm=null),r.initialization!=null&&r.hasOwnProperty("initialization")&&(l.initialization=s.onnx.GraphProto.toObject(r.initialization,u)),r.algorithm!=null&&r.hasOwnProperty("algorithm")&&(l.algorithm=s.onnx.GraphProto.toObject(r.algorithm,u)),r.initializationBinding&&r.initializationBinding.length){l.initializationBinding=[];for(var f=0;f<r.initializationBinding.length;++f)l.initializationBinding[f]=s.onnx.StringStringEntryProto.toObject(r.initializationBinding[f],u)}if(r.updateBinding&&r.updateBinding.length){l.updateBinding=[];for(var f=0;f<r.updateBinding.length;++f)l.updateBinding[f]=s.onnx.StringStringEntryProto.toObject(r.updateBinding[f],u)}return l},h.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},h.getTypeUrl=function(r){return r===void 0&&(r="type.googleapis.com"),r+"/onnx.TrainingInfoProto"},h}(),c.ModelProto=function(){function h(r){if(this.opsetImport=[],this.metadataProps=[],this.trainingInfo=[],this.functions=[],r)for(var u=Object.keys(r),l=0;l<u.length;++l)r[u[l]]!=null&&(this[u[l]]=r[u[l]])}return h.prototype.irVersion=o.Long?o.Long.fromBits(0,0,!1):0,h.prototype.opsetImport=o.emptyArray,h.prototype.producerName="",h.prototype.producerVersion="",h.prototype.domain="",h.prototype.modelVersion=o.Long?o.Long.fromBits(0,0,!1):0,h.prototype.docString="",h.prototype.graph=null,h.prototype.metadataProps=o.emptyArray,h.prototype.trainingInfo=o.emptyArray,h.prototype.functions=o.emptyArray,h.create=function(r){return new h(r)},h.encode=function(r,u){if(u||(u=p.create()),r.irVersion!=null&&Object.hasOwnProperty.call(r,"irVersion")&&u.uint32(8).int64(r.irVersion),r.producerName!=null&&Object.hasOwnProperty.call(r,"producerName")&&u.uint32(18).string(r.producerName),r.producerVersion!=null&&Object.hasOwnProperty.call(r,"producerVersion")&&u.uint32(26).string(r.producerVersion),r.domain!=null&&Object.hasOwnProperty.call(r,"domain")&&u.uint32(34).string(r.domain),r.modelVersion!=null&&Object.hasOwnProperty.call(r,"modelVersion")&&u.uint32(40).int64(r.modelVersion),r.docString!=null&&Object.hasOwnProperty.call(r,"docString")&&u.uint32(50).string(r.docString),r.graph!=null&&Object.hasOwnProperty.call(r,"graph")&&s.onnx.GraphProto.encode(r.graph,u.uint32(58).fork()).ldelim(),r.opsetImport!=null&&r.opsetImport.length)for(var l=0;l<r.opsetImport.length;++l)s.onnx.OperatorSetIdProto.encode(r.opsetImport[l],u.uint32(66).fork()).ldelim();if(r.metadataProps!=null&&r.metadataProps.length)for(var l=0;l<r.metadataProps.length;++l)s.onnx.StringStringEntryProto.encode(r.metadataProps[l],u.uint32(114).fork()).ldelim();if(r.trainingInfo!=null&&r.trainingInfo.length)for(var l=0;l<r.trainingInfo.length;++l)s.onnx.TrainingInfoProto.encode(r.trainingInfo[l],u.uint32(162).fork()).ldelim();if(r.functions!=null&&r.functions.length)for(var l=0;l<r.functions.length;++l)s.onnx.FunctionProto.encode(r.functions[l],u.uint32(202).fork()).ldelim();return u},h.encodeDelimited=function(r,u){return this.encode(r,u).ldelim()},h.decode=function(r,u){r instanceof i||(r=i.create(r));for(var l=u===void 0?r.len:r.pos+u,f=new s.onnx.ModelProto;r.pos<l;){var g=r.uint32();switch(g>>>3){case 1:{f.irVersion=r.int64();break}case 8:{f.opsetImport&&f.opsetImport.length||(f.opsetImport=[]),f.opsetImport.push(s.onnx.OperatorSetIdProto.decode(r,r.uint32()));break}case 2:{f.producerName=r.string();break}case 3:{f.producerVersion=r.string();break}case 4:{f.domain=r.string();break}case 5:{f.modelVersion=r.int64();break}case 6:{f.docString=r.string();break}case 7:{f.graph=s.onnx.GraphProto.decode(r,r.uint32());break}case 14:{f.metadataProps&&f.metadataProps.length||(f.metadataProps=[]),f.metadataProps.push(s.onnx.StringStringEntryProto.decode(r,r.uint32()));break}case 20:{f.trainingInfo&&f.trainingInfo.length||(f.trainingInfo=[]),f.trainingInfo.push(s.onnx.TrainingInfoProto.decode(r,r.uint32()));break}case 25:{f.functions&&f.functions.length||(f.functions=[]),f.functions.push(s.onnx.FunctionProto.decode(r,r.uint32()));break}default:r.skipType(g&7);break}}return f},h.decodeDelimited=function(r){return r instanceof i||(r=new i(r)),this.decode(r,r.uint32())},h.verify=function(r){if(typeof r!="object"||r===null)return"object expected";if(r.irVersion!=null&&r.hasOwnProperty("irVersion")&&!o.isInteger(r.irVersion)&&!(r.irVersion&&o.isInteger(r.irVersion.low)&&o.isInteger(r.irVersion.high)))return"irVersion: integer|Long expected";if(r.opsetImport!=null&&r.hasOwnProperty("opsetImport")){if(!Array.isArray(r.opsetImport))return"opsetImport: array expected";for(var u=0;u<r.opsetImport.length;++u){var l=s.onnx.OperatorSetIdProto.verify(r.opsetImport[u]);if(l)return"opsetImport."+l}}if(r.producerName!=null&&r.hasOwnProperty("producerName")&&!o.isString(r.producerName))return"producerName: string expected";if(r.producerVersion!=null&&r.hasOwnProperty("producerVersion")&&!o.isString(r.producerVersion))return"producerVersion: string expected";if(r.domain!=null&&r.hasOwnProperty("domain")&&!o.isString(r.domain))return"domain: string expected";if(r.modelVersion!=null&&r.hasOwnProperty("modelVersion")&&!o.isInteger(r.modelVersion)&&!(r.modelVersion&&o.isInteger(r.modelVersion.low)&&o.isInteger(r.modelVersion.high)))return"modelVersion: integer|Long expected";if(r.docString!=null&&r.hasOwnProperty("docString")&&!o.isString(r.docString))return"docString: string expected";if(r.graph!=null&&r.hasOwnProperty("graph")){var l=s.onnx.GraphProto.verify(r.graph);if(l)return"graph."+l}if(r.metadataProps!=null&&r.hasOwnProperty("metadataProps")){if(!Array.isArray(r.metadataProps))return"metadataProps: array expected";for(var u=0;u<r.metadataProps.length;++u){var l=s.onnx.StringStringEntryProto.verify(r.metadataProps[u]);if(l)return"metadataProps."+l}}if(r.trainingInfo!=null&&r.hasOwnProperty("trainingInfo")){if(!Array.isArray(r.trainingInfo))return"trainingInfo: array expected";for(var u=0;u<r.trainingInfo.length;++u){var l=s.onnx.TrainingInfoProto.verify(r.trainingInfo[u]);if(l)return"trainingInfo."+l}}if(r.functions!=null&&r.hasOwnProperty("functions")){if(!Array.isArray(r.functions))return"functions: array expected";for(var u=0;u<r.functions.length;++u){var l=s.onnx.FunctionProto.verify(r.functions[u]);if(l)return"functions."+l}}return null},h.fromObject=function(r){if(r instanceof s.onnx.ModelProto)return r;var u=new s.onnx.ModelProto;if(r.irVersion!=null&&(o.Long?(u.irVersion=o.Long.fromValue(r.irVersion)).unsigned=!1:typeof r.irVersion=="string"?u.irVersion=parseInt(r.irVersion,10):typeof r.irVersion=="number"?u.irVersion=r.irVersion:typeof r.irVersion=="object"&&(u.irVersion=new o.LongBits(r.irVersion.low>>>0,r.irVersion.high>>>0).toNumber())),r.opsetImport){if(!Array.isArray(r.opsetImport))throw TypeError(".onnx.ModelProto.opsetImport: array expected");u.opsetImport=[];for(var l=0;l<r.opsetImport.length;++l){if(typeof r.opsetImport[l]!="object")throw TypeError(".onnx.ModelProto.opsetImport: object expected");u.opsetImport[l]=s.onnx.OperatorSetIdProto.fromObject(r.opsetImport[l])}}if(r.producerName!=null&&(u.producerName=String(r.producerName)),r.producerVersion!=null&&(u.producerVersion=String(r.producerVersion)),r.domain!=null&&(u.domain=String(r.domain)),r.modelVersion!=null&&(o.Long?(u.modelVersion=o.Long.fromValue(r.modelVersion)).unsigned=!1:typeof r.modelVersion=="string"?u.modelVersion=parseInt(r.modelVersion,10):typeof r.modelVersion=="number"?u.modelVersion=r.modelVersion:typeof r.modelVersion=="object"&&(u.modelVersion=new o.LongBits(r.modelVersion.low>>>0,r.modelVersion.high>>>0).toNumber())),r.docString!=null&&(u.docString=String(r.docString)),r.graph!=null){if(typeof r.graph!="object")throw TypeError(".onnx.ModelProto.graph: object expected");u.graph=s.onnx.GraphProto.fromObject(r.graph)}if(r.metadataProps){if(!Array.isArray(r.metadataProps))throw TypeError(".onnx.ModelProto.metadataProps: array expected");u.metadataProps=[];for(var l=0;l<r.metadataProps.length;++l){if(typeof r.metadataProps[l]!="object")throw TypeError(".onnx.ModelProto.metadataProps: object expected");u.metadataProps[l]=s.onnx.StringStringEntryProto.fromObject(r.metadataProps[l])}}if(r.trainingInfo){if(!Array.isArray(r.trainingInfo))throw TypeError(".onnx.ModelProto.trainingInfo: array expected");u.trainingInfo=[];for(var l=0;l<r.trainingInfo.length;++l){if(typeof r.trainingInfo[l]!="object")throw TypeError(".onnx.ModelProto.trainingInfo: object expected");u.trainingInfo[l]=s.onnx.TrainingInfoProto.fromObject(r.trainingInfo[l])}}if(r.functions){if(!Array.isArray(r.functions))throw TypeError(".onnx.ModelProto.functions: array expected");u.functions=[];for(var l=0;l<r.functions.length;++l){if(typeof r.functions[l]!="object")throw TypeError(".onnx.ModelProto.functions: object expected");u.functions[l]=s.onnx.FunctionProto.fromObject(r.functions[l])}}return u},h.toObject=function(r,u){u||(u={});var l={};if((u.arrays||u.defaults)&&(l.opsetImport=[],l.metadataProps=[],l.trainingInfo=[],l.functions=[]),u.defaults){if(o.Long){var f=new o.Long(0,0,!1);l.irVersion=u.longs===String?f.toString():u.longs===Number?f.toNumber():f}else l.irVersion=u.longs===String?"0":0;if(l.producerName="",l.producerVersion="",l.domain="",o.Long){var f=new o.Long(0,0,!1);l.modelVersion=u.longs===String?f.toString():u.longs===Number?f.toNumber():f}else l.modelVersion=u.longs===String?"0":0;l.docString="",l.graph=null}if(r.irVersion!=null&&r.hasOwnProperty("irVersion")&&(typeof r.irVersion=="number"?l.irVersion=u.longs===String?String(r.irVersion):r.irVersion:l.irVersion=u.longs===String?o.Long.prototype.toString.call(r.irVersion):u.longs===Number?new o.LongBits(r.irVersion.low>>>0,r.irVersion.high>>>0).toNumber():r.irVersion),r.producerName!=null&&r.hasOwnProperty("producerName")&&(l.producerName=r.producerName),r.producerVersion!=null&&r.hasOwnProperty("producerVersion")&&(l.producerVersion=r.producerVersion),r.domain!=null&&r.hasOwnProperty("domain")&&(l.domain=r.domain),r.modelVersion!=null&&r.hasOwnProperty("modelVersion")&&(typeof r.modelVersion=="number"?l.modelVersion=u.longs===String?String(r.modelVersion):r.modelVersion:l.modelVersion=u.longs===String?o.Long.prototype.toString.call(r.modelVersion):u.longs===Number?new o.LongBits(r.modelVersion.low>>>0,r.modelVersion.high>>>0).toNumber():r.modelVersion),r.docString!=null&&r.hasOwnProperty("docString")&&(l.docString=r.docString),r.graph!=null&&r.hasOwnProperty("graph")&&(l.graph=s.onnx.GraphProto.toObject(r.graph,u)),r.opsetImport&&r.opsetImport.length){l.opsetImport=[];for(var g=0;g<r.opsetImport.length;++g)l.opsetImport[g]=s.onnx.OperatorSetIdProto.toObject(r.opsetImport[g],u)}if(r.metadataProps&&r.metadataProps.length){l.metadataProps=[];for(var g=0;g<r.metadataProps.length;++g)l.metadataProps[g]=s.onnx.StringStringEntryProto.toObject(r.metadataProps[g],u)}if(r.trainingInfo&&r.trainingInfo.length){l.trainingInfo=[];for(var g=0;g<r.trainingInfo.length;++g)l.trainingInfo[g]=s.onnx.TrainingInfoProto.toObject(r.trainingInfo[g],u)}if(r.functions&&r.functions.length){l.functions=[];for(var g=0;g<r.functions.length;++g)l.functions[g]=s.onnx.FunctionProto.toObject(r.functions[g],u)}return l},h.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},h.getTypeUrl=function(r){return r===void 0&&(r="type.googleapis.com"),r+"/onnx.ModelProto"},h}(),c.StringStringEntryProto=function(){function h(r){if(r)for(var u=Object.keys(r),l=0;l<u.length;++l)r[u[l]]!=null&&(this[u[l]]=r[u[l]])}return h.prototype.key="",h.prototype.value="",h.create=function(r){return new h(r)},h.encode=function(r,u){return u||(u=p.create()),r.key!=null&&Object.hasOwnProperty.call(r,"key")&&u.uint32(10).string(r.key),r.value!=null&&Object.hasOwnProperty.call(r,"value")&&u.uint32(18).string(r.value),u},h.encodeDelimited=function(r,u){return this.encode(r,u).ldelim()},h.decode=function(r,u){r instanceof i||(r=i.create(r));for(var l=u===void 0?r.len:r.pos+u,f=new s.onnx.StringStringEntryProto;r.pos<l;){var g=r.uint32();switch(g>>>3){case 1:{f.key=r.string();break}case 2:{f.value=r.string();break}default:r.skipType(g&7);break}}return f},h.decodeDelimited=function(r){return r instanceof i||(r=new i(r)),this.decode(r,r.uint32())},h.verify=function(r){return typeof r!="object"||r===null?"object expected":r.key!=null&&r.hasOwnProperty("key")&&!o.isString(r.key)?"key: string expected":r.value!=null&&r.hasOwnProperty("value")&&!o.isString(r.value)?"value: string expected":null},h.fromObject=function(r){if(r instanceof s.onnx.StringStringEntryProto)return r;var u=new s.onnx.StringStringEntryProto;return r.key!=null&&(u.key=String(r.key)),r.value!=null&&(u.value=String(r.value)),u},h.toObject=function(r,u){u||(u={});var l={};return u.defaults&&(l.key="",l.value=""),r.key!=null&&r.hasOwnProperty("key")&&(l.key=r.key),r.value!=null&&r.hasOwnProperty("value")&&(l.value=r.value),l},h.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},h.getTypeUrl=function(r){return r===void 0&&(r="type.googleapis.com"),r+"/onnx.StringStringEntryProto"},h}(),c.TensorAnnotation=function(){function h(r){if(this.quantParameterTensorNames=[],r)for(var u=Object.keys(r),l=0;l<u.length;++l)r[u[l]]!=null&&(this[u[l]]=r[u[l]])}return h.prototype.tensorName="",h.prototype.quantParameterTensorNames=o.emptyArray,h.create=function(r){return new h(r)},h.encode=function(r,u){if(u||(u=p.create()),r.tensorName!=null&&Object.hasOwnProperty.call(r,"tensorName")&&u.uint32(10).string(r.tensorName),r.quantParameterTensorNames!=null&&r.quantParameterTensorNames.length)for(var l=0;l<r.quantParameterTensorNames.length;++l)s.onnx.StringStringEntryProto.encode(r.quantParameterTensorNames[l],u.uint32(18).fork()).ldelim();return u},h.encodeDelimited=function(r,u){return this.encode(r,u).ldelim()},h.decode=function(r,u){r instanceof i||(r=i.create(r));for(var l=u===void 0?r.len:r.pos+u,f=new s.onnx.TensorAnnotation;r.pos<l;){var g=r.uint32();switch(g>>>3){case 1:{f.tensorName=r.string();break}case 2:{f.quantParameterTensorNames&&f.quantParameterTensorNames.length||(f.quantParameterTensorNames=[]),f.quantParameterTensorNames.push(s.onnx.StringStringEntryProto.decode(r,r.uint32()));break}default:r.skipType(g&7);break}}return f},h.decodeDelimited=function(r){return r instanceof i||(r=new i(r)),this.decode(r,r.uint32())},h.verify=function(r){if(typeof r!="object"||r===null)return"object expected";if(r.tensorName!=null&&r.hasOwnProperty("tensorName")&&!o.isString(r.tensorName))return"tensorName: string expected";if(r.quantParameterTensorNames!=null&&r.hasOwnProperty("quantParameterTensorNames")){if(!Array.isArray(r.quantParameterTensorNames))return"quantParameterTensorNames: array expected";for(var u=0;u<r.quantParameterTensorNames.length;++u){var l=s.onnx.StringStringEntryProto.verify(r.quantParameterTensorNames[u]);if(l)return"quantParameterTensorNames."+l}}return null},h.fromObject=function(r){if(r instanceof s.onnx.TensorAnnotation)return r;var u=new s.onnx.TensorAnnotation;if(r.tensorName!=null&&(u.tensorName=String(r.tensorName)),r.quantParameterTensorNames){if(!Array.isArray(r.quantParameterTensorNames))throw TypeError(".onnx.TensorAnnotation.quantParameterTensorNames: array expected");u.quantParameterTensorNames=[];for(var l=0;l<r.quantParameterTensorNames.length;++l){if(typeof r.quantParameterTensorNames[l]!="object")throw TypeError(".onnx.TensorAnnotation.quantParameterTensorNames: object expected");u.quantParameterTensorNames[l]=s.onnx.StringStringEntryProto.fromObject(r.quantParameterTensorNames[l])}}return u},h.toObject=function(r,u){u||(u={});var l={};if((u.arrays||u.defaults)&&(l.quantParameterTensorNames=[]),u.defaults&&(l.tensorName=""),r.tensorName!=null&&r.hasOwnProperty("tensorName")&&(l.tensorName=r.tensorName),r.quantParameterTensorNames&&r.quantParameterTensorNames.length){l.quantParameterTensorNames=[];for(var f=0;f<r.quantParameterTensorNames.length;++f)l.quantParameterTensorNames[f]=s.onnx.StringStringEntryProto.toObject(r.quantParameterTensorNames[f],u)}return l},h.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},h.getTypeUrl=function(r){return r===void 0&&(r="type.googleapis.com"),r+"/onnx.TensorAnnotation"},h}(),c.GraphProto=function(){function h(r){if(this.node=[],this.initializer=[],this.sparseInitializer=[],this.input=[],this.output=[],this.valueInfo=[],this.quantizationAnnotation=[],r)for(var u=Object.keys(r),l=0;l<u.length;++l)r[u[l]]!=null&&(this[u[l]]=r[u[l]])}return h.prototype.node=o.emptyArray,h.prototype.name="",h.prototype.initializer=o.emptyArray,h.prototype.sparseInitializer=o.emptyArray,h.prototype.docString="",h.prototype.input=o.emptyArray,h.prototype.output=o.emptyArray,h.prototype.valueInfo=o.emptyArray,h.prototype.quantizationAnnotation=o.emptyArray,h.create=function(r){return new h(r)},h.encode=function(r,u){if(u||(u=p.create()),r.node!=null&&r.node.length)for(var l=0;l<r.node.length;++l)s.onnx.NodeProto.encode(r.node[l],u.uint32(10).fork()).ldelim();if(r.name!=null&&Object.hasOwnProperty.call(r,"name")&&u.uint32(18).string(r.name),r.initializer!=null&&r.initializer.length)for(var l=0;l<r.initializer.length;++l)s.onnx.TensorProto.encode(r.initializer[l],u.uint32(42).fork()).ldelim();if(r.docString!=null&&Object.hasOwnProperty.call(r,"docString")&&u.uint32(82).string(r.docString),r.input!=null&&r.input.length)for(var l=0;l<r.input.length;++l)s.onnx.ValueInfoProto.encode(r.input[l],u.uint32(90).fork()).ldelim();if(r.output!=null&&r.output.length)for(var l=0;l<r.output.length;++l)s.onnx.ValueInfoProto.encode(r.output[l],u.uint32(98).fork()).ldelim();if(r.valueInfo!=null&&r.valueInfo.length)for(var l=0;l<r.valueInfo.length;++l)s.onnx.ValueInfoProto.encode(r.valueInfo[l],u.uint32(106).fork()).ldelim();if(r.quantizationAnnotation!=null&&r.quantizationAnnotation.length)for(var l=0;l<r.quantizationAnnotation.length;++l)s.onnx.TensorAnnotation.encode(r.quantizationAnnotation[l],u.uint32(114).fork()).ldelim();if(r.sparseInitializer!=null&&r.sparseInitializer.length)for(var l=0;l<r.sparseInitializer.length;++l)s.onnx.SparseTensorProto.encode(r.sparseInitializer[l],u.uint32(122).fork()).ldelim();return u},h.encodeDelimited=function(r,u){return this.encode(r,u).ldelim()},h.decode=function(r,u){r instanceof i||(r=i.create(r));for(var l=u===void 0?r.len:r.pos+u,f=new s.onnx.GraphProto;r.pos<l;){var g=r.uint32();switch(g>>>3){case 1:{f.node&&f.node.length||(f.node=[]),f.node.push(s.onnx.NodeProto.decode(r,r.uint32()));break}case 2:{f.name=r.string();break}case 5:{f.initializer&&f.initializer.length||(f.initializer=[]),f.initializer.push(s.onnx.TensorProto.decode(r,r.uint32()));break}case 15:{f.sparseInitializer&&f.sparseInitializer.length||(f.sparseInitializer=[]),f.sparseInitializer.push(s.onnx.SparseTensorProto.decode(r,r.uint32()));break}case 10:{f.docString=r.string();break}case 11:{f.input&&f.input.length||(f.input=[]),f.input.push(s.onnx.ValueInfoProto.decode(r,r.uint32()));break}case 12:{f.output&&f.output.length||(f.output=[]),f.output.push(s.onnx.ValueInfoProto.decode(r,r.uint32()));break}case 13:{f.valueInfo&&f.valueInfo.length||(f.valueInfo=[]),f.valueInfo.push(s.onnx.ValueInfoProto.decode(r,r.uint32()));break}case 14:{f.quantizationAnnotation&&f.quantizationAnnotation.length||(f.quantizationAnnotation=[]),f.quantizationAnnotation.push(s.onnx.TensorAnnotation.decode(r,r.uint32()));break}default:r.skipType(g&7);break}}return f},h.decodeDelimited=function(r){return r instanceof i||(r=new i(r)),this.decode(r,r.uint32())},h.verify=function(r){if(typeof r!="object"||r===null)return"object expected";if(r.node!=null&&r.hasOwnProperty("node")){if(!Array.isArray(r.node))return"node: array expected";for(var u=0;u<r.node.length;++u){var l=s.onnx.NodeProto.verify(r.node[u]);if(l)return"node."+l}}if(r.name!=null&&r.hasOwnProperty("name")&&!o.isString(r.name))return"name: string expected";if(r.initializer!=null&&r.hasOwnProperty("initializer")){if(!Array.isArray(r.initializer))return"initializer: array expected";for(var u=0;u<r.initializer.length;++u){var l=s.onnx.TensorProto.verify(r.initializer[u]);if(l)return"initializer."+l}}if(r.sparseInitializer!=null&&r.hasOwnProperty("sparseInitializer")){if(!Array.isArray(r.sparseInitializer))return"sparseInitializer: array expected";for(var u=0;u<r.sparseInitializer.length;++u){var l=s.onnx.SparseTensorProto.verify(r.sparseInitializer[u]);if(l)return"sparseInitializer."+l}}if(r.docString!=null&&r.hasOwnProperty("docString")&&!o.isString(r.docString))return"docString: string expected";if(r.input!=null&&r.hasOwnProperty("input")){if(!Array.isArray(r.input))return"input: array expected";for(var u=0;u<r.input.length;++u){var l=s.onnx.ValueInfoProto.verify(r.input[u]);if(l)return"input."+l}}if(r.output!=null&&r.hasOwnProperty("output")){if(!Array.isArray(r.output))return"output: array expected";for(var u=0;u<r.output.length;++u){var l=s.onnx.ValueInfoProto.verify(r.output[u]);if(l)return"output."+l}}if(r.valueInfo!=null&&r.hasOwnProperty("valueInfo")){if(!Array.isArray(r.valueInfo))return"valueInfo: array expected";for(var u=0;u<r.valueInfo.length;++u){var l=s.onnx.ValueInfoProto.verify(r.valueInfo[u]);if(l)return"valueInfo."+l}}if(r.quantizationAnnotation!=null&&r.hasOwnProperty("quantizationAnnotation")){if(!Array.isArray(r.quantizationAnnotation))return"quantizationAnnotation: array expected";for(var u=0;u<r.quantizationAnnotation.length;++u){var l=s.onnx.TensorAnnotation.verify(r.quantizationAnnotation[u]);if(l)return"quantizationAnnotation."+l}}return null},h.fromObject=function(r){if(r instanceof s.onnx.GraphProto)return r;var u=new s.onnx.GraphProto;if(r.node){if(!Array.isArray(r.node))throw TypeError(".onnx.GraphProto.node: array expected");u.node=[];for(var l=0;l<r.node.length;++l){if(typeof r.node[l]!="object")throw TypeError(".onnx.GraphProto.node: object expected");u.node[l]=s.onnx.NodeProto.fromObject(r.node[l])}}if(r.name!=null&&(u.name=String(r.name)),r.initializer){if(!Array.isArray(r.initializer))throw TypeError(".onnx.GraphProto.initializer: array expected");u.initializer=[];for(var l=0;l<r.initializer.length;++l){if(typeof r.initializer[l]!="object")throw TypeError(".onnx.GraphProto.initializer: object expected");u.initializer[l]=s.onnx.TensorProto.fromObject(r.initializer[l])}}if(r.sparseInitializer){if(!Array.isArray(r.sparseInitializer))throw TypeError(".onnx.GraphProto.sparseInitializer: array expected");u.sparseInitializer=[];for(var l=0;l<r.sparseInitializer.length;++l){if(typeof r.sparseInitializer[l]!="object")throw TypeError(".onnx.GraphProto.sparseInitializer: object expected");u.sparseInitializer[l]=s.onnx.SparseTensorProto.fromObject(r.sparseInitializer[l])}}if(r.docString!=null&&(u.docString=String(r.docString)),r.input){if(!Array.isArray(r.input))throw TypeError(".onnx.GraphProto.input: array expected");u.input=[];for(var l=0;l<r.input.length;++l){if(typeof r.input[l]!="object")throw TypeError(".onnx.GraphProto.input: object expected");u.input[l]=s.onnx.ValueInfoProto.fromObject(r.input[l])}}if(r.output){if(!Array.isArray(r.output))throw TypeError(".onnx.GraphProto.output: array expected");u.output=[];for(var l=0;l<r.output.length;++l){if(typeof r.output[l]!="object")throw TypeError(".onnx.GraphProto.output: object expected");u.output[l]=s.onnx.ValueInfoProto.fromObject(r.output[l])}}if(r.valueInfo){if(!Array.isArray(r.valueInfo))throw TypeError(".onnx.GraphProto.valueInfo: array expected");u.valueInfo=[];for(var l=0;l<r.valueInfo.length;++l){if(typeof r.valueInfo[l]!="object")throw TypeError(".onnx.GraphProto.valueInfo: object expected");u.valueInfo[l]=s.onnx.ValueInfoProto.fromObject(r.valueInfo[l])}}if(r.quantizationAnnotation){if(!Array.isArray(r.quantizationAnnotation))throw TypeError(".onnx.GraphProto.quantizationAnnotation: array expected");u.quantizationAnnotation=[];for(var l=0;l<r.quantizationAnnotation.length;++l){if(typeof r.quantizationAnnotation[l]!="object")throw TypeError(".onnx.GraphProto.quantizationAnnotation: object expected");u.quantizationAnnotation[l]=s.onnx.TensorAnnotation.fromObject(r.quantizationAnnotation[l])}}return u},h.toObject=function(r,u){u||(u={});var l={};if((u.arrays||u.defaults)&&(l.node=[],l.initializer=[],l.input=[],l.output=[],l.valueInfo=[],l.quantizationAnnotation=[],l.sparseInitializer=[]),u.defaults&&(l.name="",l.docString=""),r.node&&r.node.length){l.node=[];for(var f=0;f<r.node.length;++f)l.node[f]=s.onnx.NodeProto.toObject(r.node[f],u)}if(r.name!=null&&r.hasOwnProperty("name")&&(l.name=r.name),r.initializer&&r.initializer.length){l.initializer=[];for(var f=0;f<r.initializer.length;++f)l.initializer[f]=s.onnx.TensorProto.toObject(r.initializer[f],u)}if(r.docString!=null&&r.hasOwnProperty("docString")&&(l.docString=r.docString),r.input&&r.input.length){l.input=[];for(var f=0;f<r.input.length;++f)l.input[f]=s.onnx.ValueInfoProto.toObject(r.input[f],u)}if(r.output&&r.output.length){l.output=[];for(var f=0;f<r.output.length;++f)l.output[f]=s.onnx.ValueInfoProto.toObject(r.output[f],u)}if(r.valueInfo&&r.valueInfo.length){l.valueInfo=[];for(var f=0;f<r.valueInfo.length;++f)l.valueInfo[f]=s.onnx.ValueInfoProto.toObject(r.valueInfo[f],u)}if(r.quantizationAnnotation&&r.quantizationAnnotation.length){l.quantizationAnnotation=[];for(var f=0;f<r.quantizationAnnotation.length;++f)l.quantizationAnnotation[f]=s.onnx.TensorAnnotation.toObject(r.quantizationAnnotation[f],u)}if(r.sparseInitializer&&r.sparseInitializer.length){l.sparseInitializer=[];for(var f=0;f<r.sparseInitializer.length;++f)l.sparseInitializer[f]=s.onnx.SparseTensorProto.toObject(r.sparseInitializer[f],u)}return l},h.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},h.getTypeUrl=function(r){return r===void 0&&(r="type.googleapis.com"),r+"/onnx.GraphProto"},h}(),c.TensorProto=function(){function h(r){if(this.dims=[],this.floatData=[],this.int32Data=[],this.stringData=[],this.int64Data=[],this.externalData=[],this.doubleData=[],this.uint64Data=[],r)for(var u=Object.keys(r),l=0;l<u.length;++l)r[u[l]]!=null&&(this[u[l]]=r[u[l]])}return h.prototype.dims=o.emptyArray,h.prototype.dataType=0,h.prototype.segment=null,h.prototype.floatData=o.emptyArray,h.prototype.int32Data=o.emptyArray,h.prototype.stringData=o.emptyArray,h.prototype.int64Data=o.emptyArray,h.prototype.name="",h.prototype.docString="",h.prototype.rawData=o.newBuffer([]),h.prototype.externalData=o.emptyArray,h.prototype.dataLocation=0,h.prototype.doubleData=o.emptyArray,h.prototype.uint64Data=o.emptyArray,h.create=function(r){return new h(r)},h.encode=function(r,u){if(u||(u=p.create()),r.dims!=null&&r.dims.length){u.uint32(10).fork();for(var l=0;l<r.dims.length;++l)u.int64(r.dims[l]);u.ldelim()}if(r.dataType!=null&&Object.hasOwnProperty.call(r,"dataType")&&u.uint32(16).int32(r.dataType),r.segment!=null&&Object.hasOwnProperty.call(r,"segment")&&s.onnx.TensorProto.Segment.encode(r.segment,u.uint32(26).fork()).ldelim(),r.floatData!=null&&r.floatData.length){u.uint32(34).fork();for(var l=0;l<r.floatData.length;++l)u.float(r.floatData[l]);u.ldelim()}if(r.int32Data!=null&&r.int32Data.length){u.uint32(42).fork();for(var l=0;l<r.int32Data.length;++l)u.int32(r.int32Data[l]);u.ldelim()}if(r.stringData!=null&&r.stringData.length)for(var l=0;l<r.stringData.length;++l)u.uint32(50).bytes(r.stringData[l]);if(r.int64Data!=null&&r.int64Data.length){u.uint32(58).fork();for(var l=0;l<r.int64Data.length;++l)u.int64(r.int64Data[l]);u.ldelim()}if(r.name!=null&&Object.hasOwnProperty.call(r,"name")&&u.uint32(66).string(r.name),r.rawData!=null&&Object.hasOwnProperty.call(r,"rawData")&&u.uint32(74).bytes(r.rawData),r.doubleData!=null&&r.doubleData.length){u.uint32(82).fork();for(var l=0;l<r.doubleData.length;++l)u.double(r.doubleData[l]);u.ldelim()}if(r.uint64Data!=null&&r.uint64Data.length){u.uint32(90).fork();for(var l=0;l<r.uint64Data.length;++l)u.uint64(r.uint64Data[l]);u.ldelim()}if(r.docString!=null&&Object.hasOwnProperty.call(r,"docString")&&u.uint32(98).string(r.docString),r.externalData!=null&&r.externalData.length)for(var l=0;l<r.externalData.length;++l)s.onnx.StringStringEntryProto.encode(r.externalData[l],u.uint32(106).fork()).ldelim();return r.dataLocation!=null&&Object.hasOwnProperty.call(r,"dataLocation")&&u.uint32(112).int32(r.dataLocation),u},h.encodeDelimited=function(r,u){return this.encode(r,u).ldelim()},h.decode=function(r,u){r instanceof i||(r=i.create(r));for(var l=u===void 0?r.len:r.pos+u,f=new s.onnx.TensorProto;r.pos<l;){var g=r.uint32();switch(g>>>3){case 1:{if(f.dims&&f.dims.length||(f.dims=[]),(g&7)===2)for(var b=r.uint32()+r.pos;r.pos<b;)f.dims.push(r.int64());else f.dims.push(r.int64());break}case 2:{f.dataType=r.int32();break}case 3:{f.segment=s.onnx.TensorProto.Segment.decode(r,r.uint32());break}case 4:{if(f.floatData&&f.floatData.length||(f.floatData=[]),(g&7)===2)for(var b=r.uint32()+r.pos;r.pos<b;)f.floatData.push(r.float());else f.floatData.push(r.float());break}case 5:{if(f.int32Data&&f.int32Data.length||(f.int32Data=[]),(g&7)===2)for(var b=r.uint32()+r.pos;r.pos<b;)f.int32Data.push(r.int32());else f.int32Data.push(r.int32());break}case 6:{f.stringData&&f.stringData.length||(f.stringData=[]),f.stringData.push(r.bytes());break}case 7:{if(f.int64Data&&f.int64Data.length||(f.int64Data=[]),(g&7)===2)for(var b=r.uint32()+r.pos;r.pos<b;)f.int64Data.push(r.int64());else f.int64Data.push(r.int64());break}case 8:{f.name=r.string();break}case 12:{f.docString=r.string();break}case 9:{f.rawData=r.bytes();break}case 13:{f.externalData&&f.externalData.length||(f.externalData=[]),f.externalData.push(s.onnx.StringStringEntryProto.decode(r,r.uint32()));break}case 14:{f.dataLocation=r.int32();break}case 10:{if(f.doubleData&&f.doubleData.length||(f.doubleData=[]),(g&7)===2)for(var b=r.uint32()+r.pos;r.pos<b;)f.doubleData.push(r.double());else f.doubleData.push(r.double());break}case 11:{if(f.uint64Data&&f.uint64Data.length||(f.uint64Data=[]),(g&7)===2)for(var b=r.uint32()+r.pos;r.pos<b;)f.uint64Data.push(r.uint64());else f.uint64Data.push(r.uint64());break}default:r.skipType(g&7);break}}return f},h.decodeDelimited=function(r){return r instanceof i||(r=new i(r)),this.decode(r,r.uint32())},h.verify=function(r){if(typeof r!="object"||r===null)return"object expected";if(r.dims!=null&&r.hasOwnProperty("dims")){if(!Array.isArray(r.dims))return"dims: array expected";for(var u=0;u<r.dims.length;++u)if(!o.isInteger(r.dims[u])&&!(r.dims[u]&&o.isInteger(r.dims[u].low)&&o.isInteger(r.dims[u].high)))return"dims: integer|Long[] expected"}if(r.dataType!=null&&r.hasOwnProperty("dataType")&&!o.isInteger(r.dataType))return"dataType: integer expected";if(r.segment!=null&&r.hasOwnProperty("segment")){var l=s.onnx.TensorProto.Segment.verify(r.segment);if(l)return"segment."+l}if(r.floatData!=null&&r.hasOwnProperty("floatData")){if(!Array.isArray(r.floatData))return"floatData: array expected";for(var u=0;u<r.floatData.length;++u)if(typeof r.floatData[u]!="number")return"floatData: number[] expected"}if(r.int32Data!=null&&r.hasOwnProperty("int32Data")){if(!Array.isArray(r.int32Data))return"int32Data: array expected";for(var u=0;u<r.int32Data.length;++u)if(!o.isInteger(r.int32Data[u]))return"int32Data: integer[] expected"}if(r.stringData!=null&&r.hasOwnProperty("stringData")){if(!Array.isArray(r.stringData))return"stringData: array expected";for(var u=0;u<r.stringData.length;++u)if(!(r.stringData[u]&&typeof r.stringData[u].length=="number"||o.isString(r.stringData[u])))return"stringData: buffer[] expected"}if(r.int64Data!=null&&r.hasOwnProperty("int64Data")){if(!Array.isArray(r.int64Data))return"int64Data: array expected";for(var u=0;u<r.int64Data.length;++u)if(!o.isInteger(r.int64Data[u])&&!(r.int64Data[u]&&o.isInteger(r.int64Data[u].low)&&o.isInteger(r.int64Data[u].high)))return"int64Data: integer|Long[] expected"}if(r.name!=null&&r.hasOwnProperty("name")&&!o.isString(r.name))return"name: string expected";if(r.docString!=null&&r.hasOwnProperty("docString")&&!o.isString(r.docString))return"docString: string expected";if(r.rawData!=null&&r.hasOwnProperty("rawData")&&!(r.rawData&&typeof r.rawData.length=="number"||o.isString(r.rawData)))return"rawData: buffer expected";if(r.externalData!=null&&r.hasOwnProperty("externalData")){if(!Array.isArray(r.externalData))return"externalData: array expected";for(var u=0;u<r.externalData.length;++u){var l=s.onnx.StringStringEntryProto.verify(r.externalData[u]);if(l)return"externalData."+l}}if(r.dataLocation!=null&&r.hasOwnProperty("dataLocation"))switch(r.dataLocation){default:return"dataLocation: enum value expected";case 0:case 1:break}if(r.doubleData!=null&&r.hasOwnProperty("doubleData")){if(!Array.isArray(r.doubleData))return"doubleData: array expected";for(var u=0;u<r.doubleData.length;++u)if(typeof r.doubleData[u]!="number")return"doubleData: number[] expected"}if(r.uint64Data!=null&&r.hasOwnProperty("uint64Data")){if(!Array.isArray(r.uint64Data))return"uint64Data: array expected";for(var u=0;u<r.uint64Data.length;++u)if(!o.isInteger(r.uint64Data[u])&&!(r.uint64Data[u]&&o.isInteger(r.uint64Data[u].low)&&o.isInteger(r.uint64Data[u].high)))return"uint64Data: integer|Long[] expected"}return null},h.fromObject=function(r){if(r instanceof s.onnx.TensorProto)return r;var u=new s.onnx.TensorProto;if(r.dims){if(!Array.isArray(r.dims))throw TypeError(".onnx.TensorProto.dims: array expected");u.dims=[];for(var l=0;l<r.dims.length;++l)o.Long?(u.dims[l]=o.Long.fromValue(r.dims[l])).unsigned=!1:typeof r.dims[l]=="string"?u.dims[l]=parseInt(r.dims[l],10):typeof r.dims[l]=="number"?u.dims[l]=r.dims[l]:typeof r.dims[l]=="object"&&(u.dims[l]=new o.LongBits(r.dims[l].low>>>0,r.dims[l].high>>>0).toNumber())}if(r.dataType!=null&&(u.dataType=r.dataType|0),r.segment!=null){if(typeof r.segment!="object")throw TypeError(".onnx.TensorProto.segment: object expected");u.segment=s.onnx.TensorProto.Segment.fromObject(r.segment)}if(r.floatData){if(!Array.isArray(r.floatData))throw TypeError(".onnx.TensorProto.floatData: array expected");u.floatData=[];for(var l=0;l<r.floatData.length;++l)u.floatData[l]=Number(r.floatData[l])}if(r.int32Data){if(!Array.isArray(r.int32Data))throw TypeError(".onnx.TensorProto.int32Data: array expected");u.int32Data=[];for(var l=0;l<r.int32Data.length;++l)u.int32Data[l]=r.int32Data[l]|0}if(r.stringData){if(!Array.isArray(r.stringData))throw TypeError(".onnx.TensorProto.stringData: array expected");u.stringData=[];for(var l=0;l<r.stringData.length;++l)typeof r.stringData[l]=="string"?o.base64.decode(r.stringData[l],u.stringData[l]=o.newBuffer(o.base64.length(r.stringData[l])),0):r.stringData[l].length>=0&&(u.stringData[l]=r.stringData[l])}if(r.int64Data){if(!Array.isArray(r.int64Data))throw TypeError(".onnx.TensorProto.int64Data: array expected");u.int64Data=[];for(var l=0;l<r.int64Data.length;++l)o.Long?(u.int64Data[l]=o.Long.fromValue(r.int64Data[l])).unsigned=!1:typeof r.int64Data[l]=="string"?u.int64Data[l]=parseInt(r.int64Data[l],10):typeof r.int64Data[l]=="number"?u.int64Data[l]=r.int64Data[l]:typeof r.int64Data[l]=="object"&&(u.int64Data[l]=new o.LongBits(r.int64Data[l].low>>>0,r.int64Data[l].high>>>0).toNumber())}if(r.name!=null&&(u.name=String(r.name)),r.docString!=null&&(u.docString=String(r.docString)),r.rawData!=null&&(typeof r.rawData=="string"?o.base64.decode(r.rawData,u.rawData=o.newBuffer(o.base64.length(r.rawData)),0):r.rawData.length>=0&&(u.rawData=r.rawData)),r.externalData){if(!Array.isArray(r.externalData))throw TypeError(".onnx.TensorProto.externalData: array expected");u.externalData=[];for(var l=0;l<r.externalData.length;++l){if(typeof r.externalData[l]!="object")throw TypeError(".onnx.TensorProto.externalData: object expected");u.externalData[l]=s.onnx.StringStringEntryProto.fromObject(r.externalData[l])}}switch(r.dataLocation){default:if(typeof r.dataLocation=="number"){u.dataLocation=r.dataLocation;break}break;case"DEFAULT":case 0:u.dataLocation=0;break;case"EXTERNAL":case 1:u.dataLocation=1;break}if(r.doubleData){if(!Array.isArray(r.doubleData))throw TypeError(".onnx.TensorProto.doubleData: array expected");u.doubleData=[];for(var l=0;l<r.doubleData.length;++l)u.doubleData[l]=Number(r.doubleData[l])}if(r.uint64Data){if(!Array.isArray(r.uint64Data))throw TypeError(".onnx.TensorProto.uint64Data: array expected");u.uint64Data=[];for(var l=0;l<r.uint64Data.length;++l)o.Long?(u.uint64Data[l]=o.Long.fromValue(r.uint64Data[l])).unsigned=!0:typeof r.uint64Data[l]=="string"?u.uint64Data[l]=parseInt(r.uint64Data[l],10):typeof r.uint64Data[l]=="number"?u.uint64Data[l]=r.uint64Data[l]:typeof r.uint64Data[l]=="object"&&(u.uint64Data[l]=new o.LongBits(r.uint64Data[l].low>>>0,r.uint64Data[l].high>>>0).toNumber(!0))}return u},h.toObject=function(r,u){u||(u={});var l={};if((u.arrays||u.defaults)&&(l.dims=[],l.floatData=[],l.int32Data=[],l.stringData=[],l.int64Data=[],l.doubleData=[],l.uint64Data=[],l.externalData=[]),u.defaults&&(l.dataType=0,l.segment=null,l.name="",u.bytes===String?l.rawData="":(l.rawData=[],u.bytes!==Array&&(l.rawData=o.newBuffer(l.rawData))),l.docString="",l.dataLocation=u.enums===String?"DEFAULT":0),r.dims&&r.dims.length){l.dims=[];for(var f=0;f<r.dims.length;++f)typeof r.dims[f]=="number"?l.dims[f]=u.longs===String?String(r.dims[f]):r.dims[f]:l.dims[f]=u.longs===String?o.Long.prototype.toString.call(r.dims[f]):u.longs===Number?new o.LongBits(r.dims[f].low>>>0,r.dims[f].high>>>0).toNumber():r.dims[f]}if(r.dataType!=null&&r.hasOwnProperty("dataType")&&(l.dataType=r.dataType),r.segment!=null&&r.hasOwnProperty("segment")&&(l.segment=s.onnx.TensorProto.Segment.toObject(r.segment,u)),r.floatData&&r.floatData.length){l.floatData=[];for(var f=0;f<r.floatData.length;++f)l.floatData[f]=u.json&&!isFinite(r.floatData[f])?String(r.floatData[f]):r.floatData[f]}if(r.int32Data&&r.int32Data.length){l.int32Data=[];for(var f=0;f<r.int32Data.length;++f)l.int32Data[f]=r.int32Data[f]}if(r.stringData&&r.stringData.length){l.stringData=[];for(var f=0;f<r.stringData.length;++f)l.stringData[f]=u.bytes===String?o.base64.encode(r.stringData[f],0,r.stringData[f].length):u.bytes===Array?Array.prototype.slice.call(r.stringData[f]):r.stringData[f]}if(r.int64Data&&r.int64Data.length){l.int64Data=[];for(var f=0;f<r.int64Data.length;++f)typeof r.int64Data[f]=="number"?l.int64Data[f]=u.longs===String?String(r.int64Data[f]):r.int64Data[f]:l.int64Data[f]=u.longs===String?o.Long.prototype.toString.call(r.int64Data[f]):u.longs===Number?new o.LongBits(r.int64Data[f].low>>>0,r.int64Data[f].high>>>0).toNumber():r.int64Data[f]}if(r.name!=null&&r.hasOwnProperty("name")&&(l.name=r.name),r.rawData!=null&&r.hasOwnProperty("rawData")&&(l.rawData=u.bytes===String?o.base64.encode(r.rawData,0,r.rawData.length):u.bytes===Array?Array.prototype.slice.call(r.rawData):r.rawData),r.doubleData&&r.doubleData.length){l.doubleData=[];for(var f=0;f<r.doubleData.length;++f)l.doubleData[f]=u.json&&!isFinite(r.doubleData[f])?String(r.doubleData[f]):r.doubleData[f]}if(r.uint64Data&&r.uint64Data.length){l.uint64Data=[];for(var f=0;f<r.uint64Data.length;++f)typeof r.uint64Data[f]=="number"?l.uint64Data[f]=u.longs===String?String(r.uint64Data[f]):r.uint64Data[f]:l.uint64Data[f]=u.longs===String?o.Long.prototype.toString.call(r.uint64Data[f]):u.longs===Number?new o.LongBits(r.uint64Data[f].low>>>0,r.uint64Data[f].high>>>0).toNumber(!0):r.uint64Data[f]}if(r.docString!=null&&r.hasOwnProperty("docString")&&(l.docString=r.docString),r.externalData&&r.externalData.length){l.externalData=[];for(var f=0;f<r.externalData.length;++f)l.externalData[f]=s.onnx.StringStringEntryProto.toObject(r.externalData[f],u)}return r.dataLocation!=null&&r.hasOwnProperty("dataLocation")&&(l.dataLocation=u.enums===String?s.onnx.TensorProto.DataLocation[r.dataLocation]===void 0?r.dataLocation:s.onnx.TensorProto.DataLocation[r.dataLocation]:r.dataLocation),l},h.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},h.getTypeUrl=function(r){return r===void 0&&(r="type.googleapis.com"),r+"/onnx.TensorProto"},h.DataType=function(){var r={},u=Object.create(r);return u[r[0]="UNDEFINED"]=0,u[r[1]="FLOAT"]=1,u[r[2]="UINT8"]=2,u[r[3]="INT8"]=3,u[r[4]="UINT16"]=4,u[r[5]="INT16"]=5,u[r[6]="INT32"]=6,u[r[7]="INT64"]=7,u[r[8]="STRING"]=8,u[r[9]="BOOL"]=9,u[r[10]="FLOAT16"]=10,u[r[11]="DOUBLE"]=11,u[r[12]="UINT32"]=12,u[r[13]="UINT64"]=13,u[r[14]="COMPLEX64"]=14,u[r[15]="COMPLEX128"]=15,u[r[16]="BFLOAT16"]=16,u[r[17]="FLOAT8E4M3FN"]=17,u[r[18]="FLOAT8E4M3FNUZ"]=18,u[r[19]="FLOAT8E5M2"]=19,u[r[20]="FLOAT8E5M2FNUZ"]=20,u}(),h.Segment=function(){function r(u){if(u)for(var l=Object.keys(u),f=0;f<l.length;++f)u[l[f]]!=null&&(this[l[f]]=u[l[f]])}return r.prototype.begin=o.Long?o.Long.fromBits(0,0,!1):0,r.prototype.end=o.Long?o.Long.fromBits(0,0,!1):0,r.create=function(u){return new r(u)},r.encode=function(u,l){return l||(l=p.create()),u.begin!=null&&Object.hasOwnProperty.call(u,"begin")&&l.uint32(8).int64(u.begin),u.end!=null&&Object.hasOwnProperty.call(u,"end")&&l.uint32(16).int64(u.end),l},r.encodeDelimited=function(u,l){return this.encode(u,l).ldelim()},r.decode=function(u,l){u instanceof i||(u=i.create(u));for(var f=l===void 0?u.len:u.pos+l,g=new s.onnx.TensorProto.Segment;u.pos<f;){var b=u.uint32();switch(b>>>3){case 1:{g.begin=u.int64();break}case 2:{g.end=u.int64();break}default:u.skipType(b&7);break}}return g},r.decodeDelimited=function(u){return u instanceof i||(u=new i(u)),this.decode(u,u.uint32())},r.verify=function(u){return typeof u!="object"||u===null?"object expected":u.begin!=null&&u.hasOwnProperty("begin")&&!o.isInteger(u.begin)&&!(u.begin&&o.isInteger(u.begin.low)&&o.isInteger(u.begin.high))?"begin: integer|Long expected":u.end!=null&&u.hasOwnProperty("end")&&!o.isInteger(u.end)&&!(u.end&&o.isInteger(u.end.low)&&o.isInteger(u.end.high))?"end: integer|Long expected":null},r.fromObject=function(u){if(u instanceof s.onnx.TensorProto.Segment)return u;var l=new s.onnx.TensorProto.Segment;return u.begin!=null&&(o.Long?(l.begin=o.Long.fromValue(u.begin)).unsigned=!1:typeof u.begin=="string"?l.begin=parseInt(u.begin,10):typeof u.begin=="number"?l.begin=u.begin:typeof u.begin=="object"&&(l.begin=new o.LongBits(u.begin.low>>>0,u.begin.high>>>0).toNumber())),u.end!=null&&(o.Long?(l.end=o.Long.fromValue(u.end)).unsigned=!1:typeof u.end=="string"?l.end=parseInt(u.end,10):typeof u.end=="number"?l.end=u.end:typeof u.end=="object"&&(l.end=new o.LongBits(u.end.low>>>0,u.end.high>>>0).toNumber())),l},r.toObject=function(u,l){l||(l={});var f={};if(l.defaults){if(o.Long){var g=new o.Long(0,0,!1);f.begin=l.longs===String?g.toString():l.longs===Number?g.toNumber():g}else f.begin=l.longs===String?"0":0;if(o.Long){var g=new o.Long(0,0,!1);f.end=l.longs===String?g.toString():l.longs===Number?g.toNumber():g}else f.end=l.longs===String?"0":0}return u.begin!=null&&u.hasOwnProperty("begin")&&(typeof u.begin=="number"?f.begin=l.longs===String?String(u.begin):u.begin:f.begin=l.longs===String?o.Long.prototype.toString.call(u.begin):l.longs===Number?new o.LongBits(u.begin.low>>>0,u.begin.high>>>0).toNumber():u.begin),u.end!=null&&u.hasOwnProperty("end")&&(typeof u.end=="number"?f.end=l.longs===String?String(u.end):u.end:f.end=l.longs===String?o.Long.prototype.toString.call(u.end):l.longs===Number?new o.LongBits(u.end.low>>>0,u.end.high>>>0).toNumber():u.end),f},r.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},r.getTypeUrl=function(u){return u===void 0&&(u="type.googleapis.com"),u+"/onnx.TensorProto.Segment"},r}(),h.DataLocation=function(){var r={},u=Object.create(r);return u[r[0]="DEFAULT"]=0,u[r[1]="EXTERNAL"]=1,u}(),h}(),c.SparseTensorProto=function(){function h(r){if(this.dims=[],r)for(var u=Object.keys(r),l=0;l<u.length;++l)r[u[l]]!=null&&(this[u[l]]=r[u[l]])}return h.prototype.values=null,h.prototype.indices=null,h.prototype.dims=o.emptyArray,h.create=function(r){return new h(r)},h.encode=function(r,u){if(u||(u=p.create()),r.values!=null&&Object.hasOwnProperty.call(r,"values")&&s.onnx.TensorProto.encode(r.values,u.uint32(10).fork()).ldelim(),r.indices!=null&&Object.hasOwnProperty.call(r,"indices")&&s.onnx.TensorProto.encode(r.indices,u.uint32(18).fork()).ldelim(),r.dims!=null&&r.dims.length){u.uint32(26).fork();for(var l=0;l<r.dims.length;++l)u.int64(r.dims[l]);u.ldelim()}return u},h.encodeDelimited=function(r,u){return this.encode(r,u).ldelim()},h.decode=function(r,u){r instanceof i||(r=i.create(r));for(var l=u===void 0?r.len:r.pos+u,f=new s.onnx.SparseTensorProto;r.pos<l;){var g=r.uint32();switch(g>>>3){case 1:{f.values=s.onnx.TensorProto.decode(r,r.uint32());break}case 2:{f.indices=s.onnx.TensorProto.decode(r,r.uint32());break}case 3:{if(f.dims&&f.dims.length||(f.dims=[]),(g&7)===2)for(var b=r.uint32()+r.pos;r.pos<b;)f.dims.push(r.int64());else f.dims.push(r.int64());break}default:r.skipType(g&7);break}}return f},h.decodeDelimited=function(r){return r instanceof i||(r=new i(r)),this.decode(r,r.uint32())},h.verify=function(r){if(typeof r!="object"||r===null)return"object expected";if(r.values!=null&&r.hasOwnProperty("values")){var u=s.onnx.TensorProto.verify(r.values);if(u)return"values."+u}if(r.indices!=null&&r.hasOwnProperty("indices")){var u=s.onnx.TensorProto.verify(r.indices);if(u)return"indices."+u}if(r.dims!=null&&r.hasOwnProperty("dims")){if(!Array.isArray(r.dims))return"dims: array expected";for(var l=0;l<r.dims.length;++l)if(!o.isInteger(r.dims[l])&&!(r.dims[l]&&o.isInteger(r.dims[l].low)&&o.isInteger(r.dims[l].high)))return"dims: integer|Long[] expected"}return null},h.fromObject=function(r){if(r instanceof s.onnx.SparseTensorProto)return r;var u=new s.onnx.SparseTensorProto;if(r.values!=null){if(typeof r.values!="object")throw TypeError(".onnx.SparseTensorProto.values: object expected");u.values=s.onnx.TensorProto.fromObject(r.values)}if(r.indices!=null){if(typeof r.indices!="object")throw TypeError(".onnx.SparseTensorProto.indices: object expected");u.indices=s.onnx.TensorProto.fromObject(r.indices)}if(r.dims){if(!Array.isArray(r.dims))throw TypeError(".onnx.SparseTensorProto.dims: array expected");u.dims=[];for(var l=0;l<r.dims.length;++l)o.Long?(u.dims[l]=o.Long.fromValue(r.dims[l])).unsigned=!1:typeof r.dims[l]=="string"?u.dims[l]=parseInt(r.dims[l],10):typeof r.dims[l]=="number"?u.dims[l]=r.dims[l]:typeof r.dims[l]=="object"&&(u.dims[l]=new o.LongBits(r.dims[l].low>>>0,r.dims[l].high>>>0).toNumber())}return u},h.toObject=function(r,u){u||(u={});var l={};if((u.arrays||u.defaults)&&(l.dims=[]),u.defaults&&(l.values=null,l.indices=null),r.values!=null&&r.hasOwnProperty("values")&&(l.values=s.onnx.TensorProto.toObject(r.values,u)),r.indices!=null&&r.hasOwnProperty("indices")&&(l.indices=s.onnx.TensorProto.toObject(r.indices,u)),r.dims&&r.dims.length){l.dims=[];for(var f=0;f<r.dims.length;++f)typeof r.dims[f]=="number"?l.dims[f]=u.longs===String?String(r.dims[f]):r.dims[f]:l.dims[f]=u.longs===String?o.Long.prototype.toString.call(r.dims[f]):u.longs===Number?new o.LongBits(r.dims[f].low>>>0,r.dims[f].high>>>0).toNumber():r.dims[f]}return l},h.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},h.getTypeUrl=function(r){return r===void 0&&(r="type.googleapis.com"),r+"/onnx.SparseTensorProto"},h}(),c.TensorShapeProto=function(){function h(r){if(this.dim=[],r)for(var u=Object.keys(r),l=0;l<u.length;++l)r[u[l]]!=null&&(this[u[l]]=r[u[l]])}return h.prototype.dim=o.emptyArray,h.create=function(r){return new h(r)},h.encode=function(r,u){if(u||(u=p.create()),r.dim!=null&&r.dim.length)for(var l=0;l<r.dim.length;++l)s.onnx.TensorShapeProto.Dimension.encode(r.dim[l],u.uint32(10).fork()).ldelim();return u},h.encodeDelimited=function(r,u){return this.encode(r,u).ldelim()},h.decode=function(r,u){r instanceof i||(r=i.create(r));for(var l=u===void 0?r.len:r.pos+u,f=new s.onnx.TensorShapeProto;r.pos<l;){var g=r.uint32();switch(g>>>3){case 1:{f.dim&&f.dim.length||(f.dim=[]),f.dim.push(s.onnx.TensorShapeProto.Dimension.decode(r,r.uint32()));break}default:r.skipType(g&7);break}}return f},h.decodeDelimited=function(r){return r instanceof i||(r=new i(r)),this.decode(r,r.uint32())},h.verify=function(r){if(typeof r!="object"||r===null)return"object expected";if(r.dim!=null&&r.hasOwnProperty("dim")){if(!Array.isArray(r.dim))return"dim: array expected";for(var u=0;u<r.dim.length;++u){var l=s.onnx.TensorShapeProto.Dimension.verify(r.dim[u]);if(l)return"dim."+l}}return null},h.fromObject=function(r){if(r instanceof s.onnx.TensorShapeProto)return r;var u=new s.onnx.TensorShapeProto;if(r.dim){if(!Array.isArray(r.dim))throw TypeError(".onnx.TensorShapeProto.dim: array expected");u.dim=[];for(var l=0;l<r.dim.length;++l){if(typeof r.dim[l]!="object")throw TypeError(".onnx.TensorShapeProto.dim: object expected");u.dim[l]=s.onnx.TensorShapeProto.Dimension.fromObject(r.dim[l])}}return u},h.toObject=function(r,u){u||(u={});var l={};if((u.arrays||u.defaults)&&(l.dim=[]),r.dim&&r.dim.length){l.dim=[];for(var f=0;f<r.dim.length;++f)l.dim[f]=s.onnx.TensorShapeProto.Dimension.toObject(r.dim[f],u)}return l},h.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},h.getTypeUrl=function(r){return r===void 0&&(r="type.googleapis.com"),r+"/onnx.TensorShapeProto"},h.Dimension=function(){function r(l){if(l)for(var f=Object.keys(l),g=0;g<f.length;++g)l[f[g]]!=null&&(this[f[g]]=l[f[g]])}r.prototype.dimValue=null,r.prototype.dimParam=null,r.prototype.denotation="";var u;return Object.defineProperty(r.prototype,"value",{get:o.oneOfGetter(u=["dimValue","dimParam"]),set:o.oneOfSetter(u)}),r.create=function(l){return new r(l)},r.encode=function(l,f){return f||(f=p.create()),l.dimValue!=null&&Object.hasOwnProperty.call(l,"dimValue")&&f.uint32(8).int64(l.dimValue),l.dimParam!=null&&Object.hasOwnProperty.call(l,"dimParam")&&f.uint32(18).string(l.dimParam),l.denotation!=null&&Object.hasOwnProperty.call(l,"denotation")&&f.uint32(26).string(l.denotation),f},r.encodeDelimited=function(l,f){return this.encode(l,f).ldelim()},r.decode=function(l,f){l instanceof i||(l=i.create(l));for(var g=f===void 0?l.len:l.pos+f,b=new s.onnx.TensorShapeProto.Dimension;l.pos<g;){var v=l.uint32();switch(v>>>3){case 1:{b.dimValue=l.int64();break}case 2:{b.dimParam=l.string();break}case 3:{b.denotation=l.string();break}default:l.skipType(v&7);break}}return b},r.decodeDelimited=function(l){return l instanceof i||(l=new i(l)),this.decode(l,l.uint32())},r.verify=function(l){if(typeof l!="object"||l===null)return"object expected";var f={};if(l.dimValue!=null&&l.hasOwnProperty("dimValue")&&(f.value=1,!o.isInteger(l.dimValue)&&!(l.dimValue&&o.isInteger(l.dimValue.low)&&o.isInteger(l.dimValue.high))))return"dimValue: integer|Long expected";if(l.dimParam!=null&&l.hasOwnProperty("dimParam")){if(f.value===1)return"value: multiple values";if(f.value=1,!o.isString(l.dimParam))return"dimParam: string expected"}return l.denotation!=null&&l.hasOwnProperty("denotation")&&!o.isString(l.denotation)?"denotation: string expected":null},r.fromObject=function(l){if(l instanceof s.onnx.TensorShapeProto.Dimension)return l;var f=new s.onnx.TensorShapeProto.Dimension;return l.dimValue!=null&&(o.Long?(f.dimValue=o.Long.fromValue(l.dimValue)).unsigned=!1:typeof l.dimValue=="string"?f.dimValue=parseInt(l.dimValue,10):typeof l.dimValue=="number"?f.dimValue=l.dimValue:typeof l.dimValue=="object"&&(f.dimValue=new o.LongBits(l.dimValue.low>>>0,l.dimValue.high>>>0).toNumber())),l.dimParam!=null&&(f.dimParam=String(l.dimParam)),l.denotation!=null&&(f.denotation=String(l.denotation)),f},r.toObject=function(l,f){f||(f={});var g={};return f.defaults&&(g.denotation=""),l.dimValue!=null&&l.hasOwnProperty("dimValue")&&(typeof l.dimValue=="number"?g.dimValue=f.longs===String?String(l.dimValue):l.dimValue:g.dimValue=f.longs===String?o.Long.prototype.toString.call(l.dimValue):f.longs===Number?new o.LongBits(l.dimValue.low>>>0,l.dimValue.high>>>0).toNumber():l.dimValue,f.oneofs&&(g.value="dimValue")),l.dimParam!=null&&l.hasOwnProperty("dimParam")&&(g.dimParam=l.dimParam,f.oneofs&&(g.value="dimParam")),l.denotation!=null&&l.hasOwnProperty("denotation")&&(g.denotation=l.denotation),g},r.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},r.getTypeUrl=function(l){return l===void 0&&(l="type.googleapis.com"),l+"/onnx.TensorShapeProto.Dimension"},r}(),h}(),c.TypeProto=function(){function h(u){if(u)for(var l=Object.keys(u),f=0;f<l.length;++f)u[l[f]]!=null&&(this[l[f]]=u[l[f]])}h.prototype.tensorType=null,h.prototype.sequenceType=null,h.prototype.mapType=null,h.prototype.optionalType=null,h.prototype.sparseTensorType=null,h.prototype.denotation="";var r;return Object.defineProperty(h.prototype,"value",{get:o.oneOfGetter(r=["tensorType","sequenceType","mapType","optionalType","sparseTensorType"]),set:o.oneOfSetter(r)}),h.create=function(u){return new h(u)},h.encode=function(u,l){return l||(l=p.create()),u.tensorType!=null&&Object.hasOwnProperty.call(u,"tensorType")&&s.onnx.TypeProto.Tensor.encode(u.tensorType,l.uint32(10).fork()).ldelim(),u.sequenceType!=null&&Object.hasOwnProperty.call(u,"sequenceType")&&s.onnx.TypeProto.Sequence.encode(u.sequenceType,l.uint32(34).fork()).ldelim(),u.mapType!=null&&Object.hasOwnProperty.call(u,"mapType")&&s.onnx.TypeProto.Map.encode(u.mapType,l.uint32(42).fork()).ldelim(),u.denotation!=null&&Object.hasOwnProperty.call(u,"denotation")&&l.uint32(50).string(u.denotation),u.sparseTensorType!=null&&Object.hasOwnProperty.call(u,"sparseTensorType")&&s.onnx.TypeProto.SparseTensor.encode(u.sparseTensorType,l.uint32(66).fork()).ldelim(),u.optionalType!=null&&Object.hasOwnProperty.call(u,"optionalType")&&s.onnx.TypeProto.Optional.encode(u.optionalType,l.uint32(74).fork()).ldelim(),l},h.encodeDelimited=function(u,l){return this.encode(u,l).ldelim()},h.decode=function(u,l){u instanceof i||(u=i.create(u));for(var f=l===void 0?u.len:u.pos+l,g=new s.onnx.TypeProto;u.pos<f;){var b=u.uint32();switch(b>>>3){case 1:{g.tensorType=s.onnx.TypeProto.Tensor.decode(u,u.uint32());break}case 4:{g.sequenceType=s.onnx.TypeProto.Sequence.decode(u,u.uint32());break}case 5:{g.mapType=s.onnx.TypeProto.Map.decode(u,u.uint32());break}case 9:{g.optionalType=s.onnx.TypeProto.Optional.decode(u,u.uint32());break}case 8:{g.sparseTensorType=s.onnx.TypeProto.SparseTensor.decode(u,u.uint32());break}case 6:{g.denotation=u.string();break}default:u.skipType(b&7);break}}return g},h.decodeDelimited=function(u){return u instanceof i||(u=new i(u)),this.decode(u,u.uint32())},h.verify=function(u){if(typeof u!="object"||u===null)return"object expected";var l={};if(u.tensorType!=null&&u.hasOwnProperty("tensorType")){l.value=1;{var f=s.onnx.TypeProto.Tensor.verify(u.tensorType);if(f)return"tensorType."+f}}if(u.sequenceType!=null&&u.hasOwnProperty("sequenceType")){if(l.value===1)return"value: multiple values";l.value=1;{var f=s.onnx.TypeProto.Sequence.verify(u.sequenceType);if(f)return"sequenceType."+f}}if(u.mapType!=null&&u.hasOwnProperty("mapType")){if(l.value===1)return"value: multiple values";l.value=1;{var f=s.onnx.TypeProto.Map.verify(u.mapType);if(f)return"mapType."+f}}if(u.optionalType!=null&&u.hasOwnProperty("optionalType")){if(l.value===1)return"value: multiple values";l.value=1;{var f=s.onnx.TypeProto.Optional.verify(u.optionalType);if(f)return"optionalType."+f}}if(u.sparseTensorType!=null&&u.hasOwnProperty("sparseTensorType")){if(l.value===1)return"value: multiple values";l.value=1;{var f=s.onnx.TypeProto.SparseTensor.verify(u.sparseTensorType);if(f)return"sparseTensorType."+f}}return u.denotation!=null&&u.hasOwnProperty("denotation")&&!o.isString(u.denotation)?"denotation: string expected":null},h.fromObject=function(u){if(u instanceof s.onnx.TypeProto)return u;var l=new s.onnx.TypeProto;if(u.tensorType!=null){if(typeof u.tensorType!="object")throw TypeError(".onnx.TypeProto.tensorType: object expected");l.tensorType=s.onnx.TypeProto.Tensor.fromObject(u.tensorType)}if(u.sequenceType!=null){if(typeof u.sequenceType!="object")throw TypeError(".onnx.TypeProto.sequenceType: object expected");l.sequenceType=s.onnx.TypeProto.Sequence.fromObject(u.sequenceType)}if(u.mapType!=null){if(typeof u.mapType!="object")throw TypeError(".onnx.TypeProto.mapType: object expected");l.mapType=s.onnx.TypeProto.Map.fromObject(u.mapType)}if(u.optionalType!=null){if(typeof u.optionalType!="object")throw TypeError(".onnx.TypeProto.optionalType: object expected");l.optionalType=s.onnx.TypeProto.Optional.fromObject(u.optionalType)}if(u.sparseTensorType!=null){if(typeof u.sparseTensorType!="object")throw TypeError(".onnx.TypeProto.sparseTensorType: object expected");l.sparseTensorType=s.onnx.TypeProto.SparseTensor.fromObject(u.sparseTensorType)}return u.denotation!=null&&(l.denotation=String(u.denotation)),l},h.toObject=function(u,l){l||(l={});var f={};return l.defaults&&(f.denotation=""),u.tensorType!=null&&u.hasOwnProperty("tensorType")&&(f.tensorType=s.onnx.TypeProto.Tensor.toObject(u.tensorType,l),l.oneofs&&(f.value="tensorType")),u.sequenceType!=null&&u.hasOwnProperty("sequenceType")&&(f.sequenceType=s.onnx.TypeProto.Sequence.toObject(u.sequenceType,l),l.oneofs&&(f.value="sequenceType")),u.mapType!=null&&u.hasOwnProperty("mapType")&&(f.mapType=s.onnx.TypeProto.Map.toObject(u.mapType,l),l.oneofs&&(f.value="mapType")),u.denotation!=null&&u.hasOwnProperty("denotation")&&(f.denotation=u.denotation),u.sparseTensorType!=null&&u.hasOwnProperty("sparseTensorType")&&(f.sparseTensorType=s.onnx.TypeProto.SparseTensor.toObject(u.sparseTensorType,l),l.oneofs&&(f.value="sparseTensorType")),u.optionalType!=null&&u.hasOwnProperty("optionalType")&&(f.optionalType=s.onnx.TypeProto.Optional.toObject(u.optionalType,l),l.oneofs&&(f.value="optionalType")),f},h.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},h.getTypeUrl=function(u){return u===void 0&&(u="type.googleapis.com"),u+"/onnx.TypeProto"},h.Tensor=function(){function u(l){if(l)for(var f=Object.keys(l),g=0;g<f.length;++g)l[f[g]]!=null&&(this[f[g]]=l[f[g]])}return u.prototype.elemType=0,u.prototype.shape=null,u.create=function(l){return new u(l)},u.encode=function(l,f){return f||(f=p.create()),l.elemType!=null&&Object.hasOwnProperty.call(l,"elemType")&&f.uint32(8).int32(l.elemType),l.shape!=null&&Object.hasOwnProperty.call(l,"shape")&&s.onnx.TensorShapeProto.encode(l.shape,f.uint32(18).fork()).ldelim(),f},u.encodeDelimited=function(l,f){return this.encode(l,f).ldelim()},u.decode=function(l,f){l instanceof i||(l=i.create(l));for(var g=f===void 0?l.len:l.pos+f,b=new s.onnx.TypeProto.Tensor;l.pos<g;){var v=l.uint32();switch(v>>>3){case 1:{b.elemType=l.int32();break}case 2:{b.shape=s.onnx.TensorShapeProto.decode(l,l.uint32());break}default:l.skipType(v&7);break}}return b},u.decodeDelimited=function(l){return l instanceof i||(l=new i(l)),this.decode(l,l.uint32())},u.verify=function(l){if(typeof l!="object"||l===null)return"object expected";if(l.elemType!=null&&l.hasOwnProperty("elemType")&&!o.isInteger(l.elemType))return"elemType: integer expected";if(l.shape!=null&&l.hasOwnProperty("shape")){var f=s.onnx.TensorShapeProto.verify(l.shape);if(f)return"shape."+f}return null},u.fromObject=function(l){if(l instanceof s.onnx.TypeProto.Tensor)return l;var f=new s.onnx.TypeProto.Tensor;if(l.elemType!=null&&(f.elemType=l.elemType|0),l.shape!=null){if(typeof l.shape!="object")throw TypeError(".onnx.TypeProto.Tensor.shape: object expected");f.shape=s.onnx.TensorShapeProto.fromObject(l.shape)}return f},u.toObject=function(l,f){f||(f={});var g={};return f.defaults&&(g.elemType=0,g.shape=null),l.elemType!=null&&l.hasOwnProperty("elemType")&&(g.elemType=l.elemType),l.shape!=null&&l.hasOwnProperty("shape")&&(g.shape=s.onnx.TensorShapeProto.toObject(l.shape,f)),g},u.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},u.getTypeUrl=function(l){return l===void 0&&(l="type.googleapis.com"),l+"/onnx.TypeProto.Tensor"},u}(),h.Sequence=function(){function u(l){if(l)for(var f=Object.keys(l),g=0;g<f.length;++g)l[f[g]]!=null&&(this[f[g]]=l[f[g]])}return u.prototype.elemType=null,u.create=function(l){return new u(l)},u.encode=function(l,f){return f||(f=p.create()),l.elemType!=null&&Object.hasOwnProperty.call(l,"elemType")&&s.onnx.TypeProto.encode(l.elemType,f.uint32(10).fork()).ldelim(),f},u.encodeDelimited=function(l,f){return this.encode(l,f).ldelim()},u.decode=function(l,f){l instanceof i||(l=i.create(l));for(var g=f===void 0?l.len:l.pos+f,b=new s.onnx.TypeProto.Sequence;l.pos<g;){var v=l.uint32();switch(v>>>3){case 1:{b.elemType=s.onnx.TypeProto.decode(l,l.uint32());break}default:l.skipType(v&7);break}}return b},u.decodeDelimited=function(l){return l instanceof i||(l=new i(l)),this.decode(l,l.uint32())},u.verify=function(l){if(typeof l!="object"||l===null)return"object expected";if(l.elemType!=null&&l.hasOwnProperty("elemType")){var f=s.onnx.TypeProto.verify(l.elemType);if(f)return"elemType."+f}return null},u.fromObject=function(l){if(l instanceof s.onnx.TypeProto.Sequence)return l;var f=new s.onnx.TypeProto.Sequence;if(l.elemType!=null){if(typeof l.elemType!="object")throw TypeError(".onnx.TypeProto.Sequence.elemType: object expected");f.elemType=s.onnx.TypeProto.fromObject(l.elemType)}return f},u.toObject=function(l,f){f||(f={});var g={};return f.defaults&&(g.elemType=null),l.elemType!=null&&l.hasOwnProperty("elemType")&&(g.elemType=s.onnx.TypeProto.toObject(l.elemType,f)),g},u.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},u.getTypeUrl=function(l){return l===void 0&&(l="type.googleapis.com"),l+"/onnx.TypeProto.Sequence"},u}(),h.Map=function(){function u(l){if(l)for(var f=Object.keys(l),g=0;g<f.length;++g)l[f[g]]!=null&&(this[f[g]]=l[f[g]])}return u.prototype.keyType=0,u.prototype.valueType=null,u.create=function(l){return new u(l)},u.encode=function(l,f){return f||(f=p.create()),l.keyType!=null&&Object.hasOwnProperty.call(l,"keyType")&&f.uint32(8).int32(l.keyType),l.valueType!=null&&Object.hasOwnProperty.call(l,"valueType")&&s.onnx.TypeProto.encode(l.valueType,f.uint32(18).fork()).ldelim(),f},u.encodeDelimited=function(l,f){return this.encode(l,f).ldelim()},u.decode=function(l,f){l instanceof i||(l=i.create(l));for(var g=f===void 0?l.len:l.pos+f,b=new s.onnx.TypeProto.Map;l.pos<g;){var v=l.uint32();switch(v>>>3){case 1:{b.keyType=l.int32();break}case 2:{b.valueType=s.onnx.TypeProto.decode(l,l.uint32());break}default:l.skipType(v&7);break}}return b},u.decodeDelimited=function(l){return l instanceof i||(l=new i(l)),this.decode(l,l.uint32())},u.verify=function(l){if(typeof l!="object"||l===null)return"object expected";if(l.keyType!=null&&l.hasOwnProperty("keyType")&&!o.isInteger(l.keyType))return"keyType: integer expected";if(l.valueType!=null&&l.hasOwnProperty("valueType")){var f=s.onnx.TypeProto.verify(l.valueType);if(f)return"valueType."+f}return null},u.fromObject=function(l){if(l instanceof s.onnx.TypeProto.Map)return l;var f=new s.onnx.TypeProto.Map;if(l.keyType!=null&&(f.keyType=l.keyType|0),l.valueType!=null){if(typeof l.valueType!="object")throw TypeError(".onnx.TypeProto.Map.valueType: object expected");f.valueType=s.onnx.TypeProto.fromObject(l.valueType)}return f},u.toObject=function(l,f){f||(f={});var g={};return f.defaults&&(g.keyType=0,g.valueType=null),l.keyType!=null&&l.hasOwnProperty("keyType")&&(g.keyType=l.keyType),l.valueType!=null&&l.hasOwnProperty("valueType")&&(g.valueType=s.onnx.TypeProto.toObject(l.valueType,f)),g},u.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},u.getTypeUrl=function(l){return l===void 0&&(l="type.googleapis.com"),l+"/onnx.TypeProto.Map"},u}(),h.Optional=function(){function u(l){if(l)for(var f=Object.keys(l),g=0;g<f.length;++g)l[f[g]]!=null&&(this[f[g]]=l[f[g]])}return u.prototype.elemType=null,u.create=function(l){return new u(l)},u.encode=function(l,f){return f||(f=p.create()),l.elemType!=null&&Object.hasOwnProperty.call(l,"elemType")&&s.onnx.TypeProto.encode(l.elemType,f.uint32(10).fork()).ldelim(),f},u.encodeDelimited=function(l,f){return this.encode(l,f).ldelim()},u.decode=function(l,f){l instanceof i||(l=i.create(l));for(var g=f===void 0?l.len:l.pos+f,b=new s.onnx.TypeProto.Optional;l.pos<g;){var v=l.uint32();switch(v>>>3){case 1:{b.elemType=s.onnx.TypeProto.decode(l,l.uint32());break}default:l.skipType(v&7);break}}return b},u.decodeDelimited=function(l){return l instanceof i||(l=new i(l)),this.decode(l,l.uint32())},u.verify=function(l){if(typeof l!="object"||l===null)return"object expected";if(l.elemType!=null&&l.hasOwnProperty("elemType")){var f=s.onnx.TypeProto.verify(l.elemType);if(f)return"elemType."+f}return null},u.fromObject=function(l){if(l instanceof s.onnx.TypeProto.Optional)return l;var f=new s.onnx.TypeProto.Optional;if(l.elemType!=null){if(typeof l.elemType!="object")throw TypeError(".onnx.TypeProto.Optional.elemType: object expected");f.elemType=s.onnx.TypeProto.fromObject(l.elemType)}return f},u.toObject=function(l,f){f||(f={});var g={};return f.defaults&&(g.elemType=null),l.elemType!=null&&l.hasOwnProperty("elemType")&&(g.elemType=s.onnx.TypeProto.toObject(l.elemType,f)),g},u.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},u.getTypeUrl=function(l){return l===void 0&&(l="type.googleapis.com"),l+"/onnx.TypeProto.Optional"},u}(),h.SparseTensor=function(){function u(l){if(l)for(var f=Object.keys(l),g=0;g<f.length;++g)l[f[g]]!=null&&(this[f[g]]=l[f[g]])}return u.prototype.elemType=0,u.prototype.shape=null,u.create=function(l){return new u(l)},u.encode=function(l,f){return f||(f=p.create()),l.elemType!=null&&Object.hasOwnProperty.call(l,"elemType")&&f.uint32(8).int32(l.elemType),l.shape!=null&&Object.hasOwnProperty.call(l,"shape")&&s.onnx.TensorShapeProto.encode(l.shape,f.uint32(18).fork()).ldelim(),f},u.encodeDelimited=function(l,f){return this.encode(l,f).ldelim()},u.decode=function(l,f){l instanceof i||(l=i.create(l));for(var g=f===void 0?l.len:l.pos+f,b=new s.onnx.TypeProto.SparseTensor;l.pos<g;){var v=l.uint32();switch(v>>>3){case 1:{b.elemType=l.int32();break}case 2:{b.shape=s.onnx.TensorShapeProto.decode(l,l.uint32());break}default:l.skipType(v&7);break}}return b},u.decodeDelimited=function(l){return l instanceof i||(l=new i(l)),this.decode(l,l.uint32())},u.verify=function(l){if(typeof l!="object"||l===null)return"object expected";if(l.elemType!=null&&l.hasOwnProperty("elemType")&&!o.isInteger(l.elemType))return"elemType: integer expected";if(l.shape!=null&&l.hasOwnProperty("shape")){var f=s.onnx.TensorShapeProto.verify(l.shape);if(f)return"shape."+f}return null},u.fromObject=function(l){if(l instanceof s.onnx.TypeProto.SparseTensor)return l;var f=new s.onnx.TypeProto.SparseTensor;if(l.elemType!=null&&(f.elemType=l.elemType|0),l.shape!=null){if(typeof l.shape!="object")throw TypeError(".onnx.TypeProto.SparseTensor.shape: object expected");f.shape=s.onnx.TensorShapeProto.fromObject(l.shape)}return f},u.toObject=function(l,f){f||(f={});var g={};return f.defaults&&(g.elemType=0,g.shape=null),l.elemType!=null&&l.hasOwnProperty("elemType")&&(g.elemType=l.elemType),l.shape!=null&&l.hasOwnProperty("shape")&&(g.shape=s.onnx.TensorShapeProto.toObject(l.shape,f)),g},u.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},u.getTypeUrl=function(l){return l===void 0&&(l="type.googleapis.com"),l+"/onnx.TypeProto.SparseTensor"},u}(),h}(),c.OperatorSetIdProto=function(){function h(r){if(r)for(var u=Object.keys(r),l=0;l<u.length;++l)r[u[l]]!=null&&(this[u[l]]=r[u[l]])}return h.prototype.domain="",h.prototype.version=o.Long?o.Long.fromBits(0,0,!1):0,h.create=function(r){return new h(r)},h.encode=function(r,u){return u||(u=p.create()),r.domain!=null&&Object.hasOwnProperty.call(r,"domain")&&u.uint32(10).string(r.domain),r.version!=null&&Object.hasOwnProperty.call(r,"version")&&u.uint32(16).int64(r.version),u},h.encodeDelimited=function(r,u){return this.encode(r,u).ldelim()},h.decode=function(r,u){r instanceof i||(r=i.create(r));for(var l=u===void 0?r.len:r.pos+u,f=new s.onnx.OperatorSetIdProto;r.pos<l;){var g=r.uint32();switch(g>>>3){case 1:{f.domain=r.string();break}case 2:{f.version=r.int64();break}default:r.skipType(g&7);break}}return f},h.decodeDelimited=function(r){return r instanceof i||(r=new i(r)),this.decode(r,r.uint32())},h.verify=function(r){return typeof r!="object"||r===null?"object expected":r.domain!=null&&r.hasOwnProperty("domain")&&!o.isString(r.domain)?"domain: string expected":r.version!=null&&r.hasOwnProperty("version")&&!o.isInteger(r.version)&&!(r.version&&o.isInteger(r.version.low)&&o.isInteger(r.version.high))?"version: integer|Long expected":null},h.fromObject=function(r){if(r instanceof s.onnx.OperatorSetIdProto)return r;var u=new s.onnx.OperatorSetIdProto;return r.domain!=null&&(u.domain=String(r.domain)),r.version!=null&&(o.Long?(u.version=o.Long.fromValue(r.version)).unsigned=!1:typeof r.version=="string"?u.version=parseInt(r.version,10):typeof r.version=="number"?u.version=r.version:typeof r.version=="object"&&(u.version=new o.LongBits(r.version.low>>>0,r.version.high>>>0).toNumber())),u},h.toObject=function(r,u){u||(u={});var l={};if(u.defaults)if(l.domain="",o.Long){var f=new o.Long(0,0,!1);l.version=u.longs===String?f.toString():u.longs===Number?f.toNumber():f}else l.version=u.longs===String?"0":0;return r.domain!=null&&r.hasOwnProperty("domain")&&(l.domain=r.domain),r.version!=null&&r.hasOwnProperty("version")&&(typeof r.version=="number"?l.version=u.longs===String?String(r.version):r.version:l.version=u.longs===String?o.Long.prototype.toString.call(r.version):u.longs===Number?new o.LongBits(r.version.low>>>0,r.version.high>>>0).toNumber():r.version),l},h.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},h.getTypeUrl=function(r){return r===void 0&&(r="type.googleapis.com"),r+"/onnx.OperatorSetIdProto"},h}(),c.OperatorStatus=function(){var h={},r=Object.create(h);return r[h[0]="EXPERIMENTAL"]=0,r[h[1]="STABLE"]=1,r}(),c.FunctionProto=function(){function h(r){if(this.input=[],this.output=[],this.attribute=[],this.attributeProto=[],this.node=[],this.opsetImport=[],r)for(var u=Object.keys(r),l=0;l<u.length;++l)r[u[l]]!=null&&(this[u[l]]=r[u[l]])}return h.prototype.name="",h.prototype.input=o.emptyArray,h.prototype.output=o.emptyArray,h.prototype.attribute=o.emptyArray,h.prototype.attributeProto=o.emptyArray,h.prototype.node=o.emptyArray,h.prototype.docString="",h.prototype.opsetImport=o.emptyArray,h.prototype.domain="",h.create=function(r){return new h(r)},h.encode=function(r,u){if(u||(u=p.create()),r.name!=null&&Object.hasOwnProperty.call(r,"name")&&u.uint32(10).string(r.name),r.input!=null&&r.input.length)for(var l=0;l<r.input.length;++l)u.uint32(34).string(r.input[l]);if(r.output!=null&&r.output.length)for(var l=0;l<r.output.length;++l)u.uint32(42).string(r.output[l]);if(r.attribute!=null&&r.attribute.length)for(var l=0;l<r.attribute.length;++l)u.uint32(50).string(r.attribute[l]);if(r.node!=null&&r.node.length)for(var l=0;l<r.node.length;++l)s.onnx.NodeProto.encode(r.node[l],u.uint32(58).fork()).ldelim();if(r.docString!=null&&Object.hasOwnProperty.call(r,"docString")&&u.uint32(66).string(r.docString),r.opsetImport!=null&&r.opsetImport.length)for(var l=0;l<r.opsetImport.length;++l)s.onnx.OperatorSetIdProto.encode(r.opsetImport[l],u.uint32(74).fork()).ldelim();if(r.domain!=null&&Object.hasOwnProperty.call(r,"domain")&&u.uint32(82).string(r.domain),r.attributeProto!=null&&r.attributeProto.length)for(var l=0;l<r.attributeProto.length;++l)s.onnx.AttributeProto.encode(r.attributeProto[l],u.uint32(90).fork()).ldelim();return u},h.encodeDelimited=function(r,u){return this.encode(r,u).ldelim()},h.decode=function(r,u){r instanceof i||(r=i.create(r));for(var l=u===void 0?r.len:r.pos+u,f=new s.onnx.FunctionProto;r.pos<l;){var g=r.uint32();switch(g>>>3){case 1:{f.name=r.string();break}case 4:{f.input&&f.input.length||(f.input=[]),f.input.push(r.string());break}case 5:{f.output&&f.output.length||(f.output=[]),f.output.push(r.string());break}case 6:{f.attribute&&f.attribute.length||(f.attribute=[]),f.attribute.push(r.string());break}case 11:{f.attributeProto&&f.attributeProto.length||(f.attributeProto=[]),f.attributeProto.push(s.onnx.AttributeProto.decode(r,r.uint32()));break}case 7:{f.node&&f.node.length||(f.node=[]),f.node.push(s.onnx.NodeProto.decode(r,r.uint32()));break}case 8:{f.docString=r.string();break}case 9:{f.opsetImport&&f.opsetImport.length||(f.opsetImport=[]),f.opsetImport.push(s.onnx.OperatorSetIdProto.decode(r,r.uint32()));break}case 10:{f.domain=r.string();break}default:r.skipType(g&7);break}}return f},h.decodeDelimited=function(r){return r instanceof i||(r=new i(r)),this.decode(r,r.uint32())},h.verify=function(r){if(typeof r!="object"||r===null)return"object expected";if(r.name!=null&&r.hasOwnProperty("name")&&!o.isString(r.name))return"name: string expected";if(r.input!=null&&r.hasOwnProperty("input")){if(!Array.isArray(r.input))return"input: array expected";for(var u=0;u<r.input.length;++u)if(!o.isString(r.input[u]))return"input: string[] expected"}if(r.output!=null&&r.hasOwnProperty("output")){if(!Array.isArray(r.output))return"output: array expected";for(var u=0;u<r.output.length;++u)if(!o.isString(r.output[u]))return"output: string[] expected"}if(r.attribute!=null&&r.hasOwnProperty("attribute")){if(!Array.isArray(r.attribute))return"attribute: array expected";for(var u=0;u<r.attribute.length;++u)if(!o.isString(r.attribute[u]))return"attribute: string[] expected"}if(r.attributeProto!=null&&r.hasOwnProperty("attributeProto")){if(!Array.isArray(r.attributeProto))return"attributeProto: array expected";for(var u=0;u<r.attributeProto.length;++u){var l=s.onnx.AttributeProto.verify(r.attributeProto[u]);if(l)return"attributeProto."+l}}if(r.node!=null&&r.hasOwnProperty("node")){if(!Array.isArray(r.node))return"node: array expected";for(var u=0;u<r.node.length;++u){var l=s.onnx.NodeProto.verify(r.node[u]);if(l)return"node."+l}}if(r.docString!=null&&r.hasOwnProperty("docString")&&!o.isString(r.docString))return"docString: string expected";if(r.opsetImport!=null&&r.hasOwnProperty("opsetImport")){if(!Array.isArray(r.opsetImport))return"opsetImport: array expected";for(var u=0;u<r.opsetImport.length;++u){var l=s.onnx.OperatorSetIdProto.verify(r.opsetImport[u]);if(l)return"opsetImport."+l}}return r.domain!=null&&r.hasOwnProperty("domain")&&!o.isString(r.domain)?"domain: string expected":null},h.fromObject=function(r){if(r instanceof s.onnx.FunctionProto)return r;var u=new s.onnx.FunctionProto;if(r.name!=null&&(u.name=String(r.name)),r.input){if(!Array.isArray(r.input))throw TypeError(".onnx.FunctionProto.input: array expected");u.input=[];for(var l=0;l<r.input.length;++l)u.input[l]=String(r.input[l])}if(r.output){if(!Array.isArray(r.output))throw TypeError(".onnx.FunctionProto.output: array expected");u.output=[];for(var l=0;l<r.output.length;++l)u.output[l]=String(r.output[l])}if(r.attribute){if(!Array.isArray(r.attribute))throw TypeError(".onnx.FunctionProto.attribute: array expected");u.attribute=[];for(var l=0;l<r.attribute.length;++l)u.attribute[l]=String(r.attribute[l])}if(r.attributeProto){if(!Array.isArray(r.attributeProto))throw TypeError(".onnx.FunctionProto.attributeProto: array expected");u.attributeProto=[];for(var l=0;l<r.attributeProto.length;++l){if(typeof r.attributeProto[l]!="object")throw TypeError(".onnx.FunctionProto.attributeProto: object expected");u.attributeProto[l]=s.onnx.AttributeProto.fromObject(r.attributeProto[l])}}if(r.node){if(!Array.isArray(r.node))throw TypeError(".onnx.FunctionProto.node: array expected");u.node=[];for(var l=0;l<r.node.length;++l){if(typeof r.node[l]!="object")throw TypeError(".onnx.FunctionProto.node: object expected");u.node[l]=s.onnx.NodeProto.fromObject(r.node[l])}}if(r.docString!=null&&(u.docString=String(r.docString)),r.opsetImport){if(!Array.isArray(r.opsetImport))throw TypeError(".onnx.FunctionProto.opsetImport: array expected");u.opsetImport=[];for(var l=0;l<r.opsetImport.length;++l){if(typeof r.opsetImport[l]!="object")throw TypeError(".onnx.FunctionProto.opsetImport: object expected");u.opsetImport[l]=s.onnx.OperatorSetIdProto.fromObject(r.opsetImport[l])}}return r.domain!=null&&(u.domain=String(r.domain)),u},h.toObject=function(r,u){u||(u={});var l={};if((u.arrays||u.defaults)&&(l.input=[],l.output=[],l.attribute=[],l.node=[],l.opsetImport=[],l.attributeProto=[]),u.defaults&&(l.name="",l.docString="",l.domain=""),r.name!=null&&r.hasOwnProperty("name")&&(l.name=r.name),r.input&&r.input.length){l.input=[];for(var f=0;f<r.input.length;++f)l.input[f]=r.input[f]}if(r.output&&r.output.length){l.output=[];for(var f=0;f<r.output.length;++f)l.output[f]=r.output[f]}if(r.attribute&&r.attribute.length){l.attribute=[];for(var f=0;f<r.attribute.length;++f)l.attribute[f]=r.attribute[f]}if(r.node&&r.node.length){l.node=[];for(var f=0;f<r.node.length;++f)l.node[f]=s.onnx.NodeProto.toObject(r.node[f],u)}if(r.docString!=null&&r.hasOwnProperty("docString")&&(l.docString=r.docString),r.opsetImport&&r.opsetImport.length){l.opsetImport=[];for(var f=0;f<r.opsetImport.length;++f)l.opsetImport[f]=s.onnx.OperatorSetIdProto.toObject(r.opsetImport[f],u)}if(r.domain!=null&&r.hasOwnProperty("domain")&&(l.domain=r.domain),r.attributeProto&&r.attributeProto.length){l.attributeProto=[];for(var f=0;f<r.attributeProto.length;++f)l.attributeProto[f]=s.onnx.AttributeProto.toObject(r.attributeProto[f],u)}return l},h.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},h.getTypeUrl=function(r){return r===void 0&&(r="type.googleapis.com"),r+"/onnx.FunctionProto"},h}(),c}(),n.exports=s});function ur(e,n){if(!e)throw new Error(typeof n=="string"?n:n())}function kr(e){return new TextDecoder().decode(e)}var ot,Me,ai,kt,Sn,At,Rt,B,$r,Ue,Ve,ze,Y=O(()=>{wn(),qo(),ot=rr(sr()),We(),Me=class{static arraysEqual(e,n){if(e.length!==n.length)return!1;for(let a=0;a<e.length;a++)if(e[a]!==n[a])return!1;return!0}},ai=class{static preprocessInputShapes(e,n){let a=e.length===1?[1,e[0]]:e,i=n.length===1?[n[0],1]:n;return[a,i]}static postprocessOutputShape(e,n,a){n===1&&e.splice(e.length-2,1),a===1&&e.pop()}static calcMatMulShape(e,n){return e[1]!==n[0]?void 0:[e[0],n[1]]}},kt=class ve{static calcShape(n,a,i=!1){let p=n.length,o=a.length;if(p===0)return a;if(o===0)return n;let s=Math.max(n.length,a.length),c=new Array(s);if(i){if(p<2||o<2)return;let h=ai.calcMatMulShape([n[p-2],n[p-1]],[a[o-2],a[o-1]]);if(h===void 0)return;[c[s-2],c[s-1]]=h}for(let h=i?3:1;h<=s;h++){let r=p-h<0?1:n[p-h],u=o-h<0?1:a[o-h];if(r!==u&&r>1&&u>1)return;c[s-h]=Math.max(r,u)}return c}static index(n,a){let i=new Array(a.length);return ve.fillIndex(n,a,i),i}static fillIndex(n,a,i){let p=n.length-a.length;for(let o=0;o<a.length;o++)i[o]=n[p+o]%a[o]}static calc(n,a,i,p,o){let s=ve.calcShape(n.dims,a.dims);if(s){if(p&&!B.areEqual(s,n.dims))return;let c=B.size(s),h=p?n:new bt(s,o||n.type);if(s.length===0)h.set([],i(n.get([]),a.get([])));else{let r=new Array(s.length),u=new Array(n.dims.length),l=new Array(a.dims.length),f=0,g=0,b=!1,v=!1;n.dims.length===0&&(f=n.get([]),b=!0),a.dims.length===0&&(g=a.get([]),v=!0);let S;for(let P=0;P<c;P++){S=P;for(let _=s.length-1;_>=0;_--)r[_]=S%s[_],S=Math.floor(S/s[_]);b||(ve.fillIndex(r,n.dims,u),f=n.get(u)),v||(ve.fillIndex(r,a.dims,l),g=a.get(l)),h.set(r,i(f,g))}}return h}}static isValidBroadcast(n,a){let i=n.length,p=a.length;if(i>p)return!1;for(let o=1;o<=i;o++)if(n[i-o]!==1&&n[i-o]!==a[p-o])return!1;return!0}static getBroadcastDims(n,a){let i=n.length,p=[];for(let o=0;o<i;o++){let s=i-1-o,c=n[s]||1;(a[a.length-1-o]||1)>1&&c===1&&p.unshift(s)}return p}},Sn=class{static getShapeOfGemmResult(e,n,a,i,p){if(e.length!==2||a.length!==2)throw new Error("shape need to be of size 2");let o,s,c;n?(o=e[1],s=e[0]):(o=e[0],s=e[1]);let h=-1;if(i?(c=a[0],h=1):(c=a[1],h=0),a[h]!==s)throw new Error("dimension mismatch");if(o<=0||c<=0||s<=0)throw new Error("invalid shape specified");if(p&&!kt.isValidBroadcast(p,[o,c]))throw new Error("gemm: invalid bias shape for broadcast");return[o,c,s]}},At=class rn{static tensorDataTypeFromProto(n){switch(n){case ot.onnx.TensorProto.DataType.INT8:return"int8";case ot.onnx.TensorProto.DataType.UINT8:return"uint8";case ot.onnx.TensorProto.DataType.BOOL:return"bool";case ot.onnx.TensorProto.DataType.INT16:return"int16";case ot.onnx.TensorProto.DataType.UINT16:return"uint16";case ot.onnx.TensorProto.DataType.INT32:return"int32";case ot.onnx.TensorProto.DataType.UINT32:return"uint32";case ot.onnx.TensorProto.DataType.FLOAT:return"float32";case ot.onnx.TensorProto.DataType.DOUBLE:return"float64";case ot.onnx.TensorProto.DataType.STRING:return"string";case ot.onnx.TensorProto.DataType.INT64:return"int32";case ot.onnx.TensorProto.DataType.UINT64:return"uint32";default:throw new Error(`unsupported data type: ${ot.onnx.TensorProto.DataType[n]}`)}}static tensorDataTypeStringToEnum(n){switch(n){case"int8":return ot.onnx.TensorProto.DataType.INT8;case"uint8":return ot.onnx.TensorProto.DataType.UINT8;case"bool":return ot.onnx.TensorProto.DataType.BOOL;case"int16":return ot.onnx.TensorProto.DataType.INT16;case"uint16":return ot.onnx.TensorProto.DataType.UINT16;case"int32":return ot.onnx.TensorProto.DataType.INT32;case"uint32":return ot.onnx.TensorProto.DataType.UINT32;case"float32":return ot.onnx.TensorProto.DataType.FLOAT;case"float64":return ot.onnx.TensorProto.DataType.DOUBLE;case"string":return ot.onnx.TensorProto.DataType.STRING;case"int64":return ot.onnx.TensorProto.DataType.INT64;case"uint64":return ot.onnx.TensorProto.DataType.UINT64;default:throw new Error(`unsupported data type: ${n}`)}}static tensorDimsFromProto(n){return n.map(a=>xe.isLong(a)?a.toNumber():a)}static tensorValueTypeFromProto(n){return{tensorType:rn.tensorDataTypeFromProto(n.elemType),shape:{dims:rn.tensorDimsFromProto(n.shape.dim.map(a=>a.dimValue))}}}static tensorDimsFromORTFormat(n){let a=[];for(let i=0;i<n.dimsLength();i++)a.push(Rt.longToNumber(n.dims(i)));return a}static tensorAttributesFromORTFormat(n){let a=[];for(let i=0;i<n.attributesLength();i++)a.push(n.attributes(i));return a}},Rt=class{static longToNumber(e,n){return xe.isLong(e)?e.toNumber():e instanceof w.Long?xe.fromValue({low:e.low,high:e.high,unsigned:n??!1}).toNumber():e}static isLong(e){return xe.isLong(e)||e instanceof w.Long}},B=class ee{static size(n){return ee.getSizeFromDimensionRange(n,0,n.length)}static sizeFromDimension(n,a){if(a<0||a>n.length)throw new Error(`invalid dimension of ${a} for sizeFromDimension as Tensor has ${n.length} dimensions.`);return ee.getSizeFromDimensionRange(n,a,n.length)}static sizeToDimension(n,a){if(a<0||a>n.length)throw new Error(`invalid dimension of ${a} for sizeToDimension as Tensor has ${n.length} dimensions.`);return ee.getSizeFromDimensionRange(n,0,a)}static getSizeFromDimensionRange(n,a,i){let p=1;for(let o=a;o<i;o++){if(n[o]<=0)throw new Error("cannot get valid size from specified dimension range. Most likely the range contains 0 or negative values in them.");p*=n[o]}return p}static computeStrides(n){let a=n.length;if(a===0)return[];if(a===1)return[1];let i=new Array(a);i[a-1]=1,i[a-2]=n[a-1];for(let p=a-3;p>=0;--p)i[p]=i[p+1]*n[p+1];return i}static transpose(n){return n.slice().reverse()}static indicesToOffset(n,a,i){i===void 0&&(i=n.length);let p=0;for(let o=0;o<i;++o)p+=a[o]*n[o];return p}static offsetToIndices(n,a){let i=a.length;if(i===0)return[];if(i===1)return[n*a[0]];let p=new Array(a.length);for(let o=0;o<p.length-1;++o)p[o]=Math.floor(n/a[o]),n-=p[o]*a[o];return p[p.length-1]=n,p}static normalizeAxis(n,a){if(n<-a&&n>=a)throw new Error("unsupported axis for this operation.");return n<0?n+a:n}static normalizeAxes(n,a){return n.map(i=>this.normalizeAxis(i,a))}static incrementIndex(n,a,i){if(a.length===0||n.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 p=i-1;p>=0&&(n[p]++,!(n[p]<a[p]));--p)n[p]=0}static calculateReshapedDims(n,a){if(a.length===0){if(n.length===0||ee.size(n)===1)return[];throw new Error("cannot reshape to a scalar Tensor")}let i=a.length,p=new Array(i),o=-1,s=1;for(let h=0;h<i;h++){if(a[h]<-1)throw new Error("a dimension in shape hints cannot be less than -1");if(a[h]===-1){if(o!==-1)throw new Error("at most one dimension in shape hints can be -1");o=h}else{if(a[h]===0){if(h>=n.length)throw new Error("the dimension with value zero exceeds the dimension size of the input tensor");p[h]=n[h]}else p[h]=a[h];s*=p[h]}}let c=ee.size(n);if(o!==-1){if(c%s!==0)throw new Error(`the input tensor cannot be reshaped to the requested shape. Input shape: [${n}] Output shape: [${a}]`);p[o]=c/s}else if(s!==c)throw new Error("reshapedDims and originalDims don't have matching sizes");return p}static sortBasedOnPerm(n,a){return a?a.map(i=>n[i]):n.slice().reverse()}static padShape(n,a){let i=n.length;return n.map((p,o)=>p+a[o]+a[o+i])}static areEqual(n,a){return n.length!==a.length?!1:n.every((i,p)=>i===a[p])}static validateDimsAndCalcSize(n){if(n.length>6)throw new TypeError("Only rank 0 to 6 is supported for tensor shape.");let a=1;for(let i of n){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(n,a){a<0&&(a+=n.length);let i=n.reduce((o,s)=>o*s,1),p=n.slice(a).reduce((o,s)=>o*s,1);return[i/p,p]}static squeezeShape(n,a){let i=new Array;a=ee.normalizeAxes(a,n.length);for(let p=0;p<n.length;p++){let o=a.indexOf(p)>=0;if(o&&n[p]!==1)throw new Error("squeeze an axis of size different than 1");(a.length===0&&n[p]>1||a.length>0&&!o)&&i.push(n[p])}return i}static unsqueezeShape(n,a){let i=new Array(n.length+a.length);i.fill(0);for(let o=0;o<a.length;o++){let s=ee.normalizeAxis(a[o],i.length);if(s>=i.length)throw new Error("'axes' has an out of range axis");if(i[s]!==0)throw new Error("'axes' has a duplicate axis");i[s]=1}let p=0;for(let o=0;o<i.length;o++)i[o]===0&&(i[o]=n[p++]);if(p!==n.length)throw new Error("the unsqueezed dimension could not be established");return i}},$r=class Ea{static splitShape(n,a,i,p){if(i.length===0){if(!p)throw new Error("need to know number of outputs when the 'split' attribute is not specified");Ea.determineSplit(n[a],p,i)}let o=[],s=[0];for(let c=0;c<i.length;++c){c!==0&&s.push(s[c-1]+i[c-1]);let h=n.slice();h[a]=i[c],o.push(h)}return[o,s]}static determineSplit(n,a,i){if(n%a!==0)throw new Error("cannot split tensor to equal sized parts");for(let p=0;p<a;++p)i.push(n/a)}},Ue=class Oe{static adjustPoolAttributes(n,a,i,p,o,s){if(!n&&i.length!==a.length-2)throw new Error("length of specified kernel shapes should be 2 less than length of input dimensions");if(n)for(let c=0;c<a.length-2;c++)c>=i.length?i.push(a[c+2]):i[c]=a[c+2];for(let c=0;c<i.length;c++)if(c<p.length){if(p[c]<0)throw new Error("strides should be greater than or equal to 1")}else p.push(1);for(let c=0;c<i.length;c++)if(c<o.length){if(o[c]<0)throw new Error("dilations should be greater than or equal to 1")}else o.push(1);for(let c=0;c<i.length*2;c++)if(c<s.length){if(s[c]<0)throw new Error("pad should be greater than or equal to 1")}else s.push(0);for(let c=0;c<i.length;c++){if(i[c]<=0)throw new Error("kernel shapes need to be greater than 0");if(s[c]>=i[c]||s[c+i.length]>=i[c])throw new Error("pads should be smaller than kernel")}}static adjustPadsBasedOnAutoPad(n,a,i,p,o,s){if(s){if(o.length!==2*(n.length-2))throw new Error("length of pads should be twice the length of data dimensions");if(a.length!==n.length-2)throw new Error("length of strides should be the length of data dimensions");if(p.length!==n.length-2)throw new Error("length of kernel shapes should be the length of data dimensions");for(let c=0;c<n.length-2;c++)Oe.adjustPadAndReturnShape(n[c+2],a[c],i[c],p[c],o,c,c+n.length-2,s)}}static computePoolOutputShape(n,a,i,p,o,s,c){if(a.length<=0)throw new Error("input shape must be of size greater than 0");let h=[a[0],a[1]];return Oe.computeShapeHelper(n,a,h,i,p,o,s,c),h}static computeConvOutputShape(n,a,i,p,o,s,c){if(n.length<=0||a.length<=0)throw new Error("invalid input tensor dims or invalid filter tensor dims");let h=[n[0],a[0]];return Oe.computeShapeHelper(!1,n,h,i,p,o,s,c),h}static computeShapeHelper(n,a,i,p,o,s,c,h){if(n)for(let r=0;r<a.length-2;r++)i.push(1);else for(let r=0;r<a.length-2;r++)i.push(Oe.adjustPadAndReturnShape(a[r+2],p[r],o[r],s[r],c,r,r+a.length-2,h))}static adjustPadAndReturnShape(n,a,i,p,o,s,c,h){let r=i*(p-1)+1;if(h&&h!=="NOTSET")switch(h){case"VALID":return o[s]=0,o[c]=0,Math.floor((n-r)/a+1);case"SAME_LOWER":case"SAME_UPPER":if(i!==1)throw new Error("Dilation not supported for SAME_UPPER or SAME_LOWER");{let u=((n+a-1)/a-1)*a+p-n;return o[s]=Math.floor(h==="SAME_LOWER"?(u+1)/2:u/2),o[c]=u-o[s],Math.floor((n+u-p)/a+1)}default:throw new Error("Unsupported AutoPad type")}else return Math.floor((n+o[s]+o[c]-r)/a+1)}},Ve=-34028234663852886e22,ze=34028234663852886e22});function hh(e){switch(e){case"bool":case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;case"float64":return 8;default:throw new Error(`cannot calculate sizeof() on type ${e}`)}}function Wu(e){switch(e){case H.onnx.TensorProto.DataType.UINT8:case H.onnx.TensorProto.DataType.INT8:case H.onnx.TensorProto.DataType.BOOL:return 1;case H.onnx.TensorProto.DataType.UINT16:case H.onnx.TensorProto.DataType.INT16:return 2;case H.onnx.TensorProto.DataType.FLOAT:case H.onnx.TensorProto.DataType.INT32:case H.onnx.TensorProto.DataType.UINT32:return 4;case H.onnx.TensorProto.DataType.INT64:case H.onnx.TensorProto.DataType.DOUBLE:case H.onnx.TensorProto.DataType.UINT64:return 8;default:throw new Error(`cannot calculate sizeof() on type ${H.onnx.TensorProto.DataType[e]}`)}}function mh(e,n){return new(ju(n))(e)}function ju(e){switch(e){case"bool":case"uint8":return Uint8Array;case"int8":return Int8Array;case"int16":return Int16Array;case"uint16":return Uint16Array;case"int32":return Int32Array;case"uint32":return Uint32Array;case"int64":return BigInt64Array;case"float32":return Float32Array;case"float64":return Float64Array;default:throw new Error("unspecified error")}}function ui(e,n){if(n===H.onnx.TensorProto.DataType.INT64||n===si.TensorDataType.INT64){if(e.greaterThanOrEqual(2147483648)||e.lessThan(-2147483648))throw new TypeError("int64 is not supported")}else if(n===H.onnx.TensorProto.DataType.UINT32||n===si.TensorDataType.UINT32||n===H.onnx.TensorProto.DataType.UINT64||n===si.TensorDataType.UINT64){if(e.greaterThanOrEqual(4294967296)||e.lessThan(0))throw new TypeError("uint64 is not supported")}else throw new TypeError(`not a LONG type: ${H.onnx.TensorProto.DataType[n]}`);return e.toNumber()}function Hu(e,n,a){switch(n){case H.onnx.TensorProto.DataType.BOOL:case H.onnx.TensorProto.DataType.UINT8:return e.getUint8(a);case H.onnx.TensorProto.DataType.INT8:return e.getInt8(a);case H.onnx.TensorProto.DataType.UINT16:return e.getUint16(a,!0);case H.onnx.TensorProto.DataType.INT16:return e.getInt16(a,!0);case H.onnx.TensorProto.DataType.FLOAT:return e.getFloat32(a,!0);case H.onnx.TensorProto.DataType.INT32:return e.getInt32(a,!0);case H.onnx.TensorProto.DataType.UINT32:return e.getUint32(a,!0);case H.onnx.TensorProto.DataType.INT64:return ui(xe.fromBits(e.getUint32(a,!0),e.getUint32(a+4,!0),!1),n);case H.onnx.TensorProto.DataType.DOUBLE:return e.getFloat64(a,!0);case H.onnx.TensorProto.DataType.UINT64:return ui(xe.fromBits(e.getUint32(a,!0),e.getUint32(a+4,!0),!0),n);default:throw new Error(`cannot read from DataView for type ${H.onnx.TensorProto.DataType[n]}`)}}var qu,H,si,bt,We=O(()=>{qu=rr(Fs()),qo(),Pr(),H=rr(sr()),Y(),si=F.experimental.fbs,bt=class wr{constructor(n,a,i,p,o,s=qu.Guid.create()){this.dims=n,this.type=a,this.dataProvider=i,this.asyncDataProvider=p,this.cache=o,this.dataId=s,this.size=B.validateDimsAndCalcSize(n);let c=this.size,h=i===void 0&&p===void 0&&o===void 0;if(o!==void 0&&o.length!==c)throw new RangeError("Input dims doesn't match data length.");if(a==="string"){if(o!==void 0&&(!Array.isArray(o)||!o.every(r=>typeof r=="string")))throw new TypeError("cache should be a string array");h&&(this.cache=new Array(c))}else{if(o!==void 0){let r=ju(a);if(!(o instanceof r))throw new TypeError(`cache should be type ${r.name}`)}if(h){let r=new ArrayBuffer(c*hh(a));this.cache=mh(r,a)}}}get data(){if(this.cache===void 0){let n=this.dataProvider(this.dataId);if(n.length!==this.size)throw new Error("Length of data provided by the Data Provider is inconsistent with the dims of this Tensor.");this.cache=n}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(n){return this.data[B.indicesToOffset(n,this.strides)]}set(n,a){this.data[B.indicesToOffset(n,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=B.computeStrides(this.dims)),this._strides}static fromProto(n){if(!n)throw new Error("cannot construct Value from an empty tensor");let a=At.tensorDataTypeFromProto(n.dataType),i=At.tensorDimsFromProto(n.dims),p=new wr(i,a);if(a==="string")n.stringData.forEach((o,s)=>{p.data[s]=kr(o)});else if(n.rawData&&typeof n.rawData.byteLength=="number"&&n.rawData.byteLength>0){let o=p.data,s=new DataView(n.rawData.buffer,n.rawData.byteOffset,n.rawData.byteLength),c=Wu(n.dataType),h=n.rawData.byteLength/c;if(n.rawData.byteLength%c!==0)throw new Error("invalid buffer length");if(o.length!==h)throw new Error("buffer length mismatch");for(let r=0;r<h;r++){let u=Hu(s,n.dataType,r*c);o[r]=u}}else{let o;switch(n.dataType){case H.onnx.TensorProto.DataType.FLOAT:o=n.floatData;break;case H.onnx.TensorProto.DataType.INT32:case H.onnx.TensorProto.DataType.INT16:case H.onnx.TensorProto.DataType.UINT16:case H.onnx.TensorProto.DataType.INT8:case H.onnx.TensorProto.DataType.UINT8:case H.onnx.TensorProto.DataType.BOOL:o=n.int32Data;break;case H.onnx.TensorProto.DataType.INT64:o=n.int64Data;break;case H.onnx.TensorProto.DataType.DOUBLE:o=n.doubleData;break;case H.onnx.TensorProto.DataType.UINT32:case H.onnx.TensorProto.DataType.UINT64:o=n.uint64Data;break;default:throw new Error("unspecific error")}if(o==null)throw new Error("failed to populate data from a tensorproto value");let s=p.data;if(s.length!==o.length)throw new Error("array length mismatch");for(let c=0;c<o.length;c++){let h=o[c];xe.isLong(h)?s[c]=ui(h,n.dataType):s[c]=h}}return p}static fromData(n,a,i){return new wr(a,i,void 0,void 0,n)}static fromOrtTensor(n){if(!n)throw new Error("cannot construct Value from an empty tensor");let a=At.tensorDimsFromORTFormat(n),i=At.tensorDataTypeFromProto(n.dataType()),p=new wr(a,i);if(i==="string")for(let o=0;o<n.stringDataLength();o++)p.data[o]=n.stringData(o);else if(n.rawDataArray()&&typeof n.rawDataLength()=="number"&&n.rawDataLength()>0){let o=p.data,s=new DataView(n.rawDataArray().buffer,n.rawDataArray().byteOffset,n.rawDataLength()),c=Wu(n.dataType()),h=n.rawDataLength()/c;if(n.rawDataLength()%c!==0)throw new Error("invalid buffer length");if(o.length!==h)throw new Error("buffer length mismatch");for(let r=0;r<h;r++){let u=Hu(s,n.dataType(),r*c);o[r]=u}}return p}}});function G(e){return e===1?bh:gh}function Xu(e){let n=G(e);return`${n.version}
11
11
  precision highp float;
12
- ${r.attribute} vec3 position;
13
- ${r.attribute} vec2 textureCoord;
12
+ ${n.attribute} vec3 position;
13
+ ${n.attribute} vec2 textureCoord;
14
14
 
15
- ${r.varyingVertex} vec2 TexCoords;
15
+ ${n.varyingVertex} vec2 TexCoords;
16
16
 
17
17
  void main()
18
18
  {
19
19
  gl_Position = vec4(position, 1.0);
20
20
  TexCoords = textureCoord;
21
- }`}function Ku(t){let r=G(t);return`${r.version}
21
+ }`}function Ku(e){let n=G(e);return`${n.version}
22
22
  precision highp float;
23
23
  precision highp int;
24
24
  precision highp sampler2D;
25
- ${r.varyingFrag} vec2 TexCoords;
26
- ${r.outputDeclaration}
25
+ ${n.varyingFrag} vec2 TexCoords;
26
+ ${n.outputDeclaration}
27
27
  const vec2 halfCR = vec2(0.5, 0.5);
28
28
 
29
29
  // Custom vector types to handle higher dimenalities.
@@ -50,14 +50,14 @@
50
50
  return x - y * (x / y);
51
51
  }
52
52
 
53
- `}function Ju(t,r){let o=G(t);return`
53
+ `}function Ju(e,n){let a=G(e);return`
54
54
  void main() {
55
- int indices[${r}];
55
+ int indices[${n}];
56
56
  toVec(TexCoords, indices);
57
57
  vec4 result = vec4(process(indices));
58
- ${o.output} = result;
58
+ ${a.output} = result;
59
59
  }
60
- `}var bh,gh,ut=O(()=>{bh={version:"",attribute:"attribute",varyingVertex:"varying",varyingFrag:"varying",texture2D:"texture2D",output:"gl_FragColor",outputDeclaration:""},gh={version:"#version 300 es",attribute:"in",varyingVertex:"out",varyingFrag:"in",texture2D:"texture",output:"outputColor",outputDeclaration:"out vec4 outputColor;"}}),j=O(()=>{});async function li(t,r=i=>0,o){return new Promise((i,u)=>{let n=0,a=()=>{if(t()){i();return}n++;let d=r(n);setTimeout(a,d)};a()})}function An(t){return ur(typeof t<"u"&&t.length!==0,()=>"empty string found for sampler name"),"get"+t.charAt(0).toUpperCase()+t.slice(1)}function Yu(t){return ur(typeof t<"u"&&t.length!==0,()=>"empty string found for sampler name"),"get"+t.charAt(0).toUpperCase()+t.slice(1)+"AtOutCoords"}function lr(t,r){let o=JSON.parse(JSON.stringify(t));return o=r,o}function fr(t,r){return r.map(o=>t[o]).join(", ")}function Bt(t){if(t<=1)return"int";if(t===2)return"ivec2";if(t===3)return"ivec3";if(t===4)return"ivec4";if(t===5)return"ivec5";if(t===6)return"ivec6";throw Error(`GPU for rank ${t} is not yet supported`)}function ne(t=6){return["x","y","z","w","u","v"].slice(0,t)}var pe=O(()=>{Y()});function yh(t,r){return ne(r).map(o=>`${t}.${o}`)}function cr(t,r){return r===1?[t]:yh(t,r)}function de(){return`
60
+ `}var bh,gh,ut=O(()=>{bh={version:"",attribute:"attribute",varyingVertex:"varying",varyingFrag:"varying",texture2D:"texture2D",output:"gl_FragColor",outputDeclaration:""},gh={version:"#version 300 es",attribute:"in",varyingVertex:"out",varyingFrag:"in",texture2D:"texture",output:"outputColor",outputDeclaration:"out vec4 outputColor;"}}),j=O(()=>{});async function li(e,n=i=>0,a){return new Promise((i,p)=>{let o=0,s=()=>{if(e()){i();return}o++;let c=n(o);setTimeout(s,c)};s()})}function An(e){return ur(typeof e<"u"&&e.length!==0,()=>"empty string found for sampler name"),"get"+e.charAt(0).toUpperCase()+e.slice(1)}function Yu(e){return ur(typeof e<"u"&&e.length!==0,()=>"empty string found for sampler name"),"get"+e.charAt(0).toUpperCase()+e.slice(1)+"AtOutCoords"}function lr(e,n){let a=JSON.parse(JSON.stringify(e));return a=n,a}function fr(e,n){return n.map(a=>e[a]).join(", ")}function Bt(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 ne(e=6){return["x","y","z","w","u","v"].slice(0,e)}var pe=O(()=>{Y()});function yh(e,n){return ne(n).map(a=>`${e}.${a}`)}function cr(e,n){return n===1?[e]:yh(e,n)}function de(){return`
61
61
  float getChannel(vec4 frag, int dim) {
62
62
  int modCoord = imod(dim, 2);
63
63
  return modCoord == 0 ? frag.r : frag.g;
@@ -69,54 +69,54 @@
69
69
  (modCoord.y == 0. ? frag.r : frag.g) :
70
70
  (modCoord.y == 0. ? frag.b : frag.a);
71
71
  }
72
- `}var He=O(()=>{pe()});function Th(t,r,o){if(t===0)return"false";if(t===1)return`rc > ${r[0]}`;let i="";for(let u=t-2;u<t;u++)i+=`${o[u]} >= ${r[u-t+2]}`,u<t-1&&(i+="||");return i}function wh(t,r){let o=t.length;if(o===0)return"getA(), 0, 0, 0";if(o===1)return`getA(rc),
73
- rc + 1 >= ${t[0]} ? 0. : getA(rc + 1),
74
- 0, 0`;let i="r, c",u="r, cp1",n="rp1, c",a="rp1, cp1",d="";if(o>2)for(let c=0;c<o-2;++c)d=d+`${r[c]},`;return`getA(${d}${i}),
75
- rEdge ? 0. : getA(${d}${n}),
76
- cEdge ? 0. : getA(${d}${u}),
77
- rEdge || cEdge ? 0. : getA(${d}${a})`}function vh(t,r,o,i){return t===0||t===1?"":`
78
- int r = ${r[t-2]};
79
- int c = ${r[t-1]};
80
- int rp1 = ${r[t-2]} + 1;
81
- int cp1 = ${r[t-1]} + 1;
72
+ `}var He=O(()=>{pe()});function Th(e,n,a){if(e===0)return"false";if(e===1)return`rc > ${n[0]}`;let i="";for(let p=e-2;p<e;p++)i+=`${a[p]} >= ${n[p-e+2]}`,p<e-1&&(i+="||");return i}function wh(e,n){let a=e.length;if(a===0)return"getA(), 0, 0, 0";if(a===1)return`getA(rc),
73
+ rc + 1 >= ${e[0]} ? 0. : getA(rc + 1),
74
+ 0, 0`;let i="r, c",p="r, cp1",o="rp1, c",s="rp1, cp1",c="";if(a>2)for(let h=0;h<a-2;++h)c=c+`${n[h]},`;return`getA(${c}${i}),
75
+ rEdge ? 0. : getA(${c}${o}),
76
+ cEdge ? 0. : getA(${c}${p}),
77
+ rEdge || cEdge ? 0. : getA(${c}${s})`}function vh(e,n,a,i){return e===0||e===1?"":`
78
+ int r = ${n[e-2]};
79
+ int c = ${n[e-1]};
80
+ int rp1 = ${n[e-2]} + 1;
81
+ int cp1 = ${n[e-1]} + 1;
82
82
  bool rEdge = rp1 >= ${i};
83
- bool cEdge = cp1 >= ${o};
84
- `}var Zu,xh,Qu,tl=O(()=>{ut(),j(),pe(),He(),Zu={name:"pack",inputNames:["A"],inputTypes:[1]},xh=(t,r)=>{let o=G(t.session.backend.glContext.version),i=r.dims,u=i.length,n=r.dims.length,a=Bt(n),d=cr("rc",n),c=vh(n,d,i[i.length-2],i[i.length-1]),e;u===0?e=[1,1]:u===1?e=[i[0],1]:e=[i[n-1],i[n-2]];let l=Th(n,e,d),s=wh(i,d),h=`
83
+ bool cEdge = cp1 >= ${a};
84
+ `}var Zu,xh,Qu,tl=O(()=>{ut(),j(),pe(),He(),Zu={name:"pack",inputNames:["A"],inputTypes:[1]},xh=(e,n)=>{let a=G(e.session.backend.glContext.version),i=n.dims,p=i.length,o=n.dims.length,s=Bt(o),c=cr("rc",o),h=vh(o,c,i[i.length-2],i[i.length-1]),r;p===0?r=[1,1]:p===1?r=[i[0],1]:r=[i[o-1],i[o-2]];let u=Th(o,r,c),l=wh(i,c),f=`
85
85
  void main() {
86
- ${a} rc = getOutputCoords();
86
+ ${s} rc = getOutputCoords();
87
87
 
88
- if(${l}) {
89
- ${o.output} = vec4(0);
88
+ if(${u}) {
89
+ ${a.output} = vec4(0);
90
90
  } else {
91
- ${c}
91
+ ${h}
92
92
 
93
- ${o.output} = vec4(${s});
93
+ ${a.output} = vec4(${l});
94
94
  }
95
95
  }
96
- `;return{...Zu,hasMain:!0,output:{dims:r.dims,type:r.type,textureType:2},shaderSource:h}},Qu=(t,r)=>({...Zu,get:()=>xh(t,r)})});function fi(t){if(t.length===0)return[1,1,1];let r=1;for(let o=0;o<t.length-2;++o)r*=t[o];return[r,t.length>1?t[t.length-2]:1,t[t.length-1]]}function rl(t,r){let o=!1;return t.length===0||r.length===0?o=!0:t.length<2||r.length<2?o=t[t.length-1]===r[r.length-1]:o=t[t.length-1]===r[r.length-1]&&t[t.length-2]===r[r.length-2],o}function Oh(t){let r=B.computeStrides(t),o=["b","r","c"],i="index";return`
96
+ `;return{...Zu,hasMain:!0,output:{dims:n.dims,type:n.type,textureType:2},shaderSource:f}},Qu=(e,n)=>({...Zu,get:()=>xh(e,n)})});function fi(e){if(e.length===0)return[1,1,1];let n=1;for(let a=0;a<e.length-2;++a)n*=e[a];return[n,e.length>1?e[e.length-2]:1,e[e.length-1]]}function rl(e,n){let a=!1;return e.length===0||n.length===0?a=!0:e.length<2||n.length<2?a=e[e.length-1]===n[n.length-1]:a=e[e.length-1]===n[n.length-1]&&e[e.length-2]===n[n.length-2],a}function Oh(e){let n=B.computeStrides(e),a=["b","r","c"],i="index";return`
97
97
  ivec3 inputCoordsFromReshapedOutCoords(int index) {
98
- ${r.map((u,n)=>{let a=`int ${o[n]} = ${i} / ${u}`,d=n===r.length-1?`int ${o[n+1]} = ${i} - ${o[n]} * ${u}`:`index -= ${o[n]} * ${u}`;return`${a}; ${d};`}).join("")}
98
+ ${n.map((p,o)=>{let s=`int ${a[o]} = ${i} / ${p}`,c=o===n.length-1?`int ${a[o+1]} = ${i} - ${a[o]} * ${p}`:`index -= ${a[o]} * ${p}`;return`${s}; ${c};`}).join("")}
99
99
  return ivec3(b, r, c);
100
100
  }
101
- `}function Sh(t){let r=B.computeStrides(t);return`
101
+ `}function Sh(e){let n=B.computeStrides(e);return`
102
102
  int getFlattenedIndex(ivec3 coords) {
103
103
  // reverse y, z order
104
- return coords.x * ${r[0]} + coords.z * ${r[1]} + coords.y;
104
+ return coords.x * ${n[0]} + coords.z * ${n[1]} + coords.y;
105
105
  }
106
- `}var Ih,_h,el,nl=O(()=>{Y(),ut(),j(),He(),Ih=t=>({name:"Reshape (packed)",inputTypes:[2],inputNames:["A"],cacheHint:`${t}`}),_h=(t,r,o,i)=>{let u=r.dims,n=i,a="";for(let e=0;e<4;e++){let l="";switch(e){case 0:l="outputCoords = rc;";break;case 1:l="outputCoords = ivec3(rc.x, rc.y+1, rc.z);";break;case 2:l="outputCoords = ivec3(rc.x, rc.y, rc.z+1);";break;case 3:l="outputCoords = ivec3(rc.x, rc.y+1, rc.z+1);";break;default:throw new Error}a+=`
107
- ${l}
108
- ${e>0?"if(outputCoords.y < rows && outputCoords.z < cols){":""}
106
+ `}var Ih,_h,el,nl=O(()=>{Y(),ut(),j(),He(),Ih=e=>({name:"Reshape (packed)",inputTypes:[2],inputNames:["A"],cacheHint:`${e}`}),_h=(e,n,a,i)=>{let p=n.dims,o=i,s="";for(let r=0;r<4;r++){let u="";switch(r){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}s+=`
107
+ ${u}
108
+ ${r>0?"if(outputCoords.y < rows && outputCoords.z < cols){":""}
109
109
  int flattenedIndex = getFlattenedIndex(outputCoords);
110
110
 
111
111
  ivec3 inputRC = inputCoordsFromReshapedOutCoords(flattenedIndex);
112
112
  vec2 innerDims = vec2(float(inputRC.y),float(inputRC.z));
113
113
 
114
- result[${e}] = getChannel(getA(inputRC.x, inputRC.y, inputRC.z), innerDims);
114
+ result[${r}] = getChannel(getA(inputRC.x, inputRC.y, inputRC.z), innerDims);
115
115
 
116
- ${e>0?"}":""}
117
- `}let d=G(t.session.backend.glContext.version),c=`
118
- ${Oh(u)}
119
- ${Sh(n)}
116
+ ${r>0?"}":""}
117
+ `}let c=G(e.session.backend.glContext.version),h=`
118
+ ${Oh(p)}
119
+ ${Sh(o)}
120
120
  ${de()}
121
121
 
122
122
  void main() {
@@ -125,13 +125,13 @@
125
125
  vec4 result = vec4(0.0);
126
126
 
127
127
  ivec3 outputCoords;
128
- int rows = ${n[2]};
129
- int cols = ${n[1]};
128
+ int rows = ${o[2]};
129
+ int cols = ${o[1]};
130
130
 
131
- ${a}
132
- ${d.output} = result;
131
+ ${s}
132
+ ${c.output} = result;
133
133
  }
134
- `;return{...o,output:{dims:n,type:r.type,textureType:2},shaderSource:c,hasMain:!0}},el=(t,r,o)=>{let i=Ih(o);return{...i,get:()=>_h(t,r,i,o)}}}),ci,ol=O(()=>{ut(),j(),ci=(t,r)=>{let o=r.shape,i=G(t.session.backend.glContext.version),u=`
134
+ `;return{...a,output:{dims:o,type:n.type,textureType:2},shaderSource:h,hasMain:!0}},el=(e,n,a)=>{let i=Ih(a);return{...i,get:()=>_h(e,n,i,a)}}}),ci,ol=O(()=>{ut(),j(),ci=(e,n)=>{let a=n.shape,i=G(e.session.backend.glContext.version),p=`
135
135
  const float FLOAT_MAX = 1.70141184e38;
136
136
  const float FLOAT_MIN = 1.17549435e-38;
137
137
 
@@ -178,85 +178,85 @@
178
178
  void main() {
179
179
  float value = ${i.texture2D}(X,TexCoords).r;
180
180
  ${i.output} = encodeAsUint8(value);
181
- }`,n={name:"Uint8Encode",inputTypes:[0],inputNames:["X"],output:{dims:o,type:r.tensor.type,textureType:3},shaderSource:u,hasMain:!0};return t.executeProgram(n,[r.tensor])}});function Ph(t,r){if(t===1)return"rc";let o="";for(let i=0;i<t;i++)o+=r[i],i<t-1&&(o+=",");return o}var il,Ah,al,sl=O(()=>{ut(),j(),pe(),He(),il={name:"unpack",inputNames:["A"],inputTypes:[2]},Ah=(t,r)=>{let o=r.dims.length,i=cr("rc",o),u=i.slice(-2),n=Bt(o),a=de(),d=r.dims.length===0?"":Ph(o,i),c=o<=1?"rc":`vec2(${u.join(",")})`,e=G(t.session.backend.glContext.version),l=`
182
- ${a}
181
+ }`,o={name:"Uint8Encode",inputTypes:[0],inputNames:["X"],output:{dims:a,type:n.tensor.type,textureType:3},shaderSource:p,hasMain:!0};return e.executeProgram(o,[n.tensor])}});function Ph(e,n){if(e===1)return"rc";let a="";for(let i=0;i<e;i++)a+=n[i],i<e-1&&(a+=",");return a}var il,Ah,al,sl=O(()=>{ut(),j(),pe(),He(),il={name:"unpack",inputNames:["A"],inputTypes:[2]},Ah=(e,n)=>{let a=n.dims.length,i=cr("rc",a),p=i.slice(-2),o=Bt(a),s=de(),c=n.dims.length===0?"":Ph(a,i),h=a<=1?"rc":`vec2(${p.join(",")})`,r=G(e.session.backend.glContext.version),u=`
182
+ ${s}
183
183
  void main() {
184
- ${n} rc = getOutputCoords();
184
+ ${o} rc = getOutputCoords();
185
185
 
186
186
  // Sample the texture with the coords to get the rgba channel value.
187
- vec4 packedInput = getA(${d});
187
+ vec4 packedInput = getA(${c});
188
188
 
189
- ${e.output} = vec4(getChannel(packedInput, ${c}), 0, 0, 0);
189
+ ${r.output} = vec4(getChannel(packedInput, ${h}), 0, 0, 0);
190
190
  }
191
- `;return{...il,hasMain:!0,output:{dims:r.dims,type:r.type,textureType:0},shaderSource:l}},al=(t,r)=>({...il,get:()=>Ah(t,r)})}),Pn,Br,En,Fr=O(()=>{Ut(),Pn=class{constructor(t,r=1){if(r===1)this.internalFormat=t.R32F,this.format=t.RED,this.textureType=t.FLOAT,this.channelSize=r;else if(r===4)this.internalFormat=t.RGBA32F,this.format=t.RGBA,this.textureType=t.FLOAT,this.channelSize=r;else throw new Error(`Invalid number of channels: ${r}`)}encode(t,r){let o,i;return t.constructor!==Float32Array&&(tt.warning("Encoder","data was not of type Float32; creating new Float32Array"),i=new Float32Array(t)),r*this.channelSize>t.length?(tt.warning("Encoder","Source data too small. Allocating larger array"),i=t,o=this.allocate(r*this.channelSize),i.forEach((u,n)=>o[n]=u)):(i=t,o=i),o}allocate(t){return new Float32Array(t*4)}decode(t,r){return this.channelSize===1?t.filter((o,i)=>i%4===0).subarray(0,r):t.subarray(0,r)}},Br=class{constructor(t,r=1,o){if(r!==1&&r!==4)throw new Error(`Invalid number of channels: ${r}`);this.internalFormat=t.RGBA,this.format=t.RGBA,this.channelSize=r,this.textureType=o||t.FLOAT}encode(t,r){let o=t;return this.channelSize===1&&(tt.verbose("Encoder","Exploding into a larger array"),o=this.allocate(r),t.forEach((i,u)=>o[u*4]=i)),o}allocate(t){return new Float32Array(t*4)}decode(t,r){return this.channelSize===1?t.filter((o,i)=>i%4===0).subarray(0,r):t.subarray(0,r)}},En=class{constructor(t,r=1){if(this.channelSize=4,r===1)this.internalFormat=t.ALPHA,this.format=t.ALPHA,this.textureType=t.UNSIGNED_BYTE,this.channelSize=r;else if(r===4)this.internalFormat=t.RGBA,this.format=t.RGBA,this.textureType=t.UNSIGNED_BYTE,this.channelSize=r;else throw new Error(`Invalid number of channels: ${r}`)}encode(t,r){return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}allocate(t){return new Uint8Array(t*this.channelSize)}decode(t,r){if(t instanceof Uint8Array)return t.subarray(0,r);throw new Error(`Invalid array type: ${t.constructor}`)}}}),Cr,ul,pi,ll=O(()=>{Y(),j(),Cr=(t,r,o)=>{let i=o===0||o===1?1:4,u=o===2,n=o===1||o===2,a=o===4?r.length-1:void 0,d=o===4?r.map((c,e)=>e===r.length-1?c*4:c):void 0;return pi(t,r,i,d,{isPacked:u,reverseWH:n,breakAxis:a})},ul=(t,r,o)=>{let i=Cr(t,r,o);return[i.width,i.height]},pi=(t,r,o=1,i,u)=>{let n=!!(u&&u.isPacked),[a,d]=t.computeTextureWH(n&&i||r,u),c=r.length,e=r.slice(0);if(c===0&&(e=[1]),o===1)i=r;else if(n){if(o!==4)throw new Error("a packed texture must be 4-channel");i=r,c>0&&(e[c-1]=Math.ceil(e[c-1]/2)),c>1&&(e[c-2]=Math.ceil(e[c-2]/2))}else if(!i)throw new Error("Unpacked shape is needed when using channels > 1");return{width:a,height:d,channels:o,isPacked:n,shape:e,strides:B.computeStrides(e),unpackedShape:i,reversedWH:u&&u.reverseWH}}}),Dh,Dn,cl=O(()=>{Ut(),We(),Y(),tl(),nl(),ol(),sl(),Fr(),ll(),j(),Dh=(t,r)=>{let o=r.map(u=>`${u.unpackedShape.join(",")};${u.width}x${u.height}`).join("_"),i=t.name;return t.cacheHint&&(i+="["+t.cacheHint+"]"),i+=":"+o,i},Dn=class{constructor(t){this.session=t,this.packedTextureDataCache=new Map,this.unpackedTextureDataCache=new Map}calculateTextureWidthAndHeight(t,r){return ul(this.session.layoutStrategy,t,r)}executeProgram(t,r){if(r.length<t.inputNames.length)throw new Error(`Input size mustn't be less than ${t.inputNames.length}.`);if(t.inputNames.length!==t.inputTypes.length)throw new Error("input names size does not match input types");let o=[];for(let c=0;c<t.inputNames.length;++c)o[c]=this.getOrCreateTextureData(r[c],t.inputTypes[c]);let i=Dh(t,o),u=this.session.programManager.getArtifact(i),n=u?u.programInfo:typeof t.get=="function"?t.get():t,a=Cr(this.session.layoutStrategy,n.output.dims,n.output.textureType),d=this.createTextureData(a,n.output.type);return u||(u=this.session.programManager.build(n,o,d),this.session.programManager.setArtifact(i,u)),this.runProgram(u,o,d),d}run(t,r){return this.executeProgram(t,r).tensor}runProgram(t,r,o){for(let i=0;i<r.length;++i)if(!!r[i].isPacked!=(t.programInfo.inputTypes[i]===2))throw new Error(`input[${i}] property packed inconsistent`);if(!!o.isPacked!=(t.programInfo.output.textureType===2))throw new Error("output property packed inconsistent");this.session.programManager.run(t,r,o)}getOrCreateTextureData(t,r){let o=this.getTextureData(t.dataId,r===2);if(!o&&(o=this.getTextureData(t.dataId,r!==2),o))return r===2?this.pack(o):this.unpack(o);if(!o){let i=Cr(this.session.layoutStrategy,t.dims,r);if(r===4){let u=t.dims;if(u.length===4){let n=[u[0],Math.ceil(u[1]*u[2]*u[3]/4)],a=Cr(this.session.layoutStrategy,n,r),d=t.numberData;if(u[1]*u[2]*u[3]%4!==0){let c=u[0],e=u[1]*u[2]*u[3],l=Math.ceil(e*1/4)*4,s=c*l;d=new Float32Array(s);for(let h=0;h<c;++h){let f=h*e,m=h*l+h%1*e;d.set(t.numberData.subarray(f,f+e),m)}}return this.createTextureData(a,t.type,d,t,1)}}if(r===2){let u=pi(this.session.layoutStrategy,t.dims,1,[],{reverseWH:!0}),n=this.createTextureData(u,t.type,t.numberData,t,1);o=this.pack(n)}else o=this.createTextureData(i,t.type,t.numberData,t,1)}return o}createTextureDataFromLayoutBindTensor(t,r,o,i){return this.createTextureData(t,r,o,i,1)}createTextureData(t,r,o,i,u){tt.verbose("InferenceHandler",`Creating TextureData: layout:[${JSON.stringify(t)}]`);let n=this.session.textureManager.createTextureFromLayout(r,t,o,u);return this.createTextureDataFromTexture(t,r,n,i)}reshapeUnpacked(t,r){let o=this.getOrCreateTextureData(t,0),i={channels:o.channels,height:o.height,width:o.width,shape:r.length!==0?r:[1],strides:B.computeStrides(r),unpackedShape:r};return this.createTextureDataFromTexture(i,t.type,o.texture).tensor}reshapePacked(t,r){let o=this.getOrCreateTextureData(t,2);if(rl(t.dims,r)){let d={channels:o.channels,height:o.height,width:o.width,shape:r.length!==0?r:[1],strides:B.computeStrides(r),unpackedShape:r,isPacked:!0};return this.createTextureDataFromTexture(d,t.type,o.texture).tensor}let i=fi(t.dims),u=fi(r),n=this.reshapePacked(t,i),a=this.run(el(this,n,u),[n]);return this.reshapePacked(a,r)}cast(t,r){let o=this.getOrCreateTextureData(t,0);return this.createTextureDataFromTexture(o,r,o.texture).tensor}createTextureDataFromTexture(t,r,o,i,u){let n={...t,tensor:i||new bt(t.unpackedShape,r,a=>this.readTexture(n),async a=>this.readTextureAsync(n),void 0,u),texture:o};return this.setTextureData(n.tensor.dataId,n,t.isPacked),n}getTextureData(t,r=!1){return this.session.isInitializer(t)?this.session.getTextureData(t,r):r?this.packedTextureDataCache.get(t):this.unpackedTextureDataCache.get(t)}setTextureData(t,r,o=!1){this.session.isInitializer(t)?this.session.setTextureData(t,r,o):(o?this.packedTextureDataCache:this.unpackedTextureDataCache).set(t,r)}isTextureLayoutCached(t,r=!1){return!!this.getTextureData(t.dataId,r)}dispose(){this.session.textureManager.clearActiveTextures(),this.packedTextureDataCache.forEach(t=>this.session.textureManager.releaseTexture(t)),this.packedTextureDataCache=new Map,this.unpackedTextureDataCache.forEach(t=>this.session.textureManager.releaseTexture(t)),this.unpackedTextureDataCache=new Map}readTexture(t){return t.isPacked?this.readTexture(this.unpack(t)):this.session.backend.glContext.isFloat32DownloadSupported?this.session.textureManager.readTexture(t,t.tensor.type,t.channels):this.session.textureManager.readUint8TextureAsFloat(ci(this,t))}async readTextureAsync(t){return t.isPacked?this.readTextureAsync(this.unpack(t)):this.session.backend.glContext.isFloat32DownloadSupported?this.session.textureManager.readTextureAsync(t,t.tensor.type,t.channels):this.session.textureManager.readUint8TextureAsFloat(ci(this,t))}pack(t){return this.executeProgram(Qu(this,t.tensor),[t.tensor])}unpack(t){return this.executeProgram(al(this,t.tensor),[t.tensor])}}}),di,W,It=O(()=>{di=class{constructor(t){Object.assign(this,t)}get cacheKey(){return this.key||(this.key=Object.getOwnPropertyNames(this).sort().map(t=>`${this[t]}`).join(";")),this.key}},W=t=>new di(t)}),pl,dl,hl,Lh,$h,ml=O(()=>{It(),ut(),j(),pl={name:"BatchNormalization",inputNames:["A","Scale","B","Mean","Variance"],inputTypes:[0,0,0,0,0]},dl=(t,r,o)=>($h(r),[t.run({...pl,cacheHint:o.cacheKey,get:()=>Lh(t,r,o)},r)]),hl=t=>{let r=t.attributes.getFloat("epsilon",1e-5),o=t.attributes.getFloat("momentum",.9),i=t.attributes.getInt("spatial",1);return W({epsilon:r,momentum:o,spatial:i})},Lh=(t,r,o)=>{let i=G(t.session.backend.glContext.version),u=r[0].dims.length,[n,a]=t.calculateTextureWidthAndHeight(r[1].dims,0),d=`
192
- float process(int[${u}] indices) {
193
- vec2 position = offsetToCoords(indices[1], ${n}, ${a});
191
+ `;return{...il,hasMain:!0,output:{dims:n.dims,type:n.type,textureType:0},shaderSource:u}},al=(e,n)=>({...il,get:()=>Ah(e,n)})}),Pn,Br,En,Fr=O(()=>{Ut(),Pn=class{constructor(e,n=1){if(n===1)this.internalFormat=e.R32F,this.format=e.RED,this.textureType=e.FLOAT,this.channelSize=n;else if(n===4)this.internalFormat=e.RGBA32F,this.format=e.RGBA,this.textureType=e.FLOAT,this.channelSize=n;else throw new Error(`Invalid number of channels: ${n}`)}encode(e,n){let a,i;return e.constructor!==Float32Array&&(tt.warning("Encoder","data was not of type Float32; creating new Float32Array"),i=new Float32Array(e)),n*this.channelSize>e.length?(tt.warning("Encoder","Source data too small. Allocating larger array"),i=e,a=this.allocate(n*this.channelSize),i.forEach((p,o)=>a[o]=p)):(i=e,a=i),a}allocate(e){return new Float32Array(e*4)}decode(e,n){return this.channelSize===1?e.filter((a,i)=>i%4===0).subarray(0,n):e.subarray(0,n)}},Br=class{constructor(e,n=1,a){if(n!==1&&n!==4)throw new Error(`Invalid number of channels: ${n}`);this.internalFormat=e.RGBA,this.format=e.RGBA,this.channelSize=n,this.textureType=a||e.FLOAT}encode(e,n){let a=e;return this.channelSize===1&&(tt.verbose("Encoder","Exploding into a larger array"),a=this.allocate(n),e.forEach((i,p)=>a[p*4]=i)),a}allocate(e){return new Float32Array(e*4)}decode(e,n){return this.channelSize===1?e.filter((a,i)=>i%4===0).subarray(0,n):e.subarray(0,n)}},En=class{constructor(e,n=1){if(this.channelSize=4,n===1)this.internalFormat=e.ALPHA,this.format=e.ALPHA,this.textureType=e.UNSIGNED_BYTE,this.channelSize=n;else if(n===4)this.internalFormat=e.RGBA,this.format=e.RGBA,this.textureType=e.UNSIGNED_BYTE,this.channelSize=n;else throw new Error(`Invalid number of channels: ${n}`)}encode(e,n){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}allocate(e){return new Uint8Array(e*this.channelSize)}decode(e,n){if(e instanceof Uint8Array)return e.subarray(0,n);throw new Error(`Invalid array type: ${e.constructor}`)}}}),Cr,ul,pi,ll=O(()=>{Y(),j(),Cr=(e,n,a)=>{let i=a===0||a===1?1:4,p=a===2,o=a===1||a===2,s=a===4?n.length-1:void 0,c=a===4?n.map((h,r)=>r===n.length-1?h*4:h):void 0;return pi(e,n,i,c,{isPacked:p,reverseWH:o,breakAxis:s})},ul=(e,n,a)=>{let i=Cr(e,n,a);return[i.width,i.height]},pi=(e,n,a=1,i,p)=>{let o=!!(p&&p.isPacked),[s,c]=e.computeTextureWH(o&&i||n,p),h=n.length,r=n.slice(0);if(h===0&&(r=[1]),a===1)i=n;else if(o){if(a!==4)throw new Error("a packed texture must be 4-channel");i=n,h>0&&(r[h-1]=Math.ceil(r[h-1]/2)),h>1&&(r[h-2]=Math.ceil(r[h-2]/2))}else if(!i)throw new Error("Unpacked shape is needed when using channels > 1");return{width:s,height:c,channels:a,isPacked:o,shape:r,strides:B.computeStrides(r),unpackedShape:i,reversedWH:p&&p.reverseWH}}}),Dh,Dn,cl=O(()=>{Ut(),We(),Y(),tl(),nl(),ol(),sl(),Fr(),ll(),j(),Dh=(e,n)=>{let a=n.map(p=>`${p.unpackedShape.join(",")};${p.width}x${p.height}`).join("_"),i=e.name;return e.cacheHint&&(i+="["+e.cacheHint+"]"),i+=":"+a,i},Dn=class{constructor(e){this.session=e,this.packedTextureDataCache=new Map,this.unpackedTextureDataCache=new Map}calculateTextureWidthAndHeight(e,n){return ul(this.session.layoutStrategy,e,n)}executeProgram(e,n){if(n.length<e.inputNames.length)throw new Error(`Input size mustn't be less than ${e.inputNames.length}.`);if(e.inputNames.length!==e.inputTypes.length)throw new Error("input names size does not match input types");let a=[];for(let h=0;h<e.inputNames.length;++h)a[h]=this.getOrCreateTextureData(n[h],e.inputTypes[h]);let i=Dh(e,a),p=this.session.programManager.getArtifact(i),o=p?p.programInfo:typeof e.get=="function"?e.get():e,s=Cr(this.session.layoutStrategy,o.output.dims,o.output.textureType),c=this.createTextureData(s,o.output.type);return p||(p=this.session.programManager.build(o,a,c),this.session.programManager.setArtifact(i,p)),this.runProgram(p,a,c),c}run(e,n){return this.executeProgram(e,n).tensor}runProgram(e,n,a){for(let i=0;i<n.length;++i)if(!!n[i].isPacked!=(e.programInfo.inputTypes[i]===2))throw new Error(`input[${i}] property packed inconsistent`);if(!!a.isPacked!=(e.programInfo.output.textureType===2))throw new Error("output property packed inconsistent");this.session.programManager.run(e,n,a)}getOrCreateTextureData(e,n){let a=this.getTextureData(e.dataId,n===2);if(!a&&(a=this.getTextureData(e.dataId,n!==2),a))return n===2?this.pack(a):this.unpack(a);if(!a){let i=Cr(this.session.layoutStrategy,e.dims,n);if(n===4){let p=e.dims;if(p.length===4){let o=[p[0],Math.ceil(p[1]*p[2]*p[3]/4)],s=Cr(this.session.layoutStrategy,o,n),c=e.numberData;if(p[1]*p[2]*p[3]%4!==0){let h=p[0],r=p[1]*p[2]*p[3],u=Math.ceil(r*1/4)*4,l=h*u;c=new Float32Array(l);for(let f=0;f<h;++f){let g=f*r,b=f*u+f%1*r;c.set(e.numberData.subarray(g,g+r),b)}}return this.createTextureData(s,e.type,c,e,1)}}if(n===2){let p=pi(this.session.layoutStrategy,e.dims,1,[],{reverseWH:!0}),o=this.createTextureData(p,e.type,e.numberData,e,1);a=this.pack(o)}else a=this.createTextureData(i,e.type,e.numberData,e,1)}return a}createTextureDataFromLayoutBindTensor(e,n,a,i){return this.createTextureData(e,n,a,i,1)}createTextureData(e,n,a,i,p){tt.verbose("InferenceHandler",`Creating TextureData: layout:[${JSON.stringify(e)}]`);let o=this.session.textureManager.createTextureFromLayout(n,e,a,p);return this.createTextureDataFromTexture(e,n,o,i)}reshapeUnpacked(e,n){let a=this.getOrCreateTextureData(e,0),i={channels:a.channels,height:a.height,width:a.width,shape:n.length!==0?n:[1],strides:B.computeStrides(n),unpackedShape:n};return this.createTextureDataFromTexture(i,e.type,a.texture).tensor}reshapePacked(e,n){let a=this.getOrCreateTextureData(e,2);if(rl(e.dims,n)){let c={channels:a.channels,height:a.height,width:a.width,shape:n.length!==0?n:[1],strides:B.computeStrides(n),unpackedShape:n,isPacked:!0};return this.createTextureDataFromTexture(c,e.type,a.texture).tensor}let i=fi(e.dims),p=fi(n),o=this.reshapePacked(e,i),s=this.run(el(this,o,p),[o]);return this.reshapePacked(s,n)}cast(e,n){let a=this.getOrCreateTextureData(e,0);return this.createTextureDataFromTexture(a,n,a.texture).tensor}createTextureDataFromTexture(e,n,a,i,p){let o={...e,tensor:i||new bt(e.unpackedShape,n,s=>this.readTexture(o),async s=>this.readTextureAsync(o),void 0,p),texture:a};return this.setTextureData(o.tensor.dataId,o,e.isPacked),o}getTextureData(e,n=!1){return this.session.isInitializer(e)?this.session.getTextureData(e,n):n?this.packedTextureDataCache.get(e):this.unpackedTextureDataCache.get(e)}setTextureData(e,n,a=!1){this.session.isInitializer(e)?this.session.setTextureData(e,n,a):(a?this.packedTextureDataCache:this.unpackedTextureDataCache).set(e,n)}isTextureLayoutCached(e,n=!1){return!!this.getTextureData(e.dataId,n)}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(ci(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(ci(this,e))}pack(e){return this.executeProgram(Qu(this,e.tensor),[e.tensor])}unpack(e){return this.executeProgram(al(this,e.tensor),[e.tensor])}}}),di,W,It=O(()=>{di=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}},W=e=>new di(e)}),pl,dl,hl,Lh,$h,ml=O(()=>{It(),ut(),j(),pl={name:"BatchNormalization",inputNames:["A","Scale","B","Mean","Variance"],inputTypes:[0,0,0,0,0]},dl=(e,n,a)=>($h(n),[e.run({...pl,cacheHint:a.cacheKey,get:()=>Lh(e,n,a)},n)]),hl=e=>{let n=e.attributes.getFloat("epsilon",1e-5),a=e.attributes.getFloat("momentum",.9),i=e.attributes.getInt("spatial",1);return W({epsilon:n,momentum:a,spatial:i})},Lh=(e,n,a)=>{let i=G(e.session.backend.glContext.version),p=n[0].dims.length,[o,s]=e.calculateTextureWidthAndHeight(n[1].dims,0),c=`
192
+ float process(int[${p}] indices) {
193
+ vec2 position = offsetToCoords(indices[1], ${o}, ${s});
194
194
  float scale = getColorAsFloat(${i.texture2D}(Scale, position));
195
195
  float mean = getColorAsFloat(${i.texture2D}(Mean, position));
196
196
  float variance = getColorAsFloat(${i.texture2D}(Variance, position));
197
197
  float b = getColorAsFloat(${i.texture2D}(B, position));
198
198
 
199
- return scale * ( (_A(indices) - mean) / sqrt(variance + float(${o.epsilon})) ) + b;
200
- }`;return{...pl,output:{dims:r[0].dims,type:r[0].type,textureType:0},shaderSource:d}},$h=t=>{if(!t||t.length!==5)throw new Error("BatchNormalization requires 5 inputs.");let r=t[0],o=t[1],i=t[2],u=t[3],n=t[4];if(r.dims.length<3||o.dims.length!==1||i.dims.length!==1||u.dims.length!==1||n.dims.length!==1)throw new Error("invalid input shape.");if(o.dims[0]!==r.dims[1]||i.dims[0]!==r.dims[1]||u.dims[0]!==r.dims[1]||n.dims[0]!==r.dims[1])throw new Error("invalid input shape.");if(r.type!=="float32"&&r.type!=="float64"||o.type!=="float32"&&o.type!=="float64"||i.type!=="float32"&&i.type!=="float64"||u.type!=="float32"&&u.type!=="float64"||n.type!=="float32"&&n.type!=="float64")throw new Error("invalid input tensor types.")}}),Ln,Ht,k$1,Nr,$n,Te=O(()=>{Ln=class{constructor(t,r,o,i){this.glContext=t,this.programInfo=r,this.inputTextureLayouts=o,this.outputTextureLayout=i}},Ht=class{constructor(t){this.context=t}},k$1=class{constructor(t,r){this.routineBody=t,this.dependencies=r}},Nr=class{constructor(t,r,o){this.name=t,o?this.dependencies=o:this.dependencies=[],r&&(this.routineBody=r)}addDependency(t){t&&this.dependencies.push(t)}},$n=class{static returnOrderedNodes(t){if(!t||t.length===0)return[];if(t.length===1)return t;let r=new Set,o=new Set,i=new Array;return this.createOrderedNodes(t,r,o,i),i}static createOrderedNodes(t,r,o,i){for(let u=0;u<t.length;++u)this.dfsTraverse(t[u],r,o,i)}static dfsTraverse(t,r,o,i){if(!t||o.has(t.name))return;if(r.has(t.name))throw new Error("Cyclic dependency detected. Can't topologically sort routines needed for shader.");r.add(t.name);let u=t.dependencies;if(u&&u.length>0)for(let n=0;n<u.length;++n)this.dfsTraverse(u[n],r,o,i);i.push(t),o.add(t.name),r.delete(t.name)}}});function Bh(){let t="add_";return{body:`
201
- float ${t}(float a, float b) {
199
+ return scale * ( (_A(indices) - mean) / sqrt(variance + float(${a.epsilon})) ) + b;
200
+ }`;return{...pl,output:{dims:n[0].dims,type:n[0].type,textureType:0},shaderSource:c}},$h=e=>{if(!e||e.length!==5)throw new Error("BatchNormalization requires 5 inputs.");let n=e[0],a=e[1],i=e[2],p=e[3],o=e[4];if(n.dims.length<3||a.dims.length!==1||i.dims.length!==1||p.dims.length!==1||o.dims.length!==1)throw new Error("invalid input shape.");if(a.dims[0]!==n.dims[1]||i.dims[0]!==n.dims[1]||p.dims[0]!==n.dims[1]||o.dims[0]!==n.dims[1])throw new Error("invalid input shape.");if(n.type!=="float32"&&n.type!=="float64"||a.type!=="float32"&&a.type!=="float64"||i.type!=="float32"&&i.type!=="float64"||p.type!=="float32"&&p.type!=="float64"||o.type!=="float32"&&o.type!=="float64")throw new Error("invalid input tensor types.")}}),Ln,Ht,k,Nr,$n,Te=O(()=>{Ln=class{constructor(e,n,a,i){this.glContext=e,this.programInfo=n,this.inputTextureLayouts=a,this.outputTextureLayout=i}},Ht=class{constructor(e){this.context=e}},k=class{constructor(e,n){this.routineBody=e,this.dependencies=n}},Nr=class{constructor(e,n,a){this.name=e,a?this.dependencies=a:this.dependencies=[],n&&(this.routineBody=n)}addDependency(e){e&&this.dependencies.push(e)}},$n=class{static returnOrderedNodes(e){if(!e||e.length===0)return[];if(e.length===1)return e;let n=new Set,a=new Set,i=new Array;return this.createOrderedNodes(e,n,a,i),i}static createOrderedNodes(e,n,a,i){for(let p=0;p<e.length;++p)this.dfsTraverse(e[p],n,a,i)}static dfsTraverse(e,n,a,i){if(!e||a.has(e.name))return;if(n.has(e.name))throw new Error("Cyclic dependency detected. Can't topologically sort routines needed for shader.");n.add(e.name);let p=e.dependencies;if(p&&p.length>0)for(let o=0;o<p.length;++o)this.dfsTraverse(p[o],n,a,i);i.push(e),a.add(e.name),n.delete(e.name)}}});function Bh(){let e="add_";return{body:`
201
+ float ${e}(float a, float b) {
202
202
  return a + b;
203
203
  }
204
- vec4 ${t}(vec4 v1, vec4 v2) {
204
+ vec4 ${e}(vec4 v1, vec4 v2) {
205
205
  return v1 + v2;
206
206
  }
207
- `,name:t,type:0}}function Fh(){let t="div_";return{body:`
208
- float ${t}(float a, float b) {
207
+ `,name:e,type:0}}function Fh(){let e="div_";return{body:`
208
+ float ${e}(float a, float b) {
209
209
  return a / b;
210
210
  }
211
- vec4 ${t}(vec4 v1, vec4 v2) {
211
+ vec4 ${e}(vec4 v1, vec4 v2) {
212
212
  return v1 / v2;
213
213
  }
214
- `,name:t,type:0}}function Ch(){let t="mul_";return{body:`
215
- float ${t}(float a, float b) {
214
+ `,name:e,type:0}}function Ch(){let e="mul_";return{body:`
215
+ float ${e}(float a, float b) {
216
216
  return a * b;
217
217
  }
218
- vec4 ${t}(vec4 v1, vec4 v2) {
218
+ vec4 ${e}(vec4 v1, vec4 v2) {
219
219
  return v1 * v2;
220
220
  }
221
- `,name:t,type:0}}function Nh(){let t="sub_";return{body:`
222
- float ${t}(float a, float b) {
221
+ `,name:e,type:0}}function Nh(){let e="sub_";return{body:`
222
+ float ${e}(float a, float b) {
223
223
  return a - b;
224
224
  }
225
- vec4 ${t}(vec4 v1, vec4 v2) {
225
+ vec4 ${e}(vec4 v1, vec4 v2) {
226
226
  return v1 - v2;
227
227
  }
228
- `,name:t,type:0}}function Rh(){let t="equal_";return{body:`
229
- float ${t}(float a, float b) {
228
+ `,name:e,type:0}}function Rh(){let e="equal_";return{body:`
229
+ float ${e}(float a, float b) {
230
230
  return float(a == b);
231
231
  }
232
- vec4 ${t}(vec4 v1, vec4 v2) {
232
+ vec4 ${e}(vec4 v1, vec4 v2) {
233
233
  return vec4(equal(v1, v2));
234
234
  }
235
- `,name:t,type:0}}function Gh(){let t="greater_";return{body:`
236
- float ${t}(float a, float b) {
235
+ `,name:e,type:0}}function Gh(){let e="greater_";return{body:`
236
+ float ${e}(float a, float b) {
237
237
  return float(a > b);
238
238
  }
239
- vec4 ${t}(vec4 v1, vec4 v2) {
239
+ vec4 ${e}(vec4 v1, vec4 v2) {
240
240
  return vec4( v1.r > v2.r ,
241
241
  v1.g > v2.g,
242
242
  v1.b > v2.b,
243
243
  v1.a > v2.a );
244
244
  }
245
- `,name:t,type:0}}function Mh(){let t="less_";return{body:`
246
- float ${t}(float a, float b) {
245
+ `,name:e,type:0}}function Mh(){let e="less_";return{body:`
246
+ float ${e}(float a, float b) {
247
247
  return float(a < b);
248
248
  }
249
- vec4 ${t}(vec4 v1, vec4 v2) {
249
+ vec4 ${e}(vec4 v1, vec4 v2) {
250
250
  return vec4( v1.r < v2.r ,
251
251
  v1.g < v2.g,
252
252
  v1.b < v2.b,
253
253
  v1.a < v2.a );
254
254
  }
255
- `,name:t,type:0}}function Uh(){let t="and_";return{body:`
256
- float ${t}(float a, float b) {
255
+ `,name:e,type:0}}function Uh(){let e="and_";return{body:`
256
+ float ${e}(float a, float b) {
257
257
  return float( bool(a) && bool(b) );
258
258
  }
259
- vec4 ${t}(vec4 v1, vec4 v2) {
259
+ vec4 ${e}(vec4 v1, vec4 v2) {
260
260
  bvec4 b1 = bvec4(v1);
261
261
  bvec4 b2 = bvec4(v2);
262
262
  return vec4( b1.r && b2.r ,
@@ -264,11 +264,11 @@
264
264
  b1.b && b2.b,
265
265
  b1.a && b2.a );
266
266
  }
267
- `,name:t,type:0}}function Vh(){let t="or_";return{body:`
268
- float ${t}(float a, float b) {
267
+ `,name:e,type:0}}function Vh(){let e="or_";return{body:`
268
+ float ${e}(float a, float b) {
269
269
  return float( bool(a) || bool(b) );
270
270
  }
271
- vec4 ${t}(vec4 v1, vec4 v2) {
271
+ vec4 ${e}(vec4 v1, vec4 v2) {
272
272
  bvec4 b1 = bvec4(v1);
273
273
  bvec4 b2 = bvec4(v2);
274
274
  return vec4( b1.r || b2.r ,
@@ -276,11 +276,11 @@
276
276
  b1.b || b2.b,
277
277
  b1.a || b2.a );
278
278
  }
279
- `,name:t,type:0}}function zh(){let t="xor_";return{body:`
280
- float ${t}(float a, float b) {
279
+ `,name:e,type:0}}function zh(){let e="xor_";return{body:`
280
+ float ${e}(float a, float b) {
281
281
  return float( bool(a) ^^ bool(b) );
282
282
  }
283
- vec4 ${t}(vec4 v1, vec4 v2) {
283
+ vec4 ${e}(vec4 v1, vec4 v2) {
284
284
  bvec4 b1 = bvec4(v1);
285
285
  bvec4 b2 = bvec4(v2);
286
286
  return vec4( b1.r ^^ b2.r ,
@@ -288,11 +288,11 @@
288
288
  b1.b ^^ b2.b,
289
289
  b1.a ^^ b2.a );
290
290
  }
291
- `,name:t,type:0}}function Wh(){return qh("pow")}function Hh(){let t="prelu_";return{body:`
292
- float ${t}(float a, float b) {
291
+ `,name:e,type:0}}function Wh(){return qh("pow")}function Hh(){let e="prelu_";return{body:`
292
+ float ${e}(float a, float b) {
293
293
  return a < 0.0 ? a * b: a;
294
294
  }
295
- vec4 ${t}(vec4 v1, vec4 v2) {
295
+ vec4 ${e}(vec4 v1, vec4 v2) {
296
296
  return vec4(
297
297
  v1.r < 0.0 ? v1.r * v2.r: v1.r,
298
298
  v1.g < 0.0 ? v1.g * v2.g: v1.g,
@@ -300,83 +300,83 @@
300
300
  v1.a < 0.0 ? v1.a * v2.a: v1.a
301
301
  );
302
302
  }
303
- `,name:t,type:0}}function qh(t){let r=`${t}_`;return{body:`
304
- float ${r}(float a, float b) {
305
- return ${t}(a, b);
303
+ `,name:e,type:0}}function qh(e){let n=`${e}_`;return{body:`
304
+ float ${n}(float a, float b) {
305
+ return ${e}(a, b);
306
306
  }
307
- vec4 ${r}(vec4 v1, vec4 v2) {
308
- return ${t}(v1, v2);
307
+ vec4 ${n}(vec4 v1, vec4 v2) {
308
+ return ${e}(v1, v2);
309
309
  }
310
- `,name:r,type:0}}var qt,jh,bl,gl,yl,xl,Tl,wl,vl,Il,_l,Ol,Sl,Al,Pl=O(()=>{Y(),Te(),ut(),j(),qt=(t,r,o,i=r[0].type,u)=>{let n=t.session.pack?2:0;return{name:o.name,inputNames:["A","B"],inputTypes:[n,n],cacheHint:u,get:()=>jh(t,r,o,i)}},jh=(t,r,o,i=r[0].type)=>{let u=t.session.pack?2:0,n=!B.areEqual(r[0].dims,r[1].dims),a=r[0].dims,d=t.session.pack;if(n){let l=kt.calcShape(r[0].dims,r[1].dims,!1);if(!l)throw new Error("Can't perform binary op on the given tensors");a=l;let s=a.length,h=r[0].dims.length!==0?r[0].dims.length:1,f=r[1].dims.length!==0?r[1].dims.length:1,m=r[0].dims.length!==0?"bcastIndices_A(indices, aindices);":"aindices[0] = 0;",v=r[1].dims.length!==0?"bcastIndices_B(indices, bindices);":"bindices[0] = 0;",_=G(t.session.backend.glContext.version),I=d?`
311
- ${o.body}
310
+ `,name:n,type:0}}var qt,jh,bl,gl,yl,xl,Tl,wl,vl,Il,_l,Ol,Sl,Al,Pl=O(()=>{Y(),Te(),ut(),j(),qt=(e,n,a,i=n[0].type,p)=>{let o=e.session.pack?2:0;return{name:a.name,inputNames:["A","B"],inputTypes:[o,o],cacheHint:p,get:()=>jh(e,n,a,i)}},jh=(e,n,a,i=n[0].type)=>{let p=e.session.pack?2:0,o=!B.areEqual(n[0].dims,n[1].dims),s=n[0].dims,c=e.session.pack;if(o){let u=kt.calcShape(n[0].dims,n[1].dims,!1);if(!u)throw new Error("Can't perform binary op on the given tensors");s=u;let l=s.length,f=n[0].dims.length!==0?n[0].dims.length:1,g=n[1].dims.length!==0?n[1].dims.length:1,b=n[0].dims.length!==0?"bcastIndices_A(indices, aindices);":"aindices[0] = 0;",v=n[1].dims.length!==0?"bcastIndices_B(indices, bindices);":"bindices[0] = 0;",S=G(e.session.backend.glContext.version),P=c?`
311
+ ${a.body}
312
312
  void main() {
313
313
  vec4 a = getAAtOutCoords();
314
314
  vec4 b = getBAtOutCoords();
315
- vec4 result = ${o.name}(a, b);
316
- ${_.output} = result;
315
+ vec4 result = ${a.name}(a, b);
316
+ ${S.output} = result;
317
317
  }`:`
318
- ${o.body}
319
- float process(int indices[${s}]) {
320
- int aindices[${h}];
321
- int bindices[${f}];
322
- ${m}
318
+ ${a.body}
319
+ float process(int indices[${l}]) {
320
+ int aindices[${f}];
321
+ int bindices[${g}];
322
+ ${b}
323
323
  ${v}
324
- return ${o.name}(_A(aindices), _B(bindices));
325
- }`;return{name:o.name,inputNames:["A","B"],inputTypes:[u,u],output:{dims:a,type:i,textureType:u},shaderSource:I,hasMain:d}}let c=G(t.session.backend.glContext.version),e=`
326
- ${o.body}
324
+ return ${a.name}(_A(aindices), _B(bindices));
325
+ }`;return{name:a.name,inputNames:["A","B"],inputTypes:[p,p],output:{dims:s,type:i,textureType:p},shaderSource:P,hasMain:c}}let h=G(e.session.backend.glContext.version),r=`
326
+ ${a.body}
327
327
  void main() {
328
- vec4 v1 = ${c.texture2D}(A, TexCoords);
329
- vec4 v2 = ${c.texture2D}(B, TexCoords);
330
- vec4 result = ${o.name}(v1, v2);
331
- ${c.output} = result;
328
+ vec4 v1 = ${h.texture2D}(A, TexCoords);
329
+ vec4 v2 = ${h.texture2D}(B, TexCoords);
330
+ vec4 result = ${a.name}(v1, v2);
331
+ ${h.output} = result;
332
332
  }
333
- `;return{name:o.name,inputNames:["A","B"],inputTypes:[u,u],output:{dims:r[0].dims,type:i,textureType:u},shaderSource:e,hasMain:!0}},bl=(t,r)=>[t.run(qt(t,r,Bh()),r)],gl=(t,r)=>[t.run(qt(t,r,Uh(),"bool"),r)],yl=(t,r)=>[t.run(qt(t,r,Fh()),r)],xl=(t,r)=>[t.run(qt(t,r,Rh(),"bool"),r)],Tl=(t,r)=>[t.run(qt(t,r,Gh(),"bool"),r)],wl=(t,r)=>[t.run(qt(t,r,Mh(),"bool"),r)],vl=(t,r)=>[t.run(qt(t,r,Ch()),r)],Il=(t,r)=>[t.run(qt(t,r,Vh(),"bool"),r)],_l=(t,r)=>[t.run(qt(t,r,Wh()),r)],Ol=(t,r)=>[t.run(qt(t,r,Hh()),r)],Sl=(t,r)=>[t.run(qt(t,r,Nh()),r)],Al=(t,r)=>[t.run(qt(t,r,zh(),"bool"),r)]}),El,Dl,Kh,Ll=O(()=>{Y(),El=(t,r,o)=>(Kh(r),[t.cast(r[0],o)]),Dl=t=>At.tensorDataTypeFromProto(t.attributes.getInt("to")),Kh=t=>{if(!t||t.length!==1)throw new Error("Cast requires 1 input.");if(t[0].type==="string")throw new Error("Invalid input type.")}}),Jh,Yh,$l,kn,kl=O(()=>{ut(),j(),pe(),He(),Jh=(t,r)=>({name:"Concat (packed)",inputNames:Array.from({length:t},(o,i)=>`X${i}`),inputTypes:Array(t).fill(2),cacheHint:r}),Yh=(t,r,o,i)=>{let u=o[0].dims.slice();if(i>=u.length||i<-1*u.length)throw new Error("axis specified for concat doesn't match input dimensionality");i<0&&(i=u.length+i);let n=u.slice(0);for(let V=1;V<o.length;V++){let gt=o[V].dims.slice();for(let pt=0;pt<u.length;pt++)if(pt===i)n[i]+=gt[pt];else if(u[pt]!==gt[pt])throw new Error("non concat dimensions must match")}let a=n.length,d=cr("coords",a),c=Bt(a),e=de(),l=o.map(V=>V.dims),s=ne(a),h=new Array(l.length-1);h[0]=l[0][i];for(let V=1;V<h.length;V++)h[V]=h[V-1]+l[V][i];let f=s[i],m=s.slice(-2),v=s.join(),_=`if (${f} < ${h[0]}) {
333
+ `;return{name:a.name,inputNames:["A","B"],inputTypes:[p,p],output:{dims:n[0].dims,type:i,textureType:p},shaderSource:r,hasMain:!0}},bl=(e,n)=>[e.run(qt(e,n,Bh()),n)],gl=(e,n)=>[e.run(qt(e,n,Uh(),"bool"),n)],yl=(e,n)=>[e.run(qt(e,n,Fh()),n)],xl=(e,n)=>[e.run(qt(e,n,Rh(),"bool"),n)],Tl=(e,n)=>[e.run(qt(e,n,Gh(),"bool"),n)],wl=(e,n)=>[e.run(qt(e,n,Mh(),"bool"),n)],vl=(e,n)=>[e.run(qt(e,n,Ch()),n)],Il=(e,n)=>[e.run(qt(e,n,Vh(),"bool"),n)],_l=(e,n)=>[e.run(qt(e,n,Wh()),n)],Ol=(e,n)=>[e.run(qt(e,n,Hh()),n)],Sl=(e,n)=>[e.run(qt(e,n,Nh()),n)],Al=(e,n)=>[e.run(qt(e,n,zh(),"bool"),n)]}),El,Dl,Kh,Ll=O(()=>{Y(),El=(e,n,a)=>(Kh(n),[e.cast(n[0],a)]),Dl=e=>At.tensorDataTypeFromProto(e.attributes.getInt("to")),Kh=e=>{if(!e||e.length!==1)throw new Error("Cast requires 1 input.");if(e[0].type==="string")throw new Error("Invalid input type.")}}),Jh,Yh,$l,kn,kl=O(()=>{ut(),j(),pe(),He(),Jh=(e,n)=>({name:"Concat (packed)",inputNames:Array.from({length:e},(a,i)=>`X${i}`),inputTypes:Array(e).fill(2),cacheHint:n}),Yh=(e,n,a,i)=>{let p=a[0].dims.slice();if(i>=p.length||i<-1*p.length)throw new Error("axis specified for concat doesn't match input dimensionality");i<0&&(i=p.length+i);let o=p.slice(0);for(let V=1;V<a.length;V++){let ft=a[V].dims.slice();for(let lt=0;lt<p.length;lt++)if(lt===i)o[i]+=ft[lt];else if(p[lt]!==ft[lt])throw new Error("non concat dimensions must match")}let s=o.length,c=cr("coords",s),h=Bt(s),r=de(),u=a.map(V=>V.dims),l=ne(s),f=new Array(u.length-1);f[0]=u[0][i];for(let V=1;V<f.length;V++)f[V]=f[V-1]+u[V][i];let g=l[i],b=l.slice(-2),v=l.join(),S=`if (${g} < ${f[0]}) {
334
334
  return getChannel(
335
- getX0(${v}), vec2(${m.join()}));
336
- }`;for(let V=1;V<h.length;V++){let gt=h[V-1];_+=`
337
- if (${f} < ${h[V]} && ${f} >= ${h[V-1]}) {
335
+ getX0(${v}), vec2(${b.join()}));
336
+ }`;for(let V=1;V<f.length;V++){let ft=f[V-1];S+=`
337
+ if (${g} < ${f[V]} && ${g} >= ${f[V-1]}) {
338
338
  return getChannel(
339
- getX${V}(${kn(s,f,gt)}),
340
- vec2(${kn(m,f,gt)}));
341
- }`}let I=h.length,T=h[h.length-1];_+=`
339
+ getX${V}(${kn(l,g,ft)}),
340
+ vec2(${kn(b,g,ft)}));
341
+ }`}let P=f.length,_=f[f.length-1];S+=`
342
342
  return getChannel(
343
- getX${I}(${kn(s,f,T)}),
344
- vec2(${kn(m,f,T)}));`;let P=G(t.session.backend.glContext.version),C=`
345
- ${e}
346
- float getValue(${s.map(V=>"int "+V)}) {
347
- ${_}
343
+ getX${P}(${kn(l,g,_)}),
344
+ vec2(${kn(b,g,_)}));`;let A=G(e.session.backend.glContext.version),L=`
345
+ ${r}
346
+ float getValue(${l.map(V=>"int "+V)}) {
347
+ ${S}
348
348
  }
349
349
 
350
350
  void main() {
351
- ${c} coords = getOutputCoords();
352
- int lastDim = coords.${s[a-1]};
353
- coords.${s[a-1]} = coords.${s[a-2]};
354
- coords.${s[a-2]} = lastDim;
351
+ ${h} coords = getOutputCoords();
352
+ int lastDim = coords.${l[s-1]};
353
+ coords.${l[s-1]} = coords.${l[s-2]};
354
+ coords.${l[s-2]} = lastDim;
355
355
 
356
- vec4 result = vec4(getValue(${d}), 0., 0., 0.);
356
+ vec4 result = vec4(getValue(${c}), 0., 0., 0.);
357
357
 
358
- ${d[a-1]} = ${d[a-1]} + 1;
359
- if (${d[a-1]} < ${n[a-1]}) {
360
- result.g = getValue(${d});
358
+ ${c[s-1]} = ${c[s-1]} + 1;
359
+ if (${c[s-1]} < ${o[s-1]}) {
360
+ result.g = getValue(${c});
361
361
  }
362
362
 
363
- ${d[a-2]} = ${d[a-2]} + 1;
364
- if (${d[a-2]} < ${n[a-2]}) {
365
- result.a = getValue(${d});
363
+ ${c[s-2]} = ${c[s-2]} + 1;
364
+ if (${c[s-2]} < ${o[s-2]}) {
365
+ result.a = getValue(${c});
366
366
  }
367
367
 
368
- ${d[a-1]} = ${d[a-1]} - 1;
369
- if (${d[a-2]} < ${n[a-2]} &&
370
- ${d[a-1]} < ${n[a-1]}) {
371
- result.b = getValue(${d});
368
+ ${c[s-1]} = ${c[s-1]} - 1;
369
+ if (${c[s-2]} < ${o[s-2]} &&
370
+ ${c[s-1]} < ${o[s-1]}) {
371
+ result.b = getValue(${c});
372
372
  }
373
- ${P.output} = result;
373
+ ${A.output} = result;
374
374
  }
375
- `;return{...r,output:{dims:n,type:o[0].type,textureType:2},shaderSource:C,hasMain:!0}},$l=(t,r,o)=>{let i=Jh(r.length,o.cacheKey);return{...i,get:()=>Yh(t,i,r,o.axis)}},kn=(t,r,o)=>{let i=t.indexOf(r);return t.map((u,n)=>n===i?`${u} - ${o}`:u).join()}}),Bl,Zh,Qh,tm,Fl,em,rm,nm,Cl,om,Nl=O(()=>{It(),j(),kl(),Bl=(t,r,o)=>(om(r),t.session.pack&&r[0].dims.length>1?[t.run($l(t,r,o),r)]:[t.run(tm(t,r,o),r)]),Zh=(t,r)=>({name:"Concat",inputNames:Array.from({length:t},(o,i)=>`X${i}`),inputTypes:Array(t).fill(0),cacheHint:r}),Qh=(t,r,o,i)=>{let u=o[0].dims.slice();if(i>=u.length||i<-1*u.length)throw new Error("axis specified for concat doesn't match input dimensionality");i<0&&(i=u.length+i);let n=u.slice(0);for(let f=1;f<o.length;f++){let m=o[f].dims.slice();for(let v=0;v<u.length;v++)if(v===i)n[i]+=m[v];else if(u[v]!==m[v])throw new Error("non concat dimensions must match")}let a=n.length,d=new Array(o.length),c=0;for(let f=0;f<d.length;++f)c+=o[f].dims[i],d[f]=c;let e="";o.length<5?e=Fl(d):e=em(d);let l=rm(o.length,a),s=nm(d),h=`
375
+ `;return{...n,output:{dims:o,type:a[0].type,textureType:2},shaderSource:L,hasMain:!0}},$l=(e,n,a)=>{let i=Jh(n.length,a.cacheKey);return{...i,get:()=>Yh(e,i,n,a.axis)}},kn=(e,n,a)=>{let i=e.indexOf(n);return e.map((p,o)=>o===i?`${p} - ${a}`:p).join()}}),Bl,Zh,Qh,tm,Fl,em,rm,nm,Cl,om,Nl=O(()=>{It(),j(),kl(),Bl=(e,n,a)=>(om(n),e.session.pack&&n[0].dims.length>1?[e.run($l(e,n,a),n)]:[e.run(tm(e,n,a),n)]),Zh=(e,n)=>({name:"Concat",inputNames:Array.from({length:e},(a,i)=>`X${i}`),inputTypes:Array(e).fill(0),cacheHint:n}),Qh=(e,n,a,i)=>{let p=a[0].dims.slice();if(i>=p.length||i<-1*p.length)throw new Error("axis specified for concat doesn't match input dimensionality");i<0&&(i=p.length+i);let o=p.slice(0);for(let g=1;g<a.length;g++){let b=a[g].dims.slice();for(let v=0;v<p.length;v++)if(v===i)o[i]+=b[v];else if(p[v]!==b[v])throw new Error("non concat dimensions must match")}let s=o.length,c=new Array(a.length),h=0;for(let g=0;g<c.length;++g)h+=a[g].dims[i],c[g]=h;let r="";a.length<5?r=Fl(c):r=em(c);let u=rm(a.length,s),l=nm(c),f=`
376
+ ${u}
376
377
  ${l}
377
- ${s}
378
- ${e}
379
- float process(int indices[${a}]) {
378
+ ${r}
379
+ float process(int indices[${s}]) {
380
380
  int textureIndex = getTextureWhereDataResides (indices[${i}]);
381
381
 
382
382
  if(textureIndex != 0) {
@@ -384,129 +384,129 @@
384
384
  }
385
385
 
386
386
  return fetchDataFromCorrectTexture(textureIndex, indices);
387
- }`;return{...r,output:{dims:n,type:o[0].type,textureType:0},shaderSource:h}},tm=(t,r,o)=>{let i=Zh(r.length,o.cacheKey);return{...i,get:()=>Qh(t,i,r,o.axis)}},Fl=t=>`int getTextureWhereDataResides(int index) {
388
- ${t.map((r,o)=>`if(index<${r}) {return ${o};}
387
+ }`;return{...n,output:{dims:o,type:a[0].type,textureType:0},shaderSource:f}},tm=(e,n,a)=>{let i=Zh(n.length,a.cacheKey);return{...i,get:()=>Qh(e,i,n,a.axis)}},Fl=e=>`int getTextureWhereDataResides(int index) {
388
+ ${e.map((n,a)=>`if(index<${n}) {return ${a};}
389
389
  `).join("")}
390
- }`,em=t=>Fl(t),rm=(t,r)=>{let o=[`float fetchDataFromCorrectTexture(int textureIndex, int indices[${r}]) {`];for(let i=0;i<t;++i)i===0?o.push(` if (textureIndex == ${i}) { return _X${i}(indices); }`):i===t-1?o.push(` else { return _X${i}(indices); }`):o.push(` else if (textureIndex == ${i}) { return _X${i}(indices); }`);return o.push(" }"),o.join(`
391
- `)},nm=t=>{let r=["int getSizeInConcatAxisValueFromIndex(int index) {"];for(let o=0;o<t.length;++o)o===0?r.push(` if (index == ${o}) { return ${t[o]}; }`):o===t.length-1?r.push(` else { return ${t[o]}; }`):r.push(` else if (index == ${o}) { return ${t[o]}; }`);return r.push(" }"),r.join(`
392
- `)},Cl=t=>W({axis:t.attributes.getInt("axis")}),om=t=>{if(!t||t.length<1)throw new Error("too few inputs");let r=t[0].type,o=t[0].dims.length;if(r==="string")throw new Error("string tensor is not supported yet");for(let i of t){if(i.type!==r)throw new Error("input tensors should be one type");if(i.dims.length!==o)throw new Error("input tensors should have the same shape")}}});function im(){return jt("abs")}function am(){return jt("acos")}function sm(){return jt("asin")}function um(){return jt("atan")}function lm(){return jt("ceil")}function fm(){return jt("cos")}function cm(t){let r="elu";return{body:`
393
- const float alpha = float(${t});
390
+ }`,em=e=>Fl(e),rm=(e,n)=>{let a=[`float fetchDataFromCorrectTexture(int textureIndex, int indices[${n}]) {`];for(let i=0;i<e;++i)i===0?a.push(` if (textureIndex == ${i}) { return _X${i}(indices); }`):i===e-1?a.push(` else { return _X${i}(indices); }`):a.push(` else if (textureIndex == ${i}) { return _X${i}(indices); }`);return a.push(" }"),a.join(`
391
+ `)},nm=e=>{let n=["int getSizeInConcatAxisValueFromIndex(int index) {"];for(let a=0;a<e.length;++a)a===0?n.push(` if (index == ${a}) { return ${e[a]}; }`):a===e.length-1?n.push(` else { return ${e[a]}; }`):n.push(` else if (index == ${a}) { return ${e[a]}; }`);return n.push(" }"),n.join(`
392
+ `)},Cl=e=>W({axis:e.attributes.getInt("axis")}),om=e=>{if(!e||e.length<1)throw new Error("too few inputs");let n=e[0].type,a=e[0].dims.length;if(n==="string")throw new Error("string tensor is not supported yet");for(let i of e){if(i.type!==n)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 im(){return jt("abs")}function am(){return jt("acos")}function sm(){return jt("asin")}function um(){return jt("atan")}function lm(){return jt("ceil")}function fm(){return jt("cos")}function cm(e){let n="elu";return{body:`
393
+ const float alpha = float(${e});
394
394
 
395
- float ${r}_(float a) {
395
+ float ${n}_(float a) {
396
396
  return a >= 0.0 ? a: (exp(a) - 1.0) * alpha;
397
397
  }
398
- vec4 ${r}_(vec4 v) {
399
- return vec4(${r}_(v.x), ${r}_(v.y), ${r}_(v.z), ${r}_(v.w));
398
+ vec4 ${n}_(vec4 v) {
399
+ return vec4(${n}_(v.x), ${n}_(v.y), ${n}_(v.z), ${n}_(v.w));
400
400
  }
401
- `,name:r,type:0}}function pm(){return jt("exp")}function dm(){return jt("floor")}function hi(t,r){let o="clip";return{body:`
402
- const float min = float(${t});
403
- const float max = float(${r});
401
+ `,name:n,type:0}}function pm(){return jt("exp")}function dm(){return jt("floor")}function hi(e,n){let a="clip";return{body:`
402
+ const float min = float(${e});
403
+ const float max = float(${n});
404
404
 
405
- float ${o}_(float a) {
405
+ float ${a}_(float a) {
406
406
  return clamp(a, min, max);
407
407
  }
408
- vec4 ${o}_(vec4 v) {
408
+ vec4 ${a}_(vec4 v) {
409
409
  return clamp(v, min, max);
410
410
  }
411
- `,name:o,type:0}}function hm(){let t="indentity";return{body:`
412
- float ${t}_(float a) {
411
+ `,name:a,type:0}}function hm(){let e="indentity";return{body:`
412
+ float ${e}_(float a) {
413
413
  return a;
414
414
  }
415
- vec4 ${t}_(vec4 v) {
415
+ vec4 ${e}_(vec4 v) {
416
416
  return v;
417
417
  }
418
- `,name:t,type:0}}function mm(t){let r="leakyRelu";return{body:`
419
- const float alpha = float(${t});
418
+ `,name:e,type:0}}function mm(e){let n="leakyRelu";return{body:`
419
+ const float alpha = float(${e});
420
420
 
421
- float ${r}_(float a) {
421
+ float ${n}_(float a) {
422
422
  return a < 0.0 ? a * alpha : a;
423
423
  }
424
- vec4 ${r}_(vec4 v) {
425
- return vec4(${r}_(v.x), ${r}_(v.y), ${r}_(v.z), ${r}_(v.w));
424
+ vec4 ${n}_(vec4 v) {
425
+ return vec4(${n}_(v.x), ${n}_(v.y), ${n}_(v.z), ${n}_(v.w));
426
426
  }
427
- `,name:r,type:0}}function bm(){return jt("log")}function gm(){let t="neg";return{body:`
428
- float ${t}_(float a) {
427
+ `,name:n,type:0}}function bm(){return jt("log")}function gm(){let e="neg";return{body:`
428
+ float ${e}_(float a) {
429
429
  return -a;
430
430
  }
431
- vec4 ${t}_(vec4 v) {
431
+ vec4 ${e}_(vec4 v) {
432
432
  return -v;
433
433
  }
434
- `,name:t,type:0}}function ym(){let t="not";return{body:`
435
- float ${t}_(float a) {
434
+ `,name:e,type:0}}function ym(){let e="not";return{body:`
435
+ float ${e}_(float a) {
436
436
  return float( ! bool(a) );
437
437
  }
438
- bool ${t}_(bool a) {
438
+ bool ${e}_(bool a) {
439
439
  return !a;
440
440
  }
441
- vec4 ${t}_(vec4 v) {
441
+ vec4 ${e}_(vec4 v) {
442
442
  return vec4(!bool(v.x), !bool(v.y), !bool(v.z), !bool(v.w));
443
443
  }
444
- bvec4 ${t}_(bvec4 v) {
444
+ bvec4 ${e}_(bvec4 v) {
445
445
  return bvec4(!v.x, !v.y, !v.z, !v.w);
446
446
  }
447
- `,name:t,type:0}}function xm(){return jt("sin")}function mi(){let t="relu";return{body:`
448
- float ${t}_(float a) {
447
+ `,name:e,type:0}}function xm(){return jt("sin")}function mi(){let e="relu";return{body:`
448
+ float ${e}_(float a) {
449
449
  return max( a, 0.0 );
450
450
  }
451
- vec4 ${t}_(vec4 v) {
451
+ vec4 ${e}_(vec4 v) {
452
452
  return max( v, 0.0 );
453
453
  }
454
- `,name:t,type:0}}function bi(){let t="sigmoid";return{body:`
455
- float ${t}_(float a) {
454
+ `,name:e,type:0}}function bi(){let e="sigmoid";return{body:`
455
+ float ${e}_(float a) {
456
456
  return 1.0 / (1.0 + exp(-a));
457
457
  }
458
- vec4 ${t}_(vec4 v) {
458
+ vec4 ${e}_(vec4 v) {
459
459
  return 1.0 / (1.0 + exp(-v));
460
460
  }
461
- `,name:t,type:0}}function Tm(){return jt("sqrt")}function wm(){return jt("tan")}function vm(){let t="tanh";return{body:`
462
- float ${t}_(float a) {
461
+ `,name:e,type:0}}function Tm(){return jt("sqrt")}function wm(){return jt("tan")}function vm(){let e="tanh";return{body:`
462
+ float ${e}_(float a) {
463
463
  a = clamp(a, -10., 10.);
464
464
  a = exp(2.*a);
465
465
  return (a - 1.) / (a + 1.);
466
466
  }
467
- vec4 ${t}_(vec4 v) {
467
+ vec4 ${e}_(vec4 v) {
468
468
  v = clamp(v, -10., 10.);
469
469
  v = exp(2.*v);
470
470
  return (v - 1.) / (v + 1.);
471
471
  }
472
- `,name:t,type:0}}function jt(t){return{body:`
473
- float ${t}_(float a) {
474
- return ${t}(a);
472
+ `,name:e,type:0}}function jt(e){return{body:`
473
+ float ${e}_(float a) {
474
+ return ${e}(a);
475
475
  }
476
- vec4 ${t}_(vec4 v) {
477
- return ${t}(v);
476
+ vec4 ${e}_(vec4 v) {
477
+ return ${e}(v);
478
478
  }
479
- `,name:t,type:0}}var Im,dt,Rl,Gl,Ml,Ul,gi,Vl,zl,_m,Wl,Hl,ql,jl,Xl,Kl,yi,Jl,Yl,Zl,Ql,tf,ef,rf,nf,of,af,sf,xi=O(()=>{It(),Y(),Te(),ut(),j(),Im=(t,r,o,i)=>{let u=t.session.pack?2:0,n=G(t.session.backend.glContext.version);return{...r,output:{dims:o.dims,type:o.type,textureType:u},shaderSource:`
479
+ `,name:e,type:0}}var Im,dt,Rl,Gl,Ml,Ul,gi,Vl,zl,_m,Wl,Hl,ql,jl,Xl,Kl,yi,Jl,Yl,Zl,Ql,tf,ef,rf,nf,of,af,sf,xi=O(()=>{It(),Y(),Te(),ut(),j(),Im=(e,n,a,i)=>{let p=e.session.pack?2:0,o=G(e.session.backend.glContext.version);return{...n,output:{dims:a.dims,type:a.type,textureType:p},shaderSource:`
480
480
  ${i.body}
481
481
  void main() {
482
- vec4 v = ${n.texture2D}(A, TexCoords);
482
+ vec4 v = ${o.texture2D}(A, TexCoords);
483
483
  v = ${i.name}_(v);
484
- ${n.output} = v;
484
+ ${o.output} = v;
485
485
  }
486
- `,hasMain:!0}},dt=(t,r,o,i)=>{let u=t.session.pack?2:0,n={name:o.name,inputTypes:[u],inputNames:["A"],cacheHint:i};return{...n,get:()=>Im(t,n,r,o)}},Rl=(t,r)=>[t.run(dt(t,r[0],im()),r)],Gl=(t,r)=>[t.run(dt(t,r[0],am()),r)],Ml=(t,r)=>[t.run(dt(t,r[0],sm()),r)],Ul=(t,r)=>[t.run(dt(t,r[0],um()),r)],gi=(t,r,o)=>[t.run(dt(t,r[0],hi(o.min,o.max),o.cacheKey),r)],Vl=t=>W({min:t.attributes.getFloat("min",Ve),max:t.attributes.getFloat("max",ze)}),zl=(t,r)=>{let o=_m(t,r);return gi(t,[r[0]],o)},_m=(t,r)=>{if(r.length>=3&&(!t.session.isInitializer(r[1].dataId)||!t.session.isInitializer(r[2].dataId)))throw new Error("dynamic clip attributes are not allowed");let o=r.length>=3?r[1].numberData[0]:Ve,i=r.length>=3?r[2].numberData[0]:ze;return W({min:o,max:i})},Wl=(t,r)=>[t.run(dt(t,r[0],lm()),r)],Hl=(t,r)=>[t.run(dt(t,r[0],fm()),r)],ql=(t,r,o)=>[t.run(dt(t,r[0],cm(o.alpha),o.cacheKey),r)],jl=t=>W({alpha:t.attributes.getFloat("alpha",1)}),Xl=(t,r)=>[t.run(dt(t,r[0],pm()),r)],Kl=(t,r)=>[t.run(dt(t,r[0],dm()),r)],yi=(t,r)=>[t.run(dt(t,r[0],hm()),r)],Jl=(t,r,o)=>[t.run(dt(t,r[0],mm(o.alpha),o.cacheKey),r)],Yl=t=>W({alpha:t.attributes.getFloat("alpha",.01)}),Zl=(t,r)=>[t.run(dt(t,r[0],bm()),r)],Ql=(t,r)=>[t.run(dt(t,r[0],gm()),r)],tf=(t,r)=>[t.run(dt(t,r[0],ym()),r)],ef=(t,r)=>[t.run(dt(t,r[0],mi()),r)],rf=(t,r)=>[t.run(dt(t,r[0],bi()),r)],nf=(t,r)=>[t.run(dt(t,r[0],xm()),r)],of=(t,r)=>[t.run(dt(t,r[0],Tm()),r)],af=(t,r)=>[t.run(dt(t,r[0],wm()),r)],sf=(t,r)=>[t.run(dt(t,r[0],vm()),r)]});function he(t){let r;switch(t.activation){case"Relu":r=mi();break;case"Sigmoid":r=bi();break;case"Clip":r=hi(t.clipMin,t.clipMax);break;default:return{activationFunction:"",applyActivation:""}}let o=r.name,i=r.body,u=`value = ${o}_(value);`;return{activationFunction:i,applyActivation:u}}var pr,qe=O(()=>{Y(),xi(),pr=t=>{let r=t.getString("activation","");if(r==="Clip"){let[o,i]=t.getFloats("activation_params",[Ve,ze]);return{activation:r,clipMax:i,clipMin:o,activationCacheKey:`${r}:${o},${i}`}}return{activation:r,activationCacheKey:r}}}),Sm,Am,uf,lf=O(()=>{Ut(),ut(),j(),Bn(),qe(),Sm=(t,r)=>({name:"GroupedConv",inputNames:t?["X","W","Bias"]:["X","W"],inputTypes:t?[0,0,0]:[0,0],cacheHint:r}),Am=(t,r,o,i)=>{let u=r.length>2?"value += getBias(output_channel);":"",n=r[0].dims.slice(),a=r[1].dims.slice(),d=a[0]/i.group;tt.verbose("GroupedConv",`autpPad:${i.autoPad}, dilations:${i.dilations}, group:${i.group}, kernelShape:${i.kernelShape}, pads:${i.pads}, strides:${i.strides}`);let c=dr(n,a,i.dilations,i.pads,i.strides),e=G(t.session.backend.glContext.version),{activationFunction:l,applyActivation:s}=he(i),h=`
486
+ `,hasMain:!0}},dt=(e,n,a,i)=>{let p=e.session.pack?2:0,o={name:a.name,inputTypes:[p],inputNames:["A"],cacheHint:i};return{...o,get:()=>Im(e,o,n,a)}},Rl=(e,n)=>[e.run(dt(e,n[0],im()),n)],Gl=(e,n)=>[e.run(dt(e,n[0],am()),n)],Ml=(e,n)=>[e.run(dt(e,n[0],sm()),n)],Ul=(e,n)=>[e.run(dt(e,n[0],um()),n)],gi=(e,n,a)=>[e.run(dt(e,n[0],hi(a.min,a.max),a.cacheKey),n)],Vl=e=>W({min:e.attributes.getFloat("min",Ve),max:e.attributes.getFloat("max",ze)}),zl=(e,n)=>{let a=_m(e,n);return gi(e,[n[0]],a)},_m=(e,n)=>{if(n.length>=3&&(!e.session.isInitializer(n[1].dataId)||!e.session.isInitializer(n[2].dataId)))throw new Error("dynamic clip attributes are not allowed");let a=n.length>=3?n[1].numberData[0]:Ve,i=n.length>=3?n[2].numberData[0]:ze;return W({min:a,max:i})},Wl=(e,n)=>[e.run(dt(e,n[0],lm()),n)],Hl=(e,n)=>[e.run(dt(e,n[0],fm()),n)],ql=(e,n,a)=>[e.run(dt(e,n[0],cm(a.alpha),a.cacheKey),n)],jl=e=>W({alpha:e.attributes.getFloat("alpha",1)}),Xl=(e,n)=>[e.run(dt(e,n[0],pm()),n)],Kl=(e,n)=>[e.run(dt(e,n[0],dm()),n)],yi=(e,n)=>[e.run(dt(e,n[0],hm()),n)],Jl=(e,n,a)=>[e.run(dt(e,n[0],mm(a.alpha),a.cacheKey),n)],Yl=e=>W({alpha:e.attributes.getFloat("alpha",.01)}),Zl=(e,n)=>[e.run(dt(e,n[0],bm()),n)],Ql=(e,n)=>[e.run(dt(e,n[0],gm()),n)],tf=(e,n)=>[e.run(dt(e,n[0],ym()),n)],ef=(e,n)=>[e.run(dt(e,n[0],mi()),n)],rf=(e,n)=>[e.run(dt(e,n[0],bi()),n)],nf=(e,n)=>[e.run(dt(e,n[0],xm()),n)],of=(e,n)=>[e.run(dt(e,n[0],Tm()),n)],af=(e,n)=>[e.run(dt(e,n[0],wm()),n)],sf=(e,n)=>[e.run(dt(e,n[0],vm()),n)]});function he(e){let n;switch(e.activation){case"Relu":n=mi();break;case"Sigmoid":n=bi();break;case"Clip":n=hi(e.clipMin,e.clipMax);break;default:return{activationFunction:"",applyActivation:""}}let a=n.name,i=n.body,p=`value = ${a}_(value);`;return{activationFunction:i,applyActivation:p}}var pr,qe=O(()=>{Y(),xi(),pr=e=>{let n=e.getString("activation","");if(n==="Clip"){let[a,i]=e.getFloats("activation_params",[Ve,ze]);return{activation:n,clipMax:i,clipMin:a,activationCacheKey:`${n}:${a},${i}`}}return{activation:n,activationCacheKey:n}}}),Sm,Am,uf,lf=O(()=>{Ut(),ut(),j(),Bn(),qe(),Sm=(e,n)=>({name:"GroupedConv",inputNames:e?["X","W","Bias"]:["X","W"],inputTypes:e?[0,0,0]:[0,0],cacheHint:n}),Am=(e,n,a,i)=>{let p=n.length>2?"value += getBias(output_channel);":"",o=n[0].dims.slice(),s=n[1].dims.slice(),c=s[0]/i.group;tt.verbose("GroupedConv",`autpPad:${i.autoPad}, dilations:${i.dilations}, group:${i.group}, kernelShape:${i.kernelShape}, pads:${i.pads}, strides:${i.strides}`);let h=dr(o,s,i.dilations,i.pads,i.strides),r=G(e.session.backend.glContext.version),{activationFunction:u,applyActivation:l}=he(i),f=`
487
487
  const ivec2 strides = ivec2(${i.strides[0]}, ${i.strides[1]});
488
488
  const ivec2 pads = ivec2(${i.pads[0]}, ${i.pads[1]});
489
- ${l}
489
+ ${u}
490
490
  void main() {
491
491
  ivec4 coords = getOutputCoords();
492
492
  int batch = coords.x;
493
493
  int output_channel = coords.y;
494
494
  ivec2 xRCCorner = coords.zw * strides - pads;
495
- int group_id = output_channel / ${d};
495
+ int group_id = output_channel / ${c};
496
496
 
497
497
  float value = 0.0;
498
- for (int wInChannel = 0; wInChannel < ${a[1]}; wInChannel++) {
499
- int input_channel = group_id * ${a[1]} + wInChannel;
500
- for (int wHeight = 0; wHeight < ${a[2]}; wHeight++) {
498
+ for (int wInChannel = 0; wInChannel < ${s[1]}; wInChannel++) {
499
+ int input_channel = group_id * ${s[1]} + wInChannel;
500
+ for (int wHeight = 0; wHeight < ${s[2]}; wHeight++) {
501
501
  int xHeight = xRCCorner.x + wHeight * ${i.dilations[0]};
502
502
 
503
- if (xHeight < 0 || xHeight >= ${n[2]}) {
503
+ if (xHeight < 0 || xHeight >= ${o[2]}) {
504
504
  continue;
505
505
  }
506
506
 
507
- for (int wWidth = 0; wWidth < ${a[3]}; wWidth++) {
507
+ for (int wWidth = 0; wWidth < ${s[3]}; wWidth++) {
508
508
  int xWidth = xRCCorner.y + wWidth * ${i.dilations[1]};
509
- if (xWidth < 0 || xWidth >= ${n[3]}) {
509
+ if (xWidth < 0 || xWidth >= ${o[3]}) {
510
510
  continue;
511
511
  }
512
512
 
@@ -516,37 +516,37 @@
516
516
  }
517
517
  }
518
518
  }
519
- ${u}
520
- ${s}
521
- ${e.output} = vec4(value, .0, .0, .0);
519
+ ${p}
520
+ ${l}
521
+ ${r.output} = vec4(value, .0, .0, .0);
522
522
  }
523
- `;return{...o,output:{dims:c,type:r[0].type,textureType:0},shaderSource:h,hasMain:!0}},uf=(t,r,o)=>{let i=Sm(r.length>2,o.cacheKey);return{...i,get:()=>Am(t,r,i,o)}}}),Pm,Em,ff,cf=O(()=>{ut(),j(),He(),Pm=t=>({name:"Im2Col (packed)",inputNames:["A"],inputTypes:[2],cacheHint:t}),Em=(t,r,o,i,u,n)=>{let a=o.dims,d=i.dims,c=2,e=3,l=u.length,s=[d[1]*d[2]*d[3],u[2]*u[3]],h=d[2]*d[3],f=de(),m=G(t.session.backend.glContext.version),v="";for(let I=0;I<=1;I++)for(let T=0;T<=1;T++)v+=`
524
- blockIndex = rc.x + ${T};
525
- pos = rc.y + ${I};
523
+ `;return{...a,output:{dims:h,type:n[0].type,textureType:0},shaderSource:f,hasMain:!0}},uf=(e,n,a)=>{let i=Sm(n.length>2,a.cacheKey);return{...i,get:()=>Am(e,n,i,a)}}}),Pm,Em,ff,cf=O(()=>{ut(),j(),He(),Pm=e=>({name:"Im2Col (packed)",inputNames:["A"],inputTypes:[2],cacheHint:e}),Em=(e,n,a,i,p,o)=>{let s=a.dims,c=i.dims,h=2,r=3,u=p.length,l=[c[1]*c[2]*c[3],p[2]*p[3]],f=c[2]*c[3],g=de(),b=G(e.session.backend.glContext.version),v="";for(let P=0;P<=1;P++)for(let _=0;_<=1;_++)v+=`
524
+ blockIndex = rc.x + ${_};
525
+ pos = rc.y + ${P};
526
526
 
527
- if(blockIndex < ${s[1]} && pos < ${s[0]}) {
528
- offsetY = int(blockIndex / (${u[l-1]})) * ${n.strides[0]} -
529
- ${n.pads[0]};
530
- d0 = offsetY + ${n.dilations[0]} * (imod(pos, ${h}) / ${d[2]});
527
+ if(blockIndex < ${l[1]} && pos < ${l[0]}) {
528
+ offsetY = int(blockIndex / (${p[u-1]})) * ${o.strides[0]} -
529
+ ${o.pads[0]};
530
+ d0 = offsetY + ${o.dilations[0]} * (imod(pos, ${f}) / ${c[2]});
531
531
 
532
- if(d0 < ${a[c]} && d0 >= 0) {
533
- offsetX = imod(blockIndex, ${u[l-1]}) * ${n.strides[1]} -
534
- ${n.pads[1]};
535
- d1 = offsetX + ${n.dilations[1]} * imod(imod(pos, ${h}), ${d[2]});
532
+ if(d0 < ${s[h]} && d0 >= 0) {
533
+ offsetX = imod(blockIndex, ${p[u-1]}) * ${o.strides[1]} -
534
+ ${o.pads[1]};
535
+ d1 = offsetX + ${o.dilations[1]} * imod(imod(pos, ${f}), ${c[2]});
536
536
 
537
- if(d1 < ${a[e]} && d1 >= 0) {
537
+ if(d1 < ${s[r]} && d1 >= 0) {
538
538
 
539
- ch = int(float(pos)/ ${h}.);
539
+ ch = int(float(pos)/ ${f}.);
540
540
  innerDims = vec2(d0, d1);
541
- result[${I*2+T}] = getChannel(
541
+ result[${P*2+_}] = getChannel(
542
542
  getA(0, ch, int(innerDims.x),
543
543
  int(innerDims.y)), innerDims);
544
544
  }
545
545
  }
546
546
  }
547
547
 
548
- `;let _=`
549
- ${f}
548
+ `;let S=`
549
+ ${g}
550
550
 
551
551
  void main() {
552
552
  ivec2 rc = getOutputCoords();
@@ -554,94 +554,94 @@
554
554
  int blockIndex, pos, offsetY, d0, offsetX, d1, ch;
555
555
  vec2 innerDims;
556
556
  ${v}
557
- ${m.output} = result;
557
+ ${b.output} = result;
558
558
  }
559
- `;return{...r,output:{dims:s,type:o.type,textureType:2},shaderSource:_,hasMain:!0}},ff=(t,r,o,i,u)=>{let n=Pm(u.cacheKey);return{...n,get:()=>Em(t,n,r,o,i,u)}}});function Lm(t,r,o){let i=r[0].dims,u=r[1].dims,n=kt.calcShape(i,u,!0);if(!n)throw new Error("Can't use matmul on the given tensors");let a=Bt(n.length),d=ne(),{activationFunction:c,applyActivation:e}=he(o),l=r.length>2,s=l?"value += getBiasForMatmul();":"",h=l?`${wi(a,d,r[2].dims,n,!1)}`:"",f=n.length,m=i.length,v=u.length,_=i[i.length-1],I=`
560
- ${c}
559
+ `;return{...n,output:{dims:l,type:a.type,textureType:2},shaderSource:S,hasMain:!0}},ff=(e,n,a,i,p)=>{let o=Pm(p.cacheKey);return{...o,get:()=>Em(e,o,n,a,i,p)}}});function Lm(e,n,a){let i=n[0].dims,p=n[1].dims,o=kt.calcShape(i,p,!0);if(!o)throw new Error("Can't use matmul on the given tensors");let s=Bt(o.length),c=ne(),{activationFunction:h,applyActivation:r}=he(a),u=n.length>2,l=u?"value += getBiasForMatmul();":"",f=u?`${wi(s,c,n[2].dims,o,!1)}`:"",g=o.length,b=i.length,v=p.length,S=i[i.length-1],P=`
561
560
  ${h}
562
- float process(int indices[${f}]) {
563
- int a[${m}];
561
+ ${f}
562
+ float process(int indices[${g}]) {
563
+ int a[${b}];
564
564
  int b[${v}];
565
565
  bcastMatmulIndices_A(indices, a);
566
566
  bcastMatmulIndices_B(indices, b);
567
567
 
568
568
  float value;
569
- for (int k=0; k<${_}; ++k) {
570
- a[${m-1}] = k;
569
+ for (int k=0; k<${S}; ++k) {
570
+ a[${b-1}] = k;
571
571
  b[${v-2}] = k;
572
572
  value += _A(a) * _B(b);
573
573
  }
574
- ${s}
575
- ${e}
574
+ ${l}
575
+ ${r}
576
576
  return value;
577
- }`;return{...t,output:{dims:n,type:r[0].type,textureType:0},shaderSource:I}}function Ti(t,r){let o=Dm(t.length>2,r.activationCacheKey);return{...o,get:()=>Lm(o,t,r)}}function wi(t,r,o,i,u){let n="",a=o.length,d=i.length,c=d-a;d<2&&a>0?n="coords":n=o.map((h,f)=>`coords.${r[f+c]}`).join(", ");let e=kt.getBroadcastDims(o,i).map(h=>`coords.${r[h+c]} = 0;`).join(`
578
- `),l=B.size(o)===1,s="vec4(outputValue.xx, outputValue.yy)";return l&&(s="vec4(outputValue.x)"),u?`
577
+ }`;return{...e,output:{dims:o,type:n[0].type,textureType:0},shaderSource:P}}function Ti(e,n){let a=Dm(e.length>2,n.activationCacheKey);return{...a,get:()=>Lm(a,e,n)}}function wi(e,n,a,i,p){let o="",s=a.length,c=i.length,h=c-s;c<2&&s>0?o="coords":o=a.map((f,g)=>`coords.${n[g+h]}`).join(", ");let r=kt.getBroadcastDims(a,i).map(f=>`coords.${n[f+h]} = 0;`).join(`
578
+ `),u=B.size(a)===1,l="vec4(outputValue.xx, outputValue.yy)";return u&&(l="vec4(outputValue.x)"),p?`
579
579
  vec4 getBiasForMatmul() {
580
- ${t} coords = getOutputCoords();
581
- ${e}
582
- vec4 outputValue = getBias(${n});
583
- return ${s};
580
+ ${e} coords = getOutputCoords();
581
+ ${r}
582
+ vec4 outputValue = getBias(${o});
583
+ return ${l};
584
584
  }`:`
585
585
  float getBiasForMatmul() {
586
- ${t} coords = getOutputCoords();
587
- ${e}
586
+ ${e} coords = getOutputCoords();
587
+ ${r}
588
588
  return getBias(coords.x);
589
- }`}var pf,df,Dm,$m,Fn=O(()=>{Y(),j(),pe(),qe(),vi(),pf=(t,r,o)=>($m(r),t.session.pack?[t.run(Cn(t,r,o),r)]:[t.run(Ti(r,o),r)]),df=t=>pr(t.attributes),Dm=(t,r)=>({name:"MatMul",inputNames:t?["A","B","Bias"]:["A","B"],inputTypes:t?[0,0,0]:[0,0],cacheHint:r}),$m=t=>{if(!t||t.length!==2)throw new Error("MatMul requires 2 inputs.");if(t[0].dims[t[0].dims.length-1]!==t[1].dims[t[1].dims.length-2])throw new Error("shared dimension does not match.");if(t[0].type!=="float32"&&t[0].type!=="float64"||t[1].type!=="float32"&&t[1].type!=="float64")throw new Error("inputs should be float type");if(t[0].type!==t[1].type)throw new Error("inputs types should match")}});function Fm(t,r,o,i){let u=[],n=[],a=o[0].dims,d=o[1].dims,c=a.length,e=d.length,l=i.length,s=l-c,h=l-e;u=a.map((T,P)=>`coords.${r[P+s]}`),u[c-1]="i*2",u.join(", "),n=d.map((T,P)=>`coords.${r[P+h]}`),n[e-2]="i*2",n.join(", ");let f=kt.getBroadcastDims(a,i),m=kt.getBroadcastDims(d,i),v=f.map(T=>`coords.${r[T+s]} = 0;`).join(`
590
- `),_=m.map(T=>`coords.${r[T+h]} = 0;`).join(`
591
- `),I=`int lastDim = coords.${r[l-1]};
592
- coords.${r[l-1]} = coords.${r[l-2]};
593
- coords.${r[l-2]} = lastDim;`;return`
589
+ }`}var pf,df,Dm,$m,Fn=O(()=>{Y(),j(),pe(),qe(),vi(),pf=(e,n,a)=>($m(n),e.session.pack?[e.run(Cn(e,n,a),n)]:[e.run(Ti(n,a),n)]),df=e=>pr(e.attributes),Dm=(e,n)=>({name:"MatMul",inputNames:e?["A","B","Bias"]:["A","B"],inputTypes:e?[0,0,0]:[0,0],cacheHint:n}),$m=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 Fm(e,n,a,i){let p=[],o=[],s=a[0].dims,c=a[1].dims,h=s.length,r=c.length,u=i.length,l=u-h,f=u-r;p=s.map((_,A)=>`coords.${n[A+l]}`),p[h-1]="i*2",p.join(", "),o=c.map((_,A)=>`coords.${n[A+f]}`),o[r-2]="i*2",o.join(", ");let g=kt.getBroadcastDims(s,i),b=kt.getBroadcastDims(c,i),v=g.map(_=>`coords.${n[_+l]} = 0;`).join(`
590
+ `),S=b.map(_=>`coords.${n[_+f]} = 0;`).join(`
591
+ `),P=`int lastDim = coords.${n[u-1]};
592
+ coords.${n[u-1]} = coords.${n[u-2]};
593
+ coords.${n[u-2]} = lastDim;`;return`
594
594
  vec4 getAAtOutCoordsMatmul(int i) {
595
- ${t} coords = getOutputCoords();
596
- ${I}
595
+ ${e} coords = getOutputCoords();
596
+ ${P}
597
597
  ${v}
598
- vec4 outputValue = getA(${u});
598
+ vec4 outputValue = getA(${p});
599
599
  return outputValue;
600
600
  }
601
601
 
602
602
  vec4 getBAtOutCoordsMatmul(int i) {
603
- ${t} coords = getOutputCoords();
604
- ${I}
605
- ${_}
606
- vec4 outputValue = getB(${n});
603
+ ${e} coords = getOutputCoords();
604
+ ${P}
605
+ ${S}
606
+ vec4 outputValue = getB(${o});
607
607
  return outputValue;
608
- }`}function Cm(t,r){let o="";for(let i=0;i<r-2;i++)o+=`rc.${t[i]}, `;return o+=`rc.${t[r-2]}, i*2`,o}function Nm(t,r){let o="";for(let i=0;i<r-2;i++)o+=`rc.${t[i]}, `;return o+=`i*2, rc.${t[r-1]}`,o}var km,Bm,Cn,vi=O(()=>{Y(),ut(),j(),pe(),qe(),Fn(),km=(t,r)=>({name:"MatMul (packed)",inputNames:t?["A","B","Bias"]:["A","B"],inputTypes:t?[2,2,2]:[2,2],cacheHint:r}),Bm=(t,r,o,i)=>{let u=o.length>2,n=u?"value += getBiasForMatmul();":"",a=o[0].dims,d=o[1].dims,c=kt.calcShape(a,d,!0),e=!B.areEqual(o[0].dims,o[1].dims);if(!c)throw new Error("Can't use matmul on the given tensors");let l=a[a.length-1],s=Math.ceil(l/2),h=a.length,f=d.length,m=G(t.session.backend.glContext.version),v=Bt(c.length),_=c.length,I=ne(),{activationFunction:T,applyActivation:P}=he(i),C=u?`${wi(v,I,o[2].dims,c,!0)}`:"",V=e?`${Fm(v,I,o,c)}`:"",gt=e?"getAAtOutCoordsMatmul(i)":`getA(${Cm(I,h)})`,pt=e?"getBAtOutCoordsMatmul(i)":`getB(${Nm(I,f)})`,Ft=e?"":`${v} rc =
609
- getOutputCoords(); int lastDim = rc.${I[_-1]}; rc.${I[_-1]} =
610
- rc.${I[_-2]}; rc.${I[_-2]} = lastDim;
611
- `,et=`
608
+ }`}function Cm(e,n){let a="";for(let i=0;i<n-2;i++)a+=`rc.${e[i]}, `;return a+=`rc.${e[n-2]}, i*2`,a}function Nm(e,n){let a="";for(let i=0;i<n-2;i++)a+=`rc.${e[i]}, `;return a+=`i*2, rc.${e[n-1]}`,a}var km,Bm,Cn,vi=O(()=>{Y(),ut(),j(),pe(),qe(),Fn(),km=(e,n)=>({name:"MatMul (packed)",inputNames:e?["A","B","Bias"]:["A","B"],inputTypes:e?[2,2,2]:[2,2],cacheHint:n}),Bm=(e,n,a,i)=>{let p=a.length>2,o=p?"value += getBiasForMatmul();":"",s=a[0].dims,c=a[1].dims,h=kt.calcShape(s,c,!0),r=!B.areEqual(a[0].dims,a[1].dims);if(!h)throw new Error("Can't use matmul on the given tensors");let u=s[s.length-1],l=Math.ceil(u/2),f=s.length,g=c.length,b=G(e.session.backend.glContext.version),v=Bt(h.length),S=h.length,P=ne(),{activationFunction:_,applyActivation:A}=he(i),L=p?`${wi(v,P,a[2].dims,h,!0)}`:"",V=r?`${Fm(v,P,a,h)}`:"",ft=r?"getAAtOutCoordsMatmul(i)":`getA(${Cm(P,f)})`,lt=r?"getBAtOutCoordsMatmul(i)":`getB(${Nm(P,g)})`,Nt=r?"":`${v} rc =
609
+ getOutputCoords(); int lastDim = rc.${P[S-1]}; rc.${P[S-1]} =
610
+ rc.${P[S-2]}; rc.${P[S-2]} = lastDim;
611
+ `,Q=`
612
612
  ${V}
613
- ${C}
614
- ${T}
613
+ ${L}
614
+ ${_}
615
615
  void main() {
616
- ${Ft}
616
+ ${Nt}
617
617
 
618
618
  vec4 value = vec4(0);
619
- for (int i = 0; i < ${s}; i++) {
620
- vec4 a = ${gt};
621
- vec4 b = ${pt};
619
+ for (int i = 0; i < ${l}; i++) {
620
+ vec4 a = ${ft};
621
+ vec4 b = ${lt};
622
622
 
623
623
  value += (a.rrbb * b.rgrg);
624
624
  value += (a.ggaa * b.baba);
625
625
  }
626
- ${n}
627
- ${P}
628
- ${m.output} = value;
629
- }`;return{...r,output:{dims:c,type:o[0].type,textureType:2},shaderSource:et,hasMain:!0}},Cn=(t,r,o)=>{let i=km(r.length>2,o.activationCacheKey);return{...i,get:()=>Bm(t,i,r,o)}}}),hf,mf=O(()=>{Bn(),cf(),vi(),hf=(t,r,o)=>{let i=r[0].dims,u=r[1].dims,n=dr(i,u,o.dilations,o.pads,o.strides),a=t.run(ff(t,r[0],r[1],n,o),[r[0]]),d=t.reshapePacked(r[1],[u[0],u[1]*u[2]*u[3]]),c=r.length===3?[d,a,r[2]]:[d,a],e=t.run(Cn(t,c,o),c);return t.reshapePacked(e,n)}}),Rm,Gm,bf,Ii,_i=O(()=>{j(),Rm=t=>({name:"Im2Col",inputNames:["X"],inputTypes:[0],cacheHint:t}),Gm=(t,r,o,i,u,n)=>{let a=o.dims,d=i.dims,c=u.length,e=Ii(a,d,u,4),l=`
630
- const int XC = ${a[1]};
631
- const int XH = ${a[2]};
632
- const int XW = ${a[3]};
633
- const int KH = ${n.kernelShape[0]};
634
- const int KW = ${n.kernelShape[1]};
635
- const int dilationH = ${n.dilations[0]};
636
- const int dilationW = ${n.dilations[1]};
637
- const int strideH = ${n.strides[0]};
638
- const int strideW = ${n.strides[1]};
639
- const int padH = ${n.pads[0]};
640
- const int padW = ${n.pads[1]};
626
+ ${o}
627
+ ${A}
628
+ ${b.output} = value;
629
+ }`;return{...n,output:{dims:h,type:a[0].type,textureType:2},shaderSource:Q,hasMain:!0}},Cn=(e,n,a)=>{let i=km(n.length>2,a.activationCacheKey);return{...i,get:()=>Bm(e,i,n,a)}}}),hf,mf=O(()=>{Bn(),cf(),vi(),hf=(e,n,a)=>{let i=n[0].dims,p=n[1].dims,o=dr(i,p,a.dilations,a.pads,a.strides),s=e.run(ff(e,n[0],n[1],o,a),[n[0]]),c=e.reshapePacked(n[1],[p[0],p[1]*p[2]*p[3]]),h=n.length===3?[c,s,n[2]]:[c,s],r=e.run(Cn(e,h,a),h);return e.reshapePacked(r,o)}}),Rm,Gm,bf,Ii,_i=O(()=>{j(),Rm=e=>({name:"Im2Col",inputNames:["X"],inputTypes:[0],cacheHint:e}),Gm=(e,n,a,i,p,o)=>{let s=a.dims,c=i.dims,h=p.length,r=Ii(s,c,p,4),u=`
630
+ const int XC = ${s[1]};
631
+ const int XH = ${s[2]};
632
+ const int XW = ${s[3]};
633
+ const int KH = ${o.kernelShape[0]};
634
+ const int KW = ${o.kernelShape[1]};
635
+ const int dilationH = ${o.dilations[0]};
636
+ const int dilationW = ${o.dilations[1]};
637
+ const int strideH = ${o.strides[0]};
638
+ const int strideW = ${o.strides[1]};
639
+ const int padH = ${o.pads[0]};
640
+ const int padW = ${o.pads[1]};
641
641
  const int KHKW = KH*KW;
642
642
  const int XCKHKW = XC * KHKW;
643
643
  const int outputChannels = 4;
644
- vec4 process(int indices[${c}]) {
644
+ vec4 process(int indices[${h}]) {
645
645
  int b = indices[0]; // batch size
646
646
  int oh = indices[1] * strideH - padH; //output height
647
647
  int ow = indices[2] * strideW - padW; //output width
@@ -654,7 +654,7 @@ vec4 getBAtOutCoordsMatmul(int i) {
654
654
  int patchW = (p - patchC*KHKW) - patchH * KW;
655
655
  int xh2 = oh + patchH * dilationH;
656
656
  int xw2 = ow + patchW * dilationW;
657
- int x[${a.length}];
657
+ int x[${s.length}];
658
658
  x[0] = b;
659
659
  x[1] = patchC;
660
660
  x[2] = xh2;
@@ -670,31 +670,31 @@ vec4 getBAtOutCoordsMatmul(int i) {
670
670
  }
671
671
  return value;
672
672
  }
673
- `;return{...r,output:{dims:e,type:o.type,textureType:4},shaderSource:l}},bf=(t,r,o,i,u)=>{let n=Rm(u.cacheKey);return{...n,get:()=>Gm(t,n,r,o,i,u)}},Ii=(t,r,o,i=4)=>[o[0],o[2],o[3],Math.ceil(t[1]*r[2]*r[3]/i)]}),Mm,Um,gf,yf=O(()=>{Y(),ut(),j(),qe(),_i(),Mm=(t,r)=>({name:"ConvDotProduct",inputNames:t?["Im2Col","K","B"]:["Im2Col","K"],inputTypes:t?[0,4,0]:[0,4],cacheKey:r.activationCacheKey}),Um=(t,r,o,i,u)=>{let n=o[0].dims,a=o[1].dims,d=[a[0],Math.ceil(n[1]*a[2]*a[3]/4)],c=Ii(n,a,i),[e,l]=t.calculateTextureWidthAndHeight(d,4),s=B.computeStrides(c),[h,f]=t.calculateTextureWidthAndHeight(c,4),m=i.length,v=o.length<3?"0.0":"_B(b)",_=Math.ceil(n[1]*a[2]*a[3]/4),{activationFunction:I,applyActivation:T}=he(u),P=G(t.session.backend.glContext.version),C=`
674
- ${I}
675
- float process(int indices[${m}]) {
673
+ `;return{...n,output:{dims:r,type:a.type,textureType:4},shaderSource:u}},bf=(e,n,a,i,p)=>{let o=Rm(p.cacheKey);return{...o,get:()=>Gm(e,o,n,a,i,p)}},Ii=(e,n,a,i=4)=>[a[0],a[2],a[3],Math.ceil(e[1]*n[2]*n[3]/i)]}),Mm,Um,gf,yf=O(()=>{Y(),ut(),j(),qe(),_i(),Mm=(e,n)=>({name:"ConvDotProduct",inputNames:e?["Im2Col","K","B"]:["Im2Col","K"],inputTypes:e?[0,4,0]:[0,4],cacheKey:n.activationCacheKey}),Um=(e,n,a,i,p)=>{let o=a[0].dims,s=a[1].dims,c=[s[0],Math.ceil(o[1]*s[2]*s[3]/4)],h=Ii(o,s,i),[r,u]=e.calculateTextureWidthAndHeight(c,4),l=B.computeStrides(h),[f,g]=e.calculateTextureWidthAndHeight(h,4),b=i.length,v=a.length<3?"0.0":"_B(b)",S=Math.ceil(o[1]*s[2]*s[3]/4),{activationFunction:P,applyActivation:_}=he(p),A=G(e.session.backend.glContext.version),L=`
674
+ ${P}
675
+ float process(int indices[${b}]) {
676
676
  int b[1];
677
677
  b[0] = indices[1];
678
678
  int im2col[4];
679
679
  im2col[0] = indices[0];
680
680
  im2col[1] = indices[2];
681
681
  im2col[2] = indices[3];
682
- int im2colOffset = im2col[0] * ${s[0]} + im2col[1] * ${s[1]} + im2col[2] * ${s[2]};
683
- int kernelOffset = indices[1] * ${d[1]};
682
+ int im2colOffset = im2col[0] * ${l[0]} + im2col[1] * ${l[1]} + im2col[2] * ${l[2]};
683
+ int kernelOffset = indices[1] * ${c[1]};
684
684
  float value = ${v};
685
- for (int i = 0; i < ${_}; ++i) {
686
- vec2 im2colCoords = offsetToCoords(im2colOffset, ${h}, ${f});
687
- vec2 kernelCoords = offsetToCoords(kernelOffset, ${e}, ${l});
688
- value += dot(${P.texture2D}(Im2Col, im2colCoords), ${P.texture2D}(K, kernelCoords));
685
+ for (int i = 0; i < ${S}; ++i) {
686
+ vec2 im2colCoords = offsetToCoords(im2colOffset, ${f}, ${g});
687
+ vec2 kernelCoords = offsetToCoords(kernelOffset, ${r}, ${u});
688
+ value += dot(${A.texture2D}(Im2Col, im2colCoords), ${A.texture2D}(K, kernelCoords));
689
689
  ++im2colOffset;
690
690
  ++kernelOffset;
691
691
  }
692
- ${T}
692
+ ${_}
693
693
  return value;
694
- }`;return{...r,output:{dims:i,type:o[0].type,textureType:0},shaderSource:C}},gf=(t,r,o,i)=>{let u=Mm(r.length>2,i);return{...u,get:()=>Um(t,u,r,o,i)}}}),dr,Oi,Vm,zm,Wm,Hm,Si,qm,Bn=O(()=>{It(),Y(),lf(),mf(),yf(),qe(),_i(),Fn(),dr=(t,r,o,i,u)=>{let n=t[0],a=t.slice(2),d=a.length,c=r[0],e=r.slice(2).map((s,h)=>s+(s-1)*(o[h]-1)),l=a.map((s,h)=>s+i[h]+i[h+d]).map((s,h)=>Math.floor((s-e[h]+u[h])/u[h]));return[n,c].concat(...l)},Oi=(t,r,o)=>(qm(r,o),Vm(t,r,o)),Vm=(t,r,o)=>{let i=Hm(o,r),u=t.session.pack,n=i.kernelShape[0]===1&&i.kernelShape[1]===1;return i.group>1?[t.run(uf(t,r,i),r)]:n&&u?[zm(t,r,i)]:u&&r[0].dims.length===4&&r[0].dims[0]===1&&!n?[hf(t,r,i)]:[Wm(t,r,i)]},zm=(t,r,o)=>{let i=r[0].dims,u=r[1].dims,n=dr(i,u,o.dilations,o.pads,o.strides),a=t.reshapeUnpacked(r[0],[i[1],i[2]*i[3]]),d=t.reshapeUnpacked(r[1],[u[0],u[1]]),c=r.length>2?[d,a,r[2]]:[d,a],e=t.run(Ti(c,o),c);return t.reshapeUnpacked(e,n)},Wm=(t,r,o)=>{let i=r[0].dims,u=r[1].dims,n=dr(i,u,o.dilations,o.pads,o.strides),a=t.run(bf(t,r[0],r[1],n,o),[r[0]]),d=r.length===3?[a,r[1],r[2]]:[a,r[1]];return t.run(gf(t,r,n,o),d)},Hm=(t,r)=>{let o=t.kernelShape.slice();if(t.kernelShape.length===0)for(let n=2;n<r[1].dims.length;++n)o.push(r[1].dims[n]);let i=t.pads.slice();Ue.adjustPadsBasedOnAutoPad(r[0].dims,t.strides,t.dilations,o,i,t.autoPad);let u=Object.assign({},t);return Object.assign(u,{kernelShape:o,pads:i,cacheKey:t.cacheKey}),u},Si=t=>{let r=t.attributes,o=pr(r),i=r.getString("auto_pad","NOTSET"),u=r.getInts("dilations",[1,1]),n=r.getInt("group",1),a=r.getInts("kernel_shape",[]),d=r.getInts("pads",[0,0,0,0]),c=r.getInts("strides",[1,1]);return W({autoPad:i,dilations:u,group:n,kernelShape:a,pads:d,strides:c,...o})},qm=(t,r)=>{if(!t||t.length!==2&&t.length!==3)throw new Error("Conv requires 2 or 3 inputs");if(t[0].dims.length!==4||t[1].dims.length!==4)throw new Error("currently only support 2-dimensional conv");let o=t[0].dims[1],i=t[1].dims[1]*r.group;if(o!==i)throw new Error("FILTER_IN_CHANNEL should be equal to DATA_CHANNEL");if(t.length===3&&(t[2].dims.length!==1||t[1].dims[0]!==t[2].dims[0]))throw new Error("invalid bias");let u=t[0].dims.length-2;if(r.dilations.length!==u)throw new Error(`dilations should be ${u}D`);if(r.strides.length!==u)throw new Error(`strides should be ${u}D`);if(r.pads.length!==u*2)throw new Error(`pads should be ${u*2}D`);if(r.kernelShape.length!==0&&r.kernelShape.length!==t[1].dims.length-2)throw new Error("invalid kernel shape");if(t[0].type!=="float32"||t[1].type!=="float32")throw new Error("Conv input(X,W) should be float tensor");if(t.length===3&&t[2].type!=="float32")throw new Error("Conv input(bias) should be float tensor")}}),jm,Xm,Km,xf,Jm,Ym,Zm,Qm,tb,eb,Tf,rb,wf=O(()=>{It(),ut(),j(),qe(),jm=(t,r,o,i,u,n)=>(t-1)*r+o+(i-1)*u+1-n,Xm=(t,r,o,i,u)=>{let n=Math.floor(t/2);r==="SAME_UPPER"?(o[i]=n,o[u]=t-n):r==="SAME_LOWER"&&(o[i]=t-n,o[u]=n)},Km=(t,r,o,i,u,n,a,d)=>{let c=t.length-2,e=d.length===0;for(let l=0;l<c;++l){let s=e?t[l+2]*n[l]:d[l],h=jm(t[l+2],n[l],u[l],r[l],o[l],s);Xm(h,i,u,l,l+c),e&&d.push(n[l]*(t[l+2]-1)+a[l]+(r[l]-1)*o[l]+1-u[l]-u[l+c])}},xf=(t,r,o)=>(rb(r,o),Jm(t,r,o)),Jm=(t,r,o)=>{let i=eb(o,r);return[tb(t,r,i)]},Ym=(t,r)=>({name:"ConvTranspose",inputNames:t?["X","W","B"]:["X","W"],inputTypes:t?[0,0,0]:[0,0],cacheHint:r}),Zm=(t,r,o,i)=>{let u=r.length>2?"getB(output_channel)":"0.0",n=r[0].dims,a=r[1].dims,d=a[1],c=a[0]/i.group,e=[r[0].dims[0],r[1].dims[1]*i.group,...i.outputShape],l=G(t.session.backend.glContext.version),{activationFunction:s,applyActivation:h}=he(i),f=`
694
+ }`;return{...n,output:{dims:i,type:a[0].type,textureType:0},shaderSource:L}},gf=(e,n,a,i)=>{let p=Mm(n.length>2,i);return{...p,get:()=>Um(e,p,n,a,i)}}}),dr,Oi,Vm,zm,Wm,Hm,Si,qm,Bn=O(()=>{It(),Y(),lf(),mf(),yf(),qe(),_i(),Fn(),dr=(e,n,a,i,p)=>{let o=e[0],s=e.slice(2),c=s.length,h=n[0],r=n.slice(2).map((l,f)=>l+(l-1)*(a[f]-1)),u=s.map((l,f)=>l+i[f]+i[f+c]).map((l,f)=>Math.floor((l-r[f]+p[f])/p[f]));return[o,h].concat(...u)},Oi=(e,n,a)=>(qm(n,a),Vm(e,n,a)),Vm=(e,n,a)=>{let i=Hm(a,n),p=e.session.pack,o=i.kernelShape[0]===1&&i.kernelShape[1]===1;return i.group>1?[e.run(uf(e,n,i),n)]:o&&p?[zm(e,n,i)]:p&&n[0].dims.length===4&&n[0].dims[0]===1&&!o?[hf(e,n,i)]:[Wm(e,n,i)]},zm=(e,n,a)=>{let i=n[0].dims,p=n[1].dims,o=dr(i,p,a.dilations,a.pads,a.strides),s=e.reshapeUnpacked(n[0],[i[1],i[2]*i[3]]),c=e.reshapeUnpacked(n[1],[p[0],p[1]]),h=n.length>2?[c,s,n[2]]:[c,s],r=e.run(Ti(h,a),h);return e.reshapeUnpacked(r,o)},Wm=(e,n,a)=>{let i=n[0].dims,p=n[1].dims,o=dr(i,p,a.dilations,a.pads,a.strides),s=e.run(bf(e,n[0],n[1],o,a),[n[0]]),c=n.length===3?[s,n[1],n[2]]:[s,n[1]];return e.run(gf(e,n,o,a),c)},Hm=(e,n)=>{let a=e.kernelShape.slice();if(e.kernelShape.length===0)for(let o=2;o<n[1].dims.length;++o)a.push(n[1].dims[o]);let i=e.pads.slice();Ue.adjustPadsBasedOnAutoPad(n[0].dims,e.strides,e.dilations,a,i,e.autoPad);let p=Object.assign({},e);return Object.assign(p,{kernelShape:a,pads:i,cacheKey:e.cacheKey}),p},Si=e=>{let n=e.attributes,a=pr(n),i=n.getString("auto_pad","NOTSET"),p=n.getInts("dilations",[1,1]),o=n.getInt("group",1),s=n.getInts("kernel_shape",[]),c=n.getInts("pads",[0,0,0,0]),h=n.getInts("strides",[1,1]);return W({autoPad:i,dilations:p,group:o,kernelShape:s,pads:c,strides:h,...a})},qm=(e,n)=>{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]*n.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 p=e[0].dims.length-2;if(n.dilations.length!==p)throw new Error(`dilations should be ${p}D`);if(n.strides.length!==p)throw new Error(`strides should be ${p}D`);if(n.pads.length!==p*2)throw new Error(`pads should be ${p*2}D`);if(n.kernelShape.length!==0&&n.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")}}),jm,Xm,Km,xf,Jm,Ym,Zm,Qm,tb,eb,Tf,rb,wf=O(()=>{It(),ut(),j(),qe(),jm=(e,n,a,i,p,o)=>(e-1)*n+a+(i-1)*p+1-o,Xm=(e,n,a,i,p)=>{let o=Math.floor(e/2);n==="SAME_UPPER"?(a[i]=o,a[p]=e-o):n==="SAME_LOWER"&&(a[i]=e-o,a[p]=o)},Km=(e,n,a,i,p,o,s,c)=>{let h=e.length-2,r=c.length===0;for(let u=0;u<h;++u){let l=r?e[u+2]*o[u]:c[u],f=jm(e[u+2],o[u],p[u],n[u],a[u],l);Xm(f,i,p,u,u+h),r&&c.push(o[u]*(e[u+2]-1)+s[u]+(n[u]-1)*a[u]+1-p[u]-p[u+h])}},xf=(e,n,a)=>(rb(n,a),Jm(e,n,a)),Jm=(e,n,a)=>{let i=eb(a,n);return[tb(e,n,i)]},Ym=(e,n)=>({name:"ConvTranspose",inputNames:e?["X","W","B"]:["X","W"],inputTypes:e?[0,0,0]:[0,0],cacheHint:n}),Zm=(e,n,a,i)=>{let p=n.length>2?"getB(output_channel)":"0.0",o=n[0].dims,s=n[1].dims,c=s[1],h=s[0]/i.group,r=[n[0].dims[0],n[1].dims[1]*i.group,...i.outputShape],u=G(e.session.backend.glContext.version),{activationFunction:l,applyActivation:f}=he(i),g=`
695
695
  const ivec2 strides = ivec2(${i.strides[0]}, ${i.strides[1]});
696
696
  const ivec2 pads = ivec2(${i.pads[0]}, ${i.pads[1]});
697
- ${s}
697
+ ${l}
698
698
  void main() {
699
699
  ivec4 coords = getOutputCoords();
700
700
  int batch = coords.x;
@@ -702,21 +702,21 @@ float process(int indices[${m}]) {
702
702
 
703
703
  ivec2 loc = coords.zw + pads;
704
704
 
705
- int group_id = output_channel / ${d};
706
- int wOutChannel = output_channel - group_id * ${d};
705
+ int group_id = output_channel / ${c};
706
+ int wOutChannel = output_channel - group_id * ${c};
707
707
 
708
- float value = ${u};
709
- for (int inChannelOffset = 0; inChannelOffset < ${c}; inChannelOffset++) {
710
- int input_channel = group_id * ${c} + inChannelOffset;
711
- for (int wWOff = 0; wWOff < ${a[2]}; wWOff++) {
712
- for (int wHOff = 0; wHOff < ${a[3]}; wHOff++) {
708
+ float value = ${p};
709
+ for (int inChannelOffset = 0; inChannelOffset < ${h}; inChannelOffset++) {
710
+ int input_channel = group_id * ${h} + inChannelOffset;
711
+ for (int wWOff = 0; wWOff < ${s[2]}; wWOff++) {
712
+ for (int wHOff = 0; wHOff < ${s[3]}; wHOff++) {
713
713
  ivec2 wOff = ivec2(wWOff * ${i.dilations[0]}, wHOff * ${i.dilations[1]});
714
714
  ivec2 wLoc = loc - wOff;
715
715
  ivec2 wLocIn = wLoc / strides;
716
716
  if (
717
717
  wLocIn * strides == wLoc &&
718
- wLocIn.x >= 0 && wLocIn.x < ${n[2]} &&
719
- wLocIn.y >= 0 && wLocIn.y < ${n[3]}
718
+ wLocIn.x >= 0 && wLocIn.x < ${o[2]} &&
719
+ wLocIn.y >= 0 && wLocIn.y < ${o[3]}
720
720
  ) {
721
721
  float xVal = getX(batch, input_channel, wLocIn.y, wLocIn.x);
722
722
  float wVal = getW(input_channel, wOutChannel, wHOff, wWOff);
@@ -725,85 +725,85 @@ float process(int indices[${m}]) {
725
725
  }
726
726
  }
727
727
  }
728
- ${h}
729
- ${l.output} = vec4(value, .0, .0, .0);
728
+ ${f}
729
+ ${u.output} = vec4(value, .0, .0, .0);
730
730
  }
731
- `;return{...o,output:{dims:e,type:r[0].type,textureType:0},shaderSource:f,hasMain:!0}},Qm=(t,r,o)=>{let i=Ym(r.length>2,o.cacheKey);return{...i,get:()=>Zm(t,r,i,o)}},tb=(t,r,o)=>t.run(Qm(t,r,o),r),eb=(t,r)=>{let o=t.kernelShape.slice();if(t.kernelShape.length===0)for(let d=2;d<r[1].dims.length;++d)o.push(r[1].dims[d]);let i=t.pads.slice(),u=t.outputShape.slice(),n=r[0].dims;Km(n,o,t.dilations,t.autoPad,i,t.strides,t.outputPadding,u);let a=Object.assign({},t);return Object.assign(a,{kernelShape:o,pads:i,outputShape:u,cacheKey:t.cacheKey}),a},Tf=t=>{let r=t.attributes,o=pr(r),i=r.getString("auto_pad","NOTSET"),u=r.getInts("dilations",[1,1]),n=r.getInt("group",1),a=r.getInts("kernel_shape",[]),d=r.getInts("output_padding",[0,0]),c=r.getInts("output_shape",[]),e=r.getInts("pads",[0,0,0,0]),l=r.getInts("strides",[1,1]);return W({autoPad:i,dilations:u,group:n,kernelShape:a,outputPadding:d,outputShape:c,pads:e,strides:l,...o})},rb=(t,r)=>{if(!t||t.length!==2&&t.length!==3)throw new Error("Conv requires 2 or 3 inputs");if(t[0].dims.length!==4||t[1].dims.length!==4)throw new Error("currently only support 2-dimensional conv");let o=t[0].dims[1],i=t[1].dims[0];if(o!==i)throw new Error("FILTER_IN_CHANNEL should be equal to DATA_CHANNEL");let u=t[1].dims[1]*r.group;if(t.length===3&&(t[2].dims.length!==1||t[2].dims[0]!==u))throw new Error("invalid bias");let n=t[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!==t[1].dims.length-2)throw new Error("invalid kernel shape");if(r.outputShape.length!==0&&r.outputShape.length!==t[0].dims.length-2)throw new Error("invalid output shape");if(t[0].type!=="float32"||t[1].type!=="float32")throw new Error("ConvTranspose input(X,W) should be float tensor");if(t.length===3&&t[2].type!=="float32")throw new Error("ConvTranspose input(bias) should be float tensor")}}),vf,je,If,nb,_f,ob,ib,ab,Nn=O(()=>{It(),Y(),j(),vf={name:"Transpose",inputNames:["A"],inputTypes:[0]},je=(t,r,o)=>(ab(r),[t.run({...vf,cacheHint:o.cacheKey,get:()=>nb(t,r[0],o.perm)},r)]),If=t=>W({perm:t.attributes.getInts("perm",[])}),nb=(t,r,o)=>{let i=r.dims;o=_f(i,o);let u=ob(i,o),n=i.length,a=`
732
- ${ib("perm",o,n)}
733
- float process(int indices[${n}]) {
734
- int a[${n}];
731
+ `;return{...a,output:{dims:r,type:n[0].type,textureType:0},shaderSource:g,hasMain:!0}},Qm=(e,n,a)=>{let i=Ym(n.length>2,a.cacheKey);return{...i,get:()=>Zm(e,n,i,a)}},tb=(e,n,a)=>e.run(Qm(e,n,a),n),eb=(e,n)=>{let a=e.kernelShape.slice();if(e.kernelShape.length===0)for(let c=2;c<n[1].dims.length;++c)a.push(n[1].dims[c]);let i=e.pads.slice(),p=e.outputShape.slice(),o=n[0].dims;Km(o,a,e.dilations,e.autoPad,i,e.strides,e.outputPadding,p);let s=Object.assign({},e);return Object.assign(s,{kernelShape:a,pads:i,outputShape:p,cacheKey:e.cacheKey}),s},Tf=e=>{let n=e.attributes,a=pr(n),i=n.getString("auto_pad","NOTSET"),p=n.getInts("dilations",[1,1]),o=n.getInt("group",1),s=n.getInts("kernel_shape",[]),c=n.getInts("output_padding",[0,0]),h=n.getInts("output_shape",[]),r=n.getInts("pads",[0,0,0,0]),u=n.getInts("strides",[1,1]);return W({autoPad:i,dilations:p,group:o,kernelShape:s,outputPadding:c,outputShape:h,pads:r,strides:u,...a})},rb=(e,n)=>{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 p=e[1].dims[1]*n.group;if(e.length===3&&(e[2].dims.length!==1||e[2].dims[0]!==p))throw new Error("invalid bias");let o=e[0].dims.length-2;if(n.dilations.length!==o)throw new Error(`dilations should be ${o}D`);if(n.strides.length!==o)throw new Error(`strides should be ${o}D`);if(n.pads.length!==o*2)throw new Error(`pads should be ${o*2}D`);if(n.outputPadding.length!==o)throw new Error(`output_padding should be ${o}D`);if(n.kernelShape.length!==0&&n.kernelShape.length!==e[1].dims.length-2)throw new Error("invalid kernel shape");if(n.outputShape.length!==0&&n.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")}}),vf,je,If,nb,_f,ob,ib,ab,Nn=O(()=>{It(),Y(),j(),vf={name:"Transpose",inputNames:["A"],inputTypes:[0]},je=(e,n,a)=>(ab(n),[e.run({...vf,cacheHint:a.cacheKey,get:()=>nb(e,n[0],a.perm)},n)]),If=e=>W({perm:e.attributes.getInts("perm",[])}),nb=(e,n,a)=>{let i=n.dims;a=_f(i,a);let p=ob(i,a),o=i.length,s=`
732
+ ${ib("perm",a,o)}
733
+ float process(int indices[${o}]) {
734
+ int a[${o}];
735
735
  perm(a, indices);
736
736
  return _A(a);
737
- }`;return{...vf,output:{dims:u,type:r.type,textureType:0},shaderSource:a}},_f=(t,r)=>(r&&r.length!==t.length&&(r=[...t.keys()].reverse()),r),ob=(t,r)=>(r=_f(t,r),B.sortBasedOnPerm(t,r)),ib=(t,r,o)=>{let i=[];i.push(`void ${t}(out int a[${o}], int src[${o}]) {`);for(let u=0;u<o;++u)i.push(` a[${r[u]}]=src[${u}];`);return i.push(" }"),i.join(`
738
- `)},ab=t=>{if(!t||t.length!==1)throw new Error("Transpose requires 1 input.");if(t[0].type!=="float32"&&t[0].type!=="float64")throw new Error("input should be float tensor")}}),Of,Sf,sb,Af=O(()=>{Nn(),Of=(t,r,o)=>{sb(r);let i=o.blocksize,u=i*i,n=o.mode==="DCR"?[0,3,4,1,5,2]:[0,1,4,2,5,3],a=o.mode==="DCR"?[r[0].dims[0],i,i,r[0].dims[1]/u,r[0].dims[2],r[0].dims[3]]:[r[0].dims[0],r[0].dims[1]/u,i,i,r[0].dims[2],r[0].dims[3]],d=t.reshapeUnpacked(r[0],a),c={perm:n,cacheKey:`${n}`},[e]=je(t,[d],c),l=[r[0].dims[0],r[0].dims[1]/u,r[0].dims[2]*i,r[0].dims[3]*i];return[t.reshapeUnpacked(e,l)]},Sf=t=>{let r=t.attributes.getInt("blocksize");if(r<1)throw new Error(`blocksize must be >= 1, but got : ${r} for DepthToSpace`);let o=t.attributes.getString("mode","DCR");if(o!=="DCR"&&o!=="CRD")throw new Error(`unrecognized mode: ${o} for DepthToSpace`);return{mode:o,blocksize:r}},sb=t=>{if(t.length!==1)throw new Error(`DepthToSpace expect 1 inputs, but got ${t.length}`);if(t[0].type==="string"||t[0].dims.length!==4)throw new TypeError("DepthToSpace input should be a 4-D numeric tensor")}}),Pf,Ef,ub,Df=O(()=>{Y(),Pf=(t,r,o)=>{ub(r,o);let i=B.flattenShape(r[0].dims,o);return[t.reshapeUnpacked(r[0],i)]},Ef=t=>t.attributes.getInt("axis",1),ub=(t,r)=>{if(!t||t.length!==1)throw new Error("Flatten requires 1 input.");let o=t[0].dims.length;if(o===0)throw new Error("scalar tensor is not supported.");if(r<-o||r>o)throw new Error("Invalid axis");if(t[0].type==="string")throw new Error("string tensor is not supported.")}}),Pe,Rr=O(()=>{Pe=["float32","float64","int32","int16","int8","uint16","uint32","uint8"]}),Lf,$f,lb,fb,cb,pb,kf=O(()=>{It(),Rr(),Y(),j(),Lf=(t,r,o)=>(pb(r,o.axis),[t.run(cb(t,r,o),r)]),$f=t=>W({axis:t.attributes.getInt("axis",0)}),lb={name:"Gather",inputNames:["A","B"],inputTypes:[0,0]},fb=(t,r,o,i)=>{let u=o[0].dims.slice(),n=o[1].dims.slice(),a=new Array(u.length+n.length-1);i=B.normalizeAxis(i,u.length);let d=[];for(let h=0;h<a.length;h++)h<i?(a[h]=u[h],d.push(`inputIdx[${h}] = outputIdx[${h}];`)):h<i+n.length?(a[h]=n[h-i],d.push(`indexDataIdx[${h-i}] = outputIdx[${h}];`)):(a[h]=u[h-n.length+1],d.push(`inputIdx[${h-n.length+1}] = outputIdx[${h}];`));let c=a.length||1,e=u.length,l=n.length||1,s=`
739
- float process(int outputIdx[${c}]) {
740
- int inputIdx[${e}];
741
- int indexDataIdx[${l}];
737
+ }`;return{...vf,output:{dims:p,type:n.type,textureType:0},shaderSource:s}},_f=(e,n)=>(n&&n.length!==e.length&&(n=[...e.keys()].reverse()),n),ob=(e,n)=>(n=_f(e,n),B.sortBasedOnPerm(e,n)),ib=(e,n,a)=>{let i=[];i.push(`void ${e}(out int a[${a}], int src[${a}]) {`);for(let p=0;p<a;++p)i.push(` a[${n[p]}]=src[${p}];`);return i.push(" }"),i.join(`
738
+ `)},ab=e=>{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")}}),Of,Sf,sb,Af=O(()=>{Nn(),Of=(e,n,a)=>{sb(n);let i=a.blocksize,p=i*i,o=a.mode==="DCR"?[0,3,4,1,5,2]:[0,1,4,2,5,3],s=a.mode==="DCR"?[n[0].dims[0],i,i,n[0].dims[1]/p,n[0].dims[2],n[0].dims[3]]:[n[0].dims[0],n[0].dims[1]/p,i,i,n[0].dims[2],n[0].dims[3]],c=e.reshapeUnpacked(n[0],s),h={perm:o,cacheKey:`${o}`},[r]=je(e,[c],h),u=[n[0].dims[0],n[0].dims[1]/p,n[0].dims[2]*i,n[0].dims[3]*i];return[e.reshapeUnpacked(r,u)]},Sf=e=>{let n=e.attributes.getInt("blocksize");if(n<1)throw new Error(`blocksize must be >= 1, but got : ${n} 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:n}},sb=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")}}),Pf,Ef,ub,Df=O(()=>{Y(),Pf=(e,n,a)=>{ub(n,a);let i=B.flattenShape(n[0].dims,a);return[e.reshapeUnpacked(n[0],i)]},Ef=e=>e.attributes.getInt("axis",1),ub=(e,n)=>{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(n<-a||n>a)throw new Error("Invalid axis");if(e[0].type==="string")throw new Error("string tensor is not supported.")}}),Pe,Rr=O(()=>{Pe=["float32","float64","int32","int16","int8","uint16","uint32","uint8"]}),Lf,$f,lb,fb,cb,pb,kf=O(()=>{It(),Rr(),Y(),j(),Lf=(e,n,a)=>(pb(n,a.axis),[e.run(cb(e,n,a),n)]),$f=e=>W({axis:e.attributes.getInt("axis",0)}),lb={name:"Gather",inputNames:["A","B"],inputTypes:[0,0]},fb=(e,n,a,i)=>{let p=a[0].dims.slice(),o=a[1].dims.slice(),s=new Array(p.length+o.length-1);i=B.normalizeAxis(i,p.length);let c=[];for(let f=0;f<s.length;f++)f<i?(s[f]=p[f],c.push(`inputIdx[${f}] = outputIdx[${f}];`)):f<i+o.length?(s[f]=o[f-i],c.push(`indexDataIdx[${f-i}] = outputIdx[${f}];`)):(s[f]=p[f-o.length+1],c.push(`inputIdx[${f-o.length+1}] = outputIdx[${f}];`));let h=s.length||1,r=p.length,u=o.length||1,l=`
739
+ float process(int outputIdx[${h}]) {
740
+ int inputIdx[${r}];
741
+ int indexDataIdx[${u}];
742
742
  indexDataIdx[0] = 0;
743
- ${d.join(`
743
+ ${c.join(`
744
744
  `)}
745
745
  int idx = int(_B(indexDataIdx));
746
- inputIdx[${i}] = idx < 0 ? idx + ${u[i]} : idx;
746
+ inputIdx[${i}] = idx < 0 ? idx + ${p[i]} : idx;
747
747
  return _A(inputIdx);
748
- }`;return{...r,output:{dims:a,type:o[0].type,textureType:0},shaderSource:s}},cb=(t,r,o)=>{let i={...lb,cacheHint:o.cacheKey};return{...i,get:()=>fb(t,i,r,o.axis)}},pb=(t,r)=>{if(!t||t.length!==2)throw new Error("Gather requires 2 inputs.");let o=t[0].dims.length;if(o<1)throw new Error("Invalid input shape.");if(r<-o||r>o-1)throw new Error("Invalid axis.");if(Pe.indexOf(t[0].type)===-1)throw new Error("Invaid input type.");if(t[1].type!=="int32"&&t[1].type!=="int16")throw new Error("Invaid input type.")}}),Ai,Bf,Ff,Cf,db,hb,mb,Nf=O(()=>{It(),Y(),j(),Ai=(t,r,o)=>(mb(r,o),[t.run(db(r,o),r)]),Bf=(t,r)=>{let o=t.attributes.getInt("transA",0)!==0,i=t.attributes.getInt("transB",0)!==0,u=t.attributes.getFloat("alpha",1),n=t.attributes.getFloat("beta",1);return W({transA:o,transB:i,alpha:u,beta:n,isOptionalC:r})},Ff=t=>Bf(t,!1),Cf=t=>Bf(t,!0),db=(t,r)=>{let o={name:"Gemm",inputNames:t.length===3?["A","B","C"]:["A","B"],inputTypes:t.length===3?[0,0,0]:[0,0],key:r.cacheKey};return{...o,get:()=>hb(o,t,r)}},hb=(t,r,o)=>{let i=r[0].dims.slice(),u=r[1].dims.slice(),[n,a]=Sn.getShapeOfGemmResult(i,o.transA,u,o.transB,r.length===3?r[2].dims:void 0),d=[n,a];if(!d)throw new Error("Can't use gemm on the given tensors");let c=i[i.length-1],e="";o.transA&&(c=i[0]),o.transA&&o.transB?e="value += _A_T(a) * _B_T(b);":o.transA&&!o.transB?e="value += _A_T(a) * _B(b);":!o.transA&&o.transB?e="value += _A(a) * _B_T(b);":!o.transA&&!o.transB&&(e="value += _A(a) * _B(b);");let l=d.length,s=r.length===3?`int c[${r[2].dims.length}];`:"",h=r.length===3?"bcastIndices_C(indices, c);":"",f=r.length===3?"value += beta * _C(c);":"",m=`
749
- float process(int indices[${l}]) {
750
- int a[${l}];
751
- int b[${l}];
752
- ${s}
748
+ }`;return{...n,output:{dims:s,type:a[0].type,textureType:0},shaderSource:l}},cb=(e,n,a)=>{let i={...lb,cacheHint:a.cacheKey};return{...i,get:()=>fb(e,i,n,a.axis)}},pb=(e,n)=>{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(n<-a||n>a-1)throw new Error("Invalid axis.");if(Pe.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.")}}),Ai,Bf,Ff,Cf,db,hb,mb,Nf=O(()=>{It(),Y(),j(),Ai=(e,n,a)=>(mb(n,a),[e.run(db(n,a),n)]),Bf=(e,n)=>{let a=e.attributes.getInt("transA",0)!==0,i=e.attributes.getInt("transB",0)!==0,p=e.attributes.getFloat("alpha",1),o=e.attributes.getFloat("beta",1);return W({transA:a,transB:i,alpha:p,beta:o,isOptionalC:n})},Ff=e=>Bf(e,!1),Cf=e=>Bf(e,!0),db=(e,n)=>{let a={name:"Gemm",inputNames:e.length===3?["A","B","C"]:["A","B"],inputTypes:e.length===3?[0,0,0]:[0,0],key:n.cacheKey};return{...a,get:()=>hb(a,e,n)}},hb=(e,n,a)=>{let i=n[0].dims.slice(),p=n[1].dims.slice(),[o,s]=Sn.getShapeOfGemmResult(i,a.transA,p,a.transB,n.length===3?n[2].dims:void 0),c=[o,s];if(!c)throw new Error("Can't use gemm on the given tensors");let h=i[i.length-1],r="";a.transA&&(h=i[0]),a.transA&&a.transB?r="value += _A_T(a) * _B_T(b);":a.transA&&!a.transB?r="value += _A_T(a) * _B(b);":!a.transA&&a.transB?r="value += _A(a) * _B_T(b);":!a.transA&&!a.transB&&(r="value += _A(a) * _B(b);");let u=c.length,l=n.length===3?`int c[${n[2].dims.length}];`:"",f=n.length===3?"bcastIndices_C(indices, c);":"",g=n.length===3?"value += beta * _C(c);":"",b=`
749
+ float process(int indices[${u}]) {
750
+ int a[${u}];
751
+ int b[${u}];
752
+ ${l}
753
753
 
754
754
  copyVec(indices, a);
755
755
  copyVec(indices, b);
756
- ${h}
756
+ ${f}
757
757
 
758
758
  float value = 0.0;
759
- for (int k=0; k<${c}; ++k) {
760
- a[${l-1}] = k;
761
- b[${l-2}] = k;
762
- ${e}
759
+ for (int k=0; k<${h}; ++k) {
760
+ a[${u-1}] = k;
761
+ b[${u-2}] = k;
762
+ ${r}
763
763
  }
764
764
 
765
765
  value = value * alpha;
766
- ${f}
766
+ ${g}
767
767
  return value;
768
- }`;return{...t,output:{dims:d,type:r[0].type,textureType:0},variables:[{name:"alpha",type:"float",data:o.alpha},{name:"beta",type:"float",data:o.beta}],shaderSource:m}},mb=(t,r)=>{if(!t)throw new Error("Input is missing");if(r.isOptionalC&&(t.length<2||t.length>3))throw new Error("Invaid input shape.");if(!r.isOptionalC&&t.length!==3)throw new Error("Gemm requires 3 inputs");if(t.length===3&&t[2].dims.length!==1&&t[2].dims.length!==2)throw new Error("Invalid input shape of C");if(t[0].type!=="float32"&&t[0].type!=="float64"||t[1].type!=="float32"&&t[1].type!=="float64"||t.length===3&&t[2].type!=="float32"&&t[2].type!=="float64")throw new Error("Invalid input type.");if(t[0].type!==t[1].type||t.length===3&&t[0].type!==t[2].type)throw new Error("Input types are mismatched")}}),Rf,Gf,bb,gb,yb,xb,Tb,Mf=O(()=>{It(),j(),Rf=(t,r,o)=>(Tb(r),[t.run(yb(t,r,o),r)]),Gf=t=>{let r=t.attributes.getFloat("scale"),o=t.attributes.getFloats("bias");return W({scale:r,bias:o})},bb={name:"ImageScaler",inputNames:["X"],inputTypes:[0]},gb=(t,r,o,i)=>{let u=o[0].dims.slice(),n=u.length,a=`
768
+ }`;return{...e,output:{dims:c,type:n[0].type,textureType:0},variables:[{name:"alpha",type:"float",data:a.alpha},{name:"beta",type:"float",data:a.beta}],shaderSource:b}},mb=(e,n)=>{if(!e)throw new Error("Input is missing");if(n.isOptionalC&&(e.length<2||e.length>3))throw new Error("Invaid input shape.");if(!n.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")}}),Rf,Gf,bb,gb,yb,xb,Tb,Mf=O(()=>{It(),j(),Rf=(e,n,a)=>(Tb(n),[e.run(yb(e,n,a),n)]),Gf=e=>{let n=e.attributes.getFloat("scale"),a=e.attributes.getFloats("bias");return W({scale:n,bias:a})},bb={name:"ImageScaler",inputNames:["X"],inputTypes:[0]},gb=(e,n,a,i)=>{let p=a[0].dims.slice(),o=p.length,s=`
769
769
  ${xb(i.bias.length)}
770
- float process(int indices[${n}]) {
770
+ float process(int indices[${o}]) {
771
771
  return _X(indices) * scale + getBias(bias, indices[1]);
772
- }`;return{...r,output:{dims:u,type:o[0].type,textureType:0},variables:[{name:"bias",type:"float",arrayLength:i.bias.length,data:i.bias},{name:"scale",type:"float",data:i.scale}],shaderSource:a}},yb=(t,r,o)=>{let i={...bb,cacheHint:o.cacheKey};return{...i,get:()=>gb(t,i,r,o)}},xb=t=>{let r=[`float getBias(float bias[${t}], int channel) {`];for(let o=0;o<t;++o)o===0?r.push(` if (channel == ${o}) { return bias[${o}]; }`):o===t-1?r.push(` else { return bias[${o}]; }`):r.push(` else if (channel == ${o}) { return bias[${o}]; }`);return r.push(" }"),r.join(`
773
- `)},Tb=t=>{if(!t||t.length!==1)throw new Error("ImageScaler requires 1 input.");if(t[0].dims.length!==4)throw new Error("Invalid input shape.");if(t[0].type!=="float32"&&t[0].type!=="float64")throw new Error("Invalid input type.")}}),Vf,zf,Uf,wb,vb,Ib,_b,Ob,Sb,Wf=O(()=>{ut(),j(),Vf=(t,r,o)=>{Sb(r);let i=t.run(vb(r[0]),r);return[t.run(Ob(t,r[0],o,i.dims),[r[0],i,r[1],r[2]])]},zf=t=>t.attributes.getFloat("epsilon",1e-5),Uf={name:"InstanceNormalization_MeanAndVariance",inputNames:["X"],inputTypes:[0]},wb=(t,r)=>{let o=r.dims.slice(),i=o[1],u=o[2]*o[3],n=[o[0],i],a=`
772
+ }`;return{...n,output:{dims:p,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:s}},yb=(e,n,a)=>{let i={...bb,cacheHint:a.cacheKey};return{...i,get:()=>gb(e,i,n,a)}},xb=e=>{let n=[`float getBias(float bias[${e}], int channel) {`];for(let a=0;a<e;++a)a===0?n.push(` if (channel == ${a}) { return bias[${a}]; }`):a===e-1?n.push(` else { return bias[${a}]; }`):n.push(` else if (channel == ${a}) { return bias[${a}]; }`);return n.push(" }"),n.join(`
773
+ `)},Tb=e=>{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.")}}),Vf,zf,Uf,wb,vb,Ib,_b,Ob,Sb,Wf=O(()=>{ut(),j(),Vf=(e,n,a)=>{Sb(n);let i=e.run(vb(n[0]),n);return[e.run(Ob(e,n[0],a,i.dims),[n[0],i,n[1],n[2]])]},zf=e=>e.attributes.getFloat("epsilon",1e-5),Uf={name:"InstanceNormalization_MeanAndVariance",inputNames:["X"],inputTypes:[0]},wb=(e,n)=>{let a=n.dims.slice(),i=a[1],p=a[2]*a[3],o=[a[0],i],s=`
774
774
  vec4 process(int[2] indices) {
775
775
  vec4 v = vec4(0.0);
776
776
  int a[4];
777
777
  a[0] = indices[0];
778
778
  a[1] = indices[1];
779
779
  float temp = 0.0;
780
- for(int a2=0; a2<${o[2]}; a2++) {
780
+ for(int a2=0; a2<${a[2]}; a2++) {
781
781
  a[2] = a2;
782
- for(int a3=0; a3<${o[3]}; a3++) {
782
+ for(int a3=0; a3<${a[3]}; a3++) {
783
783
  a[3] = a3;
784
784
  float x = _X(a);
785
785
  temp += x;
786
786
  }
787
787
  }
788
- float mean = temp / float(${u});
788
+ float mean = temp / float(${p});
789
789
  temp = 0.0;
790
- for(int a2=0; a2<${o[2]}; a2++) {
790
+ for(int a2=0; a2<${a[2]}; a2++) {
791
791
  a[2] = a2;
792
- for(int a3=0; a3<${o[3]}; a3++) {
792
+ for(int a3=0; a3<${a[3]}; a3++) {
793
793
  a[3] = a3;
794
794
  float x = _X(a);
795
795
  temp += (x - mean) * (x - mean);
796
796
  }
797
797
  }
798
798
  v.r = mean;
799
- v.g = temp / float(${u});
799
+ v.g = temp / float(${p});
800
800
 
801
801
  return v;
802
- }`;return{...t,output:{dims:n,type:r.type,textureType:4},shaderSource:a}},vb=t=>({...Uf,get:()=>wb(Uf,t)}),Ib={name:"InstanceNormalization_ComputeOutput",inputNames:["X","MeanAndVariance","Scale","B"],inputTypes:[0,4,0,0]},_b=(t,r,o,i,u)=>{let n=G(t.session.backend.glContext.version),[a,d]=t.calculateTextureWidthAndHeight(u,4),[c,e]=[a/4,d],l=`
802
+ }`;return{...e,output:{dims:o,type:n.type,textureType:4},shaderSource:s}},vb=e=>({...Uf,get:()=>wb(Uf,e)}),Ib={name:"InstanceNormalization_ComputeOutput",inputNames:["X","MeanAndVariance","Scale","B"],inputTypes:[0,4,0,0]},_b=(e,n,a,i,p)=>{let o=G(e.session.backend.glContext.version),[s,c]=e.calculateTextureWidthAndHeight(p,4),[h,r]=[s/4,c],u=`
803
803
  vec4 get_MeanAndVariance(int[2] mv) {
804
804
  int offset = indicesToOffset_MeanAndVariance(mv);
805
- vec2 coords = offsetToCoords(offset, ${c}, ${e});
806
- return ${n.texture2D}(MeanAndVariance, coords);
805
+ vec2 coords = offsetToCoords(offset, ${h}, ${r});
806
+ return ${o.texture2D}(MeanAndVariance, coords);
807
807
  }
808
808
 
809
809
  float process(int[4] indices) {
@@ -820,116 +820,116 @@ float process(int indices[${m}]) {
820
820
  float b = _B(sb);
821
821
 
822
822
  return scale * (_X(indices) - mean) / sqrt(variance + epsilon) + b;
823
- }`;return{...r,output:{dims:o.dims,type:o.type,textureType:0},variables:[{name:"epsilon",type:"float",data:i}],shaderSource:l}},Ob=(t,r,o,i)=>{let u={...Ib,cacheHint:`${o}`};return{...u,get:()=>_b(t,u,r,o,i)}},Sb=t=>{if(!t||t.length!==3)throw new Error("InstanceNormalization requires 3 inputs.");let r=t[0],o=t[1],i=t[2];if(r.dims.length<3||o.dims.length!==1||i.dims.length!==1)throw new Error("Invalid input shape.");if(o.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"||o.type!=="float32"&&o.type!=="float64"||i.type!=="float32"&&i.type!=="float64")throw new Error("Invalid input type.");if(t[0].dims.length!==4)throw new Error("Only support 4-D input shape.")}});function Ab(t,r){let o=t[0].dims[1],i=t[0].dims.length,u=-Math.floor((r.size-1)/2),n=Math.ceil((r.size-1)/2),a=`float(${r.alpha}) / float(${r.size})`,d=`float(${r.bias})`,c=`float(${r.beta})`,e=`
823
+ }`;return{...n,output:{dims:a.dims,type:a.type,textureType:0},variables:[{name:"epsilon",type:"float",data:i}],shaderSource:u}},Ob=(e,n,a,i)=>{let p={...Ib,cacheHint:`${a}`};return{...p,get:()=>_b(e,p,n,a,i)}},Sb=e=>{if(!e||e.length!==3)throw new Error("InstanceNormalization requires 3 inputs.");let n=e[0],a=e[1],i=e[2];if(n.dims.length<3||a.dims.length!==1||i.dims.length!==1)throw new Error("Invalid input shape.");if(a.dims[0]!==n.dims[1]||i.dims[0]!==n.dims[1])throw new Error("Input shapes are mismatched.");if(n.type!=="float32"&&n.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 Ab(e,n){let a=e[0].dims[1],i=e[0].dims.length,p=-Math.floor((n.size-1)/2),o=Math.ceil((n.size-1)/2),s=`float(${n.alpha}) / float(${n.size})`,c=`float(${n.bias})`,h=`float(${n.beta})`,r=`
824
824
  float process(int indices[${i}]) {
825
825
  int c = indices[1];
826
826
  float x = _X(indices);
827
827
  float square_sum = 0.0;
828
828
 
829
- for (int i = ${u}; i <= ${n}; i++) {
829
+ for (int i = ${p}; i <= ${o}; i++) {
830
830
  int idx = c + i;
831
- if (c >= 0 && c < ${o}) {
831
+ if (c >= 0 && c < ${a}) {
832
832
  indices[1] = idx;
833
833
  float j = _X(indices);
834
834
  square_sum += j * j;
835
835
  }
836
836
  }
837
- return x / pow(${d} + ${a} * square_sum, ${c});
838
- }`;return{...jf,cacheHint:r.cacheKey,output:{dims:t[0].dims,type:t[0].type,textureType:0},shaderSource:e}}function Pb(t,r){return{...jf,cacheHint:r.cacheKey,get:()=>Ab(t,r)}}var Hf,qf,jf,Eb,Xf=O(()=>{It(),j(),Hf=(t,r,o)=>(Eb(r),[t.run(Pb(r,o),r)]),qf=t=>{let r=t.attributes.getFloat("alpha",1e-4),o=t.attributes.getFloat("beta",.75),i=t.attributes.getFloat("bias",1),u=t.attributes.getInt("size");return W({alpha:r,beta:o,bias:i,size:u})},jf={name:"LRN",inputNames:["X"],inputTypes:[0]},Eb=t=>{if(!t||t.length!==1)throw new Error("LRN requires 1 input.");if(t[0].dims.length!==4)throw new Error('currently only support LRN for input with "NCHW" format');if(t[0].type!=="float32")throw new Error("input should be float type")}}),Db,Pi,Kf,Jf,Yf,Lb,$b,kb,Bb,Fb,Cb,Nb,Rb,Zf=O(()=>{It(),Y(),ut(),j(),Db={name:"Pad",inputNames:["A"],inputTypes:[0]},Pi=(t,r,o)=>(kb(r),[t.run({...Db,cacheHint:o.cacheKey,get:()=>$b(t,r[0],o)},r)]),Kf=t=>{let r=t.attributes.getString("mode","constant"),o=t.attributes.getFloat("value",0),i=t.attributes.getInts("pads");return W({mode:r,value:o,pads:i})},Jf=(t,r,o)=>{Bb(r);let i=Lb(t,r,o);return Pi(t,[r[0]],i)},Yf=t=>t.attributes.getString("mode","constant"),Lb=(t,r,o)=>{if(!t.session.isInitializer(r[1].dataId)||r.length>=3&&!t.session.isInitializer(r[2].dataId))throw new Error("dynamic pad attributes are not allowed");let i=Array.from(r[1].integerData),u=r.length>=3?r[2].floatData[0]:0;return W({mode:o,pads:i,value:u})},$b=(t,r,o)=>{let i=B.padShape(r.dims.slice(),o.pads),u=i.length,n=`
839
- ${Fb(t,r,o)}
840
- float process(int[${u}] indices) {
837
+ return x / pow(${c} + ${s} * square_sum, ${h});
838
+ }`;return{...jf,cacheHint:n.cacheKey,output:{dims:e[0].dims,type:e[0].type,textureType:0},shaderSource:r}}function Pb(e,n){return{...jf,cacheHint:n.cacheKey,get:()=>Ab(e,n)}}var Hf,qf,jf,Eb,Xf=O(()=>{It(),j(),Hf=(e,n,a)=>(Eb(n),[e.run(Pb(n,a),n)]),qf=e=>{let n=e.attributes.getFloat("alpha",1e-4),a=e.attributes.getFloat("beta",.75),i=e.attributes.getFloat("bias",1),p=e.attributes.getInt("size");return W({alpha:n,beta:a,bias:i,size:p})},jf={name:"LRN",inputNames:["X"],inputTypes:[0]},Eb=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")}}),Db,Pi,Kf,Jf,Yf,Lb,$b,kb,Bb,Fb,Cb,Nb,Rb,Zf=O(()=>{It(),Y(),ut(),j(),Db={name:"Pad",inputNames:["A"],inputTypes:[0]},Pi=(e,n,a)=>(kb(n),[e.run({...Db,cacheHint:a.cacheKey,get:()=>$b(e,n[0],a)},n)]),Kf=e=>{let n=e.attributes.getString("mode","constant"),a=e.attributes.getFloat("value",0),i=e.attributes.getInts("pads");return W({mode:n,value:a,pads:i})},Jf=(e,n,a)=>{Bb(n);let i=Lb(e,n,a);return Pi(e,[n[0]],i)},Yf=e=>e.attributes.getString("mode","constant"),Lb=(e,n,a)=>{if(!e.session.isInitializer(n[1].dataId)||n.length>=3&&!e.session.isInitializer(n[2].dataId))throw new Error("dynamic pad attributes are not allowed");let i=Array.from(n[1].integerData),p=n.length>=3?n[2].floatData[0]:0;return W({mode:a,pads:i,value:p})},$b=(e,n,a)=>{let i=B.padShape(n.dims.slice(),a.pads),p=i.length,o=`
839
+ ${Fb(e,n,a)}
840
+ float process(int[${p}] indices) {
841
841
  return padA(indices);
842
- }`;return{name:"Pad",inputNames:["A"],inputTypes:[0],output:{dims:i,type:r.type,textureType:0},shaderSource:n}},kb=t=>{if(!t||t.length!==1)throw new Error("Pad requires 1 input");if(t[0].type!=="float32"&&t[0].type!=="float64")throw new Error("Invalid input type.")},Bb=t=>{if(!t||t.length!==2&&t.length!==3)throw new Error("Pad requires 2 or 3 inputs");if(t[1].type!=="int32")throw new Error("Invalid input type.");if(t.length>=3&&t[2].type==="string")throw new Error("Invalid input type.")},Fb=(t,r,o)=>{let i=G(t.session.backend.glContext.version),[u,n]=t.calculateTextureWidthAndHeight(r.dims,0),a=B.computeStrides(r.dims);switch(o.mode){case"constant":return Cb(i,r.dims,a,u,n,o.pads,o.value);case"reflect":return Nb(i,r.dims,a,u,n,o.pads);case"edge":return Rb(i,r.dims,a,u,n,o.pads);default:throw new Error("Invalid mode")}},Cb=(t,r,o,i,u,n,a)=>{let d=r.length,c="";for(let e=d-1;e>=0;--e)c+=`
843
- k = m[${e}] - ${n[e]};
842
+ }`;return{name:"Pad",inputNames:["A"],inputTypes:[0],output:{dims:i,type:n.type,textureType:0},shaderSource:o}},kb=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.")},Bb=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.")},Fb=(e,n,a)=>{let i=G(e.session.backend.glContext.version),[p,o]=e.calculateTextureWidthAndHeight(n.dims,0),s=B.computeStrides(n.dims);switch(a.mode){case"constant":return Cb(i,n.dims,s,p,o,a.pads,a.value);case"reflect":return Nb(i,n.dims,s,p,o,a.pads);case"edge":return Rb(i,n.dims,s,p,o,a.pads);default:throw new Error("Invalid mode")}},Cb=(e,n,a,i,p,o,s)=>{let c=n.length,h="";for(let r=c-1;r>=0;--r)h+=`
843
+ k = m[${r}] - ${o[r]};
844
844
  if (k < 0) return constant;
845
- if (k >= ${r[e]}) return constant;
846
- offset += k * ${o[e]};
845
+ if (k >= ${n[r]}) return constant;
846
+ offset += k * ${a[r]};
847
847
  `;return`
848
- float padA(int m[${d}]) {
849
- const float constant = float(${a});
848
+ float padA(int m[${c}]) {
849
+ const float constant = float(${s});
850
850
  int offset = 0;
851
851
  int k = 0;
852
- ${c}
853
- vec2 coords = offsetToCoords(offset, ${i}, ${u});
854
- float value = getColorAsFloat(${t.texture2D}(A, coords));
852
+ ${h}
853
+ vec2 coords = offsetToCoords(offset, ${i}, ${p});
854
+ float value = getColorAsFloat(${e.texture2D}(A, coords));
855
855
  return value;
856
856
  }
857
- `},Nb=(t,r,o,i,u,n)=>{let a=r.length,d="";for(let c=a-1;c>=0;--c)d+=`
858
- k = m[${c}] - ${n[c]};
857
+ `},Nb=(e,n,a,i,p,o)=>{let s=n.length,c="";for(let h=s-1;h>=0;--h)c+=`
858
+ k = m[${h}] - ${o[h]};
859
859
  if (k < 0) { k = -k; }
860
860
  {
861
- const int _2n_1 = ${2*(r[c]-1)};
861
+ const int _2n_1 = ${2*(n[h]-1)};
862
862
  k = int( mod( float(k), float(_2n_1) ) ) ;
863
- if(k >= ${r[c]}) { k = _2n_1 - k; }
863
+ if(k >= ${n[h]}) { k = _2n_1 - k; }
864
864
  }
865
- offset += k * ${o[c]};
865
+ offset += k * ${a[h]};
866
866
  `;return`
867
- float padA(int m[${a}]) {
867
+ float padA(int m[${s}]) {
868
868
  int offset = 0;
869
869
  int k = 0;
870
- ${d}
871
- vec2 coords = offsetToCoords(offset, ${i}, ${u});
872
- float value = getColorAsFloat(${t.texture2D}(A, coords));
870
+ ${c}
871
+ vec2 coords = offsetToCoords(offset, ${i}, ${p});
872
+ float value = getColorAsFloat(${e.texture2D}(A, coords));
873
873
  return value;
874
874
  }
875
- `},Rb=(t,r,o,i,u,n)=>{let a=r.length,d="";for(let c=a-1;c>=0;--c)d+=`
876
- k = m[${c}] - ${n[c]};
875
+ `},Rb=(e,n,a,i,p,o)=>{let s=n.length,c="";for(let h=s-1;h>=0;--h)c+=`
876
+ k = m[${h}] - ${o[h]};
877
877
  if (k < 0) k = 0;
878
- if (k >= ${r[c]}) k = ${r[c]-1};
879
- offset += k * ${o[c]};
878
+ if (k >= ${n[h]}) k = ${n[h]-1};
879
+ offset += k * ${a[h]};
880
880
  `;return`
881
- float padA(int m[${a}]) {
881
+ float padA(int m[${s}]) {
882
882
  int offset = 0;
883
883
  int k = 0;
884
- ${d}
885
- vec2 coords = offsetToCoords(offset, ${i}, ${u});
886
- float value = getColorAsFloat(${t.texture2D}(A, coords));
884
+ ${c}
885
+ vec2 coords = offsetToCoords(offset, ${i}, ${p});
886
+ float value = getColorAsFloat(${e.texture2D}(A, coords));
887
887
  return value;
888
888
  }
889
- `}}),tc,ec,rc,nc,oc,ic,ac,sc,uc,Gb,Qf,lc,Gn,fc,Rn,Mb,cc=O(()=>{It(),Y(),j(),tc=(t,r,o)=>{Gn(r);let i={name:"AveragePool",inputNames:["X"],inputTypes:[0],cacheHint:o.cacheKey};return[t.run({...i,get:()=>rc(r,i,!1,o)},r)]},ec=t=>{let r=t.attributes.getString("auto_pad","NOTSET"),o=t.attributes.getInt("ceil_mode",0),i=t.attributes.getInt("count_include_pad",0)!==0,u=t.attributes.getInts("kernel_shape"),n=t.attributes.getInts("strides",[]),a=t.attributes.getInts("pads",[]);if(o!==0)throw new Error("using ceil() in shape computation is not yet supported for AveragePool");return W({autoPad:r,ceilMode:o,countIncludePad:i,kernelShape:u,strides:n,pads:a})},rc=(t,r,o,i)=>{let[u,n]=uc(t,i,o),a=B.size(u.kernelShape),d="value += _X(x);",c="";u.countIncludePad?c+=`value /= float(${a});`:c+=`value /= float(${a} - pad);`;let e=`
890
- ${fc(t[0].dims,u,d,c,"0.0")}
891
- `;return{...r,output:{dims:n,type:t[0].type,textureType:0},shaderSource:e}},nc=(t,r,o)=>{Gn(r);let i={name:"GlobalAveragePool",inputNames:["X"],inputTypes:[0],cacheHint:`${o.countIncludePad}`};return[t.run({...i,get:()=>rc(r,i,!0,o)},r)]},oc=t=>{let r=t.attributes.getInt("count_include_pad",0)!==0;return W({autoPad:"",ceilMode:0,countIncludePad:r,kernelShape:[],strides:[],pads:[]})},ic=(t,r,o)=>{Gn(r);let i={name:"MaxPool",inputNames:["X"],inputTypes:[0],cacheHint:o.cacheKey};return[t.run({...i,get:()=>sc(r,i,!1,o)},r)]},ac=t=>{let r=t.attributes.getString("auto_pad","NOTSET"),o=t.attributes.getInt("ceil_mode",0),i=t.attributes.getInts("kernel_shape"),u=t.attributes.getInts("strides",[]),n=t.attributes.getInts("pads",[]),a=t.attributes.getInt("storage_order",0),d=t.attributes.getInts("dilations",[]);if(a!==0)throw new Error("column major storage order is not yet supported for MaxPool");if(o!==0)throw new Error("using ceil() in shape computation is not yet supported for MaxPool");return W({autoPad:r,ceilMode:o,countIncludePad:!1,kernelShape:i,strides:u,pads:n,storageOrder:a,dilations:d})},sc=(t,r,o,i)=>{let[u,n]=uc(t,i,o),a=`
889
+ `}}),tc,ec,rc,nc,oc,ic,ac,sc,uc,Gb,Qf,lc,Gn,fc,Rn,Mb,cc=O(()=>{It(),Y(),j(),tc=(e,n,a)=>{Gn(n);let i={name:"AveragePool",inputNames:["X"],inputTypes:[0],cacheHint:a.cacheKey};return[e.run({...i,get:()=>rc(n,i,!1,a)},n)]},ec=e=>{let n=e.attributes.getString("auto_pad","NOTSET"),a=e.attributes.getInt("ceil_mode",0),i=e.attributes.getInt("count_include_pad",0)!==0,p=e.attributes.getInts("kernel_shape"),o=e.attributes.getInts("strides",[]),s=e.attributes.getInts("pads",[]);if(a!==0)throw new Error("using ceil() in shape computation is not yet supported for AveragePool");return W({autoPad:n,ceilMode:a,countIncludePad:i,kernelShape:p,strides:o,pads:s})},rc=(e,n,a,i)=>{let[p,o]=uc(e,i,a),s=B.size(p.kernelShape),c="value += _X(x);",h="";p.countIncludePad?h+=`value /= float(${s});`:h+=`value /= float(${s} - pad);`;let r=`
890
+ ${fc(e[0].dims,p,c,h,"0.0")}
891
+ `;return{...n,output:{dims:o,type:e[0].type,textureType:0},shaderSource:r}},nc=(e,n,a)=>{Gn(n);let i={name:"GlobalAveragePool",inputNames:["X"],inputTypes:[0],cacheHint:`${a.countIncludePad}`};return[e.run({...i,get:()=>rc(n,i,!0,a)},n)]},oc=e=>{let n=e.attributes.getInt("count_include_pad",0)!==0;return W({autoPad:"",ceilMode:0,countIncludePad:n,kernelShape:[],strides:[],pads:[]})},ic=(e,n,a)=>{Gn(n);let i={name:"MaxPool",inputNames:["X"],inputTypes:[0],cacheHint:a.cacheKey};return[e.run({...i,get:()=>sc(n,i,!1,a)},n)]},ac=e=>{let n=e.attributes.getString("auto_pad","NOTSET"),a=e.attributes.getInt("ceil_mode",0),i=e.attributes.getInts("kernel_shape"),p=e.attributes.getInts("strides",[]),o=e.attributes.getInts("pads",[]),s=e.attributes.getInt("storage_order",0),c=e.attributes.getInts("dilations",[]);if(s!==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 W({autoPad:n,ceilMode:a,countIncludePad:!1,kernelShape:i,strides:p,pads:o,storageOrder:s,dilations:c})},sc=(e,n,a,i)=>{let[p,o]=uc(e,i,a),s=`
892
892
  value = max(_X(x), value);
893
- `,d="",c=`
894
- ${fc(t[0].dims,u,a,d,"-1e5")}
895
- `;return{...r,output:{dims:n,type:t[0].type,textureType:0},shaderSource:c}},uc=(t,r,o)=>{let i=t[0].dims.slice(),u=Object.hasOwnProperty.call(r,"dilations"),n=r.kernelShape.slice(),a=r.strides.slice(),d=u?r.dilations.slice():[],c=r.pads.slice();Ue.adjustPoolAttributes(o,i,n,a,d,c);let e=Ue.computePoolOutputShape(o,i,a,d,n,c,r.autoPad),l=Object.assign({},r);return u?Object.assign(l,{kernelShape:n,strides:a,pads:c,dilations:d,cacheKey:r.cacheKey}):Object.assign(l,{kernelShape:n,strides:a,pads:c,cacheKey:r.cacheKey}),[l,e]},Gb={autoPad:"",ceilMode:0,countIncludePad:!1,kernelShape:[],strides:[],pads:[],storageOrder:0,dilations:[],cacheKey:""},Qf={name:"GlobalMaxPool",inputNames:["X"],inputTypes:[0]},lc=(t,r)=>(Gn(r),[t.run({...Qf,get:()=>sc(r,Qf,!0,Gb)},r)]),Gn=t=>{if(!t||t.length!==1)throw new Error("Pool ops requires 1 input.");if(t[0].type!=="float32"&&t[0].type!=="float64")throw new Error("Invalid input type.")},fc=(t,r,o,i,u)=>{let n=t.length;if(r.kernelShape.length<=2){let a=r.kernelShape[r.kernelShape.length-1],d=r.strides[r.strides.length-1],c=r.pads[r.pads.length/2-1],e=r.pads[r.pads.length-1],l=t[n-1],s="",h="",f="";if(c+e!==0?s=`
896
- for (int i = 0; i < ${a}; i++) {
897
- x[${n} - 1] = indices[${n} - 1] * ${d} - ${c} + i;
898
- if (x[${n} - 1] < 0 || x[${n} - 1] >= ${l}) {
893
+ `,c="",h=`
894
+ ${fc(e[0].dims,p,s,c,"-1e5")}
895
+ `;return{...n,output:{dims:o,type:e[0].type,textureType:0},shaderSource:h}},uc=(e,n,a)=>{let i=e[0].dims.slice(),p=Object.hasOwnProperty.call(n,"dilations"),o=n.kernelShape.slice(),s=n.strides.slice(),c=p?n.dilations.slice():[],h=n.pads.slice();Ue.adjustPoolAttributes(a,i,o,s,c,h);let r=Ue.computePoolOutputShape(a,i,s,c,o,h,n.autoPad),u=Object.assign({},n);return p?Object.assign(u,{kernelShape:o,strides:s,pads:h,dilations:c,cacheKey:n.cacheKey}):Object.assign(u,{kernelShape:o,strides:s,pads:h,cacheKey:n.cacheKey}),[u,r]},Gb={autoPad:"",ceilMode:0,countIncludePad:!1,kernelShape:[],strides:[],pads:[],storageOrder:0,dilations:[],cacheKey:""},Qf={name:"GlobalMaxPool",inputNames:["X"],inputTypes:[0]},lc=(e,n)=>(Gn(n),[e.run({...Qf,get:()=>sc(n,Qf,!0,Gb)},n)]),Gn=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.")},fc=(e,n,a,i,p)=>{let o=e.length;if(n.kernelShape.length<=2){let s=n.kernelShape[n.kernelShape.length-1],c=n.strides[n.strides.length-1],h=n.pads[n.pads.length/2-1],r=n.pads[n.pads.length-1],u=e[o-1],l="",f="",g="";if(h+r!==0?l=`
896
+ for (int i = 0; i < ${s}; i++) {
897
+ x[${o} - 1] = indices[${o} - 1] * ${c} - ${h} + i;
898
+ if (x[${o} - 1] < 0 || x[${o} - 1] >= ${u}) {
899
899
  pad++;
900
900
  continue;
901
901
  }
902
- ${o}
903
- }`:s=`
904
- for (int i = 0; i < ${a}; i++) {
905
- x[${n} - 1] = indices[${n} - 1] * ${d} - ${c} + i;
906
- ${o}
907
- }`,r.kernelShape.length===2){let m=r.kernelShape[r.kernelShape.length-2],v=r.strides[r.strides.length-2],_=r.pads[r.pads.length/2-2],I=r.pads[r.pads.length-2],T=t[n-2];_+I!==0?h=`
908
- for (int j = 0; j < ${m}; j++) {
909
- x[${n} - 2] = indices[${n} - 2] * ${v} - ${_} + j;
910
- if (x[${n} - 2] < 0 || x[${n} - 2] >= ${T}) {
911
- pad+= ${a};
902
+ ${a}
903
+ }`:l=`
904
+ for (int i = 0; i < ${s}; i++) {
905
+ x[${o} - 1] = indices[${o} - 1] * ${c} - ${h} + i;
906
+ ${a}
907
+ }`,n.kernelShape.length===2){let b=n.kernelShape[n.kernelShape.length-2],v=n.strides[n.strides.length-2],S=n.pads[n.pads.length/2-2],P=n.pads[n.pads.length-2],_=e[o-2];S+P!==0?f=`
908
+ for (int j = 0; j < ${b}; j++) {
909
+ x[${o} - 2] = indices[${o} - 2] * ${v} - ${S} + j;
910
+ if (x[${o} - 2] < 0 || x[${o} - 2] >= ${_}) {
911
+ pad+= ${s};
912
912
  continue;
913
913
  }
914
- `:h=`
915
- for (int j = 0; j < ${m}; j++) {
916
- x[${n} - 2] = indices[${n} - 2] * ${v} - ${_} + j;
917
- `,f=`
914
+ `:f=`
915
+ for (int j = 0; j < ${b}; j++) {
916
+ x[${o} - 2] = indices[${o} - 2] * ${v} - ${S} + j;
917
+ `,g=`
918
918
  }
919
919
  `}return`
920
- float process(int indices[${n}]) {
921
- int x[${n}];
920
+ float process(int indices[${o}]) {
921
+ int x[${o}];
922
922
  copyVec(indices, x);
923
923
 
924
- float value = ${u};
924
+ float value = ${p};
925
925
  int pad = 0;
926
- ${h}
927
- ${s}
928
926
  ${f}
927
+ ${l}
928
+ ${g}
929
929
  ${i}
930
930
  return value;
931
931
  }
932
- `}else{let a=B.size(r.kernelShape),d=B.computeStrides(r.kernelShape),c=d.length,e=r.pads.length,l=Mb(c),s=Rn(t,"inputDims"),h=Rn(r.pads,"pads"),f=Rn(d,"kernelStrides"),m=Rn(r.strides,"strides"),v=r.pads.reduce((I,T)=>I+T),_="";return v?_=`
932
+ `}else{let s=B.size(n.kernelShape),c=B.computeStrides(n.kernelShape),h=c.length,r=n.pads.length,u=Mb(h),l=Rn(e,"inputDims"),f=Rn(n.pads,"pads"),g=Rn(c,"kernelStrides"),b=Rn(n.strides,"strides"),v=n.pads.reduce((P,_)=>P+_),S="";return v?S=`
933
933
  if (x[j] >= inputDims[j] || x[j] < 0) {
934
934
  pad++;
935
935
  isPad = true;
@@ -937,92 +937,92 @@ float process(int indices[${m}]) {
937
937
  }
938
938
  }
939
939
  if (!isPad) {
940
- ${o}
941
- }`:_=`
940
+ ${a}
941
+ }`:S=`
942
942
  }
943
- ${o}
943
+ ${a}
944
944
  `,`
945
- ${l}
946
- float process(int indices[${n}]) {
947
- int x[${n}];
945
+ ${u}
946
+ float process(int indices[${o}]) {
947
+ int x[${o}];
948
948
  copyVec(indices, x);
949
- int offset[${c}];
950
- int pads[${e}];
951
- int inputDims[${n}];
952
- int kernelStrides[${c}];
953
- int strides[${c}];
954
- ${h}
955
- ${s}
956
- ${m}
949
+ int offset[${h}];
950
+ int pads[${r}];
951
+ int inputDims[${o}];
952
+ int kernelStrides[${h}];
953
+ int strides[${h}];
957
954
  ${f}
955
+ ${l}
956
+ ${b}
957
+ ${g}
958
958
 
959
- float value = ${u};
959
+ float value = ${p};
960
960
  int pad = 0;
961
961
  bool isPad = false;
962
- for (int i = 0; i < ${a}; i++) {
962
+ for (int i = 0; i < ${s}; i++) {
963
963
  offsetToIndices(i, kernelStrides, offset);
964
964
  isPad = false;
965
- for (int j = ${n} - ${c}; j < ${n}; j++) {
966
- x[j] = indices[j] * strides[j - ${n} + ${c}]
967
- + offset[j - ${n} + ${c}] - pads[j - 2];
968
- ${_}
965
+ for (int j = ${o} - ${h}; j < ${o}; j++) {
966
+ x[j] = indices[j] * strides[j - ${o} + ${h}]
967
+ + offset[j - ${o} + ${h}] - pads[j - 2];
968
+ ${S}
969
969
  }
970
970
  ${i}
971
971
 
972
972
  return value;
973
973
  }
974
- `}},Rn=(t,r)=>{let o="";for(let i=0;i<t.length;i++)o+=`
975
- ${r}[${i}] = ${t[i]};
976
- `;return o},Mb=t=>`
977
- void offsetToIndices(int offset, int[${t}] strides, out int[${t}] indices) {
978
- if (${t} == 0) {
974
+ `}},Rn=(e,n)=>{let a="";for(let i=0;i<e.length;i++)a+=`
975
+ ${n}[${i}] = ${e[i]};
976
+ `;return a},Mb=e=>`
977
+ void offsetToIndices(int offset, int[${e}] strides, out int[${e}] indices) {
978
+ if (${e} == 0) {
979
979
  return;
980
980
  }
981
- for (int i = 0; i < ${t} - 1; ++i) {
981
+ for (int i = 0; i < ${e} - 1; ++i) {
982
982
  indices[i] = offset / strides[i];
983
983
  offset -= indices[i] * strides[i];
984
984
  }
985
- indices[${t} - 1] = offset;
986
- }`}),Xe,Ee,Ub,Vb,pc,dc,hc,mc,bc,gc,yc,xc=O(()=>{It(),Rr(),Y(),j(),Xe=(t,r,o,i,u)=>{Vb(r);let n={name:i,inputNames:["A"],inputTypes:[0]};return[t.run({...n,cacheHint:o.cacheKey,get:()=>Ub(t,r,o,i,u,n)},r)]},Ee=t=>{let r=t.attributes.getInts("axes",[]),o=t.attributes.getInt("keepdims",1)===1;return W({axes:r,keepDims:o})},Ub=(t,r,o,i,u,n)=>{let a=[],d=r[0].dims.length||1,c=[],e=B.normalizeAxes(o.axes,r[0].dims.length),l=u(r,e),s=l[1];for(let f=0;f<r[0].dims.length;f++)e.indexOf(f)>=0||e.length===0?(o.keepDims&&a.push(1),s=`
987
- for(int j${f} = 0; j${f} < ${r[0].dims[f]}; j${f}++) {
988
- inputIdx[${f}] = j${f};
989
- ${s}
990
- }`):(c.push(`inputIdx[${f}] = outputIdx[${a.length}];`),a.push(r[0].dims[f]));let h=`
991
- float process(int outputIdx[${a.length||1}]) {
985
+ indices[${e} - 1] = offset;
986
+ }`}),Xe,Ee,Ub,Vb,pc,dc,hc,mc,bc,gc,yc,xc=O(()=>{It(),Rr(),Y(),j(),Xe=(e,n,a,i,p)=>{Vb(n);let o={name:i,inputNames:["A"],inputTypes:[0]};return[e.run({...o,cacheHint:a.cacheKey,get:()=>Ub(e,n,a,i,p,o)},n)]},Ee=e=>{let n=e.attributes.getInts("axes",[]),a=e.attributes.getInt("keepdims",1)===1;return W({axes:n,keepDims:a})},Ub=(e,n,a,i,p,o)=>{let s=[],c=n[0].dims.length||1,h=[],r=B.normalizeAxes(a.axes,n[0].dims.length),u=p(n,r),l=u[1];for(let g=0;g<n[0].dims.length;g++)r.indexOf(g)>=0||r.length===0?(a.keepDims&&s.push(1),l=`
987
+ for(int j${g} = 0; j${g} < ${n[0].dims[g]}; j${g}++) {
988
+ inputIdx[${g}] = j${g};
989
+ ${l}
990
+ }`):(h.push(`inputIdx[${g}] = outputIdx[${s.length}];`),s.push(n[0].dims[g]));let f=`
991
+ float process(int outputIdx[${s.length||1}]) {
992
992
  float value; // final result
993
- int inputIdx[${d}]; // addressing input data
994
- ${c.join(`
993
+ int inputIdx[${c}]; // addressing input data
994
+ ${h.join(`
995
995
  `)}
996
- ${l[0]} // init ops for reduce max/min
997
- ${s}
998
- ${l[2]} // final computation for reduce mean
996
+ ${u[0]} // init ops for reduce max/min
997
+ ${l}
998
+ ${u[2]} // final computation for reduce mean
999
999
  return value;
1000
- }`;return{...n,output:{dims:a,type:r[0].type,textureType:0},shaderSource:h}},Vb=t=>{if(!t||t.length!==1)throw new Error("Reduce op requires 1 input.");if(Pe.indexOf(t[0].type)===-1)throw new Error("Invalid input type.")},pc=(t,r,o)=>Xe(t,r,o,"ReduceSum",()=>["value = 0.0;","value += _A(inputIdx);",""]),dc=(t,r,o)=>Xe(t,r,o,"ReduceMean",(i,u)=>{let n=1;for(let a=0;a<i[0].dims.length;a++)(u.indexOf(a)>=0||u.length===0)&&(n*=i[0].dims[a]);return["value = 0.0;","value += _A(inputIdx);",`value /= ${n}.;`]}),hc=(t,r,o)=>Xe(t,r,o,"ReduceMax",(i,u)=>{let n=[];for(let a=0;a<i[0].dims.length;a++)(u.indexOf(a)>=0||u.length===0)&&n.push(`inputIdx[${a}] = 0;`);return[`${n.join(`
1000
+ }`;return{...o,output:{dims:s,type:n[0].type,textureType:0},shaderSource:f}},Vb=e=>{if(!e||e.length!==1)throw new Error("Reduce op requires 1 input.");if(Pe.indexOf(e[0].type)===-1)throw new Error("Invalid input type.")},pc=(e,n,a)=>Xe(e,n,a,"ReduceSum",()=>["value = 0.0;","value += _A(inputIdx);",""]),dc=(e,n,a)=>Xe(e,n,a,"ReduceMean",(i,p)=>{let o=1;for(let s=0;s<i[0].dims.length;s++)(p.indexOf(s)>=0||p.length===0)&&(o*=i[0].dims[s]);return["value = 0.0;","value += _A(inputIdx);",`value /= ${o}.;`]}),hc=(e,n,a)=>Xe(e,n,a,"ReduceMax",(i,p)=>{let o=[];for(let s=0;s<i[0].dims.length;s++)(p.indexOf(s)>=0||p.length===0)&&o.push(`inputIdx[${s}] = 0;`);return[`${o.join(`
1001
1001
  `)}
1002
- value = _A(inputIdx);`,"value = max(value, _A(inputIdx));",""]}),mc=(t,r,o)=>Xe(t,r,o,"ReduceMin",(i,u)=>{let n=[];for(let a=0;a<i[0].dims.length;a++)(u.indexOf(a)>=0||u.length===0)&&n.push(`inputIdx[${a}] = 0;`);return[`${n.join(`
1002
+ value = _A(inputIdx);`,"value = max(value, _A(inputIdx));",""]}),mc=(e,n,a)=>Xe(e,n,a,"ReduceMin",(i,p)=>{let o=[];for(let s=0;s<i[0].dims.length;s++)(p.indexOf(s)>=0||p.length===0)&&o.push(`inputIdx[${s}] = 0;`);return[`${o.join(`
1003
1003
  `)}
1004
- value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(t,r,o)=>Xe(t,r,o,"ReduceProd",()=>["value = 1.0;","value *= _A(inputIdx);",""]),gc=(t,r,o)=>Xe(t,r,o,"ReduceLogSum",()=>["value = 0.0;","value += _A(inputIdx);","value = log(value);"]),yc=(t,r,o)=>Xe(t,r,o,"ReduceLogSumSquare",()=>["float t; value = 0.0;","t = _A(inputIdx); value += t * t;",""])}),Tc,wc=O(()=>{Y(),Tc=(t,r)=>{let o=B.calculateReshapedDims(r[0].dims,r[1].integerData);return t.session.pack?[t.reshapePacked(r[0],o)]:[t.reshapeUnpacked(r[0],o)]}}),vc,Ei,Ic,_c,Gr,zb,Di,Mn,Li=O(()=>{It(),ut(),j(),vc={name:"Upsample",inputNames:["X"],inputTypes:[0]},Ei=(t,r,o)=>(Di(r,o),[t.run({...vc,cacheHint:o.cacheKey,get:()=>zb(t,r,o)},r)]),Ic=t=>Gr(t,7),_c=t=>Gr(t,9),Gr=(t,r)=>{let o=r>=10,i=t.attributes.getString("mode","nearest");if(i!=="nearest"&&i!=="linear"&&(r<11||i!=="cubic"))throw new Error(`unrecognized mode: ${i}`);let u=[];r<9&&(u=t.attributes.getFloats("scales"),Mn(u,i,o));let n=t.attributes.getFloat("extrapolation_value",0),a=r>10?t.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(a)===-1)throw new Error(`coordinate_transform_mode '${a}' is not supported`);let d=a==="tf_crop_and_resize",c=d,e=i==="nearest"&&r>=11?t.attributes.getString("nearest_mode","round_prefer_floor"):"";if(["round_prefer_floor","round_prefer_ceil","floor","ceil",""].indexOf(e)===-1)throw new Error(`nearest_mode '${e}' is not supported`);let l=t.attributes.getFloat("cubic_coeff_a",-.75),s=t.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 h=r<11?!0:i==="nearest"&&a==="asymmetric"&&e==="floor",f=0,m=0,v=0;return r>10?t.inputs.length>2?(f=1,m=2,v=3):(m=1,v=2):r===9&&(m=1),W({opset:r,isResize:o,mode:i,scales:u,extrapolationValue:n,coordinateTransformMode:a,useExtrapolation:c,needRoiInput:d,nearestMode:e,cubicCoefficientA:l,excludeOutside:s,useNearest2xOptimization:h,roiInputIdx:f,scalesInputIdx:m,sizesInputIdx:v})},zb=(t,r,o)=>{let i=G(t.session.backend.glContext.version),[u,n]=t.calculateTextureWidthAndHeight(r[0].dims,0),a=r[0].dims.map((v,_)=>Math.floor(v*o.scales[_])),[d,c]=t.calculateTextureWidthAndHeight(a,0),e=a.length,l=new Array(e),s=new Array(e),h=`
1005
- int output_pitches[${e}];
1006
- int input_pitches[${e}];
1007
- `;for(let v=e-1;v>=0;v--)l[v]=v===e-1?1:l[v+1]*a[v+1],s[v]=v===e-1?1:s[v+1]*r[0].dims[v+1],h+=`
1008
- output_pitches[${v}] = ${l[v]};
1009
- input_pitches[${v}] = ${s[v]};
1010
- `;let f=`
1004
+ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(e,n,a)=>Xe(e,n,a,"ReduceProd",()=>["value = 1.0;","value *= _A(inputIdx);",""]),gc=(e,n,a)=>Xe(e,n,a,"ReduceLogSum",()=>["value = 0.0;","value += _A(inputIdx);","value = log(value);"]),yc=(e,n,a)=>Xe(e,n,a,"ReduceLogSumSquare",()=>["float t; value = 0.0;","t = _A(inputIdx); value += t * t;",""])}),Tc,wc=O(()=>{Y(),Tc=(e,n)=>{let a=B.calculateReshapedDims(n[0].dims,n[1].integerData);return e.session.pack?[e.reshapePacked(n[0],a)]:[e.reshapeUnpacked(n[0],a)]}}),vc,Ei,Ic,_c,Gr,zb,Di,Mn,Li=O(()=>{It(),ut(),j(),vc={name:"Upsample",inputNames:["X"],inputTypes:[0]},Ei=(e,n,a)=>(Di(n,a),[e.run({...vc,cacheHint:a.cacheKey,get:()=>zb(e,n,a)},n)]),Ic=e=>Gr(e,7),_c=e=>Gr(e,9),Gr=(e,n)=>{let a=n>=10,i=e.attributes.getString("mode","nearest");if(i!=="nearest"&&i!=="linear"&&(n<11||i!=="cubic"))throw new Error(`unrecognized mode: ${i}`);let p=[];n<9&&(p=e.attributes.getFloats("scales"),Mn(p,i,a));let o=e.attributes.getFloat("extrapolation_value",0),s=n>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(s)===-1)throw new Error(`coordinate_transform_mode '${s}' is not supported`);let c=s==="tf_crop_and_resize",h=c,r=i==="nearest"&&n>=11?e.attributes.getString("nearest_mode","round_prefer_floor"):"";if(["round_prefer_floor","round_prefer_ceil","floor","ceil",""].indexOf(r)===-1)throw new Error(`nearest_mode '${r}' is not supported`);let u=e.attributes.getFloat("cubic_coeff_a",-.75),l=e.attributes.getInt("exclude_outside",0)!==0;if(l&&i!=="cubic")throw new Error("exclude_outside can be set to 1 only when mode is CUBIC.");let f=n<11?!0:i==="nearest"&&s==="asymmetric"&&r==="floor",g=0,b=0,v=0;return n>10?e.inputs.length>2?(g=1,b=2,v=3):(b=1,v=2):n===9&&(b=1),W({opset:n,isResize:a,mode:i,scales:p,extrapolationValue:o,coordinateTransformMode:s,useExtrapolation:h,needRoiInput:c,nearestMode:r,cubicCoefficientA:u,excludeOutside:l,useNearest2xOptimization:f,roiInputIdx:g,scalesInputIdx:b,sizesInputIdx:v})},zb=(e,n,a)=>{let i=G(e.session.backend.glContext.version),[p,o]=e.calculateTextureWidthAndHeight(n[0].dims,0),s=n[0].dims.map((v,S)=>Math.floor(v*a.scales[S])),[c,h]=e.calculateTextureWidthAndHeight(s,0),r=s.length,u=new Array(r),l=new Array(r),f=`
1005
+ int output_pitches[${r}];
1006
+ int input_pitches[${r}];
1007
+ `;for(let v=r-1;v>=0;v--)u[v]=v===r-1?1:u[v+1]*s[v+1],l[v]=v===r-1?1:l[v+1]*n[0].dims[v+1],f+=`
1008
+ output_pitches[${v}] = ${u[v]};
1009
+ input_pitches[${v}] = ${l[v]};
1010
+ `;let g=`
1011
1011
  float getInputFloat(int index) {
1012
- vec2 coords = offsetToCoords(index, ${u}, ${n});
1012
+ vec2 coords = offsetToCoords(index, ${p}, ${o});
1013
1013
  float value = getColorAsFloat(${i.texture2D}(X, coords));
1014
1014
  return value;
1015
1015
  }
1016
- `,m=o.mode==="nearest"?`
1017
- ${f}
1018
- float process(int indices[${e}]) {
1016
+ `,b=a.mode==="nearest"?`
1017
+ ${g}
1018
+ float process(int indices[${r}]) {
1019
1019
  int input_index = 0;
1020
- int output_index = coordsToOffset(TexCoords, ${d}, ${c});
1020
+ int output_index = coordsToOffset(TexCoords, ${c}, ${h});
1021
1021
 
1022
- ${h}
1022
+ ${f}
1023
1023
 
1024
1024
  int d, m;
1025
- for (int dim = 0; dim < ${e}; ++dim) {
1025
+ for (int dim = 0; dim < ${r}; ++dim) {
1026
1026
  d = output_index / output_pitches[dim];
1027
1027
  m = output_index - d * output_pitches[dim];
1028
1028
  output_index = m;
@@ -1036,13 +1036,13 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(t,r,o)=>Xe(
1036
1036
  }
1037
1037
 
1038
1038
  return getInputFloat(input_index);
1039
- }`:e===4?`
1040
- ${f}
1039
+ }`:r===4?`
1040
+ ${g}
1041
1041
  float process(int indices[4]) {
1042
1042
  int input_index = 0;
1043
- int output_index = coordsToOffset(TexCoords, ${d}, ${c});
1043
+ int output_index = coordsToOffset(TexCoords, ${c}, ${h});
1044
1044
 
1045
- ${h}
1045
+ ${f}
1046
1046
 
1047
1047
  int m;
1048
1048
  int index_of_dim0, index_of_dim1, index_of_dim2, index_of_dim3;
@@ -1069,7 +1069,7 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(t,r,o)=>Xe(
1069
1069
  float x10, x01, x11;
1070
1070
 
1071
1071
  bool end_of_dim2 = false;
1072
- if (index_of_input_dim2 == (${r[0].dims[2]} - 1)) {
1072
+ if (index_of_input_dim2 == (${n[0].dims[2]} - 1)) {
1073
1073
  // It's the end in dimension 2
1074
1074
  x01 = x00;
1075
1075
  end_of_dim2 = true;
@@ -1091,12 +1091,12 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(t,r,o)=>Xe(
1091
1091
  float y1 = x10 + float(y_offset) * (x11 - x10) / float(scales[2]);
1092
1092
  return y0 + float(x_offset) * (y1 - y0) / float(scales[3]);
1093
1093
  }`:`
1094
- ${f}
1094
+ ${g}
1095
1095
  float process(int indices[2]) {
1096
1096
  int input_index = 0;
1097
- int output_index = coordsToOffset(TexCoords, ${d}, ${c});
1097
+ int output_index = coordsToOffset(TexCoords, ${c}, ${h});
1098
1098
 
1099
- ${h}
1099
+ ${f}
1100
1100
 
1101
1101
  int m;
1102
1102
  int index_of_dim0, index_of_dim1;
@@ -1116,7 +1116,7 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(t,r,o)=>Xe(
1116
1116
  float x10, x01, x11;
1117
1117
 
1118
1118
  bool end_of_dim0 = false;
1119
- if (index_of_input_dim0 == (${r[0].dims[0]} - 1)) {
1119
+ if (index_of_input_dim0 == (${n[0].dims[0]} - 1)) {
1120
1120
  // It's the end in dimension 0
1121
1121
  x01 = x00;
1122
1122
  end_of_dim0 = true;
@@ -1137,41 +1137,41 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(t,r,o)=>Xe(
1137
1137
  float y0 = x00 + float(y_offset) * (x01 - x00) / float(scales[0]);
1138
1138
  float y1 = x10 + float(y_offset) * (x11 - x10) / float(scales[0]);
1139
1139
  return y0 + float(x_offset) * (y1 - y0) / float(scales[1]);
1140
- }`;return{...vc,output:{dims:a,type:r[0].type,textureType:0},shaderSource:m,variables:[{name:"scales",type:"int",arrayLength:o.scales.length,data:o.scales.map(v=>Math.ceil(v))}]}},Di=(t,r)=>{if(!t||r.opset<9&&t.length!==1||r.opset>=9&&r.opset<11&&t.length!==2||r.opset>=11&&t.length<2)throw new Error("invalid inputs.");if(r.scales.length>0&&t[0].dims.length!==r.scales.length)throw new Error("Invalid input shape.");if(t[0].type==="string")throw new Error("Invalid input tensor types.")},Mn=(t,r,o)=>{if(o){for(let i of t)if(i<=0)throw new Error("Scale value should be greater than 0.")}else for(let i of t)if(i<1)throw new Error("Scale value should be greater than or equal to 1.");if((r==="linear"||r==="cubic")&&t.length!==2&&(t.length!==4||t[0]!==1||t[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 ${o?"Resize":"Upsample"} opeartor.`)}}),$i,ki,Oc,Sc,Wb,Hb,qb,jb,Ac=O(()=>{ut(),j(),pe(),He(),Li(),$i={name:"Resize",inputNames:["A"],inputTypes:[2]},ki=(t,r,o)=>(Di(r,o),[t.run({...$i,cacheHint:o.cacheKey,get:()=>Wb(t,r,o)},r)]),Oc=t=>Gr(t,10),Sc=t=>Gr(t,11),Wb=(t,r,o)=>{let i=G(t.session.backend.glContext.version),[u,n]=Hb(r,o);if(u.every(T=>T===1)&&o.coordinateTransformMode!=="tf_crop_and_resize")return{...$i,output:{dims:n,type:r[0].type,textureType:2},hasMain:!0,shaderSource:`void main() {
1140
+ }`;return{...vc,output:{dims:s,type:n[0].type,textureType:0},shaderSource:b,variables:[{name:"scales",type:"int",arrayLength:a.scales.length,data:a.scales.map(v=>Math.ceil(v))}]}},Di=(e,n)=>{if(!e||n.opset<9&&e.length!==1||n.opset>=9&&n.opset<11&&e.length!==2||n.opset>=11&&e.length<2)throw new Error("invalid inputs.");if(n.scales.length>0&&e[0].dims.length!==n.scales.length)throw new Error("Invalid input shape.");if(e[0].type==="string")throw new Error("Invalid input tensor types.")},Mn=(e,n,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((n==="linear"||n==="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.`)}}),$i,ki,Oc,Sc,Wb,Hb,qb,jb,Ac=O(()=>{ut(),j(),pe(),He(),Li(),$i={name:"Resize",inputNames:["A"],inputTypes:[2]},ki=(e,n,a)=>(Di(n,a),[e.run({...$i,cacheHint:a.cacheKey,get:()=>Wb(e,n,a)},n)]),Oc=e=>Gr(e,10),Sc=e=>Gr(e,11),Wb=(e,n,a)=>{let i=G(e.session.backend.glContext.version),[p,o]=Hb(n,a);if(p.every(_=>_===1)&&a.coordinateTransformMode!=="tf_crop_and_resize")return{...$i,output:{dims:o,type:n[0].type,textureType:2},hasMain:!0,shaderSource:`void main() {
1141
1141
  vec4 v = ${i.texture2D}(X, TexCoords);
1142
1142
  ${i.output} = v;
1143
- }`};let a=n.length;if(a<2)throw new Error(`output dimension should be at least 2, but got ${a}`);let d=n[a-2],c=n[a-1],e=r[0].dims;if(a!==e.length)throw new Error(`output dimension should match input ${e.length}, but got ${a}`);let l=e[a-2],s=e[a-1],h=u[a-2],f=u[a-1],m="";if(o.mode!=="linear")throw new Error(`resize (packed) does not support mode: '${o.mode}'`);switch(o.coordinateTransformMode){case"asymmetric":m=`
1143
+ }`};let s=o.length;if(s<2)throw new Error(`output dimension should be at least 2, but got ${s}`);let c=o[s-2],h=o[s-1],r=n[0].dims;if(s!==r.length)throw new Error(`output dimension should match input ${r.length}, but got ${s}`);let u=r[s-2],l=r[s-1],f=p[s-2],g=p[s-1],b="";if(a.mode!=="linear")throw new Error(`resize (packed) does not support mode: '${a.mode}'`);switch(a.coordinateTransformMode){case"asymmetric":b=`
1144
1144
  vec4 getSourceFracIndex(ivec4 coords) {
1145
1145
  return vec4(coords) / scaleWHWH;
1146
1146
  }
1147
- `;break;case"half_pixel":m=`
1147
+ `;break;case"half_pixel":b=`
1148
1148
  vec4 getSourceFracIndex(ivec4 coords) {
1149
1149
  return (vec4(coords) + 0.5) / scaleWHWH - 0.5;
1150
1150
  }
1151
- `;break;case"pytorch_half_pixel":m=`
1151
+ `;break;case"pytorch_half_pixel":b=`
1152
1152
  vec4 getSourceFracIndex(ivec4 coords) {
1153
1153
  vec4 fcoords = vec4(coords);
1154
1154
  return vec4(
1155
- ${c}.0 > 1.0 ? (fcoords.x + 0.5) / scaleWHWH.x - 0.5 : 0.0,
1156
- ${d}.0 > 1.0 ? (fcoords.y + 0.5) / scaleWHWH.y - 0.5 : 0.0,
1157
- ${c}.0 > 1.0 ? (fcoords.z + 0.5) / scaleWHWH.z - 0.5 : 0.0,
1158
- ${d}.0 > 1.0 ? (fcoords.w + 0.5) / scaleWHWH.w - 0.5 : 0.0
1155
+ ${h}.0 > 1.0 ? (fcoords.x + 0.5) / scaleWHWH.x - 0.5 : 0.0,
1156
+ ${c}.0 > 1.0 ? (fcoords.y + 0.5) / scaleWHWH.y - 0.5 : 0.0,
1157
+ ${h}.0 > 1.0 ? (fcoords.z + 0.5) / scaleWHWH.z - 0.5 : 0.0,
1158
+ ${c}.0 > 1.0 ? (fcoords.w + 0.5) / scaleWHWH.w - 0.5 : 0.0
1159
1159
  );
1160
1160
  }
1161
- `;break;case"align_corners":m=`
1161
+ `;break;case"align_corners":b=`
1162
1162
  vec4 getSourceFracIndex(ivec4 coords) {
1163
- vec4 resized = vec4(${c}.0 - 1.0, ${d}.0 - 1.0, ${c}.0 - 1.0,
1164
- ${d}.0 - 1.0);
1165
- vec4 original = vec4(${s}.0 - 1.0, ${l}.0 - 1.0, ${s}.0 - 1.0,
1166
- ${l}.0 - 1.0);
1163
+ vec4 resized = vec4(${h}.0 - 1.0, ${c}.0 - 1.0, ${h}.0 - 1.0,
1164
+ ${c}.0 - 1.0);
1165
+ vec4 original = vec4(${l}.0 - 1.0, ${u}.0 - 1.0, ${l}.0 - 1.0,
1166
+ ${u}.0 - 1.0);
1167
1167
  vec4 new_scale = original / resized;
1168
1168
  return vec4(coords) * new_scale;
1169
1169
  }
1170
- `;break;default:throw new Error(`resize (packed) does not support coordinateTransformMode: '${o.coordinateTransformMode}'`)}let v=Bt(a),_=de(),I=`
1171
- const vec2 inputWH = vec2(${l}.0, ${s}.0);
1172
- const vec4 scaleWHWH = vec4(float(${h}), float(${f}), float(${h}), float(${f}));
1173
- ${_}
1174
- ${m}
1170
+ `;break;default:throw new Error(`resize (packed) does not support coordinateTransformMode: '${a.coordinateTransformMode}'`)}let v=Bt(s),S=de(),P=`
1171
+ const vec2 inputWH = vec2(${u}.0, ${l}.0);
1172
+ const vec4 scaleWHWH = vec4(float(${f}), float(${g}), float(${f}), float(${g}));
1173
+ ${S}
1174
+ ${b}
1175
1175
  float getAValue(int x10, int r, int c, int d) {
1176
1176
  return getChannel(getA(x10, r, c, d), vec2(c, d));
1177
1177
  }
@@ -1193,8 +1193,8 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(t,r,o)=>Xe(
1193
1193
  ivec4 x10 = ivec4(max(sourceFrac.zy, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.zy)));
1194
1194
  ivec4 x11 = ivec4(max(sourceFrac.zw, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.zw)));
1195
1195
 
1196
- bool hasNextRow = rc.w < ${d-1};
1197
- bool hasNextCol = rc.z < ${c-1};
1196
+ bool hasNextRow = rc.w < ${c-1};
1197
+ bool hasNextCol = rc.z < ${h-1};
1198
1198
 
1199
1199
  // pack x00, x01, x10, x11's top-left corner into one vec4 structure
1200
1200
  vec4 topLeft = vec4(
@@ -1234,44 +1234,44 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(t,r,o)=>Xe(
1234
1234
 
1235
1235
  ${i.output} = vec4(newValue);
1236
1236
  }
1237
- `;return{...$i,output:{dims:n,type:r[0].type,textureType:2},hasMain:!0,shaderSource:I}},Hb=(t,r)=>{let o=t[0].dims,i=r.scales,u;if(i.length===0){let a=t[r.scalesInputIdx];if(a&&a.size!==0){if(t[r.sizesInputIdx])throw new Error("Only one of scales or sizes must be provided as input.");i=qb(a,r.mode,r.isResize)}else{let d=t[r.sizesInputIdx];if(!d||d.size===0)throw new Error("Either scales or sizes MUST be provided as input.");u=Array.from(d.integerData),i=jb(u,o,r.mode,r.isResize)}}else if(t[r.sizesInputIdx])throw new Error("Only one of scales or sizes must be provided as input.");let n=u||o.map((a,d)=>Math.floor(a*i[d]));return[i,n]},qb=(t,r,o)=>{let i=Array.from(t.floatData);return Mn(i,r,o),i},jb=(t,r,o,i)=>{let u=r.length,n=new Array(u);for(let a=0,d=u;a<d;a++)if(r[a]===0){if(t[a]!==0)throw new Error("Input dim is zero but required output dim is non-zero.");n[a]=1}else n[a]=t[a]/r[a];return Mn(n,o,i),n}}),Pc,Xb,Ec=O(()=>{We(),Pc=(t,r)=>(Xb(r),[new bt([r[0].dims.length],"int32",void 0,void 0,new Int32Array(r[0].dims))]),Xb=t=>{if(!t||t.length!==1)throw new Error("Shape requires 1 input.")}}),Bi,Dc,Lc,$c,Kb,kc,Jb,Yb,Bc=O(()=>{It(),Rr(),Y(),j(),Bi={name:"Slice",inputNames:["A"],inputTypes:[0]},Dc=(t,r,o)=>(Kb(r),[t.run({...Bi,cacheHint:o.cacheKey,get:()=>$c(t,r[0],o)},r)]),Lc=t=>{let r=t.attributes.getInts("starts"),o=t.attributes.getInts("ends"),i=t.attributes.getInts("axes",[]);return W({starts:r,ends:o,axes:i})},$c=(t,r,o)=>{let i=o.axes.length===0?r.dims.slice(0).map((l,s)=>s):o.axes,u=B.normalizeAxes(i,r.dims.length),n=o.starts.map((l,s)=>l>r.dims[u[s]]-1?r.dims[u[s]]:B.normalizeAxis(l,r.dims[u[s]])),a=o.ends.map((l,s)=>l>r.dims[u[s]]-1?r.dims[u[s]]:B.normalizeAxis(l,r.dims[u[s]])),d=r.dims.slice(),c=[];for(let l=0;l<u.length;l++)d[u[l]]=a[l]-n[l],n[l]>0&&c.push(`outputIdx[${u[l]}] += ${n[l]};`);let e=`
1238
- float process(int outputIdx[${d.length}]) {
1239
- ${c.join(`
1237
+ `;return{...$i,output:{dims:o,type:n[0].type,textureType:2},hasMain:!0,shaderSource:P}},Hb=(e,n)=>{let a=e[0].dims,i=n.scales,p;if(i.length===0){let s=e[n.scalesInputIdx];if(s&&s.size!==0){if(e[n.sizesInputIdx])throw new Error("Only one of scales or sizes must be provided as input.");i=qb(s,n.mode,n.isResize)}else{let c=e[n.sizesInputIdx];if(!c||c.size===0)throw new Error("Either scales or sizes MUST be provided as input.");p=Array.from(c.integerData),i=jb(p,a,n.mode,n.isResize)}}else if(e[n.sizesInputIdx])throw new Error("Only one of scales or sizes must be provided as input.");let o=p||a.map((s,c)=>Math.floor(s*i[c]));return[i,o]},qb=(e,n,a)=>{let i=Array.from(e.floatData);return Mn(i,n,a),i},jb=(e,n,a,i)=>{let p=n.length,o=new Array(p);for(let s=0,c=p;s<c;s++)if(n[s]===0){if(e[s]!==0)throw new Error("Input dim is zero but required output dim is non-zero.");o[s]=1}else o[s]=e[s]/n[s];return Mn(o,a,i),o}}),Pc,Xb,Ec=O(()=>{We(),Pc=(e,n)=>(Xb(n),[new bt([n[0].dims.length],"int32",void 0,void 0,new Int32Array(n[0].dims))]),Xb=e=>{if(!e||e.length!==1)throw new Error("Shape requires 1 input.")}}),Bi,Dc,Lc,$c,Kb,kc,Jb,Yb,Bc=O(()=>{It(),Rr(),Y(),j(),Bi={name:"Slice",inputNames:["A"],inputTypes:[0]},Dc=(e,n,a)=>(Kb(n),[e.run({...Bi,cacheHint:a.cacheKey,get:()=>$c(e,n[0],a)},n)]),Lc=e=>{let n=e.attributes.getInts("starts"),a=e.attributes.getInts("ends"),i=e.attributes.getInts("axes",[]);return W({starts:n,ends:a,axes:i})},$c=(e,n,a)=>{let i=a.axes.length===0?n.dims.slice(0).map((u,l)=>l):a.axes,p=B.normalizeAxes(i,n.dims.length),o=a.starts.map((u,l)=>u>n.dims[p[l]]-1?n.dims[p[l]]:B.normalizeAxis(u,n.dims[p[l]])),s=a.ends.map((u,l)=>u>n.dims[p[l]]-1?n.dims[p[l]]:B.normalizeAxis(u,n.dims[p[l]])),c=n.dims.slice(),h=[];for(let u=0;u<p.length;u++)c[p[u]]=s[u]-o[u],o[u]>0&&h.push(`outputIdx[${p[u]}] += ${o[u]};`);let r=`
1238
+ float process(int outputIdx[${c.length}]) {
1239
+ ${h.join(`
1240
1240
  `)}
1241
1241
  return _A(outputIdx);
1242
- }`;return{...Bi,output:{dims:d,type:r.type,textureType:0},shaderSource:e}},Kb=t=>{if(!t||t.length!==1)throw new Error("Slice requires 1 input.");if(Pe.indexOf(t[0].type)===-1)throw new Error("Invalid input type.")},kc=(t,r)=>{Yb(r);let o=Jb(t,r);return[t.run({...Bi,cacheHint:o.cacheKey,get:()=>$c(t,r[0],o)},[r[0]])]},Jb=(t,r)=>{if(!t.session.isInitializer(r[1].dataId)||!t.session.isInitializer(r[2].dataId)||r.length>=4&&!t.session.isInitializer(r[3].dataId)||r.length>=5&&!t.session.isInitializer(r[4].dataId))throw new Error("dynamic slice attributes are not allowed");if(r.length>=5&&r[4].integerData.some(a=>a!==1))throw new Error("currently non-1 steps is not supported for Slice");let o=Array.from(r[1].integerData),i=Array.from(r[2].integerData),u=r.length>=4?Array.from(r[3].integerData):[],n=`${u};${o};${i}`;return{starts:o,ends:i,axes:u,cacheKey:n}},Yb=t=>{if(!t||t.length<3||t.length>5)throw new Error("Invalid input number.");if(t[1].type!=="int32"||t[1].dims.length!==1)throw new Error("Invalid input type.");if(t[2].type!=="int32"||t[2].dims.length!==1)throw new Error("Invalid input type.");if(t.length>=4&&(t[3].type!=="int32"||t[3].dims.length!==1))throw new Error("Invalid input type.");if(t.length>=5&&(t[4].type!=="int32"||t[4].dims.length!==1))throw new Error("Invalid input type.")}}),Fc,Cc,Nc,Rc,Gc,Mc,Uc,Vc,Zb,Qb,tg,zc,Wc=O(()=>{It(),Y(),ut(),j(),Nn(),Fc={name:"SoftmaxComputeMax",inputNames:["A"],inputTypes:[0]},Cc={name:"SoftmaxComputeScale",inputNames:["A","Max"],inputTypes:[0,0]},Nc={name:"SoftMax",inputNames:["A","Max","Norm"],inputTypes:[0,0,0]},Rc=(t,r,o)=>{zc(r);let i=r[0].dims.slice(),u=B.normalizeAxis(o.axis,i.length),n=B.sizeToDimension(i,u),a=B.sizeFromDimension(i,u);return Vc(t,r,o,n,a)},Gc=t=>W({axis:t.attributes.getInt("axis",1)}),Mc=t=>W({axis:t.attributes.getInt("axis",-1)}),Uc=(t,r,o)=>{zc(r);let i=r[0].dims.slice(),u=B.normalizeAxis(o.axis,i.length),n=i.length,a=u!==n-1,d=[],c=[],e=[],l;a&&(c=Array.from({length:n}).map((m,v)=>v),c[u]=n-1,c[n-1]=u,c.map(m=>d.push(i[m])),l=W({perm:c}),e=je(t,r,l));let s=a?B.sizeToDimension(d,n-1):B.sizeToDimension(i,n-1),h=a?B.sizeFromDimension(d,n-1):B.sizeFromDimension(i,n-1),f=Vc(t,a?e:r,o,s,h);return a?je(t,f,l):f},Vc=(t,r,o,i,u)=>{let n=Zb(t,r[0],i,u,[i]),a=t.run({...Fc,cacheHint:o.cacheKey,get:()=>n},r),d=Qb(t,r[0],i,u,n.output.dims,[i]),c=t.run({...Cc,cacheHint:o.cacheKey,get:()=>d},[r[0],a]),e=tg(t,r[0],i,u,n.output.dims,d.output.dims);return[t.run({...Nc,cacheHint:o.cacheKey,get:()=>e},[r[0],a,c])]},Zb=(t,r,o,i,u)=>{let[n,a]=t.calculateTextureWidthAndHeight(r.dims,0),d=u.length;if(o<1||i<1)throw new Error("Logical row count N and feature count D must be greater than or equal to 1");if(u.length!==1)throw new Error("Dimensionality of the output should be 1");if(u[0]!==o)throw new Error("Shape of the output should be equal to logical row count");let c=G(t.session.backend.glContext.version),e=`
1243
- float process(int[${d}] indices) {
1242
+ }`;return{...Bi,output:{dims:c,type:n.type,textureType:0},shaderSource:r}},Kb=e=>{if(!e||e.length!==1)throw new Error("Slice requires 1 input.");if(Pe.indexOf(e[0].type)===-1)throw new Error("Invalid input type.")},kc=(e,n)=>{Yb(n);let a=Jb(e,n);return[e.run({...Bi,cacheHint:a.cacheKey,get:()=>$c(e,n[0],a)},[n[0]])]},Jb=(e,n)=>{if(!e.session.isInitializer(n[1].dataId)||!e.session.isInitializer(n[2].dataId)||n.length>=4&&!e.session.isInitializer(n[3].dataId)||n.length>=5&&!e.session.isInitializer(n[4].dataId))throw new Error("dynamic slice attributes are not allowed");if(n.length>=5&&n[4].integerData.some(s=>s!==1))throw new Error("currently non-1 steps is not supported for Slice");let a=Array.from(n[1].integerData),i=Array.from(n[2].integerData),p=n.length>=4?Array.from(n[3].integerData):[],o=`${p};${a};${i}`;return{starts:a,ends:i,axes:p,cacheKey:o}},Yb=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.")}}),Fc,Cc,Nc,Rc,Gc,Mc,Uc,Vc,Zb,Qb,tg,zc,Wc=O(()=>{It(),Y(),ut(),j(),Nn(),Fc={name:"SoftmaxComputeMax",inputNames:["A"],inputTypes:[0]},Cc={name:"SoftmaxComputeScale",inputNames:["A","Max"],inputTypes:[0,0]},Nc={name:"SoftMax",inputNames:["A","Max","Norm"],inputTypes:[0,0,0]},Rc=(e,n,a)=>{zc(n);let i=n[0].dims.slice(),p=B.normalizeAxis(a.axis,i.length),o=B.sizeToDimension(i,p),s=B.sizeFromDimension(i,p);return Vc(e,n,a,o,s)},Gc=e=>W({axis:e.attributes.getInt("axis",1)}),Mc=e=>W({axis:e.attributes.getInt("axis",-1)}),Uc=(e,n,a)=>{zc(n);let i=n[0].dims.slice(),p=B.normalizeAxis(a.axis,i.length),o=i.length,s=p!==o-1,c=[],h=[],r=[],u;s&&(h=Array.from({length:o}).map((b,v)=>v),h[p]=o-1,h[o-1]=p,h.map(b=>c.push(i[b])),u=W({perm:h}),r=je(e,n,u));let l=s?B.sizeToDimension(c,o-1):B.sizeToDimension(i,o-1),f=s?B.sizeFromDimension(c,o-1):B.sizeFromDimension(i,o-1),g=Vc(e,s?r:n,a,l,f);return s?je(e,g,u):g},Vc=(e,n,a,i,p)=>{let o=Zb(e,n[0],i,p,[i]),s=e.run({...Fc,cacheHint:a.cacheKey,get:()=>o},n),c=Qb(e,n[0],i,p,o.output.dims,[i]),h=e.run({...Cc,cacheHint:a.cacheKey,get:()=>c},[n[0],s]),r=tg(e,n[0],i,p,o.output.dims,c.output.dims);return[e.run({...Nc,cacheHint:a.cacheKey,get:()=>r},[n[0],s,h])]},Zb=(e,n,a,i,p)=>{let[o,s]=e.calculateTextureWidthAndHeight(n.dims,0),c=p.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(p.length!==1)throw new Error("Dimensionality of the output should be 1");if(p[0]!==a)throw new Error("Shape of the output should be equal to logical row count");let h=G(e.session.backend.glContext.version),r=`
1243
+ float process(int[${c}] indices) {
1244
1244
  int logical_row_start_offset = indices[0] * ${i};
1245
1245
 
1246
- float max = getColorAsFloat(${c.texture2D}(A, offsetToCoords(logical_row_start_offset, ${n},
1247
- ${a} )));
1246
+ float max = getColorAsFloat(${h.texture2D}(A, offsetToCoords(logical_row_start_offset, ${o},
1247
+ ${s} )));
1248
1248
  for(int i=1; i<${i}; ++i)
1249
1249
  {
1250
- float current = getColorAsFloat(${c.texture2D}(A, offsetToCoords(logical_row_start_offset + i,
1251
- ${n}, ${a})));
1250
+ float current = getColorAsFloat(${h.texture2D}(A, offsetToCoords(logical_row_start_offset + i,
1251
+ ${o}, ${s})));
1252
1252
  if(current > max)
1253
1253
  max = current;
1254
1254
  }
1255
1255
 
1256
1256
  return max;
1257
- }`;return{...Fc,output:{dims:u,type:r.type,textureType:0},shaderSource:e}},Qb=(t,r,o,i,u,n)=>{let[a,d]=t.calculateTextureWidthAndHeight(r.dims,0),c=n.length;if(o<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]!==o)throw new Error("Shape of the output should be equal to logical row count");if(u.length!==1)throw new Error("Dimensionality of the intermediate results should be 1");if(u[0]!==o)throw new Error("Shape of the intermediate results should be equal to logical row count");let e=G(t.session.backend.glContext.version),l=`
1258
- float process(int[${c}] indices) {
1257
+ }`;return{...Fc,output:{dims:p,type:n.type,textureType:0},shaderSource:r}},Qb=(e,n,a,i,p,o)=>{let[s,c]=e.calculateTextureWidthAndHeight(n.dims,0),h=o.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(o.length!==1)throw new Error("Dimensionality of the output should be 1");if(o[0]!==a)throw new Error("Shape of the output should be equal to logical row count");if(p.length!==1)throw new Error("Dimensionality of the intermediate results should be 1");if(p[0]!==a)throw new Error("Shape of the intermediate results should be equal to logical row count");let r=G(e.session.backend.glContext.version),u=`
1258
+ float process(int[${h}] indices) {
1259
1259
  int logical_row_start_offset = indices[0] * ${i};
1260
1260
 
1261
1261
  float norm_factor = 0.0;
1262
1262
  float max = _Max(indices);
1263
1263
  for(int i=0; i<${i}; ++i)
1264
1264
  {
1265
- norm_factor += exp(getColorAsFloat(${e.texture2D}(A, offsetToCoords(logical_row_start_offset + i,
1266
- ${a}, ${d}))) - max);
1265
+ norm_factor += exp(getColorAsFloat(${r.texture2D}(A, offsetToCoords(logical_row_start_offset + i,
1266
+ ${s}, ${c}))) - max);
1267
1267
  }
1268
1268
 
1269
1269
  return norm_factor;
1270
- }`;return{...Cc,output:{dims:n,type:r.type,textureType:0},shaderSource:l}},tg=(t,r,o,i,u,n)=>{let[a,d]=t.calculateTextureWidthAndHeight(r.dims,0),c=r.dims.length;if(o<1||i<1)throw new Error("Logical row count N and feature count D must be greater than or equal to 1");if(u.length!==1||n.length!==1)throw new Error("Dimensionality of the intermediate results should be 1");if(u[0]!==o||n[0]!==o)throw new Error("Shape of the intermediate results should be equal to logical row count");let e=`
1271
- float process(int[${c}] indices) {
1270
+ }`;return{...Cc,output:{dims:o,type:n.type,textureType:0},shaderSource:u}},tg=(e,n,a,i,p,o)=>{let[s,c]=e.calculateTextureWidthAndHeight(n.dims,0),h=n.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(p.length!==1||o.length!==1)throw new Error("Dimensionality of the intermediate results should be 1");if(p[0]!==a||o[0]!==a)throw new Error("Shape of the intermediate results should be equal to logical row count");let r=`
1271
+ float process(int[${h}] indices) {
1272
1272
 
1273
1273
  // get offset of current logical tensor index from the 2-D texture coordinates (TexCoords)
1274
- int offset = coordsToOffset(TexCoords, ${a}, ${d});
1274
+ int offset = coordsToOffset(TexCoords, ${s}, ${c});
1275
1275
 
1276
1276
  //determine the logical row for this index
1277
1277
  int logical_row_index[1];
@@ -1286,75 +1286,75 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(t,r,o)=>Xe(
1286
1286
  return 0.0;
1287
1287
 
1288
1288
  return exp(_A(indices) - _Max(logical_row_index)) / norm_factor;
1289
- }`;return{...Nc,output:{dims:r.dims,type:r.type,textureType:0},shaderSource:e}},zc=t=>{if(!t||t.length!==1)throw new Error("Softmax requires 1 input.");if(t[0].type!=="float32"&&t[0].type!=="float64")throw new Error("Invalid input type")}}),Hc,qc,jc,eg,rg,ng,Xc=O(()=>{It(),Y(),j(),Hc={name:"Split",inputNames:["A"],inputTypes:[0]},qc=(t,r,o)=>{ng(r);let i=B.normalizeAxis(o.axis,r[0].dims.length),u=eg(t,r,i,o),n=[];for(let a=0;a<u;++a)n.push(t.run({...Hc,cacheHint:`${o.cacheKey};${a}`,get:()=>rg(t,r[0],o,i,a)},r));return n},jc=t=>{let r=t.attributes.getInt("axis",0),o=t.attributes.getInts("split",[]),i=t.outputs.length;return W({axis:r,split:o,numOutputs:i})},eg=(t,r,o,i)=>{let[,u]=$r.splitShape(r[0].dims,o,i.split,i.numOutputs);return u.length},rg=(t,r,o,i,u)=>{let[n,a]=$r.splitShape(r.dims,i,o.split,o.numOutputs),d=a[u],c=n[u],e=`
1290
- float process(int indices[${c.length}]) {
1291
- indices[${i}] += ${d};
1289
+ }`;return{...Nc,output:{dims:n.dims,type:n.type,textureType:0},shaderSource:r}},zc=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")}}),Hc,qc,jc,eg,rg,ng,Xc=O(()=>{It(),Y(),j(),Hc={name:"Split",inputNames:["A"],inputTypes:[0]},qc=(e,n,a)=>{ng(n);let i=B.normalizeAxis(a.axis,n[0].dims.length),p=eg(e,n,i,a),o=[];for(let s=0;s<p;++s)o.push(e.run({...Hc,cacheHint:`${a.cacheKey};${s}`,get:()=>rg(e,n[0],a,i,s)},n));return o},jc=e=>{let n=e.attributes.getInt("axis",0),a=e.attributes.getInts("split",[]),i=e.outputs.length;return W({axis:n,split:a,numOutputs:i})},eg=(e,n,a,i)=>{let[,p]=$r.splitShape(n[0].dims,a,i.split,i.numOutputs);return p.length},rg=(e,n,a,i,p)=>{let[o,s]=$r.splitShape(n.dims,i,a.split,a.numOutputs),c=s[p],h=o[p],r=`
1290
+ float process(int indices[${h.length}]) {
1291
+ indices[${i}] += ${c};
1292
1292
  return _A(indices);
1293
1293
  }
1294
- `;return{...Hc,cacheHint:`${o.cacheKey}:${u}`,output:{dims:c,type:r.type,textureType:0},shaderSource:e}},ng=t=>{if(!t||t.length!==1)throw new Error("Split requires one input.");if(t[0].type!=="int8"&&t[0].type!=="uint8"&&t[0].type!=="int16"&&t[0].type!=="uint16"&&t[0].type!=="int32"&&t[0].type!=="uint32"&&t[0].type!=="float32"&&t[0].type!=="float64"&&t[0].type!=="bool")throw new Error("Invalid input type.")}}),Fi,Kc,Jc,og,ig,Yc=O(()=>{Y(),Fi=(t,r,o)=>{og(r);let i=B.squeezeShape(r[0].dims,o);return[t.reshapeUnpacked(r[0],i)]},Kc=(t,r)=>(ig(r),Fi(t,[r[0]],Array.from(r[1].integerData))),Jc=t=>t.attributes.getInts("axes"),og=t=>{if(!t||t.length!==1)throw new Error("Squeeze requires 1 input.");if(t[0].type==="string")throw new Error("invalid input tensor types.")},ig=t=>{if(!t||t.length!==2)throw new Error("Squeeze requires 2 inputs.");if(t[1].type!=="int32")throw new Error("Invalid input type.")}}),Zc,ag,sg,Qc=O(()=>{ut(),j(),Zc=(t,r)=>{sg(r);let o={name:"Sum",inputNames:r.map((i,u)=>`X${u}`),inputTypes:new Array(r.length).fill(0)};return[t.run({...o,get:()=>ag(t,r,o)},r)]},ag=(t,r,o)=>{let i=G(t.session.backend.glContext.version),u=r[0].dims.slice(),n=`
1294
+ `;return{...Hc,cacheHint:`${a.cacheKey}:${p}`,output:{dims:h,type:n.type,textureType:0},shaderSource:r}},ng=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.")}}),Fi,Kc,Jc,og,ig,Yc=O(()=>{Y(),Fi=(e,n,a)=>{og(n);let i=B.squeezeShape(n[0].dims,a);return[e.reshapeUnpacked(n[0],i)]},Kc=(e,n)=>(ig(n),Fi(e,[n[0]],Array.from(n[1].integerData))),Jc=e=>e.attributes.getInts("axes"),og=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.")},ig=e=>{if(!e||e.length!==2)throw new Error("Squeeze requires 2 inputs.");if(e[1].type!=="int32")throw new Error("Invalid input type.")}}),Zc,ag,sg,Qc=O(()=>{ut(),j(),Zc=(e,n)=>{sg(n);let a={name:"Sum",inputNames:n.map((i,p)=>`X${p}`),inputTypes:new Array(n.length).fill(0)};return[e.run({...a,get:()=>ag(e,n,a)},n)]},ag=(e,n,a)=>{let i=G(e.session.backend.glContext.version),p=n[0].dims.slice(),o=`
1295
1295
  void main() {
1296
- vec4 result = ${r.map((a,d)=>`${i.texture2D}(X${d},TexCoords)`).join(" + ")};
1296
+ vec4 result = ${n.map((s,c)=>`${i.texture2D}(X${c},TexCoords)`).join(" + ")};
1297
1297
  ${i.output} = result;
1298
1298
  }
1299
- `;return{...o,output:{dims:u,type:r[0].type,textureType:0},hasMain:!0,shaderSource:n}},sg=t=>{if(!t||t.length===0)throw new Error("Sum requires inputs.");let r=t[0].dims.length;for(let o=1;o<t.length;o++){if(r!==t[o].dims.length)throw new Error("Input shapes are mismatched.");for(let i=0;i<r;i++)if(t[0].dims[i]!==t[o].dims[i])throw new Error("Input shapes are not matched.")}if(t[0].type!=="float32"&&t[0].type!=="float64")throw new Error("Invalid input type.");for(let o=1;o<t.length;o++)if(t[0].type!==t[o].type)throw new Error("Input types are not matched.")}}),tp,ug,lg,ep=O(()=>{Rr(),j(),tp=(t,r)=>{lg(r);let o={name:"Tile",inputNames:["A"],inputTypes:[0]};return[t.run({...o,get:()=>ug(t,r,o)},r)]},ug=(t,r,o)=>{let i=r[0].dims.slice(),u=new Array(i.length),n=[];for(let c=0;c<i.length;c++)u[c]=i[c]*r[1].numberData[c],n.push(`inputIdx[${c}] = int(mod(float(outputIdx[${c}]), ${i[c]}.));`);let a=u.length,d=`
1300
- float process(int outputIdx[${a}]) {
1301
- int inputIdx[${a}];
1302
- ${n.join(`
1299
+ `;return{...a,output:{dims:p,type:n[0].type,textureType:0},hasMain:!0,shaderSource:o}},sg=e=>{if(!e||e.length===0)throw new Error("Sum requires inputs.");let n=e[0].dims.length;for(let a=1;a<e.length;a++){if(n!==e[a].dims.length)throw new Error("Input shapes are mismatched.");for(let i=0;i<n;i++)if(e[0].dims[i]!==e[a].dims[i])throw new Error("Input shapes are not matched.")}if(e[0].type!=="float32"&&e[0].type!=="float64")throw new Error("Invalid input type.");for(let a=1;a<e.length;a++)if(e[0].type!==e[a].type)throw new Error("Input types are not matched.")}}),tp,ug,lg,ep=O(()=>{Rr(),j(),tp=(e,n)=>{lg(n);let a={name:"Tile",inputNames:["A"],inputTypes:[0]};return[e.run({...a,get:()=>ug(e,n,a)},n)]},ug=(e,n,a)=>{let i=n[0].dims.slice(),p=new Array(i.length),o=[];for(let h=0;h<i.length;h++)p[h]=i[h]*n[1].numberData[h],o.push(`inputIdx[${h}] = int(mod(float(outputIdx[${h}]), ${i[h]}.));`);let s=p.length,c=`
1300
+ float process(int outputIdx[${s}]) {
1301
+ int inputIdx[${s}];
1302
+ ${o.join(`
1303
1303
  `)}
1304
1304
  return _A(inputIdx);
1305
1305
  }
1306
- `;return{...o,output:{dims:u,type:r[0].type,textureType:0},shaderSource:d}},lg=t=>{if(!t||t.length!==2)throw new Error("Tile requires 2 input.");if(t[1].dims.length!==1)throw new Error("The second input shape must 1 dimension.");if(t[1].dims[0]!==t[0].dims.length)throw new Error("Invalid input shape.");if(Pe.indexOf(t[0].type)===-1)throw new Error("Invalid input type.");if(t[1].type!=="int32"&&t[1].type!=="int16")throw new Error("Invalid repeat type.")}}),Ci,rp,np,fg,cg,op=O(()=>{Y(),Ci=(t,r,o)=>{fg(r);let i=B.unsqueezeShape(r[0].dims,o);return[t.reshapeUnpacked(r[0],i)]},rp=(t,r)=>(cg(r),Ci(t,[r[0]],Array.from(r[1].integerData))),np=t=>t.attributes.getInts("axes"),fg=t=>{if(!t||t.length!==1)throw new Error("Unsqueeze requires 1 input.");if(t[0].type==="string")throw new Error("invalid input tensor types.")},cg=t=>{if(!t||t.length!==2)throw new Error("Unsqueeze requires 2 inputs.");if(t[1].type!=="int32")throw new Error("Invalid input type.")}}),ip,ap=O(()=>{ml(),Pl(),Ll(),Nl(),Bn(),wf(),Af(),Df(),kf(),Nf(),Mf(),Wf(),Xf(),Fn(),Zf(),cc(),xc(),wc(),Ac(),Ec(),Bc(),Wc(),Xc(),Yc(),Qc(),ep(),Nn(),xi(),op(),Li(),ip=[["Abs","","6+",Rl],["Acos","","7+",Gl],["Add","","7+",bl],["And","","7+",gl],["Asin","","7+",Ml],["Atan","","7+",Ul],["AveragePool","","7+",tc,ec],["BatchNormalization","","7+",dl,hl],["Cast","","6+",El,Dl],["Ceil","","6+",Wl],["Clip","","6-10",gi,Vl],["Clip","","11+",zl],["Concat","","4+",Bl,Cl],["Conv","","1+",Oi,Si],["ConvTranspose","","1+",xf,Tf],["Cos","","7+",Hl],["Div","","7+",yl],["Dropout","","7+",yi],["DepthToSpace","","1+",Of,Sf],["Equal","","7+",xl],["Elu","","6+",ql,jl],["Exp","","6+",Xl],["Flatten","","1+",Pf,Ef],["Floor","","6+",Kl],["FusedConv","com.microsoft","1+",Oi,Si],["Gather","","1+",Lf,$f],["Gemm","","7-10",Ai,Ff],["Gemm","","11+",Ai,Cf],["GlobalAveragePool","","1+",nc,oc],["GlobalMaxPool","","1+",lc],["Greater","","7+",Tl],["Identity","","1+",yi],["ImageScaler","","1+",Rf,Gf],["InstanceNormalization","","6+",Vf,zf],["LeakyRelu","","6+",Jl,Yl],["Less","","7+",wl],["LRN","","1+",Hf,qf],["Log","","6+",Zl],["MatMul","","1+",pf,df],["MaxPool","","1+",ic,ac],["Mul","","7+",vl],["Neg","","6+",Ql],["Not","","1+",tf],["Or","","7+",Il],["Pad","","2-10",Pi,Kf],["Pad","","11+",Jf,Yf],["Pow","","7+",_l],["PRelu","","7+",Ol],["ReduceLogSum","","1+",gc,Ee],["ReduceMax","","1+",hc,Ee],["ReduceMean","","1+",dc,Ee],["ReduceMin","","1+",mc,Ee],["ReduceProd","","1+",bc,Ee],["ReduceSum","","1-12",pc,Ee],["ReduceSumSquare","","1+",yc,Ee],["Relu","","6+",ef],["Reshape","","5+",Tc],["Resize","","10",ki,Oc],["Resize","","11+",ki,Sc],["Shape","","1+",Pc],["Sigmoid","","6+",rf],["Sin","","7+",nf],["Slice","","10+",kc],["Slice","","1-9",Dc,Lc],["Softmax","","1-12",Rc,Gc],["Softmax","","13+",Uc,Mc],["Split","","2-12",qc,jc],["Sqrt","","6+",of],["Squeeze","","1-12",Fi,Jc],["Squeeze","","13+",Kc],["Sub","","7+",Sl],["Sum","","6+",Zc],["Tan","","7+",af],["Tanh","","6+",sf],["Tile","","6+",tp],["Transpose","","1+",je,If],["Upsample","","7-8",Ei,Ic],["Upsample","","9",Ei,_c],["Unsqueeze","","1-12",Ci,np],["Unsqueeze","","13+",rp],["Xor","","7+",Al]]});function up(t){let r={},o;for(;(o=sp.exec(t))!==null;){let i=o[3].split(",").map(u=>{let n=u.trim().split(" ");return n&&n.length===2?{type:n[0],name:n[1]}:null}).filter(u=>u!==null);r[o[2]]={params:i,body:o[4]}}for(let i in r){let u=pg.replace("__FUNC__",i),n=new RegExp(u,"gm");for(;(o=n.exec(t))!==null;){let a=o[1],d=o[2],c=o[3].split(","),e=a?`${a} ${d};`:"",l=r[i].body,s="";r[i].params.forEach((f,m)=>{f&&(s+=`${f.type} ${f.name} = ${c[m]};
1307
- `)}),l=`${s}
1308
- ${l}`,l=l.replace("return",`${d} = `);let h=`
1309
- ${e}
1306
+ `;return{...a,output:{dims:p,type:n[0].type,textureType:0},shaderSource:c}},lg=e=>{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(Pe.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.")}}),Ci,rp,np,fg,cg,op=O(()=>{Y(),Ci=(e,n,a)=>{fg(n);let i=B.unsqueezeShape(n[0].dims,a);return[e.reshapeUnpacked(n[0],i)]},rp=(e,n)=>(cg(n),Ci(e,[n[0]],Array.from(n[1].integerData))),np=e=>e.attributes.getInts("axes"),fg=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.")},cg=e=>{if(!e||e.length!==2)throw new Error("Unsqueeze requires 2 inputs.");if(e[1].type!=="int32")throw new Error("Invalid input type.")}}),ip,ap=O(()=>{ml(),Pl(),Ll(),Nl(),Bn(),wf(),Af(),Df(),kf(),Nf(),Mf(),Wf(),Xf(),Fn(),Zf(),cc(),xc(),wc(),Ac(),Ec(),Bc(),Wc(),Xc(),Yc(),Qc(),ep(),Nn(),xi(),op(),Li(),ip=[["Abs","","6+",Rl],["Acos","","7+",Gl],["Add","","7+",bl],["And","","7+",gl],["Asin","","7+",Ml],["Atan","","7+",Ul],["AveragePool","","7+",tc,ec],["BatchNormalization","","7+",dl,hl],["Cast","","6+",El,Dl],["Ceil","","6+",Wl],["Clip","","6-10",gi,Vl],["Clip","","11+",zl],["Concat","","4+",Bl,Cl],["Conv","","1+",Oi,Si],["ConvTranspose","","1+",xf,Tf],["Cos","","7+",Hl],["Div","","7+",yl],["Dropout","","7+",yi],["DepthToSpace","","1+",Of,Sf],["Equal","","7+",xl],["Elu","","6+",ql,jl],["Exp","","6+",Xl],["Flatten","","1+",Pf,Ef],["Floor","","6+",Kl],["FusedConv","com.microsoft","1+",Oi,Si],["Gather","","1+",Lf,$f],["Gemm","","7-10",Ai,Ff],["Gemm","","11+",Ai,Cf],["GlobalAveragePool","","1+",nc,oc],["GlobalMaxPool","","1+",lc],["Greater","","7+",Tl],["Identity","","1+",yi],["ImageScaler","","1+",Rf,Gf],["InstanceNormalization","","6+",Vf,zf],["LeakyRelu","","6+",Jl,Yl],["Less","","7+",wl],["LRN","","1+",Hf,qf],["Log","","6+",Zl],["MatMul","","1+",pf,df],["MaxPool","","1+",ic,ac],["Mul","","7+",vl],["Neg","","6+",Ql],["Not","","1+",tf],["Or","","7+",Il],["Pad","","2-10",Pi,Kf],["Pad","","11+",Jf,Yf],["Pow","","7+",_l],["PRelu","","7+",Ol],["ReduceLogSum","","1+",gc,Ee],["ReduceMax","","1+",hc,Ee],["ReduceMean","","1+",dc,Ee],["ReduceMin","","1+",mc,Ee],["ReduceProd","","1+",bc,Ee],["ReduceSum","","1-12",pc,Ee],["ReduceSumSquare","","1+",yc,Ee],["Relu","","6+",ef],["Reshape","","5+",Tc],["Resize","","10",ki,Oc],["Resize","","11+",ki,Sc],["Shape","","1+",Pc],["Sigmoid","","6+",rf],["Sin","","7+",nf],["Slice","","10+",kc],["Slice","","1-9",Dc,Lc],["Softmax","","1-12",Rc,Gc],["Softmax","","13+",Uc,Mc],["Split","","2-12",qc,jc],["Sqrt","","6+",of],["Squeeze","","1-12",Fi,Jc],["Squeeze","","13+",Kc],["Sub","","7+",Sl],["Sum","","6+",Zc],["Tan","","7+",af],["Tanh","","6+",sf],["Tile","","6+",tp],["Transpose","","1+",je,If],["Upsample","","7-8",Ei,Ic],["Upsample","","9",Ei,_c],["Unsqueeze","","1-12",Ci,np],["Unsqueeze","","13+",rp],["Xor","","7+",Al]]});function up(e){let n={},a;for(;(a=sp.exec(e))!==null;){let i=a[3].split(",").map(p=>{let o=p.trim().split(" ");return o&&o.length===2?{type:o[0],name:o[1]}:null}).filter(p=>p!==null);n[a[2]]={params:i,body:a[4]}}for(let i in n){let p=pg.replace("__FUNC__",i),o=new RegExp(p,"gm");for(;(a=o.exec(e))!==null;){let s=a[1],c=a[2],h=a[3].split(","),r=s?`${s} ${c};`:"",u=n[i].body,l="";n[i].params.forEach((g,b)=>{g&&(l+=`${g.type} ${g.name} = ${h[b]};
1307
+ `)}),u=`${l}
1308
+ ${u}`,u=u.replace("return",`${c} = `);let f=`
1309
+ ${r}
1310
1310
  {
1311
- ${l}
1311
+ ${u}
1312
1312
  }
1313
- `;t=t.replace(o[0],h)}}return t=t.replace(sp,""),t}var sp,pg,lp=O(()=>{sp=/@inline[\s\n\r]+(\w+)[\s\n\r]+([0-9a-zA-Z_]+)\s*\(([^)]*)\)\s*{(([^}]|[\n\r])*)}/gm,pg="(\\w+)?\\s+([_0-9a-zA-Z]+)\\s+=\\s+__FUNC__\\((.*)\\)\\s*;"});function hr(t,r){let o=[],i=[];for(let u=0;u<t.length;++u)t[u]!==1&&(o.push(t[u]),i.push(u));return{newShape:o,keptDims:i}}function mg(t){if(t.length===0)return 1;let r=t[0];for(let o=1;o<t.length;o++)r*=t[o];return r}function fp(t){let r=Math.ceil(Math.sqrt(t));return[r,Math.ceil(t/r)]}var Un,Ni=O(()=>{Ut(),Y(),Un=class{constructor(t){this.maxTextureSize=t}computeTextureWH(t,r){let o=this.computeTexture(t,r);return r&&r.isPacked&&(o[0]/=2,o[1]/=2),r&&r.reverseWH?[o[1],o[0]]:o}computeTexture(t,r){let o=r&&r.isPacked;if(t.length===0)return o?[2,2]:[1,1];let i=this.maxTextureSize;if(r&&r.breakAxis!==void 0){let a=r.breakAxis>=t.length?1:t.slice(r.breakAxis).reduce((c,e)=>c*e),d=r.breakAxis<=0?1:t.slice(0,r.breakAxis).reduce((c,e)=>c*e);if(a>i||d>i)tt.verbose("TextureLayout",`Given width/height preferences were unattainable: shape:${t}, breakAxis:${r.breakAxis}`);else return[a,d]}let u=t.slice(0);o&&(i=i*2,u=u.map((a,d)=>d>=u.length-2?u[d]%2===0?u[d]:u[d]+1:u[d]),u.length===1&&(u=[2,u[0]])),u.length!==2&&(u=hr(u).newShape);let n=mg(u);return u.length<=1&&n<=i?[1,n]:u.length===2&&u[0]<=i&&u[1]<=i?u:u.length===3&&u[0]*u[1]<=i&&u[2]<=i?[u[0]*u[1],u[2]]:u.length===3&&u[0]<=i&&u[1]*u[2]<=i?[u[0],u[1]*u[2]]:u.length===4&&u[0]*u[1]*u[2]<=i&&u[3]<=i?[u[0]*u[1]*u[2],u[3]]:u.length===4&&u[0]<=i&&u[1]*u[2]*u[3]<=i?[u[0],u[1]*u[2]*u[3]]:o?fp(n/4).map(a=>a*2):fp(n)}}}),Vn,cp=O(()=>{Y(),Te(),ut(),Ni(),pe(),Vn=class extends Ht{constructor(t){super(t)}getFunctions(){return{...this.offsetToCoords(),...this.coordsToOffset(),...this.toVec(),...this.valueFrom(),...this.getCommonUtilFuncs(),...this.getInputsSamplingSnippets(),...this.getOutputSamplingSnippet()}}getCustomTypes(){return{}}offsetToCoords(){let t="offsetToCoords";return{offsetToCoords:new k$1(`
1314
- vec2 ${t}(int offset, int width, int height) {
1313
+ `;e=e.replace(a[0],f)}}return e=e.replace(sp,""),e}var sp,pg,lp=O(()=>{sp=/@inline[\s\n\r]+(\w+)[\s\n\r]+([0-9a-zA-Z_]+)\s*\(([^)]*)\)\s*{(([^}]|[\n\r])*)}/gm,pg="(\\w+)?\\s+([_0-9a-zA-Z]+)\\s+=\\s+__FUNC__\\((.*)\\)\\s*;"});function hr(e,n){let a=[],i=[];for(let p=0;p<e.length;++p)e[p]!==1&&(a.push(e[p]),i.push(p));return{newShape:a,keptDims:i}}function mg(e){if(e.length===0)return 1;let n=e[0];for(let a=1;a<e.length;a++)n*=e[a];return n}function fp(e){let n=Math.ceil(Math.sqrt(e));return[n,Math.ceil(e/n)]}var Un,Ni=O(()=>{Ut(),Y(),Un=class{constructor(e){this.maxTextureSize=e}computeTextureWH(e,n){let a=this.computeTexture(e,n);return n&&n.isPacked&&(a[0]/=2,a[1]/=2),n&&n.reverseWH?[a[1],a[0]]:a}computeTexture(e,n){let a=n&&n.isPacked;if(e.length===0)return a?[2,2]:[1,1];let i=this.maxTextureSize;if(n&&n.breakAxis!==void 0){let s=n.breakAxis>=e.length?1:e.slice(n.breakAxis).reduce((h,r)=>h*r),c=n.breakAxis<=0?1:e.slice(0,n.breakAxis).reduce((h,r)=>h*r);if(s>i||c>i)tt.verbose("TextureLayout",`Given width/height preferences were unattainable: shape:${e}, breakAxis:${n.breakAxis}`);else return[s,c]}let p=e.slice(0);a&&(i=i*2,p=p.map((s,c)=>c>=p.length-2?p[c]%2===0?p[c]:p[c]+1:p[c]),p.length===1&&(p=[2,p[0]])),p.length!==2&&(p=hr(p).newShape);let o=mg(p);return p.length<=1&&o<=i?[1,o]:p.length===2&&p[0]<=i&&p[1]<=i?p:p.length===3&&p[0]*p[1]<=i&&p[2]<=i?[p[0]*p[1],p[2]]:p.length===3&&p[0]<=i&&p[1]*p[2]<=i?[p[0],p[1]*p[2]]:p.length===4&&p[0]*p[1]*p[2]<=i&&p[3]<=i?[p[0]*p[1]*p[2],p[3]]:p.length===4&&p[0]<=i&&p[1]*p[2]*p[3]<=i?[p[0],p[1]*p[2]*p[3]]:a?fp(o/4).map(s=>s*2):fp(o)}}}),Vn,cp=O(()=>{Y(),Te(),ut(),Ni(),pe(),Vn=class extends Ht{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 k(`
1314
+ vec2 ${e}(int offset, int width, int height) {
1315
1315
  int t = offset / width;
1316
1316
  int s = offset - t*width;
1317
1317
  vec2 coords = (vec2(s,t) + vec2(0.5,0.5)) / vec2(width, height);
1318
1318
  return coords;
1319
1319
  }
1320
- `)}}coordsToOffset(){let t="coordsToOffset";return{coordsToOffset:new k$1(`
1321
- int ${t}(vec2 coords, int width, int height) {
1320
+ `)}}coordsToOffset(){let e="coordsToOffset";return{coordsToOffset:new k(`
1321
+ int ${e}(vec2 coords, int width, int height) {
1322
1322
  float s = coords.s * float(width);
1323
1323
  float t = coords.t * float(height);
1324
1324
  int offset = int(t) * width + int(s);
1325
1325
  return offset;
1326
1326
  }
1327
- `)}}getOutputSamplingSnippet(){let t=this.context.outputTextureLayout;return t.isPacked?this.getPackedOutputSamplingSnippet(t):this.getUnpackedOutputSamplingSnippet(t)}getPackedOutputSamplingSnippet(t){let r=t.unpackedShape,o=[t.width,t.height],i={},u="getOutputCoords";switch(r.length){case 0:i[u]=this.getOutputScalarCoords();break;case 1:i[u]=this.getOutputPacked1DCoords(r,o);break;case 2:i[u]=this.getOutputPacked2DCoords(r,o);break;case 3:i[u]=this.getOutputPacked3DCoords(r,o);break;default:i[u]=this.getOutputPackedNDCoords(r,o)}let n=`
1327
+ `)}}getOutputSamplingSnippet(){let e=this.context.outputTextureLayout;return e.isPacked?this.getPackedOutputSamplingSnippet(e):this.getUnpackedOutputSamplingSnippet(e)}getPackedOutputSamplingSnippet(e){let n=e.unpackedShape,a=[e.width,e.height],i={},p="getOutputCoords";switch(n.length){case 0:i[p]=this.getOutputScalarCoords();break;case 1:i[p]=this.getOutputPacked1DCoords(n,a);break;case 2:i[p]=this.getOutputPacked2DCoords(n,a);break;case 3:i[p]=this.getOutputPacked3DCoords(n,a);break;default:i[p]=this.getOutputPackedNDCoords(n,a)}let o=`
1328
1328
  void setOutput(vec4 val) {
1329
1329
  ${G(this.context.glContext.version).output} = val;
1330
1330
  }
1331
- `,a="floatTextureSetRGBA";return i[a]=new k$1(n),i}getUnpackedOutputSamplingSnippet(t){let r=t.unpackedShape,o=[t.width,t.height],i={},u="getOutputCoords";switch(r.length){case 0:i[u]=this.getOutputScalarCoords();break;case 1:i[u]=this.getOutputUnpacked1DCoords(r,o);break;case 2:i[u]=this.getOutputUnpacked2DCoords(r,o);break;case 3:i[u]=this.getOutputUnpacked3DCoords(r,o);break;case 4:i[u]=this.getOutputUnpacked4DCoords(r,o);break;case 5:i[u]=this.getOutputUnpacked5DCoords(r,o);break;case 6:i[u]=this.getOutputUnpacked6DCoords(r,o);break;default:throw new Error(`Unsupported output dimensionality: ${r.length}`)}let n=`
1331
+ `,s="floatTextureSetRGBA";return i[s]=new k(o),i}getUnpackedOutputSamplingSnippet(e){let n=e.unpackedShape,a=[e.width,e.height],i={},p="getOutputCoords";switch(n.length){case 0:i[p]=this.getOutputScalarCoords();break;case 1:i[p]=this.getOutputUnpacked1DCoords(n,a);break;case 2:i[p]=this.getOutputUnpacked2DCoords(n,a);break;case 3:i[p]=this.getOutputUnpacked3DCoords(n,a);break;case 4:i[p]=this.getOutputUnpacked4DCoords(n,a);break;case 5:i[p]=this.getOutputUnpacked5DCoords(n,a);break;case 6:i[p]=this.getOutputUnpacked6DCoords(n,a);break;default:throw new Error(`Unsupported output dimensionality: ${n.length}`)}let o=`
1332
1332
  void setOutput(float val) {
1333
1333
  ${G(this.context.glContext.version).output} = vec4(val, 0, 0, 0);
1334
1334
  }
1335
- `,a="floatTextureSetR";return i[a]=new k$1(n),i}getOutputScalarCoords(){return new k$1(`
1335
+ `,s="floatTextureSetR";return i[s]=new k(o),i}getOutputScalarCoords(){return new k(`
1336
1336
  int getOutputCoords() {
1337
1337
  return 0;
1338
1338
  }
1339
- `)}getOutputPacked1DCoords(t,r){let o=r,i="";return o[0]===1?(i=`
1339
+ `)}getOutputPacked1DCoords(e,n){let a=n,i="";return a[0]===1?(i=`
1340
1340
  int getOutputCoords() {
1341
- return 2 * int(TexCoords.y * ${o[1]}.0);
1341
+ return 2 * int(TexCoords.y * ${a[1]}.0);
1342
1342
  }
1343
- `,new k$1(i)):o[1]===1?(i=`
1343
+ `,new k(i)):a[1]===1?(i=`
1344
1344
  int getOutputCoords() {
1345
- return 2 * int(TexCoords.x * ${o[0]}.0);
1345
+ return 2 * int(TexCoords.x * ${a[0]}.0);
1346
1346
  }
1347
- `,new k$1(i)):(i=`
1347
+ `,new k(i)):(i=`
1348
1348
  int getOutputCoords() {
1349
1349
  ivec2 resTexRC = ivec2(TexCoords.xy *
1350
- vec2(${o[0]}, ${o[1]}));
1351
- return 2 * (resTexRC.y * ${o[0]} + resTexRC.x);
1350
+ vec2(${a[0]}, ${a[1]}));
1351
+ return 2 * (resTexRC.y * ${a[0]} + resTexRC.x);
1352
1352
  }
1353
- `,new k$1(i))}getOutputPacked2DCoords(t,r){let o="";if(Me.arraysEqual(t,r))return o=`
1353
+ `,new k(i))}getOutputPacked2DCoords(e,n){let a="";if(Me.arraysEqual(e,n))return a=`
1354
1354
  ivec2 getOutputCoords() {
1355
- return 2 * ivec2(TexCoords.xy * vec2(${r[0]}, ${r[1]}));
1355
+ return 2 * ivec2(TexCoords.xy * vec2(${n[0]}, ${n[1]}));
1356
1356
  }
1357
- `,new k$1(o);let i=r,u=Math.ceil(t[1]/2);return o=`
1357
+ `,new k(a);let i=n,p=Math.ceil(e[1]/2);return a=`
1358
1358
  ivec2 getOutputCoords() {
1359
1359
  ivec2 resTexRC = ivec2(TexCoords.xy *
1360
1360
  vec2(${i[0]}, ${i[1]}));
@@ -1362,19 +1362,19 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(t,r,o)=>Xe(
1362
1362
  int index = resTexRC.y * ${i[0]} + resTexRC.x;
1363
1363
 
1364
1364
  // reverse r and c order for packed texture
1365
- int r = imod(index, ${u}) * 2;
1366
- int c = 2 * (index / ${u});
1365
+ int r = imod(index, ${p}) * 2;
1366
+ int c = 2 * (index / ${p});
1367
1367
 
1368
1368
  return ivec2(r, c);
1369
1369
  }
1370
- `,new k$1(o)}getOutputPacked3DCoords(t,r){let o=[r[0],r[1]],i=Math.ceil(t[2]/2),u=i*Math.ceil(t[1]/2),n=`
1370
+ `,new k(a)}getOutputPacked3DCoords(e,n){let a=[n[0],n[1]],i=Math.ceil(e[2]/2),p=i*Math.ceil(e[1]/2),o=`
1371
1371
  ivec3 getOutputCoords() {
1372
1372
  ivec2 resTexRC = ivec2(TexCoords.xy *
1373
- vec2(${o[0]}, ${o[1]}));
1374
- int index = resTexRC.y * ${o[0]} + resTexRC.x;
1373
+ vec2(${a[0]}, ${a[1]}));
1374
+ int index = resTexRC.y * ${a[0]} + resTexRC.x;
1375
1375
 
1376
- int b = index / ${u};
1377
- index -= b * ${u};
1376
+ int b = index / ${p};
1377
+ index -= b * ${p};
1378
1378
 
1379
1379
  // reverse r and c order for packed texture
1380
1380
  int r = imod(index, ${i}) * 2;
@@ -1382,74 +1382,74 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(t,r,o)=>Xe(
1382
1382
 
1383
1383
  return ivec3(b, r, c);
1384
1384
  }
1385
- `;return new k$1(n)}getOutputPackedNDCoords(t,r){let o=[r[0],r[1]],i=Math.ceil(t[t.length-1]/2),u=i*Math.ceil(t[t.length-2]/2),n=u,a="",d="b, r, c";for(let e=2;e<t.length-1;e++)n*=t[t.length-e-1],a=`
1386
- int b${e} = index / ${n};
1387
- index -= b${e} * ${n};
1388
- `+a,d=`b${e}, `+d;let c=`
1389
- ivec${t.length} getOutputCoords() {
1385
+ `;return new k(o)}getOutputPackedNDCoords(e,n){let a=[n[0],n[1]],i=Math.ceil(e[e.length-1]/2),p=i*Math.ceil(e[e.length-2]/2),o=p,s="",c="b, r, c";for(let r=2;r<e.length-1;r++)o*=e[e.length-r-1],s=`
1386
+ int b${r} = index / ${o};
1387
+ index -= b${r} * ${o};
1388
+ `+s,c=`b${r}, `+c;let h=`
1389
+ ivec${e.length} getOutputCoords() {
1390
1390
  ivec2 resTexRC = ivec2(TexCoords.xy *
1391
- vec2(${o[0]}, ${o[1]}));
1392
- int index = resTexRC.y * ${o[0]} + resTexRC.x;
1391
+ vec2(${a[0]}, ${a[1]}));
1392
+ int index = resTexRC.y * ${a[0]} + resTexRC.x;
1393
1393
 
1394
- ${a}
1394
+ ${s}
1395
1395
 
1396
- int b = index / ${u};
1397
- index -= b * ${u};
1396
+ int b = index / ${p};
1397
+ index -= b * ${p};
1398
1398
 
1399
1399
  // reverse r and c order for packed texture
1400
1400
  int r = imod(index, ${i}) * 2;
1401
1401
  int c = 2 * (index / ${i});
1402
1402
 
1403
- return ivec${t.length}(${d});
1403
+ return ivec${e.length}(${c});
1404
1404
  }
1405
- `;return new k$1(c)}getOutputUnpacked1DCoords(t,r){let o=`
1405
+ `;return new k(h)}getOutputUnpacked1DCoords(e,n){let a=`
1406
1406
  int getOutputCoords() {
1407
1407
  ivec2 resTexRC = ivec2(TexCoords.xy *
1408
- vec2(${r[0]}, ${r[1]}));
1409
- return resTexRC.y * ${r[0]} + resTexRC.x;
1408
+ vec2(${n[0]}, ${n[1]}));
1409
+ return resTexRC.y * ${n[0]} + resTexRC.x;
1410
1410
  }
1411
- `;return new k$1(o)}getOutputUnpacked2DCoords(t,r){let o=`
1411
+ `;return new k(a)}getOutputUnpacked2DCoords(e,n){let a=`
1412
1412
  ivec2 getOutputCoords() {
1413
1413
  ivec2 resTexRC = ivec2(TexCoords.xy *
1414
- vec2(${r[0]}, ${r[1]}));
1415
- int index = resTexRC.y * ${r[0]} + resTexRC.x;
1416
- int r = index / ${t[1]};
1417
- int c = index - r * ${t[1]};
1414
+ vec2(${n[0]}, ${n[1]}));
1415
+ int index = resTexRC.y * ${n[0]} + resTexRC.x;
1416
+ int r = index / ${e[1]};
1417
+ int c = index - r * ${e[1]};
1418
1418
  return ivec2(r, c);
1419
1419
  }
1420
- `;return new k$1(o)}getOutputUnpacked3DCoords(t,r){let o="",i=t.length,u=null;i<2&&(u=[]),u=new Array(i-1),u[i-2]=t[i-1];for(let d=i-3;d>=0;--d)u[d]=u[d+1]*t[d+1];let n=["r","c","d"],a=u.map((d,c)=>{let e=`int ${n[c]} = index / ${d}`,l=c===u.length-1?`int ${n[c+1]} = index - ${n[c]} * ${d}`:`index -= ${n[c]} * ${d}`;return`${e}; ${l};`}).join("");return o=`
1420
+ `;return new k(a)}getOutputUnpacked3DCoords(e,n){let a="",i=e.length,p=null;i<2&&(p=[]),p=new Array(i-1),p[i-2]=e[i-1];for(let c=i-3;c>=0;--c)p[c]=p[c+1]*e[c+1];let o=["r","c","d"],s=p.map((c,h)=>{let r=`int ${o[h]} = index / ${c}`,u=h===p.length-1?`int ${o[h+1]} = index - ${o[h]} * ${c}`:`index -= ${o[h]} * ${c}`;return`${r}; ${u};`}).join("");return a=`
1421
1421
  ivec3 getOutputCoords() {
1422
1422
  ivec2 resTexRC = ivec2(TexCoords.xy *
1423
- vec2(${r[0]}, ${r[1]}));
1424
- int index = resTexRC.y * ${r[0]} + resTexRC.x;
1425
- ${a}
1423
+ vec2(${n[0]}, ${n[1]}));
1424
+ int index = resTexRC.y * ${n[0]} + resTexRC.x;
1425
+ ${s}
1426
1426
  return ivec3(r, c, d);
1427
1427
  }
1428
- `,new k$1(o)}getOutputUnpacked4DCoords(t,r){let o="",i=t.length,u=null;i<2&&(u=[]),u=new Array(i-1),u[i-2]=t[i-1];for(let d=i-3;d>=0;--d)u[d]=u[d+1]*t[d+1];let n=["r","c","d","d2"],a=u.map((d,c)=>{let e=`int ${n[c]} = index / ${d}`,l=c===u.length-1?`int ${n[c+1]} = index - ${n[c]} * ${d}`:`index -= ${n[c]} * ${d}`;return`${e}; ${l};`}).join("");return o=`
1428
+ `,new k(a)}getOutputUnpacked4DCoords(e,n){let a="",i=e.length,p=null;i<2&&(p=[]),p=new Array(i-1),p[i-2]=e[i-1];for(let c=i-3;c>=0;--c)p[c]=p[c+1]*e[c+1];let o=["r","c","d","d2"],s=p.map((c,h)=>{let r=`int ${o[h]} = index / ${c}`,u=h===p.length-1?`int ${o[h+1]} = index - ${o[h]} * ${c}`:`index -= ${o[h]} * ${c}`;return`${r}; ${u};`}).join("");return a=`
1429
1429
  ivec4 getOutputCoords() {
1430
1430
  ivec2 resTexRC = ivec2(TexCoords.xy *
1431
- vec2(${r[0]}, ${r[1]}));
1432
- int index = resTexRC.y * ${r[0]} + resTexRC.x;
1433
- ${a}
1431
+ vec2(${n[0]}, ${n[1]}));
1432
+ int index = resTexRC.y * ${n[0]} + resTexRC.x;
1433
+ ${s}
1434
1434
  return ivec4(r, c, d, d2);
1435
1435
  }
1436
- `,new k$1(o)}getOutputUnpacked5DCoords(t,r){let o="",i=t.length,u=null;i<2&&(u=[]),u=new Array(i-1),u[i-2]=t[i-1];for(let d=i-3;d>=0;--d)u[d]=u[d+1]*t[d+1];let n=["r","c","d","d2","d3"],a=u.map((d,c)=>{let e=`int ${n[c]} = index / ${d}`,l=c===u.length-1?`int ${n[c+1]} = index - ${n[c]} * ${d}`:`index -= ${n[c]} * ${d}`;return`${e}; ${l};`}).join("");return o=`
1436
+ `,new k(a)}getOutputUnpacked5DCoords(e,n){let a="",i=e.length,p=null;i<2&&(p=[]),p=new Array(i-1),p[i-2]=e[i-1];for(let c=i-3;c>=0;--c)p[c]=p[c+1]*e[c+1];let o=["r","c","d","d2","d3"],s=p.map((c,h)=>{let r=`int ${o[h]} = index / ${c}`,u=h===p.length-1?`int ${o[h+1]} = index - ${o[h]} * ${c}`:`index -= ${o[h]} * ${c}`;return`${r}; ${u};`}).join("");return a=`
1437
1437
  ivec5 getOutputCoords() {
1438
1438
  ivec2 resTexRC = ivec2(TexCoords.xy *
1439
- vec2(${r[0]}, ${r[1]}));
1440
- int index = resTexRC.y * ${r[0]} + resTexRC.x;
1441
- ${a}
1439
+ vec2(${n[0]}, ${n[1]}));
1440
+ int index = resTexRC.y * ${n[0]} + resTexRC.x;
1441
+ ${s}
1442
1442
  return ivec5(r, c, d, d2, d3);
1443
1443
  }
1444
- `,new k$1(o)}getOutputUnpacked6DCoords(t,r){let o="",i=t.length,u=null;i<2&&(u=[]),u=new Array(i-1),u[i-2]=t[i-1];for(let d=i-3;d>=0;--d)u[d]=u[d+1]*t[d+1];let n=["r","c","d","d2","d3","d4"],a=u.map((d,c)=>{let e=`int ${n[c]} = index / ${d}`,l=c===u.length-1?`int ${n[c+1]} = index - ${n[c]} * ${d}`:`index -= ${n[c]} * ${d}`;return`${e}; ${l};`}).join("");return o=`
1444
+ `,new k(a)}getOutputUnpacked6DCoords(e,n){let a="",i=e.length,p=null;i<2&&(p=[]),p=new Array(i-1),p[i-2]=e[i-1];for(let c=i-3;c>=0;--c)p[c]=p[c+1]*e[c+1];let o=["r","c","d","d2","d3","d4"],s=p.map((c,h)=>{let r=`int ${o[h]} = index / ${c}`,u=h===p.length-1?`int ${o[h+1]} = index - ${o[h]} * ${c}`:`index -= ${o[h]} * ${c}`;return`${r}; ${u};`}).join("");return a=`
1445
1445
  ivec6 getOutputCoords() {
1446
1446
  ivec2 resTexRC = ivec2(TexCoords.xy *
1447
- vec2(${r[0]}, ${r[1]}));
1448
- int index = resTexRC.y * ${r[0]} + resTexRC.x;
1449
- ${a}
1447
+ vec2(${n[0]}, ${n[1]}));
1448
+ int index = resTexRC.y * ${n[0]} + resTexRC.x;
1449
+ ${s}
1450
1450
  return ivec6(r, c, d, d2, d3, d4);
1451
1451
  }
1452
- `,new k$1(o)}getCommonUtilFuncs(){let t={},r="uvFromFlat";t[r]=new k$1(`
1452
+ `,new k(a)}getCommonUtilFuncs(){let e={},n="uvFromFlat";e[n]=new k(`
1453
1453
  vec2 uvFromFlat(int texNumR, int texNumC, int index) {
1454
1454
  int texC = index / texNumR;
1455
1455
  int texR = index - texC * texNumR;
@@ -1457,21 +1457,21 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(t,r,o)=>Xe(
1457
1457
  // v.
1458
1458
  return (vec2(texR, texC) + halfCR) / vec2(texNumR, texNumC);
1459
1459
  }
1460
- `),r="packedUVfrom1D",t[r]=new k$1(`
1460
+ `),n="packedUVfrom1D",e[n]=new k(`
1461
1461
  vec2 packedUVfrom1D(int texNumR, int texNumC, int index) {
1462
1462
  int texelIndex = index / 2;
1463
1463
  int texR = texelIndex / texNumC;
1464
1464
  int texC = texelIndex - texR * texNumC;
1465
1465
  return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);
1466
1466
  }
1467
- `),r="packedUVfrom2D",t[r]=new k$1(`
1467
+ `),n="packedUVfrom2D",e[n]=new k(`
1468
1468
  vec2 packedUVfrom2D(int texNumR, int texNumC, int texelsInLogicalRow, int row, int col) {
1469
1469
  int texelIndex = (row / 2) * texelsInLogicalRow + (col / 2);
1470
1470
  int texR = texelIndex / texNumC;
1471
1471
  int texC = texelIndex - texR * texNumC;
1472
1472
  return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);
1473
1473
  }
1474
- `),r="packedUVfrom3D",t[r]=new k$1(`
1474
+ `),n="packedUVfrom3D",e[n]=new k(`
1475
1475
  vec2 packedUVfrom3D(int texNumR, int texNumC,
1476
1476
  int texelsInBatch, int texelsInLogicalRow, int b,
1477
1477
  int row, int col) {
@@ -1480,200 +1480,200 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(t,r,o)=>Xe(
1480
1480
  int texC = index - texR * texNumC;
1481
1481
  return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);
1482
1482
  }
1483
- `),r="sampleTexture";let o=G(this.context.glContext.version);return t[r]=new k$1(`
1483
+ `),n="sampleTexture";let a=G(this.context.glContext.version);return e[n]=new k(`
1484
1484
  float sampleTexture(sampler2D textureSampler, vec2 uv) {
1485
- return ${o.texture2D}(textureSampler, uv).r;
1486
- }`),t}getInputsSamplingSnippets(){let t={},r=this.context.outputTextureLayout;return this.context.programInfo.inputNames.forEach((o,i)=>{let u=this.context.inputTextureLayouts[i],n=An(o);u.isPacked?t[n]=this.getPackedSamplerFromInput(n,o,u):t[n]=this.getUnpackedSamplerFromInput(n,o,u);let a=Yu(o);u.unpackedShape.length<=r.unpackedShape.length&&(u.isPacked?t[a]=this.getPackedSamplerAtOutputCoords(a,u,r,o):t[a]=this.getUnpackedSamplerAtOutputCoords(a,u,r,o))}),t}getPackedSamplerAtOutputCoords(t,r,o,i){let u=r.unpackedShape,n=o.unpackedShape,a=An(i),d=u.length,c=n.length,e=kt.getBroadcastDims(u,n),l=Bt(c),s=c-d,h,f=ne();d===0?h="":c<2&&e.length>=1?h="coords = 0;":h=e.map(C=>`coords.${f[C+s]} = 0;`).join(`
1487
- `);let m="";c<2&&d>0?m="coords":m=u.map((C,V)=>`coords.${f[V+s]}`).join(", ");let v="return outputValue;",_=B.size(u)===1,I=B.size(n)===1;if(d===1&&!_&&!I)v=`
1485
+ return ${a.texture2D}(textureSampler, uv).r;
1486
+ }`),e}getInputsSamplingSnippets(){let e={},n=this.context.outputTextureLayout;return this.context.programInfo.inputNames.forEach((a,i)=>{let p=this.context.inputTextureLayouts[i],o=An(a);p.isPacked?e[o]=this.getPackedSamplerFromInput(o,a,p):e[o]=this.getUnpackedSamplerFromInput(o,a,p);let s=Yu(a);p.unpackedShape.length<=n.unpackedShape.length&&(p.isPacked?e[s]=this.getPackedSamplerAtOutputCoords(s,p,n,a):e[s]=this.getUnpackedSamplerAtOutputCoords(s,p,n,a))}),e}getPackedSamplerAtOutputCoords(e,n,a,i){let p=n.unpackedShape,o=a.unpackedShape,s=An(i),c=p.length,h=o.length,r=kt.getBroadcastDims(p,o),u=Bt(h),l=h-c,f,g=ne();c===0?f="":h<2&&r.length>=1?f="coords = 0;":f=r.map(L=>`coords.${g[L+l]} = 0;`).join(`
1487
+ `);let b="";h<2&&c>0?b="coords":b=p.map((L,V)=>`coords.${g[V+l]}`).join(", ");let v="return outputValue;",S=B.size(p)===1,P=B.size(o)===1;if(c===1&&!S&&!P)v=`
1488
1488
  return vec4(outputValue.xy, outputValue.xy);
1489
- `;else if(_&&!I)c===1?v=`
1489
+ `;else if(S&&!P)h===1?v=`
1490
1490
  return vec4(outputValue.x, outputValue.x, 0., 0.);
1491
1491
  `:v=`
1492
1492
  return vec4(outputValue.x);
1493
- `;else if(e.length){let C=d-2,V=d-1;e.indexOf(C)>-1&&e.indexOf(V)>-1?v="return vec4(outputValue.x);":e.indexOf(C)>-1?v="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":e.indexOf(V)>-1&&(v="return vec4(outputValue.xx, outputValue.zz);")}let T=`
1494
- int lastDim = coords.${f[c-1]};
1495
- coords.${f[c-1]} = coords.${f[c-2]};
1496
- coords.${f[c-2]} = lastDim;
1497
- `,P=`
1498
- vec4 ${t}() {
1499
- ${l} coords = getOutputCoords();
1500
- ${T}
1501
- ${h}
1502
- vec4 outputValue = ${a}(${m});
1493
+ `;else if(r.length){let L=c-2,V=c-1;r.indexOf(L)>-1&&r.indexOf(V)>-1?v="return vec4(outputValue.x);":r.indexOf(L)>-1?v="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":r.indexOf(V)>-1&&(v="return vec4(outputValue.xx, outputValue.zz);")}let _=`
1494
+ int lastDim = coords.${g[h-1]};
1495
+ coords.${g[h-1]} = coords.${g[h-2]};
1496
+ coords.${g[h-2]} = lastDim;
1497
+ `,A=`
1498
+ vec4 ${e}() {
1499
+ ${u} coords = getOutputCoords();
1500
+ ${_}
1501
+ ${f}
1502
+ vec4 outputValue = ${s}(${b});
1503
1503
  ${v}
1504
1504
  }
1505
- `;return new k$1(P,["coordinates.getOutputCoords"])}getUnpackedSamplerAtOutputCoords(t,r,o,i){let u=[o.width,o.height],n=[r.width,r.height],a=r.unpackedShape.length,d=o.unpackedShape.length,c=r.unpackedShape,e=o.unpackedShape,l=An(i);if(a===d&&Me.arraysEqual(n,u)){let T=`
1506
- float ${t}() {
1505
+ `;return new k(A,["coordinates.getOutputCoords"])}getUnpackedSamplerAtOutputCoords(e,n,a,i){let p=[a.width,a.height],o=[n.width,n.height],s=n.unpackedShape.length,c=a.unpackedShape.length,h=n.unpackedShape,r=a.unpackedShape,u=An(i);if(s===c&&Me.arraysEqual(o,p)){let _=`
1506
+ float ${e}() {
1507
1507
  return sampleTexture(${i}, TexCoords);
1508
1508
  }
1509
- `;return new k$1(T,["coordinates.sampleTexture"])}let s=Bt(d),h=kt.getBroadcastDims(c,e),f=d-a,m,v=ne();a===0?m="":d<2&&h.length>=1?m="coords = 0;":m=h.map(T=>`coords.${v[T+f]} = 0;`).join(`
1510
- `);let _="";d<2&&a>0?_="coords":_=r.unpackedShape.map((T,P)=>`coords.${v[P+f]}`).join(", ");let I=`
1511
- float ${t}() {
1512
- ${s} coords = getOutputCoords();
1513
- ${m}
1514
- return ${l}(${_});
1509
+ `;return new k(_,["coordinates.sampleTexture"])}let l=Bt(c),f=kt.getBroadcastDims(h,r),g=c-s,b,v=ne();s===0?b="":c<2&&f.length>=1?b="coords = 0;":b=f.map(_=>`coords.${v[_+g]} = 0;`).join(`
1510
+ `);let S="";c<2&&s>0?S="coords":S=n.unpackedShape.map((_,A)=>`coords.${v[A+g]}`).join(", ");let P=`
1511
+ float ${e}() {
1512
+ ${l} coords = getOutputCoords();
1513
+ ${b}
1514
+ return ${u}(${S});
1515
1515
  }
1516
- `;return new k$1(I,["coordinates.getOutputCoords"])}getPackedSamplerFromInput(t,r,o){switch(o.unpackedShape.length){case 0:return this.getPackedSamplerScalar(t,r);case 1:return this.getPackedSampler1D(t,r,o);case 2:return this.getPackedSampler2D(t,r,o);case 3:return this.getPackedSampler3D(t,r,o);default:return this.getPackedSamplerND(t,r,o)}}getUnpackedSamplerFromInput(t,r,o){let i=o.unpackedShape;switch(i.length){case 0:return this.getUnpackedSamplerScalar(t,r,o);case 1:return this.getUnpackedSampler1D(t,r,o);case 2:return this.getUnpackedSampler2D(t,r,o);case 3:return this.getUnpackedSampler3D(t,r,o);case 4:return this.getUnpackedSampler4D(t,r,o);case 5:return this.getUnpackedSampler5D(t,r,o);case 6:return this.getUnpackedSampler6D(t,r,o);default:throw new Error(`Unsupported dimension ${i.length}-D`)}}getPackedSamplerScalar(t,r){let o=G(this.context.glContext.version),i=`
1517
- vec4 ${t}() {
1518
- return ${o.texture2D}(${r}, halfCR);
1516
+ `;return new k(P,["coordinates.getOutputCoords"])}getPackedSamplerFromInput(e,n,a){switch(a.unpackedShape.length){case 0:return this.getPackedSamplerScalar(e,n);case 1:return this.getPackedSampler1D(e,n,a);case 2:return this.getPackedSampler2D(e,n,a);case 3:return this.getPackedSampler3D(e,n,a);default:return this.getPackedSamplerND(e,n,a)}}getUnpackedSamplerFromInput(e,n,a){let i=a.unpackedShape;switch(i.length){case 0:return this.getUnpackedSamplerScalar(e,n,a);case 1:return this.getUnpackedSampler1D(e,n,a);case 2:return this.getUnpackedSampler2D(e,n,a);case 3:return this.getUnpackedSampler3D(e,n,a);case 4:return this.getUnpackedSampler4D(e,n,a);case 5:return this.getUnpackedSampler5D(e,n,a);case 6:return this.getUnpackedSampler6D(e,n,a);default:throw new Error(`Unsupported dimension ${i.length}-D`)}}getPackedSamplerScalar(e,n){let a=G(this.context.glContext.version),i=`
1517
+ vec4 ${e}() {
1518
+ return ${a.texture2D}(${n}, halfCR);
1519
1519
  }
1520
- `;return new k$1(i)}getPackedSampler1D(t,r,o){let i=[o.width,o.height],u=[i[1],i[0]],n=G(this.context.glContext.version),a=`vec4 ${t}(int index) {
1520
+ `;return new k(i)}getPackedSampler1D(e,n,a){let i=[a.width,a.height],p=[i[1],i[0]],o=G(this.context.glContext.version),s=`vec4 ${e}(int index) {
1521
1521
  vec2 uv = packedUVfrom1D(
1522
- ${u[0]}, ${u[1]}, index);
1523
- return ${n.texture2D}(${r}, uv);
1524
- }`;return new k$1(a,["coordinates.packedUVfrom1D"])}getPackedSampler2D(t,r,o){let i=o.unpackedShape,u=[o.width,o.height],n=G(this.context.glContext.version),a=u[0],d=u[1];if(u!=null&&Me.arraysEqual(i,u)){let s=`vec4 ${t}(int row, int col) {
1525
- vec2 uv = (vec2(col, row) + halfCR) / vec2(${d}.0, ${a}.0);
1526
- return ${n.texture2D}(${r}, uv);
1527
- }`;return new k$1(s)}let c=u,e=Math.ceil(i[1]/2),l=`vec4 ${t}(int row, int col) {
1528
- vec2 uv = packedUVfrom2D(${c[1]}, ${c[0]}, ${e}, row, col);
1529
- return ${n.texture2D}(${r}, uv);
1530
- }`;return new k$1(l,["coordinates.packedUVfrom2D"])}getPackedSampler3D(t,r,o){let i=o.unpackedShape,u=[o.width,o.height],n=[u[0],u[1]],a=G(this.context.glContext.version);if(i[0]===1){let h=i.slice(1),f=[1,2],m=lr(i,h),v=["b","row","col"],_=JSON.parse(JSON.stringify(o));_.unpackedShape=m;let I=this.getPackedSamplerFromInput(t,r,_),T=`${I.routineBody}
1531
- vec4 ${t}(int b, int row, int col) {
1532
- return ${t}(${fr(v,f)});
1533
- } `;return new k$1(T,I.dependencies)}let d=n[0],c=n[1],e=Math.ceil(i[2]/2),l=e*Math.ceil(i[1]/2),s=`vec4 ${t}(int b, int row, int col) {
1522
+ ${p[0]}, ${p[1]}, index);
1523
+ return ${o.texture2D}(${n}, uv);
1524
+ }`;return new k(s,["coordinates.packedUVfrom1D"])}getPackedSampler2D(e,n,a){let i=a.unpackedShape,p=[a.width,a.height],o=G(this.context.glContext.version),s=p[0],c=p[1];if(p!=null&&Me.arraysEqual(i,p)){let l=`vec4 ${e}(int row, int col) {
1525
+ vec2 uv = (vec2(col, row) + halfCR) / vec2(${c}.0, ${s}.0);
1526
+ return ${o.texture2D}(${n}, uv);
1527
+ }`;return new k(l)}let h=p,r=Math.ceil(i[1]/2),u=`vec4 ${e}(int row, int col) {
1528
+ vec2 uv = packedUVfrom2D(${h[1]}, ${h[0]}, ${r}, row, col);
1529
+ return ${o.texture2D}(${n}, uv);
1530
+ }`;return new k(u,["coordinates.packedUVfrom2D"])}getPackedSampler3D(e,n,a){let i=a.unpackedShape,p=[a.width,a.height],o=[p[0],p[1]],s=G(this.context.glContext.version);if(i[0]===1){let f=i.slice(1),g=[1,2],b=lr(i,f),v=["b","row","col"],S=JSON.parse(JSON.stringify(a));S.unpackedShape=b;let P=this.getPackedSamplerFromInput(e,n,S),_=`${P.routineBody}
1531
+ vec4 ${e}(int b, int row, int col) {
1532
+ return ${e}(${fr(v,g)});
1533
+ } `;return new k(_,P.dependencies)}let c=o[0],h=o[1],r=Math.ceil(i[2]/2),u=r*Math.ceil(i[1]/2),l=`vec4 ${e}(int b, int row, int col) {
1534
1534
  vec2 uv = packedUVfrom3D(
1535
- ${c}, ${d}, ${l}, ${e}, b, row, col);
1536
- return ${a.texture2D}(${r}, uv);}`;return new k$1(s,["coordinates.packedUVfrom3D"])}getPackedSamplerND(t,r,o){let i=o.unpackedShape,u=i.length,n=[o.width,o.height],a=G(this.context.glContext.version),d=[n[0],n[1]],c=d[1],e=d[0],l=Math.ceil(i[u-1]/2),s=l*Math.ceil(i[u-2]/2),h="int b, int row, int col",f=`b * ${s} + (row / 2) * ${l} + (col / 2)`;for(let v=2;v<u-1;v++)h=`int b${v}, `+h,s*=i[u-v-1],f=`b${v} * ${s} + `+f;let m=`vec4 ${t}(${h}) {
1537
- int index = ${f};
1538
- int texR = index / ${e};
1539
- int texC = index - texR * ${e};
1540
- vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${e}, ${c});
1541
- return ${a.texture2D}(${r}, uv);
1542
- }`;return new k$1(m)}getUnpackedSamplerScalar(t,r,o){let[i,u]=[o.width,o.height];if(i===1&&u===1){let a=`
1543
- float ${t}() {
1544
- return sampleTexture(${r}, halfCR);
1535
+ ${h}, ${c}, ${u}, ${r}, b, row, col);
1536
+ return ${s.texture2D}(${n}, uv);}`;return new k(l,["coordinates.packedUVfrom3D"])}getPackedSamplerND(e,n,a){let i=a.unpackedShape,p=i.length,o=[a.width,a.height],s=G(this.context.glContext.version),c=[o[0],o[1]],h=c[1],r=c[0],u=Math.ceil(i[p-1]/2),l=u*Math.ceil(i[p-2]/2),f="int b, int row, int col",g=`b * ${l} + (row / 2) * ${u} + (col / 2)`;for(let v=2;v<p-1;v++)f=`int b${v}, `+f,l*=i[p-v-1],g=`b${v} * ${l} + `+g;let b=`vec4 ${e}(${f}) {
1537
+ int index = ${g};
1538
+ int texR = index / ${r};
1539
+ int texC = index - texR * ${r};
1540
+ vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${r}, ${h});
1541
+ return ${s.texture2D}(${n}, uv);
1542
+ }`;return new k(b)}getUnpackedSamplerScalar(e,n,a){let[i,p]=[a.width,a.height];if(i===1&&p===1){let s=`
1543
+ float ${e}() {
1544
+ return sampleTexture(${n}, halfCR);
1545
1545
  }
1546
- `;return new k$1(a,["coordinates.sampleTexture"])}let n=`
1547
- float ${t}() {
1548
- int offset_${r} = coordsToOffset(TexCoords, ${i}, ${u});
1549
- vec2 uv = uvFromFlat(${i}, ${u}, offset_${r});
1550
- return sampleTexture(${r}, uv);
1546
+ `;return new k(s,["coordinates.sampleTexture"])}let o=`
1547
+ float ${e}() {
1548
+ int offset_${n} = coordsToOffset(TexCoords, ${i}, ${p});
1549
+ vec2 uv = uvFromFlat(${i}, ${p}, offset_${n});
1550
+ return sampleTexture(${n}, uv);
1551
1551
  }
1552
- `;return new k$1(n,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}getUnpackedSampler1D(t,r,o){let i=o.width,u=o.height;if(u===1&&i===1){let a=`
1553
- float ${t}(int index) {
1554
- return sampleTexture(${r}, halfCR);
1552
+ `;return new k(o,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}getUnpackedSampler1D(e,n,a){let i=a.width,p=a.height;if(p===1&&i===1){let s=`
1553
+ float ${e}(int index) {
1554
+ return sampleTexture(${n}, halfCR);
1555
1555
  }
1556
- `;return new k$1(a,["coordinates.sampleTexture"])}if(u===1){let a=`
1557
- float ${t}(int index) {
1556
+ `;return new k(s,["coordinates.sampleTexture"])}if(p===1){let s=`
1557
+ float ${e}(int index) {
1558
1558
  vec2 uv = vec2((float(index) + 0.5) / ${i}.0, 0.5);
1559
- return sampleTexture(${r}, uv);
1559
+ return sampleTexture(${n}, uv);
1560
1560
  }
1561
- `;return new k$1(a,["coordinates.sampleTexture"])}if(i===1){let a=`
1562
- float ${t}(int index) {
1563
- vec2 uv = vec2(0.5, (float(index) + 0.5) / ${u}.0);
1564
- return sampleTexture(${r}, uv);
1561
+ `;return new k(s,["coordinates.sampleTexture"])}if(i===1){let s=`
1562
+ float ${e}(int index) {
1563
+ vec2 uv = vec2(0.5, (float(index) + 0.5) / ${p}.0);
1564
+ return sampleTexture(${n}, uv);
1565
1565
  }
1566
- `;return new k$1(a,["coordinates.sampleTexture"])}let n=`
1567
- float ${t}(int index) {
1568
- vec2 uv = uvFromFlat(${i}, ${u}, index);
1569
- return sampleTexture(${r}, uv);
1566
+ `;return new k(s,["coordinates.sampleTexture"])}let o=`
1567
+ float ${e}(int index) {
1568
+ vec2 uv = uvFromFlat(${i}, ${p}, index);
1569
+ return sampleTexture(${n}, uv);
1570
1570
  }
1571
- `;return new k$1(n,["coordinates.uvFromFlat","coordinates.sampleTexture"])}getUnpackedSampler2D(t,r,o){let i=o.unpackedShape,u=[o.height,o.width];if(u!=null&&Me.arraysEqual(i,u)){let s=u[1],h=u[0],f=`
1572
- float ${t}(int row, int col) {
1573
- vec2 uv = (vec2(row, col) + halfCR) / vec2(${s}.0, ${h}.0);
1574
- return sampleTexture(${r}, uv);
1571
+ `;return new k(o,["coordinates.uvFromFlat","coordinates.sampleTexture"])}getUnpackedSampler2D(e,n,a){let i=a.unpackedShape,p=[a.height,a.width];if(p!=null&&Me.arraysEqual(i,p)){let l=p[1],f=p[0],g=`
1572
+ float ${e}(int row, int col) {
1573
+ vec2 uv = (vec2(row, col) + halfCR) / vec2(${l}.0, ${f}.0);
1574
+ return sampleTexture(${n}, uv);
1575
1575
  }
1576
- `;return new k$1(f,["coordinates.sampleTexture"])}let{newShape:n,keptDims:a}=hr(i),d=n;if(d.length<i.length){let s=lr(i,d),h=JSON.parse(JSON.stringify(o));h.unpackedShape=s;let f=["col","row"],m=`
1577
- ${this.getUnpackedSamplerFromInput(t,r,h).routineBody}
1578
- float ${t}(int row, int col) {
1579
- return ${t}(${fr(f,a)});
1576
+ `;return new k(g,["coordinates.sampleTexture"])}let{newShape:o,keptDims:s}=hr(i),c=o;if(c.length<i.length){let l=lr(i,c),f=JSON.parse(JSON.stringify(a));f.unpackedShape=l;let g=["col","row"],b=`
1577
+ ${this.getUnpackedSamplerFromInput(e,n,f).routineBody}
1578
+ float ${e}(int row, int col) {
1579
+ return ${e}(${fr(g,s)});
1580
1580
  }
1581
- `;return new k$1(m,["coordinates.sampleTexture"])}let c=u[1],e=u[0];if(e===1){let s=`
1582
- float ${t}(int row, int col) {
1583
- int offset_${r} = coordsToOffset(TexCoords, ${c}, ${e});
1584
- float index = dot(vec3(row, col, offset_${r}), vec3(${i[1]}, 1, 1));
1585
- vec2 uv = vec2(0.5, (index + 0.5) / ${c}.0);
1586
- return sampleTexture(${r}, uv);
1581
+ `;return new k(b,["coordinates.sampleTexture"])}let h=p[1],r=p[0];if(r===1){let l=`
1582
+ float ${e}(int row, int col) {
1583
+ int offset_${n} = coordsToOffset(TexCoords, ${h}, ${r});
1584
+ float index = dot(vec3(row, col, offset_${n}), vec3(${i[1]}, 1, 1));
1585
+ vec2 uv = vec2(0.5, (index + 0.5) / ${h}.0);
1586
+ return sampleTexture(${n}, uv);
1587
1587
  }
1588
- `;return new k$1(s,["coordinates.sampleTexture","coordinates.coordsToOffset"])}if(c===1){let s=`
1589
- float ${t}(int row, int col) {
1590
- int offset_${r} = coordsToOffset(TexCoords, ${c}, ${e});
1591
- float index = dot(vec3(row, col, offset_${r}), vec3(${i[1]}, 1, 1));
1592
- vec2 uv = vec2((index + 0.5) / ${e}.0, 0.5);
1593
- return sampleTexture(${r}, uv);
1588
+ `;return new k(l,["coordinates.sampleTexture","coordinates.coordsToOffset"])}if(h===1){let l=`
1589
+ float ${e}(int row, int col) {
1590
+ int offset_${n} = coordsToOffset(TexCoords, ${h}, ${r});
1591
+ float index = dot(vec3(row, col, offset_${n}), vec3(${i[1]}, 1, 1));
1592
+ vec2 uv = vec2((index + 0.5) / ${r}.0, 0.5);
1593
+ return sampleTexture(${n}, uv);
1594
1594
  }
1595
- `;return new k$1(s,["coordinates.sampleTexture","coordinates.coordsToOffset"])}let l=`
1596
- float ${t}(int row, int col) {
1595
+ `;return new k(l,["coordinates.sampleTexture","coordinates.coordsToOffset"])}let u=`
1596
+ float ${e}(int row, int col) {
1597
1597
  int index = col * ${i[1]} + row;
1598
- vec2 uv = uvFromFlat(${c}, ${e}, index);
1599
- return sampleTexture(${r}, uv);
1598
+ vec2 uv = uvFromFlat(${h}, ${r}, index);
1599
+ return sampleTexture(${n}, uv);
1600
1600
  }
1601
- `;return new k$1(l,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}getUnpackedSampler3D(t,r,o){let i=o.unpackedShape,u=i[1]*i[2],n=i[2],{newShape:a,keptDims:d}=hr(i),c=a;if(c.length<i.length){let h=lr(i,c),f=["batch","col","row"],m=JSON.parse(JSON.stringify(o));m.unpackedShape=h;let v=this.getUnpackedSamplerFromInput(t,r,m),_=d.reverse(),I=`
1601
+ `;return new k(u,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}getUnpackedSampler3D(e,n,a){let i=a.unpackedShape,p=i[1]*i[2],o=i[2],{newShape:s,keptDims:c}=hr(i),h=s;if(h.length<i.length){let f=lr(i,h),g=["batch","col","row"],b=JSON.parse(JSON.stringify(a));b.unpackedShape=f;let v=this.getUnpackedSamplerFromInput(e,n,b),S=c.reverse(),P=`
1602
1602
  ${v.routineBody}
1603
- float ${t}(int batch, int row, int col) {
1604
- return ${t}(${fr(f,_)});
1603
+ float ${e}(int batch, int row, int col) {
1604
+ return ${e}(${fr(g,S)});
1605
1605
  }
1606
- `;return new k$1(I,v.dependencies)}let e=o.width,l=o.height,s=`
1607
- float ${t}(int depth, int row, int col) {
1606
+ `;return new k(P,v.dependencies)}let r=a.width,u=a.height,l=`
1607
+ float ${e}(int depth, int row, int col) {
1608
1608
  // Explicitly use integer operations as dot() only works on floats.
1609
- int index = depth * ${u} + col * ${n} + row;
1610
- vec2 uv = uvFromFlat(${e}, ${l}, index);
1611
- return sampleTexture(${r}, uv);
1609
+ int index = depth * ${p} + col * ${o} + row;
1610
+ vec2 uv = uvFromFlat(${r}, ${u}, index);
1611
+ return sampleTexture(${n}, uv);
1612
1612
  }
1613
- `;return new k$1(s,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}getUnpackedSampler4D(t,r,o){let i=o.unpackedShape,u=i[3],n=i[2]*u,a=i[1]*n,d=o.width,c=o.height,e=`
1614
- float ${t}(int row, int col, int depth, int depth2) {
1615
- int index = row * ${a} + col * ${n} +
1616
- depth2 * ${u} + depth;
1617
- vec2 uv = uvFromFlat(${d}, ${c}, index);
1618
- return sampleTexture(${r}, uv);
1613
+ `;return new k(l,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}getUnpackedSampler4D(e,n,a){let i=a.unpackedShape,p=i[3],o=i[2]*p,s=i[1]*o,c=a.width,h=a.height,r=`
1614
+ float ${e}(int row, int col, int depth, int depth2) {
1615
+ int index = row * ${s} + col * ${o} +
1616
+ depth2 * ${p} + depth;
1617
+ vec2 uv = uvFromFlat(${c}, ${h}, index);
1618
+ return sampleTexture(${n}, uv);
1619
1619
  }
1620
- `;return new k$1(e,["coordinates.uvFromFlat","coordinates.sampleTexture"])}getUnpackedSampler5D(t,r,o){let i=o.unpackedShape,u=i[4],n=i[3]*u,a=i[2]*n,d=i[1]*a,{newShape:c,keptDims:e}=hr(i);if(c.length<i.length){let f=lr(i,c),m=["row","col","depth","depth2","depth3"],v=JSON.parse(JSON.stringify(o));v.unpackedShape=f;let _=`
1621
- ${this.getUnpackedSamplerFromInput(t,r,v).routineBody}
1622
- float ${t}(int row, int col, int depth, int depth2, int depth3) {
1623
- return ${t}(${fr(m,e)});
1620
+ `;return new k(r,["coordinates.uvFromFlat","coordinates.sampleTexture"])}getUnpackedSampler5D(e,n,a){let i=a.unpackedShape,p=i[4],o=i[3]*p,s=i[2]*o,c=i[1]*s,{newShape:h,keptDims:r}=hr(i);if(h.length<i.length){let g=lr(i,h),b=["row","col","depth","depth2","depth3"],v=JSON.parse(JSON.stringify(a));v.unpackedShape=g;let S=`
1621
+ ${this.getUnpackedSamplerFromInput(e,n,v).routineBody}
1622
+ float ${e}(int row, int col, int depth, int depth2, int depth3) {
1623
+ return ${e}(${fr(b,r)});
1624
1624
  }
1625
- `;return new k$1(_,["coordinates.sampleTexture","coordinates.uvFromFlat"])}let l=o.width,s=o.height,h=`
1626
- float ${t}(int row, int col, int depth, int depth2, int depth3) {
1627
- int index = row * ${d} + col * ${a} + depth * ${n} +
1628
- depth3 * ${u} + depth2;
1629
- vec2 uv = uvFromFlat(${l}, ${s}, index);
1630
- return sampleTexture(${r}, uv);
1625
+ `;return new k(S,["coordinates.sampleTexture","coordinates.uvFromFlat"])}let u=a.width,l=a.height,f=`
1626
+ float ${e}(int row, int col, int depth, int depth2, int depth3) {
1627
+ int index = row * ${c} + col * ${s} + depth * ${o} +
1628
+ depth3 * ${p} + depth2;
1629
+ vec2 uv = uvFromFlat(${u}, ${l}, index);
1630
+ return sampleTexture(${n}, uv);
1631
1631
  }
1632
- `;return new k$1(h,["coordinates.sampleTexture","coordinates.uvFromFlat"])}getUnpackedSampler6D(t,r,o){let i=o.unpackedShape,u=i[5],n=i[4]*u,a=i[3]*n,d=i[2]*a,c=i[1]*d,{newShape:e,keptDims:l}=hr(i);if(e.length<i.length){let m=lr(i,e),v=["row","col","depth","depth2","depth3","depth4"],_=JSON.parse(JSON.stringify(o));_.unpackedShape=m;let I=`
1633
- ${this.getUnpackedSamplerFromInput(t,r,_).routineBody}
1634
- float ${t}(int row, int col, int depth,
1632
+ `;return new k(f,["coordinates.sampleTexture","coordinates.uvFromFlat"])}getUnpackedSampler6D(e,n,a){let i=a.unpackedShape,p=i[5],o=i[4]*p,s=i[3]*o,c=i[2]*s,h=i[1]*c,{newShape:r,keptDims:u}=hr(i);if(r.length<i.length){let b=lr(i,r),v=["row","col","depth","depth2","depth3","depth4"],S=JSON.parse(JSON.stringify(a));S.unpackedShape=b;let P=`
1633
+ ${this.getUnpackedSamplerFromInput(e,n,S).routineBody}
1634
+ float ${e}(int row, int col, int depth,
1635
1635
  int depth2, int depth3, int depth4) {
1636
- return ${t}(${fr(v,l)});
1636
+ return ${e}(${fr(v,u)});
1637
1637
  }
1638
- `;return new k$1(I,["coordinates.sampleTexture","coordinates.uvFromFlat"])}let s=o.width,h=o.height,f=`
1639
- float ${t}(int row, int col, int depth,
1638
+ `;return new k(P,["coordinates.sampleTexture","coordinates.uvFromFlat"])}let l=a.width,f=a.height,g=`
1639
+ float ${e}(int row, int col, int depth,
1640
1640
  int depth2, int depth3, int depth4) {
1641
- int index = row * ${c} + col * ${d} + depth * ${a} +
1642
- depth2 * ${n} + depth3 * ${u} + depth4;
1643
- vec2 uv = uvFromFlat(${s}, ${h}, index);
1644
- return sampleTexture(${r}, uv);
1641
+ int index = row * ${h} + col * ${c} + depth * ${s} +
1642
+ depth2 * ${o} + depth3 * ${p} + depth4;
1643
+ vec2 uv = uvFromFlat(${l}, ${f}, index);
1644
+ return sampleTexture(${n}, uv);
1645
1645
  }
1646
- `;return new k$1(f,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}toVec(){let t=this.context.outputTextureLayout,r=t.shape.length,o=t.strides,i=t.width,u=t.height,n=[];for(let d=0;d<r-1;++d)n.push(`
1647
- c[${d}] = offset / ${o[d]};`),n.push(`
1648
- offset -= c[${d}] * ${o[d]};`);n.push(`
1649
- c[${r-1}] = offset;`);let a=`
1650
- void toVec(vec2 texCoords, out int c[${r}]) {
1651
- int offset = coordsToOffset(texCoords, ${i}, ${u});
1652
- ${n.join("")}
1646
+ `;return new k(g,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}toVec(){let e=this.context.outputTextureLayout,n=e.shape.length,a=e.strides,i=e.width,p=e.height,o=[];for(let c=0;c<n-1;++c)o.push(`
1647
+ c[${c}] = offset / ${a[c]};`),o.push(`
1648
+ offset -= c[${c}] * ${a[c]};`);o.push(`
1649
+ c[${n-1}] = offset;`);let s=`
1650
+ void toVec(vec2 texCoords, out int c[${n}]) {
1651
+ int offset = coordsToOffset(texCoords, ${i}, ${p});
1652
+ ${o.join("")}
1653
1653
  }
1654
- void toVec(int offset, out int c[${r}]) {
1655
- ${n.join("")}
1654
+ void toVec(int offset, out int c[${n}]) {
1655
+ ${o.join("")}
1656
1656
  }
1657
- `;return{toVec:new k$1(a,["coordinates.coordsToOffset"])}}valueFrom(){let t={};return this.context.programInfo.inputNames.forEach((r,o)=>{let i=this.context.inputTextureLayouts[o],u=(i.unpackedShape.length>0?i.unpackedShape:i.shape).length,n=`_${r}`;t[n]=new k$1(this.getValueFromSingle(r,u,i.width,i.height,!1),[`shapeUtils.indicesToOffset${n}`,"coordinates.offsetToCoords","fragcolor.getColorAsFloat"]),n=n+"_T",t[n]=new k$1(this.getValueFromSingle(r,u,i.width,i.height,!0),[`shapeUtils.indicesToOffset${n}`,"coordinates.offsetToCoords","fragcolor.getColorAsFloat"])}),t}getValueFromSingle(t,r,o,i,u){let n=`_${t}`;u&&(n=n+"_T");let a=G(this.context.glContext.version);return`
1658
- float ${n}(int m[${r}]) {
1659
- int offset = indicesToOffset${n}(m);
1660
- vec2 coords = offsetToCoords(offset, ${o}, ${i});
1661
- float value = getColorAsFloat(${a.texture2D}(${t}, coords));
1657
+ `;return{toVec:new k(s,["coordinates.coordsToOffset"])}}valueFrom(){let e={};return this.context.programInfo.inputNames.forEach((n,a)=>{let i=this.context.inputTextureLayouts[a],p=(i.unpackedShape.length>0?i.unpackedShape:i.shape).length,o=`_${n}`;e[o]=new k(this.getValueFromSingle(n,p,i.width,i.height,!1),[`shapeUtils.indicesToOffset${o}`,"coordinates.offsetToCoords","fragcolor.getColorAsFloat"]),o=o+"_T",e[o]=new k(this.getValueFromSingle(n,p,i.width,i.height,!0),[`shapeUtils.indicesToOffset${o}`,"coordinates.offsetToCoords","fragcolor.getColorAsFloat"])}),e}getValueFromSingle(e,n,a,i,p){let o=`_${e}`;p&&(o=o+"_T");let s=G(this.context.glContext.version);return`
1658
+ float ${o}(int m[${n}]) {
1659
+ int offset = indicesToOffset${o}(m);
1660
+ vec2 coords = offsetToCoords(offset, ${a}, ${i});
1661
+ float value = getColorAsFloat(${s.texture2D}(${e}, coords));
1662
1662
  return value;
1663
1663
  }
1664
- `}getPackedValueFrom(t,r,o,i,u){let n=`_${t}_Pack`;u&&(n=n+"_T");let a=G(this.context.glContext.version);return`
1665
- vec4 ${n}(int m[${r}]) {
1666
- int offset = indicesToOffset_${t}(m);
1667
- vec2 coords = offsetToCoords(offset, ${o}, ${i});
1668
- return ${a.texture2D}(${t}, coords);
1664
+ `}getPackedValueFrom(e,n,a,i,p){let o=`_${e}_Pack`;p&&(o=o+"_T");let s=G(this.context.glContext.version);return`
1665
+ vec4 ${o}(int m[${n}]) {
1666
+ int offset = indicesToOffset_${e}(m);
1667
+ vec2 coords = offsetToCoords(offset, ${a}, ${i});
1668
+ return ${s.texture2D}(${e}, coords);
1669
1669
  }
1670
- `}}}),zn,pp=O(()=>{Te(),zn=class on extends Ht{constructor(r){super(r)}getFunctions(){return{...this.encodeFloat32(),...this.decodeFloat32()}}getCustomTypes(){return{}}encodeFloat32(){return{encode:new k$1(`highp vec4 encode(highp float f) {
1670
+ `}}}),zn,pp=O(()=>{Te(),zn=class nn extends Ht{constructor(n){super(n)}getFunctions(){return{...this.encodeFloat32(),...this.decodeFloat32()}}getCustomTypes(){return{}}encodeFloat32(){return{encode:new k(`highp vec4 encode(highp float f) {
1671
1671
  return vec4(f, 0.0, 0.0, 0.0);
1672
1672
  }
1673
- `)}}decodeFloat32(){return{decode:new k$1(`highp float decode(highp vec4 rgba) {
1673
+ `)}}decodeFloat32(){return{decode:new k(`highp float decode(highp vec4 rgba) {
1674
1674
  return rgba.r;
1675
1675
  }
1676
- `)}}encodeUint8(){let r=on.isLittleEndian()?"rgba.rgba=rgba.abgr;":"";return{encode:new k$1(`
1676
+ `)}}encodeUint8(){let n=nn.isLittleEndian()?"rgba.rgba=rgba.abgr;":"";return{encode:new k(`
1677
1677
  highp vec4 encode(highp float f) {
1678
1678
  highp float F = abs(f);
1679
1679
  highp float Sign = step(0.0,-f);
@@ -1685,63 +1685,63 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(t,r,o)=>Xe(
1685
1685
  rgba[1] = 128.0 * mod(Exponent,2.0) + mod(floor(Mantissa*128.0),128.0);
1686
1686
  rgba[2] = floor(mod(floor(Mantissa*exp2(23.0 -8.0)),exp2(8.0)));
1687
1687
  rgba[3] = floor(exp2(23.0)*mod(Mantissa,exp2(-15.0)));
1688
- ${r}
1688
+ ${n}
1689
1689
  rgba = rgba / 255.0; // values need to be normalized to [0,1]
1690
1690
  return rgba;
1691
1691
  }
1692
- `)}}decodeUint8(){let r=on.isLittleEndian()?"rgba.rgba=rgba.abgr;":"";return{decode:new k$1(`
1692
+ `)}}decodeUint8(){let n=nn.isLittleEndian()?"rgba.rgba=rgba.abgr;":"";return{decode:new k(`
1693
1693
  highp float decode(highp vec4 rgba) {
1694
1694
  rgba = rgba * 255.0; // values need to be de-normalized from [0,1] to [0,255]
1695
- ${r}
1695
+ ${n}
1696
1696
  highp float Sign = 1.0 - step(128.0,rgba[0])*2.0;
1697
1697
  highp float Exponent = 2.0 * mod(rgba[0],128.0) + step(128.0,rgba[1]) - 127.0;
1698
1698
  highp float Mantissa = mod(rgba[1],128.0)*65536.0 + rgba[2]*256.0 +rgba[3] + float(0x800000);
1699
1699
  highp float Result = Sign * exp2(Exponent) * (Mantissa * exp2(-23.0 ));
1700
1700
  return Result;
1701
1701
  }
1702
- `)}}static isLittleEndian(){let r=new ArrayBuffer(4),o=new Uint32Array(r),i=new Uint8Array(r);if(o[0]=3735928559,i[0]===239)return!0;if(i[0]===222)return!1;throw new Error("unknown endianness")}}}),Wn,dp=O(()=>{Te(),ut(),Wn=class extends Ht{constructor(t){super(t)}getFunctions(){return{...this.setFragColor(),...this.getColorAsFloat()}}getCustomTypes(){return{}}setFragColor(){let t=G(this.context.glContext.version);return{setFragColor:new k$1(`
1702
+ `)}}static isLittleEndian(){let n=new ArrayBuffer(4),a=new Uint32Array(n),i=new Uint8Array(n);if(a[0]=3735928559,i[0]===239)return!0;if(i[0]===222)return!1;throw new Error("unknown endianness")}}}),Wn,dp=O(()=>{Te(),ut(),Wn=class extends Ht{constructor(e){super(e)}getFunctions(){return{...this.setFragColor(),...this.getColorAsFloat()}}getCustomTypes(){return{}}setFragColor(){let e=G(this.context.glContext.version);return{setFragColor:new k(`
1703
1703
  void setFragColor(float value) {
1704
- ${t.output} = encode(value);
1704
+ ${e.output} = encode(value);
1705
1705
  }
1706
- `,["encoding.encode"])}}getColorAsFloat(){return{getColorAsFloat:new k$1(`
1706
+ `,["encoding.encode"])}}getColorAsFloat(){return{getColorAsFloat:new k(`
1707
1707
  float getColorAsFloat(vec4 color) {
1708
1708
  return decode(color);
1709
1709
  }
1710
- `,["encoding.decode"])}}}}),Hn,hp=O(()=>{Te(),Hn=class $e extends Ht{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,o={};return this.context.programInfo.inputNames.forEach((i,u)=>{let n=this.context.inputTextureLayouts[u].unpackedShape;if(n.length<=r){let a=n.length,d=r-a,c=`bcastIndices_${i}`,e="";for(let s=0;s<a;++s)e+=`
1711
- realIndices[${s}] = int( mod(float(bcastedIndices[${d+s}]), ${n[s]}.0) );
1712
- `;let l=`
1713
- void ${c} (int bcastedIndices[${r}], out int realIndices[${a}]) {
1714
- ${e}
1710
+ `,["encoding.decode"])}}}}),Hn,hp=O(()=>{Te(),Hn=class Ie extends Ht{constructor(n){super(n)}getFunctions(){return{...this.bcastIndex(),...this.bcastMatmulIndex(),...this.offsetToIndices(),...this.indicesToOffset(),...this.incrementIndices()}}getCustomTypes(){return{}}bcastIndex(){let n=this.context.outputTextureLayout.shape.length,a={};return this.context.programInfo.inputNames.forEach((i,p)=>{let o=this.context.inputTextureLayouts[p].unpackedShape;if(o.length<=n){let s=o.length,c=n-s,h=`bcastIndices_${i}`,r="";for(let l=0;l<s;++l)r+=`
1711
+ realIndices[${l}] = int( mod(float(bcastedIndices[${c+l}]), ${o[l]}.0) );
1712
+ `;let u=`
1713
+ void ${h} (int bcastedIndices[${n}], out int realIndices[${s}]) {
1714
+ ${r}
1715
1715
  }
1716
- `;o[c]=new k$1(l)}}),o}bcastMatmulIndex(){let r=this.context.outputTextureLayout.shape.length,o={};return this.context.programInfo.inputNames.forEach((i,u)=>{let n=this.context.inputTextureLayouts[u].shape;if(!(n.length<2||n.length>r)){let a=n.length,d=r-a,c=`bcastMatmulIndices_${i}`,e="";for(let s=0;s<a-2;++s)e+=`
1717
- realIndices[${s}] = int( mod(float(bcastedIndices[${d+s}]), ${n[s]}.0) );
1718
- `;let l=`
1719
- void ${c}(int bcastedIndices[${r}], out int realIndices[${a}]) {
1720
- ${e}
1721
- realIndices[${a-1}] = bcastedIndices[${r-1}];
1722
- realIndices[${a-2}] = bcastedIndices[${r-2}];
1716
+ `;a[h]=new k(u)}}),a}bcastMatmulIndex(){let n=this.context.outputTextureLayout.shape.length,a={};return this.context.programInfo.inputNames.forEach((i,p)=>{let o=this.context.inputTextureLayouts[p].shape;if(!(o.length<2||o.length>n)){let s=o.length,c=n-s,h=`bcastMatmulIndices_${i}`,r="";for(let l=0;l<s-2;++l)r+=`
1717
+ realIndices[${l}] = int( mod(float(bcastedIndices[${c+l}]), ${o[l]}.0) );
1718
+ `;let u=`
1719
+ void ${h}(int bcastedIndices[${n}], out int realIndices[${s}]) {
1720
+ ${r}
1721
+ realIndices[${s-1}] = bcastedIndices[${n-1}];
1722
+ realIndices[${s-2}] = bcastedIndices[${n-2}];
1723
1723
  }
1724
- `;o[c]=new k$1(l)}}),o}indicesToOffset(){let r={};return this.context.programInfo.inputNames.forEach((o,i)=>{let u=this.context.inputTextureLayouts[i].shape,n=this.context.inputTextureLayouts[i].strides,a=u.length,d=`indicesToOffset_${o}`;r[d]=new k$1($e.indexToOffsetSingle(d,a,n)),d=`indicesToOffset_${o}_T`,r[d]=new k$1($e.indexToOffsetSingle(d,a,n.slice().reverse()))}),r}static indexToOffsetSingle(r,o,i){let u="";for(let n=o-1;n>=0;--n)u+=`
1725
- offset += indices[${n}] * ${i[n]};
1724
+ `;a[h]=new k(u)}}),a}indicesToOffset(){let n={};return this.context.programInfo.inputNames.forEach((a,i)=>{let p=this.context.inputTextureLayouts[i].shape,o=this.context.inputTextureLayouts[i].strides,s=p.length,c=`indicesToOffset_${a}`;n[c]=new k(Ie.indexToOffsetSingle(c,s,o)),c=`indicesToOffset_${a}_T`,n[c]=new k(Ie.indexToOffsetSingle(c,s,o.slice().reverse()))}),n}static indexToOffsetSingle(n,a,i){let p="";for(let o=a-1;o>=0;--o)p+=`
1725
+ offset += indices[${o}] * ${i[o]};
1726
1726
  `;return`
1727
- int ${r}(int indices[${o}]) {
1727
+ int ${n}(int indices[${a}]) {
1728
1728
  int offset = 0;
1729
- ${u}
1729
+ ${p}
1730
1730
  return offset;
1731
1731
  }
1732
- `}offsetToIndices(){let r={};return this.context.programInfo.inputNames.forEach((o,i)=>{let u=this.context.inputTextureLayouts[i].shape,n=this.context.inputTextureLayouts[i].strides,a=u.length,d=`offsetToIndices_${o}`;r[d]=new k$1($e.offsetToIndicesSingle(d,a,n)),d=`offsetToIndices_${o}_T`,r[d]=new k$1($e.offsetToIndicesSingle(d,a,n.slice().reverse()))}),r}static offsetToIndicesSingle(r,o,i){let u=[];for(let n=0;n<o-1;++n)u.push(`
1733
- indices[${n}] = offset / ${i[n]};`),u.push(`
1734
- offset -= indices[${n}] * ${i[n]};`);return u.push(`
1735
- indices[${o-1}] = offset;`),`
1736
- void ${r}(int offset, out int indices[${o}]) {
1737
- ${u.join("")}
1732
+ `}offsetToIndices(){let n={};return this.context.programInfo.inputNames.forEach((a,i)=>{let p=this.context.inputTextureLayouts[i].shape,o=this.context.inputTextureLayouts[i].strides,s=p.length,c=`offsetToIndices_${a}`;n[c]=new k(Ie.offsetToIndicesSingle(c,s,o)),c=`offsetToIndices_${a}_T`,n[c]=new k(Ie.offsetToIndicesSingle(c,s,o.slice().reverse()))}),n}static offsetToIndicesSingle(n,a,i){let p=[];for(let o=0;o<a-1;++o)p.push(`
1733
+ indices[${o}] = offset / ${i[o]};`),p.push(`
1734
+ offset -= indices[${o}] * ${i[o]};`);return p.push(`
1735
+ indices[${a-1}] = offset;`),`
1736
+ void ${n}(int offset, out int indices[${a}]) {
1737
+ ${p.join("")}
1738
1738
  }
1739
- `}incrementIndices(){let r={};return this.context.programInfo.inputNames.forEach((o,i)=>{let u=this.context.inputTextureLayouts[i].shape,n=u.length,a=`incrementIndices_${o}`,d="";for(let e=0;e<n;++e)d+=`
1740
- shape[${e}] = ${u[e]};`;let c=`
1741
- void ${a}(int axis, out int indices[${n}]) {
1742
- int shape[${n}];
1743
- ${d};
1744
- for(int i = ${n} -1 ; i >= 0; --i) {
1739
+ `}incrementIndices(){let n={};return this.context.programInfo.inputNames.forEach((a,i)=>{let p=this.context.inputTextureLayouts[i].shape,o=p.length,s=`incrementIndices_${a}`,c="";for(let r=0;r<o;++r)c+=`
1740
+ shape[${r}] = ${p[r]};`;let h=`
1741
+ void ${s}(int axis, out int indices[${o}]) {
1742
+ int shape[${o}];
1743
+ ${c};
1744
+ for(int i = ${o} -1 ; i >= 0; --i) {
1745
1745
  if(i > axis) continue;
1746
1746
  indices[i] += 1;
1747
1747
  if(indices[i] < shape[i]) {
@@ -1750,63 +1750,63 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(t,r,o)=>Xe(
1750
1750
  indices[i] = 0;
1751
1751
  }
1752
1752
  }
1753
- `;r[a]=new k$1(c)}),r}}}),qn,mp=O(()=>{Te(),qn=class extends Ht{constructor(t){super(t)}getCustomTypes(){return{}}getFunctions(){return{...this.binaryVecFunctions(),...this.copyVec(),...this.setVecItem(),...this.getVecItem()}}binaryVecFunctions(){let t=this.context.outputTextureLayout.shape.length,r={add:"+=",sub:"-=",mul:"*=",div:"/="},o={};for(let i in r){let u=`${i}Vec`,n="";for(let d=0;d<t;++d)n+=`
1754
- dest[${d}] ${r[i]} src[${d}];
1755
- `;let a=`
1756
- void ${u}(int src[${t}], out int dest[${t}]) {
1757
- ${n}
1753
+ `;n[s]=new k(h)}),n}}}),qn,mp=O(()=>{Te(),qn=class extends Ht{constructor(e){super(e)}getCustomTypes(){return{}}getFunctions(){return{...this.binaryVecFunctions(),...this.copyVec(),...this.setVecItem(),...this.getVecItem()}}binaryVecFunctions(){let e=this.context.outputTextureLayout.shape.length,n={add:"+=",sub:"-=",mul:"*=",div:"/="},a={};for(let i in n){let p=`${i}Vec`,o="";for(let c=0;c<e;++c)o+=`
1754
+ dest[${c}] ${n[i]} src[${c}];
1755
+ `;let s=`
1756
+ void ${p}(int src[${e}], out int dest[${e}]) {
1757
+ ${o}
1758
1758
  }
1759
- `;o[u]=new k$1(a)}return o}copyVec(){let t=this.context.outputTextureLayout.shape.length,r="";for(let i=0;i<t;++i)r+=`
1759
+ `;a[p]=new k(s)}return a}copyVec(){let e=this.context.outputTextureLayout.shape.length,n="";for(let i=0;i<e;++i)n+=`
1760
1760
  dest[${i}] = src[${i}];
1761
- `;let o=`
1762
- void copyVec(int src[${t}], out int dest[${t}]) {
1763
- ${r}
1761
+ `;let a=`
1762
+ void copyVec(int src[${e}], out int dest[${e}]) {
1763
+ ${n}
1764
1764
  }
1765
- `;return{copyVec:new k$1(o)}}setVecItem(){let t=this.context.outputTextureLayout.shape.length,r=`
1765
+ `;return{copyVec:new k(a)}}setVecItem(){let e=this.context.outputTextureLayout.shape.length,n=`
1766
1766
  if(index < 0)
1767
- index =${t} + index;
1767
+ index =${e} + index;
1768
1768
  if (index == 0)
1769
1769
  m[0] = value;
1770
- `;for(let i=1;i<t-1;++i)r+=`
1770
+ `;for(let i=1;i<e-1;++i)n+=`
1771
1771
  else if (index == ${i})
1772
1772
  m[${i}] = value;
1773
- `;r+=`
1773
+ `;n+=`
1774
1774
  else
1775
- m[${t-1}] = value;
1776
- `;let o=`
1777
- void setVecItem(out int m[${t}], int index, int value) {
1778
- ${r}
1775
+ m[${e-1}] = value;
1776
+ `;let a=`
1777
+ void setVecItem(out int m[${e}], int index, int value) {
1778
+ ${n}
1779
1779
  }
1780
- `;return{setVecItem:new k$1(o)}}getVecItem(){let t=this.context.outputTextureLayout.shape.length,r=`
1780
+ `;return{setVecItem:new k(a)}}getVecItem(){let e=this.context.outputTextureLayout.shape.length,n=`
1781
1781
  if(index < 0)
1782
- index = ${t} + index;
1782
+ index = ${e} + index;
1783
1783
  if (index == 0)
1784
1784
  return m[0];
1785
- `;for(let i=1;i<t-1;++i)r+=`
1785
+ `;for(let i=1;i<e-1;++i)n+=`
1786
1786
  else if (index == ${i})
1787
1787
  return m[${i}];
1788
- `;r+=`
1788
+ `;n+=`
1789
1789
  else
1790
- return m[${t-1}];
1791
- `;let o=`
1792
- int getVecItem(int m[${t}], int index) {
1793
- ${r}
1790
+ return m[${e-1}];
1791
+ `;let a=`
1792
+ int getVecItem(int m[${e}], int index) {
1793
+ ${n}
1794
1794
  }
1795
- `;return{getVecItem:new k$1(o)}}}}),Ri,bp=O(()=>{cp(),pp(),dp(),hp(),mp(),Ri={encoding:zn,fragcolor:Wn,vec:qn,shapeUtils:Hn,coordinates:Vn}}),jn,gp=O(()=>{Te(),lp(),bp(),ut(),jn=class{constructor(t,r,o,i){this.libs={},this.glslLibRoutineDependencyGraph={},this.context=new Ln(t,r,o,i),Object.keys(Ri).forEach(n=>{let a=new Ri[n](this.context);this.libs[n]=a});let u=this.glslLibRoutineDependencyGraph;for(let n in this.libs){let a=this.libs[n].getFunctions();for(let d in a){let c=n+"."+d,e;u[c]?(e=u[c],e.routineBody=a[d].routineBody):(e=new Nr(c,a[d].routineBody),u[c]=e);let l=a[d].dependencies;if(l)for(let s=0;s<l.length;++s)if(u[l[s]])e.addDependency(u[l[s]]);else{let h=new Nr(l[s]);u[l[s]]=h,e.addDependency(h)}}}}preprocess(){let t=this.context.programInfo,r=t.shaderSource;return this.context.programInfo.hasMain||(r=`${r}
1796
- ${Ju(this.context.glContext.version,this.context.outputTextureLayout.shape.length)}`),r=up(r),`${Ku(this.context.glContext.version)}
1797
- ${this.getUniforms(t.inputNames,t.variables)}
1798
- ${this.getImports(r)}
1799
- ${r}`}getImports(t){let r=this.selectGlslLibRoutinesToBeIncluded(t);if(r.length===0)return"";let o="";for(let i=0;i<r.length;++i)if(r[i].routineBody)o+=r[i].routineBody+`
1800
- `;else throw new Error(`Missing body for the Glsl Library routine: ${r[i].name}`);return o}selectGlslLibRoutinesToBeIncluded(t){let r=[];return Object.keys(this.glslLibRoutineDependencyGraph).forEach(o=>{let i=o.split(".")[1];t.indexOf(i)!==-1&&r.push(this.glslLibRoutineDependencyGraph[o])}),$n.returnOrderedNodes(r)}getUniforms(t,r){let o=[];if(t)for(let i of t)o.push(`uniform sampler2D ${i};`);if(r)for(let i of r)o.push(`uniform ${i.type} ${i.name}${i.arrayLength?`[${i.arrayLength}]`:""};`);return o.join(`
1801
- `)}}}),Xn,yp=O(()=>{Yt(),Ut(),gp(),ut(),Xn=class{constructor(t,r,o){this.profiler=t,this.glContext=r,this.textureLayoutStrategy=o,this.repo=new Map,this.attributesBound=!1}getArtifact(t){return this.repo.get(t)}setArtifact(t,r){this.repo.set(t,r)}run(t,r,o){this.profiler.event("op",`ProgramManager.run ${t.programInfo.name??"unknown kernel"}`,()=>{let i=this.glContext.gl,u=t.program;i.useProgram(u);try{this.bindOutput(o),this.attributesBound||this.bindAttributes(t.attribLocations),this.bindUniforms(t.uniformLocations,t.programInfo.variables??[],r)}catch(n){throw tt.error("ProgramManager",t.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(t=>this.glContext.deleteProgram(t.program))}build(t,r,o){return this.profiler.event("backend","ProgramManager.build",()=>{let i=new jn(this.glContext,t,r,o),u=i.preprocess(),n=this.compile(u);return{programInfo:t,program:n,uniformLocations:this.getUniformLocations(n,i.context.programInfo.inputNames,i.context.programInfo.variables),attribLocations:this.getAttribLocations(n)}})}compile(t){if(!this.vertexShader){tt.verbose("ProrgramManager","Compiling and caching Vertex shader for the first time");let i=Xu(this.glContext.version);this.vertexShader=this.glContext.compileShader(i,this.glContext.gl.VERTEX_SHADER)}z.debug&&tt.verbose("ProrgramManager",`FragShader:
1802
- ${t}
1803
- `);let r=this.glContext.compileShader(t,this.glContext.gl.FRAGMENT_SHADER),o=this.glContext.createProgram(this.vertexShader,r);return this.glContext.deleteShader(r),o}bindOutput(t){let r=t.width,o=t.height;tt.verbose("ProrgramManager",`Binding output texture to Framebuffer: w/h=${r}/${o}, shape=${t.shape}, type=${t.tensor.type}`),this.glContext.attachFramebuffer(t.texture,r,o)}bindAttributes(t){let r=t.position,o=t.textureCoord;this.glContext.setVertexAttributes(r,o),this.attributesBound=!0}bindUniforms(t,r,o){var n;let i=this.glContext.gl,u=0;for(let{name:a,type:d,location:c,arrayLength:e}of t){let l=(n=r.find(s=>s.name===a))==null?void 0:n.data;if(d!=="sampler2D"&&!l)throw new Error(`variable '${a}' does not have data defined in program info`);switch(d){case"sampler2D":this.bindTexture(o[u],c,u),u++;break;case"float":e?i.uniform1fv(c,l):i.uniform1f(c,l);break;case"int":e?i.uniform1iv(c,l):i.uniform1i(c,l);break;default:throw new Error(`Uniform not implemented: ${d}`)}}}bindTexture(t,r,o){this.glContext.bindTextureToUniform(t.texture,o,r)}getAttribLocations(t){return{position:this.getAttribLocation(t,"position"),textureCoord:this.getAttribLocation(t,"textureCoord")}}getUniformLocations(t,r,o){let i=[];if(r)for(let u of r)i.push({name:u,type:"sampler2D",location:this.getUniformLocation(t,u)});if(o)for(let u of o)i.push({...u,location:this.getUniformLocation(t,u.name)});return i}getUniformLocation(t,r){let o=this.glContext.gl.getUniformLocation(t,r);if(o===null)throw new Error(`Uniform ${r} not found.`);return o}getAttribLocation(t,r){return this.glContext.gl.getAttribLocation(t,r)}}}),Kn,xp=O(()=>{Ut(),Fr(),Kn=class{constructor(t,r,o,i){this.glContext=t,this.layoutStrategy=r,this.profiler=o,this.config=i,this.pendingRead=new Map,i.reuseTextures&&(this.inUseTextures=new Map,this.idleTextures=new Map,this.textureLookup=new Map)}createTextureFromLayout(t,r,o,i){let u=this.toEncoderType(t),n=this.glContext.getEncoder(u,r.channels||1,i);if(r.isPacked&&i===1)throw new Error("not implemented");let a=r.width,d=r.height,c,e;if(this.config.reuseTextures){c=`${a}x${d}_${n.format}_${n.internalFormat}_${n.textureType}`,e=this.inUseTextures.get(c),e||(e=[],this.inUseTextures.set(c,e));let s=this.idleTextures.get(c);if(s&&s.length>0){let h=s.pop();return e.push(h),i===1&&this.glContext.updateTexture(h,a,d,n,this.toTextureData(t,o)),h}}tt.verbose("TextureManager",`Creating new texture of size ${r.width}x${r.height}`);let l=this.glContext.allocateTexture(a,d,n,this.toTextureData(t,o));return this.config.reuseTextures&&(e.push(l),this.textureLookup.set(l,c)),l}readTexture(t,r,o){return o||(o=1),this.profiler.event("backend","TextureManager.readTexture",()=>{let i=t.shape.reduce((n,a)=>n*a)*o,u=this.glContext.readTexture(t.texture,t.width,t.height,i,this.toEncoderType(r),o);return this.toTensorData(r,u)})}async readTextureAsync(t,r,o){let i=t.tensor.dataId;if(o||(o=1),this.pendingRead.has(i)){let u=this.pendingRead.get(i);return new Promise(n=>u==null?void 0:u.push(n))}return this.profiler.event("backend","TextureManager.readTextureAsync",async()=>{this.pendingRead.set(i,[]);let u=t.shape.reduce((c,e)=>c*e)*o;await this.glContext.createAndWaitForFence();let n=this.glContext.readTexture(t.texture,t.width,t.height,u,this.toEncoderType(r),o),a=this.toTensorData(r,n),d=this.pendingRead.get(i);return this.pendingRead.delete(i),d==null||d.forEach(c=>c(a)),a})}readUint8TextureAsFloat(t){return this.profiler.event("backend","TextureManager.readUint8TextureAsFloat",()=>{let r=t.shape.reduce((i,u)=>i*u),o=this.glContext.readTexture(t.texture,t.width,t.height,r*4,"byte",4);return new Float32Array(o.buffer,o.byteOffset,r)})}releaseTexture(t,r){let o;if(this.config.reuseTextures&&(o=this.textureLookup.get(t.texture),o)){r&&this.textureLookup.delete(o);let i=this.inUseTextures.get(o);if(i){let u=i.indexOf(t.texture);if(u!==-1){i.splice(u,1);let n=this.idleTextures.get(o);n||(n=[],this.idleTextures.set(o,n)),n.push(t.texture)}}}(!o||r)&&(tt.verbose("TextureManager",`Deleting texture of size ${t.width}x${t.height}`),this.glContext.deleteTexture(t.texture))}toTensorData(t,r){switch(t){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 ${t} is not supported`)}}toTextureData(t,r){if(r)return r instanceof Float32Array?r:new Float32Array(r)}toEncoderType(t){return"float"}clearActiveTextures(){this.glContext.clearActiveTextures()}}}),Jn,Tp=O(()=>{Ut(),Bs(),cl(),ap(),yp(),Ni(),xp(),Jn=class{constructor(t,r){this.backend=t,this.context=r,this.layoutStrategy=new Un(t.glContext.maxTextureSize),this.programManager=new Xn(this.context.profiler,t.glContext,this.layoutStrategy),this.textureManager=new Kn(t.glContext,this.layoutStrategy,this.context.profiler,{reuseTextures:t.textureCacheMode==="full"}),this.packedTextureDataCache=new Map,this.unpackedTextureDataCache=new Map,this.pack=t.pack,this.pack2unpackMap=new Map,this.unpack2packMap=new Map}createInferenceHandler(){return new Dn(this)}onGraphInitialized(t){let r=t.getValues().filter(o=>o.from===-1&&o.tensor).map(o=>o.tensor.dataId);this.initializers=new Set(r)}isInitializer(t){return this.initializers?this.initializers.has(t):!1}addInitializer(t){this.initializers.add(t)}getTextureData(t,r){return r?this.packedTextureDataCache.get(t):this.unpackedTextureDataCache.get(t)}setTextureData(t,r,o=!1){tt.verbose("WebGLSessionHandler","Storing Texture data in cache"),o?this.packedTextureDataCache.set(t,r):this.unpackedTextureDataCache.set(t,r)}dispose(){this.programManager.dispose(),this.textureManager.clearActiveTextures(),this.packedTextureDataCache.forEach(t=>this.textureManager.releaseTexture(t,!0)),this.packedTextureDataCache=new Map,this.unpackedTextureDataCache.forEach(t=>this.textureManager.releaseTexture(t,!0)),this.unpackedTextureDataCache=new Map}resolve(t,r,o){let i=ks(t,r,ip);return{impl:i.opImpl,context:i.opInit?i.opInit(t,o):t}}}});function bg(t){let r=0;for(;r<t.length&&t[r]();++r);return r-1}var Mr,wp=O(()=>{Yt(),Fr(),Fr(),pe(),Mr=class{constructor(t,r){this.frameBufferBound=!1,this.itemsToPoll=[],this.gl=t,this.version=r,this.getExtensions(),this.vertexbuffer=this.createVertexbuffer(),this.framebuffer=this.createFramebuffer(),this.queryVitalParameters()}allocateTexture(t,r,o,i){let u=this.gl,n=u.createTexture();u.bindTexture(u.TEXTURE_2D,n),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MIN_FILTER,u.NEAREST),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MAG_FILTER,u.NEAREST),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_S,u.CLAMP_TO_EDGE),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_T,u.CLAMP_TO_EDGE);let a=i?o.encode(i,t*r):null;return u.texImage2D(u.TEXTURE_2D,0,o.internalFormat,t,r,0,o.format,o.textureType,a),this.checkError(),n}updateTexture(t,r,o,i,u){let n=this.gl;n.bindTexture(n.TEXTURE_2D,t);let a=i.encode(u,r*o);n.texSubImage2D(n.TEXTURE_2D,0,0,0,r,o,i.format,i.textureType,a),this.checkError()}attachFramebuffer(t,r,o){let i=this.gl;i.bindTexture(i.TEXTURE_2D,t),i.bindFramebuffer(i.FRAMEBUFFER,this.framebuffer),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,t,0),this.checkError(),i.viewport(0,0,r,o),i.scissor(0,0,r,o)}readTexture(t,r,o,i,u,n){let a=this.gl;n||(n=1),this.frameBufferBound||this.attachFramebuffer(t,r,o);let d=this.getEncoder(u,n),c=d.allocate(r*o);return a.bindTexture(a.TEXTURE_2D,t),a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,t,0),a.readPixels(0,0,r,o,a.RGBA,d.textureType,c),this.checkError(),d.decode(c,i)}isFramebufferReady(){return!0}getActiveTexture(){let t=this.gl;return`TEXTURE${t.getParameter(this.gl.ACTIVE_TEXTURE)-t.TEXTURE0}`}getTextureBinding(){return this.gl.getParameter(this.gl.TEXTURE_BINDING_2D)}getFramebufferBinding(){return this.gl.getParameter(this.gl.FRAMEBUFFER_BINDING)}setVertexAttributes(t,r){let o=this.gl;o.vertexAttribPointer(t,3,o.FLOAT,!1,20,0),o.enableVertexAttribArray(t),r!==-1&&(o.vertexAttribPointer(r,2,o.FLOAT,!1,20,12),o.enableVertexAttribArray(r)),this.checkError()}createProgram(t,r){let o=this.gl,i=o.createProgram();return o.attachShader(i,t),o.attachShader(i,r),o.linkProgram(i),i}compileShader(t,r){let o=this.gl,i=o.createShader(r);if(!i)throw new Error(`createShader() returned null with type ${r}`);if(o.shaderSource(i,t),o.compileShader(i),o.getShaderParameter(i,o.COMPILE_STATUS)===!1)throw new Error(`Failed to compile shader: ${o.getShaderInfoLog(i)}
1795
+ `;return{getVecItem:new k(a)}}}}),Ri,bp=O(()=>{cp(),pp(),dp(),hp(),mp(),Ri={encoding:zn,fragcolor:Wn,vec:qn,shapeUtils:Hn,coordinates:Vn}}),jn,gp=O(()=>{Te(),lp(),bp(),ut(),jn=class{constructor(e,n,a,i){this.libs={},this.glslLibRoutineDependencyGraph={},this.context=new Ln(e,n,a,i),Object.keys(Ri).forEach(o=>{let s=new Ri[o](this.context);this.libs[o]=s});let p=this.glslLibRoutineDependencyGraph;for(let o in this.libs){let s=this.libs[o].getFunctions();for(let c in s){let h=o+"."+c,r;p[h]?(r=p[h],r.routineBody=s[c].routineBody):(r=new Nr(h,s[c].routineBody),p[h]=r);let u=s[c].dependencies;if(u)for(let l=0;l<u.length;++l)if(p[u[l]])r.addDependency(p[u[l]]);else{let f=new Nr(u[l]);p[u[l]]=f,r.addDependency(f)}}}}preprocess(){let e=this.context.programInfo,n=e.shaderSource;return this.context.programInfo.hasMain||(n=`${n}
1796
+ ${Ju(this.context.glContext.version,this.context.outputTextureLayout.shape.length)}`),n=up(n),`${Ku(this.context.glContext.version)}
1797
+ ${this.getUniforms(e.inputNames,e.variables)}
1798
+ ${this.getImports(n)}
1799
+ ${n}`}getImports(e){let n=this.selectGlslLibRoutinesToBeIncluded(e);if(n.length===0)return"";let a="";for(let i=0;i<n.length;++i)if(n[i].routineBody)a+=n[i].routineBody+`
1800
+ `;else throw new Error(`Missing body for the Glsl Library routine: ${n[i].name}`);return a}selectGlslLibRoutinesToBeIncluded(e){let n=[];return Object.keys(this.glslLibRoutineDependencyGraph).forEach(a=>{let i=a.split(".")[1];e.indexOf(i)!==-1&&n.push(this.glslLibRoutineDependencyGraph[a])}),$n.returnOrderedNodes(n)}getUniforms(e,n){let a=[];if(e)for(let i of e)a.push(`uniform sampler2D ${i};`);if(n)for(let i of n)a.push(`uniform ${i.type} ${i.name}${i.arrayLength?`[${i.arrayLength}]`:""};`);return a.join(`
1801
+ `)}}}),Xn,yp=O(()=>{Yt(),Ut(),gp(),ut(),Xn=class{constructor(e,n,a){this.profiler=e,this.glContext=n,this.textureLayoutStrategy=a,this.repo=new Map,this.attributesBound=!1}getArtifact(e){return this.repo.get(e)}setArtifact(e,n){this.repo.set(e,n)}run(e,n,a){this.profiler.event("op",`ProgramManager.run ${e.programInfo.name??"unknown kernel"}`,()=>{let i=this.glContext.gl,p=e.program;i.useProgram(p);try{this.bindOutput(a),this.attributesBound||this.bindAttributes(e.attribLocations),this.bindUniforms(e.uniformLocations,e.programInfo.variables??[],n)}catch(o){throw tt.error("ProgramManager",e.programInfo.shaderSource),o}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,n,a){return this.profiler.event("backend","ProgramManager.build",()=>{let i=new jn(this.glContext,e,n,a),p=i.preprocess(),o=this.compile(p);return{programInfo:e,program:o,uniformLocations:this.getUniformLocations(o,i.context.programInfo.inputNames,i.context.programInfo.variables),attribLocations:this.getAttribLocations(o)}})}compile(e){if(!this.vertexShader){tt.verbose("ProrgramManager","Compiling and caching Vertex shader for the first time");let i=Xu(this.glContext.version);this.vertexShader=this.glContext.compileShader(i,this.glContext.gl.VERTEX_SHADER)}z.debug&&tt.verbose("ProrgramManager",`FragShader:
1802
+ ${e}
1803
+ `);let n=this.glContext.compileShader(e,this.glContext.gl.FRAGMENT_SHADER),a=this.glContext.createProgram(this.vertexShader,n);return this.glContext.deleteShader(n),a}bindOutput(e){let n=e.width,a=e.height;tt.verbose("ProrgramManager",`Binding output texture to Framebuffer: w/h=${n}/${a}, shape=${e.shape}, type=${e.tensor.type}`),this.glContext.attachFramebuffer(e.texture,n,a)}bindAttributes(e){let n=e.position,a=e.textureCoord;this.glContext.setVertexAttributes(n,a),this.attributesBound=!0}bindUniforms(e,n,a){var o;let i=this.glContext.gl,p=0;for(let{name:s,type:c,location:h,arrayLength:r}of e){let u=(o=n.find(l=>l.name===s))==null?void 0:o.data;if(c!=="sampler2D"&&!u)throw new Error(`variable '${s}' does not have data defined in program info`);switch(c){case"sampler2D":this.bindTexture(a[p],h,p),p++;break;case"float":r?i.uniform1fv(h,u):i.uniform1f(h,u);break;case"int":r?i.uniform1iv(h,u):i.uniform1i(h,u);break;default:throw new Error(`Uniform not implemented: ${c}`)}}}bindTexture(e,n,a){this.glContext.bindTextureToUniform(e.texture,a,n)}getAttribLocations(e){return{position:this.getAttribLocation(e,"position"),textureCoord:this.getAttribLocation(e,"textureCoord")}}getUniformLocations(e,n,a){let i=[];if(n)for(let p of n)i.push({name:p,type:"sampler2D",location:this.getUniformLocation(e,p)});if(a)for(let p of a)i.push({...p,location:this.getUniformLocation(e,p.name)});return i}getUniformLocation(e,n){let a=this.glContext.gl.getUniformLocation(e,n);if(a===null)throw new Error(`Uniform ${n} not found.`);return a}getAttribLocation(e,n){return this.glContext.gl.getAttribLocation(e,n)}}}),Kn,xp=O(()=>{Ut(),Fr(),Kn=class{constructor(e,n,a,i){this.glContext=e,this.layoutStrategy=n,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,n,a,i){let p=this.toEncoderType(e),o=this.glContext.getEncoder(p,n.channels||1,i);if(n.isPacked&&i===1)throw new Error("not implemented");let s=n.width,c=n.height,h,r;if(this.config.reuseTextures){h=`${s}x${c}_${o.format}_${o.internalFormat}_${o.textureType}`,r=this.inUseTextures.get(h),r||(r=[],this.inUseTextures.set(h,r));let l=this.idleTextures.get(h);if(l&&l.length>0){let f=l.pop();return r.push(f),i===1&&this.glContext.updateTexture(f,s,c,o,this.toTextureData(e,a)),f}}tt.verbose("TextureManager",`Creating new texture of size ${n.width}x${n.height}`);let u=this.glContext.allocateTexture(s,c,o,this.toTextureData(e,a));return this.config.reuseTextures&&(r.push(u),this.textureLookup.set(u,h)),u}readTexture(e,n,a){return a||(a=1),this.profiler.event("backend","TextureManager.readTexture",()=>{let i=e.shape.reduce((o,s)=>o*s)*a,p=this.glContext.readTexture(e.texture,e.width,e.height,i,this.toEncoderType(n),a);return this.toTensorData(n,p)})}async readTextureAsync(e,n,a){let i=e.tensor.dataId;if(a||(a=1),this.pendingRead.has(i)){let p=this.pendingRead.get(i);return new Promise(o=>p==null?void 0:p.push(o))}return this.profiler.event("backend","TextureManager.readTextureAsync",async()=>{this.pendingRead.set(i,[]);let p=e.shape.reduce((h,r)=>h*r)*a;await this.glContext.createAndWaitForFence();let o=this.glContext.readTexture(e.texture,e.width,e.height,p,this.toEncoderType(n),a),s=this.toTensorData(n,o),c=this.pendingRead.get(i);return this.pendingRead.delete(i),c==null||c.forEach(h=>h(s)),s})}readUint8TextureAsFloat(e){return this.profiler.event("backend","TextureManager.readUint8TextureAsFloat",()=>{let n=e.shape.reduce((i,p)=>i*p),a=this.glContext.readTexture(e.texture,e.width,e.height,n*4,"byte",4);return new Float32Array(a.buffer,a.byteOffset,n)})}releaseTexture(e,n){let a;if(this.config.reuseTextures&&(a=this.textureLookup.get(e.texture),a)){n&&this.textureLookup.delete(a);let i=this.inUseTextures.get(a);if(i){let p=i.indexOf(e.texture);if(p!==-1){i.splice(p,1);let o=this.idleTextures.get(a);o||(o=[],this.idleTextures.set(a,o)),o.push(e.texture)}}}(!a||n)&&(tt.verbose("TextureManager",`Deleting texture of size ${e.width}x${e.height}`),this.glContext.deleteTexture(e.texture))}toTensorData(e,n){switch(e){case"int16":return n instanceof Int16Array?n:Int16Array.from(n);case"int32":return n instanceof Int32Array?n:Int32Array.from(n);case"int8":return n instanceof Int8Array?n:Int8Array.from(n);case"uint16":return n instanceof Uint16Array?n:Uint16Array.from(n);case"uint32":return n instanceof Uint32Array?n:Uint32Array.from(n);case"uint8":case"bool":return n instanceof Uint8Array?n:Uint8Array.from(n);case"float32":return n instanceof Float32Array?n:Float32Array.from(n);case"float64":return n instanceof Float64Array?n:Float64Array.from(n);default:throw new Error(`TensorData type ${e} is not supported`)}}toTextureData(e,n){if(n)return n instanceof Float32Array?n:new Float32Array(n)}toEncoderType(e){return"float"}clearActiveTextures(){this.glContext.clearActiveTextures()}}}),Jn,Tp=O(()=>{Ut(),Bs(),cl(),ap(),yp(),Ni(),xp(),Jn=class{constructor(e,n){this.backend=e,this.context=n,this.layoutStrategy=new Un(e.glContext.maxTextureSize),this.programManager=new Xn(this.context.profiler,e.glContext,this.layoutStrategy),this.textureManager=new Kn(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 Dn(this)}onGraphInitialized(e){let n=e.getValues().filter(a=>a.from===-1&&a.tensor).map(a=>a.tensor.dataId);this.initializers=new Set(n)}isInitializer(e){return this.initializers?this.initializers.has(e):!1}addInitializer(e){this.initializers.add(e)}getTextureData(e,n){return n?this.packedTextureDataCache.get(e):this.unpackedTextureDataCache.get(e)}setTextureData(e,n,a=!1){tt.verbose("WebGLSessionHandler","Storing Texture data in cache"),a?this.packedTextureDataCache.set(e,n):this.unpackedTextureDataCache.set(e,n)}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,n,a){let i=ks(e,n,ip);return{impl:i.opImpl,context:i.opInit?i.opInit(e,a):e}}}});function bg(e){let n=0;for(;n<e.length&&e[n]();++n);return n-1}var Mr,wp=O(()=>{Yt(),Fr(),Fr(),pe(),Mr=class{constructor(e,n){this.frameBufferBound=!1,this.itemsToPoll=[],this.gl=e,this.version=n,this.getExtensions(),this.vertexbuffer=this.createVertexbuffer(),this.framebuffer=this.createFramebuffer(),this.queryVitalParameters()}allocateTexture(e,n,a,i){let p=this.gl,o=p.createTexture();p.bindTexture(p.TEXTURE_2D,o),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MIN_FILTER,p.NEAREST),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MAG_FILTER,p.NEAREST),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_S,p.CLAMP_TO_EDGE),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_T,p.CLAMP_TO_EDGE);let s=i?a.encode(i,e*n):null;return p.texImage2D(p.TEXTURE_2D,0,a.internalFormat,e,n,0,a.format,a.textureType,s),this.checkError(),o}updateTexture(e,n,a,i,p){let o=this.gl;o.bindTexture(o.TEXTURE_2D,e);let s=i.encode(p,n*a);o.texSubImage2D(o.TEXTURE_2D,0,0,0,n,a,i.format,i.textureType,s),this.checkError()}attachFramebuffer(e,n,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,n,a),i.scissor(0,0,n,a)}readTexture(e,n,a,i,p,o){let s=this.gl;o||(o=1),this.frameBufferBound||this.attachFramebuffer(e,n,a);let c=this.getEncoder(p,o),h=c.allocate(n*a);return s.bindTexture(s.TEXTURE_2D,e),s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,e,0),s.readPixels(0,0,n,a,s.RGBA,c.textureType,h),this.checkError(),c.decode(h,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,n){let a=this.gl;a.vertexAttribPointer(e,3,a.FLOAT,!1,20,0),a.enableVertexAttribArray(e),n!==-1&&(a.vertexAttribPointer(n,2,a.FLOAT,!1,20,12),a.enableVertexAttribArray(n)),this.checkError()}createProgram(e,n){let a=this.gl,i=a.createProgram();return a.attachShader(i,e),a.attachShader(i,n),a.linkProgram(i),i}compileShader(e,n){let a=this.gl,i=a.createShader(n);if(!i)throw new Error(`createShader() returned null with type ${n}`);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)}
1804
1804
  Shader source:
1805
- ${t}`);return i}deleteShader(t){this.gl.deleteShader(t)}bindTextureToUniform(t,r,o){let i=this.gl;i.activeTexture(i.TEXTURE0+r),this.checkError(),i.bindTexture(i.TEXTURE_2D,t),this.checkError(),i.uniform1i(o,r),this.checkError()}draw(){this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4),this.checkError()}checkError(){if(z.debug){let t=this.gl,r=t.getError(),o="";switch(r){case t.NO_ERROR:return;case t.INVALID_ENUM:o="INVALID_ENUM";break;case t.INVALID_VALUE:o="INVALID_VALUE";break;case t.INVALID_OPERATION:o="INVALID_OPERATION";break;case t.INVALID_FRAMEBUFFER_OPERATION:o="INVALID_FRAMEBUFFER_OPERATION";break;case t.OUT_OF_MEMORY:o="OUT_OF_MEMORY";break;case t.CONTEXT_LOST_WEBGL:o="CONTEXT_LOST_WEBGL";break;default:o=`Unknown WebGL Error: ${r.toString(16)}`}throw new Error(o)}}deleteTexture(t){this.gl.deleteTexture(t)}deleteProgram(t){this.gl.deleteProgram(t)}getEncoder(t,r,o=0){if(this.version===2)return new Pn(this.gl,r);switch(t){case"float":return o===1||this.isRenderFloat32Supported?new Br(this.gl,r):new Br(this.gl,r,this.textureHalfFloatExtension.HALF_FLOAT_OES);case"int":throw new Error("not implemented");case"byte":return new En(this.gl,r);default:throw new Error(`Invalid dataType: ${t}`)}}clearActiveTextures(){let t=this.gl;for(let r=0;r<this.maxTextureImageUnits;++r)t.activeTexture(t.TEXTURE0+r),t.bindTexture(t.TEXTURE_2D,null)}dispose(){if(this.disposed)return;let t=this.gl;t.bindFramebuffer(t.FRAMEBUFFER,null),t.deleteFramebuffer(this.framebuffer),t.bindBuffer(t.ARRAY_BUFFER,null),t.deleteBuffer(this.vertexbuffer),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null),t.finish(),this.disposed=!0}createDefaultGeometry(){return new Float32Array([-1,1,0,0,1,-1,-1,0,0,0,1,1,0,1,1,1,-1,0,1,0])}createVertexbuffer(){let t=this.gl,r=t.createBuffer();if(!r)throw new Error("createBuffer() returned null");let o=this.createDefaultGeometry();return t.bindBuffer(t.ARRAY_BUFFER,r),t.bufferData(t.ARRAY_BUFFER,o,t.STATIC_DRAW),this.checkError(),r}createFramebuffer(){let t=this.gl.createFramebuffer();if(!t)throw new Error("createFramebuffer returned null");return t}queryVitalParameters(){let t=this.gl;if(this.isFloatTextureAttachableToFrameBuffer=this.checkFloatTextureAttachableToFrameBuffer(),this.isRenderFloat32Supported=this.checkRenderFloat32(),this.isFloat32DownloadSupported=this.checkFloat32Download(),this.version===1&&!this.textureHalfFloatExtension&&!this.isRenderFloat32Supported)throw new Error("both float32 and float16 TextureType are not supported");this.isBlendSupported=!this.isRenderFloat32Supported||this.checkFloat32Blend(),this.maxTextureSize=t.getParameter(t.MAX_TEXTURE_SIZE),this.maxTextureImageUnits=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),this.version}getExtensions(){this.version===2?(this.colorBufferFloatExtension=this.gl.getExtension("EXT_color_buffer_float"),this.disjointTimerQueryWebgl2Extension=this.gl.getExtension("EXT_disjoint_timer_query_webgl2")):(this.textureFloatExtension=this.gl.getExtension("OES_texture_float"),this.textureHalfFloatExtension=this.gl.getExtension("OES_texture_half_float"))}checkFloatTextureAttachableToFrameBuffer(){let t=this.gl,r=t.createTexture();t.bindTexture(t.TEXTURE_2D,r);let o=this.version===2?t.RGBA32F:t.RGBA;t.texImage2D(t.TEXTURE_2D,0,o,1,1,0,t.RGBA,t.FLOAT,null);let i=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,i),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,r,0);let u=t.checkFramebufferStatus(t.FRAMEBUFFER)===t.FRAMEBUFFER_COMPLETE;return t.bindTexture(t.TEXTURE_2D,null),t.bindFramebuffer(t.FRAMEBUFFER,null),t.deleteTexture(r),t.deleteFramebuffer(i),u}checkRenderFloat32(){if(this.version===2){if(!this.colorBufferFloatExtension)return!1}else if(!this.textureFloatExtension)return!1;return this.isFloatTextureAttachableToFrameBuffer}checkFloat32Download(){if(this.version===2){if(!this.colorBufferFloatExtension)return!1}else if(!this.textureFloatExtension||!this.gl.getExtension("WEBGL_color_buffer_float"))return!1;return this.isFloatTextureAttachableToFrameBuffer}checkFloat32Blend(){let t=this.gl,r,o,i,u,n;try{r=t.createTexture(),o=t.createFramebuffer(),t.bindTexture(t.TEXTURE_2D,r);let a=this.version===2?t.RGBA32F:t.RGBA;return t.texImage2D(t.TEXTURE_2D,0,a,1,1,0,t.RGBA,t.FLOAT,null),t.bindFramebuffer(t.FRAMEBUFFER,o),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,r,0),t.enable(t.BLEND),i=t.createShader(t.VERTEX_SHADER),!i||(t.shaderSource(i,"void main(){}"),t.compileShader(i),u=t.createShader(t.FRAGMENT_SHADER),!u)||(t.shaderSource(u,"precision highp float;void main(){gl_FragColor=vec4(0.5);}"),t.compileShader(u),n=t.createProgram(),!n)?!1:(t.attachShader(n,i),t.attachShader(n,u),t.linkProgram(n),t.useProgram(n),t.drawArrays(t.POINTS,0,1),t.getError()===t.NO_ERROR)}finally{t.disable(t.BLEND),n&&t.deleteProgram(n),i&&t.deleteShader(i),u&&t.deleteShader(u),o&&(t.bindFramebuffer(t.FRAMEBUFFER,null),t.deleteFramebuffer(o)),r&&(t.bindTexture(t.TEXTURE_2D,null),t.deleteTexture(r))}}beginTimer(){if(this.version===2&&this.disjointTimerQueryWebgl2Extension){let t=this.gl,r=this.disjointTimerQueryWebgl2Extension,o=t.createQuery();return t.beginQuery(r.TIME_ELAPSED_EXT,o),o}else throw new Error("WebGL1 profiling currently not supported.")}endTimer(){if(this.version===2&&this.disjointTimerQueryWebgl2Extension){let t=this.gl,r=this.disjointTimerQueryWebgl2Extension;t.endQuery(r.TIME_ELAPSED_EXT);return}else throw new Error("WebGL1 profiling currently not supported")}isTimerResultAvailable(t){let r=!1,o=!1;if(this.version===2&&this.disjointTimerQueryWebgl2Extension){let i=this.gl,u=this.disjointTimerQueryWebgl2Extension;r=i.getQueryParameter(t,i.QUERY_RESULT_AVAILABLE),o=i.getParameter(u.GPU_DISJOINT_EXT)}else throw new Error("WebGL1 profiling currently not supported");return r&&!o}getTimerResult(t){let r=0;if(this.version===2){let o=this.gl;r=o.getQueryParameter(t,o.QUERY_RESULT),o.deleteQuery(t)}else throw new Error("WebGL1 profiling currently not supported");return r/1e6}async waitForQueryAndGetTime(t){return await li(()=>this.isTimerResultAvailable(t)),this.getTimerResult(t)}async createAndWaitForFence(){let t=this.createFence(this.gl);return this.pollFence(t)}createFence(t){let r,o=t,i=o.fenceSync(o.SYNC_GPU_COMMANDS_COMPLETE,0);return t.flush(),i===null?r=()=>!0:r=()=>{let u=o.clientWaitSync(i,0,0);return u===o.ALREADY_SIGNALED||u===o.CONDITION_SATISFIED},{query:i,isFencePassed:r}}async pollFence(t){return new Promise(r=>{this.addItemToPoll(()=>t.isFencePassed(),()=>r())})}pollItems(){let t=bg(this.itemsToPoll.map(r=>r.isDoneFn));for(let r=0;r<=t;++r){let{resolveFn:o}=this.itemsToPoll[r];o()}this.itemsToPoll=this.itemsToPoll.slice(t+1)}async addItemToPoll(t,r){this.itemsToPoll.push({isDoneFn:t,resolveFn:r}),!(this.itemsToPoll.length>1)&&await li(()=>(this.pollItems(),this.itemsToPoll.length===0))}}});function Gi(t){let r;if((!t||t==="webgl2")&&"webgl2"in mr?r=mr.webgl2:(!t||t==="webgl")&&"webgl"in mr&&(r=mr.webgl),!r)try{let i=yg();r=vp(i,t)}catch{let i=gg();r=vp(i,t)}t=t||r.version===1?"webgl":"webgl2";let o=r.gl;return mr[t]=r,o.isContextLost()?(delete mr[t],Gi(t)):(o.disable(o.DEPTH_TEST),o.disable(o.STENCIL_TEST),o.disable(o.BLEND),o.disable(o.DITHER),o.disable(o.POLYGON_OFFSET_FILL),o.disable(o.SAMPLE_COVERAGE),o.enable(o.SCISSOR_TEST),o.enable(o.CULL_FACE),o.cullFace(o.BACK),r)}function vp(t,r){let o={alpha:!1,depth:!1,antialias:!1,stencil:!1,preserveDrawingBuffer:!1,premultipliedAlpha:!1,failIfMajorPerformanceCaveat:!1},i,u=o;if((!r||r==="webgl2")&&(i=t.getContext("webgl2",u),i))try{return new Mr(i,2)}catch(n){tt.warning("GlContextFactory",`failed to create WebGLContext using contextId 'webgl2'. Error: ${n}`)}if((!r||r==="webgl")&&(i=t.getContext("webgl",u)||t.getContext("experimental-webgl",u),i))try{return new Mr(i,1)}catch(n){tt.warning("GlContextFactory",`failed to create WebGLContext using contextId 'webgl' or 'experimental-webgl'. Error: ${n}`)}throw new Error("WebGL is not supported")}function gg(){if(typeof document>"u")throw new TypeError("failed to create canvas: document is not supported");let t=document.createElement("canvas");return t.width=1,t.height=1,t}function yg(){if(typeof OffscreenCanvas>"u")throw new TypeError("failed to create offscreen canvas: OffscreenCanvas is not supported");return new OffscreenCanvas(1,1)}var mr,Ip=O(()=>{Ut(),wp(),mr={}}),Yn,_p=O(()=>{Yt(),Ut(),Tp(),Ip(),Yn=class{get contextId(){return z.webgl.contextId}set contextId(t){z.webgl.contextId=t}get matmulMaxBatchSize(){return z.webgl.matmulMaxBatchSize}set matmulMaxBatchSize(t){z.webgl.matmulMaxBatchSize=t}get textureCacheMode(){return z.webgl.textureCacheMode}set textureCacheMode(t){z.webgl.textureCacheMode=t}get pack(){return z.webgl.pack}set pack(t){z.webgl.pack=t}get async(){return z.webgl.async}set async(t){z.webgl.async=t}initialize(){try{return this.glContext=Gi(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),tt.setWithEnv(z),z.webgl.context||Object.defineProperty(z.webgl,"context",{value:this.glContext.gl}),tt.verbose("WebGLBackend",`Created WebGLContext: ${typeof this.glContext} with matmulMaxBatchSize: ${this.matmulMaxBatchSize}; textureCacheMode: ${this.textureCacheMode}; pack: ${this.pack}; async: ${this.async}.`),!0}catch(t){return tt.warning("WebGLBackend",`Unable to initialize WebGLBackend. ${t}`),!1}}createSessionHandler(t){return new Jn(this,t)}dispose(){this.glContext.dispose()}}});async function Mi(t){if(t){let r=typeof t=="string"?[t]:t;for(let o of r){let i=Op.get(o);if(i)return i;let u=await Tg(o);if(u)return u}}else return Mi(["webgl"]);throw new Error("no available backend to use")}async function Tg(t){let r=xg;if(typeof r[t]<"u"&&wg(r[t])){let o=r[t],i=o.initialize();if(typeof i=="object"&&"then"in i&&(i=await i),i)return Op.set(t,o),o}}function wg(t){let r=t;return"initialize"in r&&typeof r.initialize=="function"&&"createSessionHandler"in r&&typeof r.createSessionHandler=="function"&&"dispose"in r&&typeof r.dispose=="function"}var Op,xg,Sp=O(()=>{_p(),Op=new Map,xg={webgl:new Yn}}),Ui,Zn,Ap=O(()=>{Ut(),Ui=class{constructor(t,r){this.op=t,this.node=r}},Zn=class{constructor(t,r,o){this.graph=t,this.profiler=o,this.initialize(r)}initialize(t){this.profiler.event("session","ExecutionPlan.initialize",()=>{let r=this.graph.getNodes();if(r.length!==t.length)throw new Error("The size of nodes and OPs do not match.");this._ops=t.map((o,i)=>new Ui(o,r[i])),this.reset(),this._starter=[],this._ops.forEach((o,i)=>{let u=!0;for(let n of o.node.inputs)if(!this._values[n]&&this.graph.getInputIndices().indexOf(n)===-1){u=!1;break}u&&this._starter.push(i)})})}reset(){this._values=this.graph.getValues().map(t=>t.tensor)}async execute(t,r){return this.profiler.event("session","ExecutionPlan.execute",async()=>{this.reset();let o=t.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((e,l)=>{let s=i[l];this._values[s]=e});let u=this._starter.slice(0),n=this.graph.getValues(),a=this.graph.getNodes(),d=0;for(;d<u.length;){let e=u[d++],l=this._ops[e],s=l.node.inputs.map(v=>this._values[v]);if(s.indexOf(void 0)!==-1)throw new Error(`unresolved input detected: op: ${l.node}`);let h=s;tt.verbose("ExecPlan",`Running op:${l.node.name} (${h.map((v,_)=>`'${l.node.inputs[_]}': ${v.type}[${v.dims.join(",")}]`).join(", ")})`);let f=await this.profiler.event("node",l.node.name,async()=>l.op.impl(o,h,l.op.context));if(f.length!==l.node.outputs.length)throw new Error("the size of output does not match model definition.");f.forEach((v,_)=>{let I=l.node.outputs[_];if(this._values[I])throw new Error(`output [${I}] already has value: op:${l.node.name}`);this._values[I]=v});let m=new Set;f.forEach((v,_)=>{let I=l.node.outputs[_];for(let T of n[I].to){let P=a[T],C=!0;for(let V of P.inputs)if(!this._values[V]){C=!1;break}C&&m.add(T)}}),u.push(...m)}let c=[];for(let e=0;e<this.graph.getOutputIndices().length;e++){let l=this.graph.getOutputIndices()[e],s=this._values[l];if(s===void 0)throw new Error(`required output [${l}] does not have value`);l===0?await s.getData():s.data,c.push(s)}return tt.verbose("ExecPlan","disposing of inferenceHandler"),o.dispose(),c})}}}),q,Xt,Ur,Pp=O(()=>{Pr(),q=rr(sr()),We(),Y(),Xt=F.experimental.fbs,Ur=class Ae{constructor(r){if(this._attributes=new Map,r!=null){for(let o of r)o instanceof q.onnx.AttributeProto?this._attributes.set(o.name,[Ae.getValue(o),Ae.getType(o)]):o instanceof Xt.Attribute&&this._attributes.set(o.name(),[Ae.getValue(o),Ae.getType(o)]);if(this._attributes.size<r.length)throw new Error("duplicated attribute names")}}set(r,o,i){this._attributes.set(r,[i,o])}delete(r){this._attributes.delete(r)}getFloat(r,o){return this.get(r,"float",o)}getInt(r,o){return this.get(r,"int",o)}getString(r,o){return this.get(r,"string",o)}getTensor(r,o){return this.get(r,"tensor",o)}getFloats(r,o){return this.get(r,"floats",o)}getInts(r,o){return this.get(r,"ints",o)}getStrings(r,o){return this.get(r,"strings",o)}getTensors(r,o){return this.get(r,"tensors",o)}get(r,o,i){let u=this._attributes.get(r);if(u===void 0){if(i!==void 0)return i;throw new Error(`required attribute not found: ${r}`)}if(u[1]!==o)throw new Error(`type mismatch: expected ${o} but got ${u[1]}`);return u[0]}static getType(r){let o=r instanceof q.onnx.AttributeProto?r.type:r.type();switch(o){case q.onnx.AttributeProto.AttributeType.FLOAT:return"float";case q.onnx.AttributeProto.AttributeType.INT:return"int";case q.onnx.AttributeProto.AttributeType.STRING:return"string";case q.onnx.AttributeProto.AttributeType.TENSOR:return"tensor";case q.onnx.AttributeProto.AttributeType.FLOATS:return"floats";case q.onnx.AttributeProto.AttributeType.INTS:return"ints";case q.onnx.AttributeProto.AttributeType.STRINGS:return"strings";case q.onnx.AttributeProto.AttributeType.TENSORS:return"tensors";default:throw new Error(`attribute type is not supported yet: ${q.onnx.AttributeProto.AttributeType[o]}`)}}static getValue(r){let o=r instanceof q.onnx.AttributeProto?r.type:r.type();if(o===q.onnx.AttributeProto.AttributeType.GRAPH||o===q.onnx.AttributeProto.AttributeType.GRAPHS)throw new Error("graph attribute is not supported yet");let i=this.getValueNoCheck(r);if(o===q.onnx.AttributeProto.AttributeType.INT&&Rt.isLong(i))return Rt.longToNumber(i);if(o===q.onnx.AttributeProto.AttributeType.INTS){let u=i,n=new Array(u.length);for(let a=0;a<u.length;a++){let d=u[a];n[a]=Rt.longToNumber(d)}return n}if(o===q.onnx.AttributeProto.AttributeType.TENSOR)return r instanceof q.onnx.AttributeProto?bt.fromProto(i):bt.fromOrtTensor(i);if(o===q.onnx.AttributeProto.AttributeType.TENSORS){if(r instanceof q.onnx.AttributeProto)return i.map(u=>bt.fromProto(u));if(r instanceof Xt.Attribute)return i.map(u=>bt.fromOrtTensor(u))}return o===q.onnx.AttributeProto.AttributeType.STRING&&r instanceof q.onnx.AttributeProto?kr(i):o===q.onnx.AttributeProto.AttributeType.STRINGS&&r instanceof q.onnx.AttributeProto?i.map(kr):i}static getValueNoCheck(r){return r instanceof q.onnx.AttributeProto?this.getValueNoCheckFromOnnxFormat(r):this.getValueNoCheckFromOrtFormat(r)}static getValueNoCheckFromOnnxFormat(r){switch(r.type){case q.onnx.AttributeProto.AttributeType.FLOAT:return r.f;case q.onnx.AttributeProto.AttributeType.INT:return r.i;case q.onnx.AttributeProto.AttributeType.STRING:return r.s;case q.onnx.AttributeProto.AttributeType.TENSOR:return r.t;case q.onnx.AttributeProto.AttributeType.GRAPH:return r.g;case q.onnx.AttributeProto.AttributeType.FLOATS:return r.floats;case q.onnx.AttributeProto.AttributeType.INTS:return r.ints;case q.onnx.AttributeProto.AttributeType.STRINGS:return r.strings;case q.onnx.AttributeProto.AttributeType.TENSORS:return r.tensors;case q.onnx.AttributeProto.AttributeType.GRAPHS:return r.graphs;default:throw new Error(`unsupported attribute type: ${q.onnx.AttributeProto.AttributeType[r.type]}`)}}static getValueNoCheckFromOrtFormat(r){switch(r.type()){case Xt.AttributeType.FLOAT:return r.f();case Xt.AttributeType.INT:return r.i();case Xt.AttributeType.STRING:return r.s();case Xt.AttributeType.TENSOR:return r.t();case Xt.AttributeType.GRAPH:return r.g();case Xt.AttributeType.FLOATS:return r.floatsArray();case Xt.AttributeType.INTS:{let o=[];for(let i=0;i<r.intsLength();i++)o.push(r.ints(i));return o}case Xt.AttributeType.STRINGS:{let o=[];for(let i=0;i<r.stringsLength();i++)o.push(r.strings(i));return o}case Xt.AttributeType.TENSORS:{let o=[];for(let i=0;i<r.tensorsLength();i++)o.push(r.tensors(i));return o}default:throw new Error(`unsupported attribute type: ${Xt.AttributeType[r.type()]}`)}}}}),zi,Qn,Wi,me,to,Vi,Ep=O(()=>{Pp(),Pr(),zi=rr(sr()),We(),Y(),Qn=F.experimental.fbs,Wi={from:(t,r)=>new Vi(t,r)},me=class{constructor(t){this._from=void 0,this._to=[],this.tensor=void 0,this.type=void 0,t&&(this.type=At.tensorValueTypeFromProto(t.type.tensorType))}get from(){return this._from}get to(){return this._to}},to=class{constructor(t,r){t instanceof zi.onnx.NodeProto?(this.name=t.name,this.opType=t.opType,this.attributes=new Ur(t.attribute)):t instanceof Qn.Node&&(this.name=r??t.name(),this.opType=t.opType(),this.attributes=new Ur(At.tensorAttributesFromORTFormat(t))),this.inputs=[],this.outputs=[],this.executeNode=!0}},Vi=class{constructor(t,r){if(!t)throw new TypeError("graph is empty");this.buildGraph(t),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(t){if(t instanceof zi.onnx.GraphProto)this.buildGraphFromOnnxFormat(t);else if(t instanceof Qn.Graph)this.buildGraphFromOrtFormat(t);else throw new TypeError("Graph type is not supported.")}buildGraphFromOnnxFormat(t){let r=new Map;this._allData=[],this._allInputIndices=[],this._allInputNames=[],this._allOutputIndices=[],this._allOutputNames=[],this._nodes=[];let o=new Map;if(!t.input)throw new Error("missing information in graph: input");let i=[];for(let u of t.input){if(r.has(u.name))throw new Error(`duplicated input name: ${u.name}`);let n=this._allData.push(new me(u))-1;r.set(u.name,n),i.push(u.name)}if(!t.initializer)throw new Error("missing information in graph: initializer");for(let u of t.initializer){let n=r.get(u.name);if(n===void 0){let a=new me;a.type={shape:{dims:At.tensorDimsFromProto(u.dims)},tensorType:At.tensorDataTypeFromProto(u.dataType)},n=this._allData.push(a)-1,r.set(u.name,n)}this._allData[n]._from=-1,this._allData[n].tensor=bt.fromProto(u)}for(let u=0;u<this._allData.length;u++)this._allData[u].tensor||(this._allInputIndices.push(u),this._allInputNames.push(i[u]));if(!t.output)throw new Error("missing information in graph: output");for(let u of t.output){if(r.has(u.name))throw new Error(`duplicated output name: ${u.name}`);let n=this._allData.push(new me(u))-1;r.set(u.name,n),this._allOutputIndices.push(n),this._allOutputNames.push(u.name)}if(!t.node)throw new Error("missing information in graph: node");for(let u of t.node){if(!u.name)for(let a=0;;a++){let d=`unnamed_${u.opType}_${a}`;if(!o.has(d)){u.name=d;break}}if(o.has(u.name))throw new Error(`duplicated node name: ${u.name}`);let n=this._nodes.push(new to(u))-1;o.set(u.name,n)}for(let u=0;u<this._nodes.length;u++){let n=this._nodes[u],a=t.node[u];if(!a.output)throw new Error(`missing output for node: ${a.name}`);for(let d of a.output){let c=r.get(d);if(typeof c>"u"&&(c=this._allData.push(new me)-1,r.set(d,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=u,a.opType==="Constant"){if(!a.attribute||a.attribute.length!==1||!a.attribute[0].t)throw new Error("missing attributes or missing tensor value in attributes for this Constant operator");if(!a.output||a.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=bt.fromProto(a.attribute[0].t)}}}for(let u=0;u<this._nodes.length;u++){let n=this._nodes[u],a=t.node[u];if(!a.input)throw new Error(`missing input for node: ${a.name}`);for(let d of a.input){let c=r.get(d);if(typeof c>"u"){if(d===""&&(a.input.length===3||a.input.length===4)&&a.opType==="Resize")continue;throw new Error(`unrecognized input '${d}' for node: ${a.name}`)}n.inputs.push(c),this._allData[c]._to.push(u)}}return!0}buildGraphFromOrtFormat(t){var u,n,a;let r=new Map;this._allData=[],this._allInputIndices=[],this._allInputNames=[],this._allOutputIndices=[],this._allOutputNames=[],this._nodes=[];let o=new Map,i=[];for(let d=0;d<t.inputsLength();d++){let c=t.inputs(d);if(r.has(c))throw new Error(`duplicated input name: ${c}`);for(let e=0;e<t.nodeArgsLength();e++)if(((u=t.nodeArgs(e))==null?void 0:u.name())===c){let l=new me;if(((a=(n=t.nodeArgs(e))==null?void 0:n.type())==null?void 0:a.valueType())!==Qn.TypeInfoValue.tensor_type)throw new Error("Unexpected value type for the nodeArg.");let s=t.nodeArgs(e).type().value(new Qn.TensorTypeAndShape),h=At.tensorDataTypeFromProto(s.elemType()),f=s.shape(),m=[];for(let _=0;_<f.dimLength();_++)m.push(Rt.longToNumber(f.dim(_).value().dimValue()));l.type={shape:{dims:m},tensorType:h};let v=this._allData.push(l)-1;r.set(c,v),i.push(c)}}for(let d=0;d<t.initializersLength();d++){let c=t.initializers(d),e=r.get(c.name());if(e===void 0){let l=new me,s=At.tensorDimsFromORTFormat(c),h=At.tensorDataTypeFromProto(c.dataType());l.type={shape:{dims:s},tensorType:h},e=this._allData.push(l)-1,r.set(c.name(),e)}this._allData[e]._from=-1,this._allData[e].tensor=bt.fromOrtTensor(c)}for(let d=0;d<this._allData.length;d++)this._allData[d].tensor||(this._allInputIndices.push(d),this._allInputNames.push(i[d]));for(let d=0;d<t.outputsLength();d++){let c=t.outputs(d);if(r.has(c))throw new Error(`duplicated output name: ${c}`);let e=this._allData.push(new me)-1;r.set(c,e),this._allOutputIndices.push(e),this._allOutputNames.push(c)}if(!t.nodes)throw new Error("missing information in graph: node");for(let d=0;d<t.nodesLength();d++){let c=t.nodes(d),e=c.name();if(!e)for(let s=0;e=`unnamed_${c.opType()}_${s}`,!!o.has(e);s++);if(o.has(e))throw new Error(`duplicated node name: ${e}`);let l=this._nodes.push(new to(c,e))-1;o.set(e,l)}for(let d=0;d<this._nodes.length;d++){let c=this._nodes[d],e=t.nodes(d);if(e==null)throw new Error(`No node exists at index ${d}`);if((e==null?void 0:e.outputsLength())===0)throw new Error(`missing output for node: ${e.name}`);for(let l=0;l<(e==null?void 0:e.outputsLength());l++){let s=e==null?void 0:e.outputs(l),h=r.get(s);if(typeof h>"u"&&(h=this._allData.push(new me)-1,r.set(s,h)),c.outputs.push(h),this._allData[h]._from!==void 0)throw new Error(`multiple nodes output to one data value: ${h}`);if(this._allData[h]._from=d,e.opType()==="Constant"){if(e.attributesLength()!==1||!e.attributes(0).t())throw new Error("missing attributes or missing tensor value in attributes for this Constant operator");if(e.outputsLength()!==1)throw new Error("missing output or incorrect number of outputs for this Constant operator");c.outputs.pop(),c.executeNode=!1,this._allData[h]._from=-1,this._allData[h].tensor=bt.fromOrtTensor(e.attributes(0).t())}}}for(let d=0;d<this._nodes.length;d++){let c=this._nodes[d],e=t.nodes(d);if(e.inputsLength()===0)throw new Error(`missing input for node: ${e.name}`);for(let l=0;l<e.inputsLength();l++){let s=e.inputs(l),h=r.get(s);if(typeof h>"u")throw new Error(`unrecognized input '${s}' for node: ${e.name()}`);c.inputs.push(h),this._allData[h]._to.push(d)}}}checkIsAcyclic(){let t=new Set;this._allInputIndices.forEach(i=>{this._allData[i]._to.forEach(u=>{t.add(u)})});let r=Array.from(t),o=new Array(this._nodes.length).fill("white");for(;r.length>0;){let i=r.pop();o[i]==="gray"?o[i]="black":(r.push(i),o[i]="gray",this._nodes[i].outputs.forEach(u=>{let n=this._allData[u];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(a=>{if(o[a]==="gray")throw new Error("model graph is cyclic");o[a]==="white"&&r.push(a)})}))}}transformGraph(t){this.removeAllIdentityNodes(),this.removeAllDropoutNodes(),this.fuseConvActivationNodes(),t&&t.transformGraph(this),this.finalizeGraph()}finalizeGraph(){let t=0,r=new Array(this._nodes.length,0),o=0;for(let i=0;i<this._nodes.length;i++)r[i]=o,this._nodes[i].executeNode?(o!==i&&(this._nodes[o]=this._nodes[i]),o++):this._nodes[i].outputs.forEach(u=>{this._allData[u]._from=-2});this._nodes.splice(o,this._nodes.length-o);for(let i=0;i<this._allData.length;i++){let u=this._allData[i];u._from!==void 0&&u._from!==-1&&u._from!==-2&&(u._from=r[u._from]);for(let n=0;n<u._to.length;n++)if(u._to[n]>=0)u._to[n]=r[u._to[n]];else throw new Error("Trying to update a removed node")}t=0;for(let i=0;i<this._allData.length;i++){if(this._allData[i].from===-2&&this._allOutputIndices.indexOf(i+t)===-1){t++,this._allData.splice(i,1),i--;continue}if(t>0){let u=-1;this._allData[i].from!==void 0&&this._allData[i].from!==-1?(u=this._nodes[this._allData[i].from].outputs.indexOf(i+t),u!==-1&&(this._nodes[this._allData[i].from].outputs[u]=i)):(u=this._allInputIndices.indexOf(i+t),u!==-1&&(this._allInputIndices[u]=i)),this._allData[i].to.forEach(n=>{u=this._nodes[n].inputs.indexOf(i+t),u!==-1&&(this._nodes[n].inputs[u]=i)}),this._allData[i].to.length===0&&(u=this._allOutputIndices.indexOf(i+t),u!==-1&&(this._allOutputIndices[u]=i))}}}deleteNode(t){let r=this._nodes[t];if(r.outputs.length>1){for(let a=1;a<r.outputs.length;a++)if(this._allData[r.outputs[a]].to.length>0)throw new Error("Node deletion with more than one output connected to other nodes is not supported. ")}r.executeNode=!1;let o=r.inputs[0],i=r.outputs[0],u=this._allData[i].to;for(let a=0;a<r.inputs.length;a++){let d=this._allData[r.inputs[a]].to.indexOf(t);if(d===-1)throw new Error("The Value object doesn't have the current Node in it's 'to' property ");this._allData[r.inputs[a]].to.splice(d,1)}this._allData[i]._to=[];let n=this._allOutputIndices.indexOf(i);if(n!==-1&&(this._allOutputIndices[n]=o),u&&u.length>0)for(let a of u){let d=this._nodes[a].inputs.indexOf(i);if(d===-1)throw new Error("The Node object doesn't have the output Value in it's 'inputs' property ");this._nodes[a].inputs[d]=o,this._allData[o].to.push(a)}}removeAllDropoutNodes(){let t=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(t)}t++}}removeAllIdentityNodes(){let t=0;for(let r of this._nodes)r.opType==="Identity"&&this.deleteNode(t),t++}isActivation(t){switch(t.opType){case"Relu":case"Sigmoid":case"Clip":return!0;default:return!1}}fuseConvActivationNodes(){for(let t of this._nodes)if(t.opType==="Conv"){let r=this._allData[t.outputs[0]]._to;if(r.length===1&&this.isActivation(this._nodes[r[0]])){let o=this._nodes[r[0]];if(o.opType==="Clip")if(o.inputs.length===1)try{t.attributes.set("activation_params","floats",[o.attributes.getFloat("min"),o.attributes.getFloat("max")])}catch{t.attributes.set("activation_params","floats",[Ve,ze])}else if(o.inputs.length>=3&&this._allData[o.inputs[1]].tensor!==void 0&&this._allData[o.inputs[2]].tensor!==void 0)t.attributes.set("activation_params","floats",[this._allData[o.inputs[1]].tensor.floatData[0],this._allData[o.inputs[2]].tensor.floatData[0]]);else continue;t.attributes.set("activation","string",o.opType),this.deleteNode(r[0])}}}}}),Dp,vg,eo,Lp=O(()=>{wn(),Ep(),Pr(),Dp=rr(sr()),Y(),vg=F.experimental.fbs,eo=class{constructor(){}load(t,r,o){let i;if(!o)try{this.loadFromOnnxFormat(t,r);return}catch(u){if(o!==void 0)throw u;i=u}try{this.loadFromOrtFormat(t,r)}catch(u){throw o!==void 0?u:new Error(`Failed to load model as ONNX format: ${i}
1806
- as ORT format: ${u}`)}}loadFromOnnxFormat(t,r){let o=Dp.onnx.ModelProto.decode(t);if(Rt.longToNumber(o.irVersion)<3)throw new Error("only support ONNX model with IR_VERSION>=3");this._opsets=o.opsetImport.map(i=>({domain:i.domain,version:Rt.longToNumber(i.version)})),this._graph=Wi.from(o.graph,r)}loadFromOrtFormat(t,r){let o=new w.ByteBuffer(t),i=vg.InferenceSession.getRootAsInferenceSession(o).model();if(Rt.longToNumber(i.irVersion())<3)throw new Error("only support ONNX model with IR_VERSION>=3");this._opsets=[];for(let u=0;u<i.opsetImportLength();u++){let n=i.opsetImport(u);this._opsets.push({domain:n==null?void 0:n.domain(),version:Rt.longToNumber(n.version())})}this._graph=Wi.from(i.graph(),r)}get graph(){return this._graph}get opsets(){return this._opsets}}}),ro,$p=O(()=>{Sp(),Ap(),Ut(),Lp(),ro=class{constructor(t={}){this._initialized=!1,this.backendHint=t.backendHint,this.profiler=xn.create(t.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(t,r,o){await this.profiler.event("session","Session.loadModel",async()=>{let i=await Mi(this.backendHint);if(this.sessionHandler=i.createSessionHandler(this.context),this._model=new eo,typeof t=="string"){let u=t.endsWith(".ort");{let n=await(await fetch(t)).arrayBuffer();this.initialize(new Uint8Array(n),u)}}else if(ArrayBuffer.isView(t))this.initialize(t);else{let u=new Uint8Array(t,r||0,o||t.byteLength);this.initialize(u)}})}initialize(t,r){if(this._initialized)throw new Error("already initialized");this.profiler.event("session","Session.initialize",()=>{let o=this.sessionHandler.transformGraph?this.sessionHandler:void 0;this._model.load(t,o,r),this.sessionHandler.onGraphInitialized&&this.sessionHandler.onGraphInitialized(this._model.graph),this.initializeOps(this._model.graph),this._executionPlan=new Zn(this._model.graph,this._ops,this.profiler)}),this._initialized=!0}async run(t){if(!this._initialized)throw new Error("session not initialized yet");return this.profiler.event("session","Session.run",async()=>{let r=this.normalizeAndValidateInputs(t),o=await this._executionPlan.execute(this.sessionHandler,r);return this.createOutput(o)})}normalizeAndValidateInputs(t){let r=this._model.graph.getInputNames();if(Array.isArray(t)){if(t.length!==r.length)throw new Error(`incorrect input array length: expected ${r.length} but got ${t.length}`)}else{if(t.size!==r.length)throw new Error(`incorrect input map size: expected ${r.length} but got ${t.size}`);let o=new Array(t.size),i=0;for(let u=0;u<r.length;++u){let n=t.get(r[u]);if(!n)throw new Error(`missing input tensor for: '${name}'`);o[i++]=n}t=o}if(!this.context.graphInputTypes||this.context.graphInputTypes.length===0||!this.context.graphInputDims||this.context.graphInputDims.length===0){let o=this._model.graph.getInputIndices(),i=this._model.graph.getValues(),u=new Array(o.length);for(let n=0;n<o.length;++n){let a=i[o[n]];u[n]=a.type.shape.dims,this.context.graphInputTypes.push(a.type.tensorType),this.context.graphInputDims.push(t[n].dims)}this.validateInputTensorDims(u,t,!0)}else this.validateInputTensorDims(this.context.graphInputDims,t,!1);return this.validateInputTensorTypes(this.context.graphInputTypes,t),t}validateInputTensorTypes(t,r){for(let o=0;o<r.length;o++){let i=t[o],u=r[o].type;if(i!==u)throw new Error(`input tensor[${o}] check failed: expected type '${i}' but got ${u}`)}}validateInputTensorDims(t,r,o){for(let i=0;i<r.length;i++){let u=t[i],n=r[i].dims;if(!this.compareTensorDims(u,n,o))throw new Error(`input tensor[${i}] check failed: expected shape '[${u.join(",")}]' but got [${n.join(",")}]`)}}compareTensorDims(t,r,o){if(t.length!==r.length)return!1;for(let i=0;i<t.length;++i)if(t[i]!==r[i]&&(!o||t[i]!==0))return!1;return!0}createOutput(t){let r=this._model.graph.getOutputNames();if(t.length!==r.length)throw new Error("expected number of outputs do not match number of generated outputs");let o=new Map;for(let i=0;i<r.length;++i)o.set(r[i],t[i]);return o}initializeOps(t){let r=t.getNodes();this._ops=new Array(r.length);for(let o=0;o<r.length;o++)this._ops[o]=this.sessionHandler.resolve(r[o],this._model.opsets,t)}}}),no,kp=O(()=>{Yt(),We(),no=class{constructor(t){this.session=t,this.inputNames=this.session.inputNames,this.outputNames=this.session.outputNames}async dispose(){}async run(t,r,o){let i=new Map;for(let a in t)if(Object.hasOwnProperty.call(t,a)){let d=t[a];i.set(a,new bt(d.dims,d.type,void 0,void 0,d.data))}let u=await this.session.run(i),n={};return u.forEach((a,d)=>{n[d]=new yt(a.type,a.data,a.dims)}),n}startProfiling(){this.session.startProfiling()}endProfiling(){this.session.endProfiling()}}}),Bp={};Or(Bp,{onnxjsBackend:()=>Ig});var Hi,Ig,Fp=O(()=>{$p(),kp(),Hi=class{async init(){}async createInferenceSessionHandler(t,r){let o=new ro(r);return typeof t=="string"?await o.loadModel(t):await o.loadModel(t),new no(o)}},Ig=new Hi}),oo=O(()=>{}),Rp={};Or(Rp,{default:()=>_g});var Cp,Np,_g,Gp=O(()=>{var t;qi(),Ke(),Vr(),Cp="ort-wasm-proxy-worker",Np=((t=globalThis.self)==null?void 0:t.name)===Cp,Np&&(self.onmessage=r=>{let{type:o,in:i}=r.data;try{switch(o){case"init-wasm":io(i.wasm).then(()=>{ao(i).then(()=>{postMessage({type:o})},u=>{postMessage({type:o,err:u})})},u=>{postMessage({type:o,err:u})});break;case"init-ep":{let{epName:u,env:n}=i;so(n,u).then(()=>{postMessage({type:o})},a=>{postMessage({type:o,err:a})});break}case"copy-from":{let{buffer:u}=i,n=zr(u);postMessage({type:o,out:n});break}case"create":{let{model:u,options:n}=i;uo(u,n).then(a=>{postMessage({type:o,out:a})},a=>{postMessage({type:o,err:a})});break}case"release":lo(i),postMessage({type:o});break;case"run":{let{sessionId:u,inputIndices:n,inputs:a,outputIndices:d,options:c}=i;fo(u,n,a,d,new Array(d.length).fill(null),c).then(e=>{e.some(l=>l[3]!=="cpu")?postMessage({type:o,err:"Proxy does not support non-cpu tensor location."}):postMessage({type:o,out:e},po([...a,...e]))},e=>{postMessage({type:o,err:e})});break}case"end-profiling":co(i),postMessage({type:o});break;default:}}catch(u){postMessage({type:o,err:u})}}),_g=Np?null:r=>new Worker(r??br,{type:"module",name:Cp})}),Up={};Or(Up,{default:()=>Og});var ji,Mp,Og,Vp=O(()=>{var t;Mp=(ji=_documentCurrentScript&&_documentCurrentScript.tagName.toUpperCase()==="SCRIPT"&&_documentCurrentScript.src||new URL("segmentation.js",document.baseURI).href,async function(r={}){function o(){return wt.buffer!=vt.buffer&&st(),vt}function i(){return wt.buffer!=vt.buffer&&st(),K}function u(){return wt.buffer!=vt.buffer&&st(),Jt}function n(){return wt.buffer!=vt.buffer&&st(),Re}function a(){return wt.buffer!=vt.buffer&&st(),le}var d,c,e=Object.assign({},r),l=new Promise((g,y)=>{d=g,c=y}),s=typeof window=="object",h=typeof importScripts=="function",f=h&&self.name=="em-pthread";e.mountExternalData=(g,y)=>{g.startsWith("./")&&(g=g.substring(2)),(e.Ua||(e.Ua=new Map)).set(g,y)},e.unmountExternalData=()=>{delete e.Ua};var m,v,_=globalThis.SharedArrayBuffer??new WebAssembly.Memory({initial:0,maximum:0,shared:!0}).buffer.constructor,I=Object.assign({},e),T="./this.program",P=(g,y)=>{throw y},C="";(s||h)&&(h?C=self.location.href:typeof document<"u"&&document.currentScript&&(C=document.currentScript.src),ji&&(C=ji),C=C.startsWith("blob:")?"":C.substr(0,C.replace(/[?#].*/,"").lastIndexOf("/")+1),h&&(v=g=>{var y=new XMLHttpRequest;return y.open("GET",g,!1),y.responseType="arraybuffer",y.send(null),new Uint8Array(y.response)}),m=(g,y,x)=>{var S=new XMLHttpRequest;S.open("GET",g,!0),S.responseType="arraybuffer",S.onload=()=>{S.status==200||S.status==0&&S.response?y(S.response):x()},S.onerror=x,S.send(null)});var V,gt=console.log.bind(console),pt=console.error.bind(console),Ft=gt,et=pt;if(Object.assign(e,I),I=null,f){let g=function(y){try{var x=y.data,S=x.cmd;if(S==="load"){let E=[];self.onmessage=N=>E.push(N),self.startWorker=()=>{postMessage({cmd:"loaded"});for(let N of E)g(N);self.onmessage=g};for(let N of x.handlers)e[N]&&!e[N].proxy||(e[N]=(...L)=>{postMessage({Za:"callHandler",kb:N,args:L})},N=="print"&&(Ft=e[N]),N=="printErr"&&(et=e[N]));wt=x.wasmMemory,st(),$t(x.wasmModule)}else if(S==="run"){Qr(x.pthread_ptr,0,0,1,0,0),Lr(x.pthread_ptr),$a(),So(),De||(De=!0);try{Aa(x.start_routine,x.arg)}catch(E){if(E!="unwind")throw E}}else S==="cancel"?ce()&&gr(-1):x.target!=="setimmediate"&&(S==="checkMailbox"?De&&tr():S&&(et(`worker: received unknown command ${S}`),et(x)))}catch(E){throw ba(),E}};var $t,De=!1;et=function(...y){y=y.join(" "),console.error(y)},self.alert=function(...y){postMessage({Za:"alert",text:y.join(" "),nb:ce()})},e.instantiateWasm=(y,x)=>new Promise(S=>{$t=E=>{E=new WebAssembly.Instance(E,vn()),x(E),S()}}),self.onunhandledrejection=y=>{throw y.reason||y},self.onmessage=g}e.wasmBinary&&(V=e.wasmBinary);var wt,Le,Lt,vt,K,Jt,Re,Ot,le,at=!1;function st(){var g=wt.buffer;e.HEAP8=vt=new Int8Array(g),e.HEAP16=new Int16Array(g),e.HEAPU8=K=new Uint8Array(g),e.HEAPU16=new Uint16Array(g),e.HEAP32=Jt=new Int32Array(g),e.HEAPU32=Re=new Uint32Array(g),e.HEAPF32=new Float32Array(g),e.HEAPF64=le=new Float64Array(g),e.HEAP64=Ot=new BigInt64Array(g),e.HEAPU64=new BigUint64Array(g)}if(!f){if(!((wt=new WebAssembly.Memory({initial:256,maximum:65536,shared:!0})).buffer instanceof _))throw et("requested a shared WebAssembly.Memory but the returned buffer is not a SharedArrayBuffer, indicating that while the browser has SharedArrayBuffer it does not have WebAssembly threads support - you may need to set a flag"),Error("bad memory");st()}var oe=[],te=[],Ge=[],ie=0,Pt=null;function Dt(){if(--ie==0&&Pt){var g=Pt;Pt=null,g()}}function Mt(g){throw et(g="Aborted("+g+")"),at=!0,Lt=1,g=new WebAssembly.RuntimeError(g+". Build with -sASSERTIONS for more info."),c(g),g}var it,lt=g=>g.startsWith("data:application/octet-stream;base64,"),Wt=g=>g.startsWith("file://");function fe(g){if(g==it&&V)return new Uint8Array(V);if(v)return v(g);throw"both async and sync fetching of the wasm failed"}function Ye(g,y,x){return function(S){if(!V&&(s||h)){if(typeof fetch=="function"&&!Wt(S))return fetch(S,{credentials:"same-origin"}).then(E=>{if(!E.ok)throw`failed to load wasm binary file at '${S}'`;return E.arrayBuffer()}).catch(()=>fe(S));if(m)return new Promise((E,N)=>{m(S,L=>E(new Uint8Array(L)),N)})}return Promise.resolve().then(()=>fe(S))}(g).then(S=>WebAssembly.instantiate(S,y)).then(x,S=>{et(`failed to asynchronously prepare wasm: ${S}`),Mt(S)})}function vn(){return{a:{j:Pa,b:ka,E:Ao,g:Fo,V:Lo,A:zo,C:Xo,W:Ko,T:Jo,L:Yo,S:Zo,o:Qo,B:ti,y:ri,U:ni,z:ii,_:Na,Z:Fa,P:Ca,w:La,F:Ra,k:ja,O:Lr,Y:Ba,I:Va,J:za,K:Ma,G:na,H:oa,v:Ua,q:Ga,l:Ha,p:qa,e:Wa,X:Xa,x:Ka,d:ia,f:Ja,i:Ya,u:Za,t:qs,s:Xs,Q:la,R:ua,D:Dr,h:pa,n:da,M:ca,m:ha,a:wt,r:Ir,N:ma,c:Zs}}}var _n={837620:(g,y,x,S,E)=>{if(e===void 0||!e.Ua)return 1;if((g=be(g>>>0)).startsWith("./")&&(g=g.substring(2)),!(g=e.Ua.get(g)))return 2;if(S>>>=0,(y>>>=0)+(x>>>=0)>g.byteLength)return 3;try{let N=g.subarray(y,y+x);switch(E){case 0:i().set(N,S>>>0);break;case 1:e.mb(S,N);break;default:return 4}return 0}catch{return 4}},838303:()=>typeof wasmOffsetConverter<"u"};function Pa(){return typeof wasmOffsetConverter<"u"}function _r(g){this.name="ExitStatus",this.message=`Program terminated with exit(${g})`,this.status=g}var Er=g=>{g.terminate(),g.onmessage=()=>{}},On=g=>{ee.length==0&&(Io(),Eo(ee[0]));var y=ee.pop();if(!y)return 6;ae.push(y),Nt[g.Ra]=y,y.Ra=g.Ra;var x={cmd:"run",start_routine:g.cb,arg:g.ab,pthread_ptr:g.Ra};return y.postMessage(x,g.ib),0},ge=0,Q=(g,y,...x)=>{for(var S=2*x.length,E=rn(),N=en(8*S),L=N>>>3,Z=0;Z<x.length;Z++){var ct=x[Z];typeof ct=="bigint"?(Ot[L+2*Z]=1n,Ot[L+2*Z+1]=ct):(Ot[L+2*Z]=0n,a()[L+2*Z+1>>>0]=ct)}return g=ya(g,0,S,N,y),wr(E),g};function Ir(g){if(f)return Q(0,1,g);if(Lt=g,!(0<ge)){for(var y of ae)Er(y);for(y of ee)Er(y);ee=[],ae=[],Nt=[],at=!0}P(g,new _r(g))}function In(g){if(f)return Q(1,0,g);Dr(g)}var Dr=g=>{if(Lt=g,f)throw In(g),"unwind";Ir(g)},ee=[],ae=[],_o=[],Nt={},Oo=g=>{var y=g.Ra;delete Nt[y],ee.push(g),ae.splice(ae.indexOf(g),1),g.Ra=0,tn(y)};function So(){_o.forEach(g=>g())}var Eo=g=>new Promise(y=>{g.onmessage=E=>{var N=(E=E.data).cmd;if(E.targetThread&&E.targetThread!=ce()){var L=Nt[E.targetThread];L?L.postMessage(E,E.transferList):et(`Internal error! Worker sent a message "${N}" to target pthread ${E.targetThread}, but that thread no longer exists!`)}else N==="checkMailbox"?tr():N==="spawnThread"?On(E):N==="cleanupThread"?Oo(Nt[E.thread]):N==="killThread"?(E=E.thread,N=Nt[E],delete Nt[E],Er(N),tn(E),ae.splice(ae.indexOf(N),1),N.Ra=0):N==="cancelThread"?Nt[E.thread].postMessage({cmd:"cancel"}):N==="loaded"?(g.loaded=!0,y(g)):N==="alert"?alert(`Thread ${E.threadId}: ${E.text}`):E.target==="setimmediate"?g.postMessage(E):N==="callHandler"?e[E.handler](...E.args):N&&et(`worker sent an unknown command ${N}`)},g.onerror=E=>{throw et(`worker sent an error! ${E.filename}:${E.lineno}: ${E.message}`),E};var x,S=[];for(x of[])e.hasOwnProperty(x)&&S.push(x);g.postMessage({cmd:"load",handlers:S,wasmMemory:wt,wasmModule:Le})});function Io(){var g=new Worker(new URL(_documentCurrentScript&&_documentCurrentScript.tagName.toUpperCase()==="SCRIPT"&&_documentCurrentScript.src||new URL("segmentation.js",document.baseURI).href),{type:"module",workerData:"em-pthread",name:"em-pthread"});ee.push(g)}var Po,Ze=g=>{for(;0<g.length;)g.shift()(e)},$a=()=>{var g=ce(),y=n()[g+52>>>2>>>0];g=n()[g+56>>>2>>>0],va(y,y-g),wr(y)},Qe=[],Aa=(g,y)=>{ge=0;var x=Qe[g];x||(g>=Qe.length&&(Qe.length=g+1),Qe[g]=x=Po.get(g)),g=x(y),0<ge?Lt=g:gr(g)};class Da{constructor(y){this.Xa=y-24}}function ka(g,y,x){var S=new Da(g>>>=0);throw y>>>=0,x>>>=0,n()[S.Xa+16>>>2>>>0]=0,n()[S.Xa+4>>>2>>>0]=y,n()[S.Xa+8>>>2>>>0]=x,g}function $o(g,y,x,S){return f?Q(2,1,g,y,x,S):Ao(g,y,x,S)}function Ao(g,y,x,S){if(g>>>=0,y>>>=0,x>>>=0,S>>>=0,_===void 0)return et("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var E=[];return f&&E.length===0?$o(g,y,x,S):(g={cb:x,Ra:g,ab:S,ib:E},f?(g.Za="spawnThread",postMessage(g,E),0):On(g))}var Do=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,ko=(g,y,x)=>{var S=(y>>>=0)+x;for(x=y;g[x]&&!(x>=S);)++x;if(16<x-y&&g.buffer&&Do)return Do.decode(g.buffer instanceof _?g.slice(y,x):g.subarray(y,x));for(S="";y<x;){var E=g[y++];if(128&E){var N=63&g[y++];if((224&E)==192)S+=String.fromCharCode((31&E)<<6|N);else{var L=63&g[y++];65536>(E=(240&E)==224?(15&E)<<12|N<<6|L:(7&E)<<18|N<<12|L<<6|63&g[y++])?S+=String.fromCharCode(E):(E-=65536,S+=String.fromCharCode(55296|E>>10,56320|1023&E))}}else S+=String.fromCharCode(E)}return S},be=(g,y)=>(g>>>=0)?ko(i(),g,y):"";function Fo(g,y,x){return f?Q(3,1,g,y,x):0}function Lo(g,y){if(f)return Q(4,1,g,y)}var jo=g=>{for(var y=0,x=0;x<g.length;++x){var S=g.charCodeAt(x);127>=S?y++:2047>=S?y+=2:55296<=S&&57343>=S?(y+=4,++x):y+=3}return y},Bo=(g,y,x,S)=>{if(!(0<S))return 0;var E=x>>>=0;S=x+S-1;for(var N=0;N<g.length;++N){var L=g.charCodeAt(N);if(55296<=L&&57343>=L&&(L=65536+((1023&L)<<10)|1023&g.charCodeAt(++N)),127>=L){if(x>=S)break;y[x++>>>0]=L}else{if(2047>=L){if(x+1>=S)break;y[x++>>>0]=192|L>>6}else{if(65535>=L){if(x+2>=S)break;y[x++>>>0]=224|L>>12}else{if(x+3>=S)break;y[x++>>>0]=240|L>>18,y[x++>>>0]=128|L>>12&63}y[x++>>>0]=128|L>>6&63}y[x++>>>0]=128|63&L}}return y[x>>>0]=0,x-E},we=(g,y,x)=>Bo(g,i(),y,x);function zo(g,y){if(f)return Q(5,1,g,y)}function Xo(g,y,x){if(f)return Q(6,1,g,y,x)}function Ko(g,y,x){return f?Q(7,1,g,y,x):0}function Jo(g,y){if(f)return Q(8,1,g,y)}function Yo(g,y,x){if(f)return Q(9,1,g,y,x)}function Zo(g,y,x,S){if(f)return Q(10,1,g,y,x,S)}function Qo(g,y,x,S){if(f)return Q(11,1,g,y,x,S)}function ti(g,y,x,S){if(f)return Q(12,1,g,y,x,S)}function ri(g){if(f)return Q(13,1,g)}function ni(g,y){if(f)return Q(14,1,g,y)}function ii(g,y,x){if(f)return Q(15,1,g,y,x)}var Na=()=>{Mt("")},Fa=()=>1;function Ca(g){Qr(g>>>0,!h,1,!s,131072,!1),So()}function Lr(g){g>>>=0,typeof Atomics.jb=="function"&&(Atomics.jb(u(),g>>>2,g).value.then(tr),g+=128,Atomics.store(u(),g>>>2,1))}var tr=()=>{var g=ce();if(g&&(Lr(g),g=wa,!at))try{if(g(),!(0<ge))try{f?gr(Lt):Dr(Lt)}catch(y){y instanceof _r||y=="unwind"||P(1,y)}}catch(y){y instanceof _r||y=="unwind"||P(1,y)}};function La(g,y){(g>>>=0)==y>>>0?setTimeout(tr):f?postMessage({targetThread:g,cmd:"checkMailbox"}):(g=Nt[g])&&g.postMessage({cmd:"checkMailbox"})}var Kr=[];function Ra(g,y,x,S,E){for(y>>>=0,S/=2,Kr.length=S,x=E>>>0>>>3,E=0;E<S;E++)Kr[E]=Ot[x+2*E]?Ot[x+2*E+1]:a()[x+2*E+1>>>0];return(y?_n[y]:fl[g])(...Kr)}function ja(g){g>>>=0,f?postMessage({cmd:"cleanupThread",thread:g}):Oo(Nt[g])}function Ba(g){}function Va(g,y){g=-9007199254740992>g||9007199254740992<g?NaN:Number(g),y>>>=0,g=new Date(1e3*g),u()[y>>>2>>>0]=g.getUTCSeconds(),u()[y+4>>>2>>>0]=g.getUTCMinutes(),u()[y+8>>>2>>>0]=g.getUTCHours(),u()[y+12>>>2>>>0]=g.getUTCDate(),u()[y+16>>>2>>>0]=g.getUTCMonth(),u()[y+20>>>2>>>0]=g.getUTCFullYear()-1900,u()[y+24>>>2>>>0]=g.getUTCDay(),g=(g.getTime()-Date.UTC(g.getUTCFullYear(),0,1,0,0,0,0))/864e5|0,u()[y+28>>>2>>>0]=g}var ue=g=>g%4==0&&(g%100!=0||g%400==0),ea=[0,31,60,91,121,152,182,213,244,274,305,335],ra=[0,31,59,90,120,151,181,212,243,273,304,334];function za(g,y){g=-9007199254740992>g||9007199254740992<g?NaN:Number(g),y>>>=0,g=new Date(1e3*g),u()[y>>>2>>>0]=g.getSeconds(),u()[y+4>>>2>>>0]=g.getMinutes(),u()[y+8>>>2>>>0]=g.getHours(),u()[y+12>>>2>>>0]=g.getDate(),u()[y+16>>>2>>>0]=g.getMonth(),u()[y+20>>>2>>>0]=g.getFullYear()-1900,u()[y+24>>>2>>>0]=g.getDay();var x=(ue(g.getFullYear())?ea:ra)[g.getMonth()]+g.getDate()-1|0;u()[y+28>>>2>>>0]=x,u()[y+36>>>2>>>0]=-60*g.getTimezoneOffset(),x=new Date(g.getFullYear(),6,1).getTimezoneOffset();var S=new Date(g.getFullYear(),0,1).getTimezoneOffset();g=0|(x!=S&&g.getTimezoneOffset()==Math.min(S,x)),u()[y+32>>>2>>>0]=g}function Ma(g){g>>>=0;var y=new Date(u()[g+20>>>2>>>0]+1900,u()[g+16>>>2>>>0],u()[g+12>>>2>>>0],u()[g+8>>>2>>>0],u()[g+4>>>2>>>0],u()[g>>>2>>>0],0),x=u()[g+32>>>2>>>0],S=y.getTimezoneOffset(),E=new Date(y.getFullYear(),6,1).getTimezoneOffset(),N=new Date(y.getFullYear(),0,1).getTimezoneOffset(),L=Math.min(N,E);return 0>x?u()[g+32>>>2>>>0]=+(E!=N&&L==S):0<x!=(L==S)&&(E=Math.max(N,E),y.setTime(y.getTime()+6e4*((0<x?L:E)-S))),u()[g+24>>>2>>>0]=y.getDay(),x=(ue(y.getFullYear())?ea:ra)[y.getMonth()]+y.getDate()-1|0,u()[g+28>>>2>>>0]=x,u()[g>>>2>>>0]=y.getSeconds(),u()[g+4>>>2>>>0]=y.getMinutes(),u()[g+8>>>2>>>0]=y.getHours(),u()[g+12>>>2>>>0]=y.getDate(),u()[g+16>>>2>>>0]=y.getMonth(),u()[g+20>>>2>>>0]=y.getYear(),g=y.getTime(),BigInt(isNaN(g)?-1:g/1e3)}function na(g,y,x,S,E,N,L){return f?Q(16,1,g,y,x,S,E,N,L):-52}function oa(g,y,x,S,E,N){if(f)return Q(17,1,g,y,x,S,E,N)}function Ua(g,y,x,S){g>>>=0,y>>>=0,x>>>=0,S>>>=0;var E=new Date().getFullYear(),N=new Date(E,0,1),L=new Date(E,6,1);E=N.getTimezoneOffset();var Z=L.getTimezoneOffset(),ct=Math.max(E,Z);n()[g>>>2>>>0]=60*ct,u()[y>>>2>>>0]=+(E!=Z),N=(g=ft=>ft.toLocaleTimeString(void 0,{hour12:!1,timeZoneName:"short"}).split(" ")[1])(N),L=g(L),Z<E?(we(N,x,17),we(L,S,17)):(we(N,S,17),we(L,x,17))}var Jr=[];function Ga(g,y,x){g>>>=0,y>>>=0,x>>>=0,Jr.length=0;for(var S;S=i()[y++>>>0];){var E=S!=105;x+=(E&=S!=112)&&x%8?4:0,Jr.push(S==112?n()[x>>>2>>>0]:S==106?Ot[x>>>3]:S==105?u()[x>>>2>>>0]:a()[x>>>3>>>0]),x+=E?8:4}return _n[g](...Jr)}var Ha=()=>{},qa=()=>Date.now();function Wa(g,y){return et(be(g>>>0,y>>>0))}var ia,Xa=()=>{throw ge+=1,"unwind"};function Ka(){return 4294901760}ia=()=>performance.timeOrigin+performance.now();var Ja=()=>navigator.hardwareConcurrency;function Ya(){return Mt("Cannot use emscripten_pc_get_function without -sUSE_OFFSET_CONVERTER"),0}function Za(g){g>>>=0;var y=i().length;if(g<=y||4294901760<g)return!1;for(var x=1;4>=x;x*=2){var S=y*(1+.2/x);S=Math.min(S,g+100663296);var E=Math;S=Math.max(g,S);t:{E=(E.min.call(E,4294901760,S+(65536-S%65536)%65536)-wt.buffer.byteLength+65535)/65536;try{wt.grow(E),st();var N=1;break t}catch{}N=void 0}if(N)return!0}return!1}var er=()=>(Mt("Cannot use convertFrameToPC (needed by __builtin_return_address) without -sUSE_OFFSET_CONVERTER"),0),ve={},aa=g=>{g.forEach(y=>{er()})};function qs(){var g=Error().stack.toString().split(`
1807
- `);return g[0]=="Error"&&g.shift(),aa(g),ve.$a=er(),ve.bb=g,ve.$a}function Xs(g,y,x){if(g>>>=0,y>>>=0,ve.$a==g)var S=ve.bb;else(S=Error().stack.toString().split(`
1808
- `))[0]=="Error"&&S.shift(),aa(S);for(var E=3;S[E]&&er()!=g;)++E;for(g=0;g<x&&S[g+E];++g)u()[y+4*g>>>2>>>0]=er();return g}var Yr,Zr={},sa=()=>{if(!Yr){var g,y={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",_:T};for(g in Zr)Zr[g]===void 0?delete y[g]:y[g]=Zr[g];var x=[];for(g in y)x.push(`${g}=${y[g]}`);Yr=x}return Yr};function la(g,y){if(f)return Q(18,1,g,y);g>>>=0,y>>>=0;var x=0;return sa().forEach((S,E)=>{var N=y+x;for(E=n()[g+4*E>>>2>>>0]=N,N=0;N<S.length;++N)o()[E++>>>0]=S.charCodeAt(N);o()[E>>>0]=0,x+=S.length+1}),0}function ua(g,y){if(f)return Q(19,1,g,y);g>>>=0,y>>>=0;var x=sa();n()[g>>>2>>>0]=x.length;var S=0;return x.forEach(E=>S+=E.length+1),n()[y>>>2>>>0]=S,0}function pa(g){return f?Q(20,1,g):52}function da(g,y,x,S){return f?Q(21,1,g,y,x,S):52}function ca(g,y,x,S){return f?Q(22,1,g,y,x,S):70}var Ks=[null,[],[]];function ha(g,y,x,S){if(f)return Q(23,1,g,y,x,S);y>>>=0,x>>>=0,S>>>=0;for(var E=0,N=0;N<x;N++){var L=n()[y>>>2>>>0],Z=n()[y+4>>>2>>>0];y+=8;for(var ct=0;ct<Z;ct++){var ft=i()[L+ct>>>0],_t=Ks[g];ft===0||ft===10?((g===1?Ft:et)(ko(_t,0)),_t.length=0):_t.push(ft)}E+=Z}return n()[S>>>2>>>0]=E,0}var fa=[31,29,31,30,31,30,31,31,30,31,30,31],ga=[31,28,31,30,31,30,31,31,30,31,30,31],Js=(g,y)=>{o().set(g,y>>>0)};function ma(g,y,x,S){function E($,X,nt){for($=typeof $=="number"?$.toString():$||"";$.length<X;)$=nt[0]+$;return $}function N($,X){return E($,X,"0")}function L($,X){function nt(Oa){return 0>Oa?-1:0<Oa?1:0}var se;return(se=nt($.getFullYear()-X.getFullYear()))===0&&(se=nt($.getMonth()-X.getMonth()))===0&&(se=nt($.getDate()-X.getDate())),se}function Z($){switch($.getDay()){case 0:return new Date($.getFullYear()-1,11,29);case 1:return $;case 2:return new Date($.getFullYear(),0,3);case 3:return new Date($.getFullYear(),0,2);case 4:return new Date($.getFullYear(),0,1);case 5:return new Date($.getFullYear()-1,11,31);case 6:return new Date($.getFullYear()-1,11,30)}}function ct($){var X=$.Sa;for($=new Date(new Date($.Ta+1900,0,1).getTime());0<X;){var nt=$.getMonth(),se=(ue($.getFullYear())?fa:ga)[nt];if(!(X>se-$.getDate())){$.setDate($.getDate()+X);break}X-=se-$.getDate()+1,$.setDate(1),11>nt?$.setMonth(nt+1):($.setMonth(0),$.setFullYear($.getFullYear()+1))}return nt=new Date($.getFullYear()+1,0,4),X=Z(new Date($.getFullYear(),0,4)),nt=Z(nt),0>=L(X,$)?0>=L(nt,$)?$.getFullYear()+1:$.getFullYear():$.getFullYear()-1}g>>>=0,y>>>=0,x>>>=0,S>>>=0;var ft=n()[S+40>>>2>>>0];for(var _t in S={gb:u()[S>>>2>>>0],fb:u()[S+4>>>2>>>0],Va:u()[S+8>>>2>>>0],Ya:u()[S+12>>>2>>>0],Wa:u()[S+16>>>2>>>0],Ta:u()[S+20>>>2>>>0],Qa:u()[S+24>>>2>>>0],Sa:u()[S+28>>>2>>>0],ob:u()[S+32>>>2>>>0],eb:u()[S+36>>>2>>>0],hb:ft?be(ft):""},x=be(x),ft={"%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"})x=x.replace(new RegExp(_t,"g"),ft[_t]);var Ta="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),_a="January February March April May June July August September October November December".split(" ");for(_t in ft={"%a":$=>Ta[$.Qa].substring(0,3),"%A":$=>Ta[$.Qa],"%b":$=>_a[$.Wa].substring(0,3),"%B":$=>_a[$.Wa],"%C":$=>N(($.Ta+1900)/100|0,2),"%d":$=>N($.Ya,2),"%e":$=>E($.Ya,2," "),"%g":$=>ct($).toString().substring(2),"%G":ct,"%H":$=>N($.Va,2),"%I":$=>(($=$.Va)==0?$=12:12<$&&($-=12),N($,2)),"%j":$=>{for(var X=0,nt=0;nt<=$.Wa-1;X+=(ue($.Ta+1900)?fa:ga)[nt++]);return N($.Ya+X,3)},"%m":$=>N($.Wa+1,2),"%M":$=>N($.fb,2),"%n":()=>`
1809
- `,"%p":$=>0<=$.Va&&12>$.Va?"AM":"PM","%S":$=>N($.gb,2),"%t":()=>" ","%u":$=>$.Qa||7,"%U":$=>N(Math.floor(($.Sa+7-$.Qa)/7),2),"%V":$=>{var X=Math.floor(($.Sa+7-($.Qa+6)%7)/7);if(2>=($.Qa+371-$.Sa-2)%7&&X++,X)X==53&&((nt=($.Qa+371-$.Sa)%7)==4||nt==3&&ue($.Ta)||(X=1));else{X=52;var nt=($.Qa+7-$.Sa-1)%7;(nt==4||nt==5&&ue($.Ta%400-1))&&X++}return N(X,2)},"%w":$=>$.Qa,"%W":$=>N(Math.floor(($.Sa+7-($.Qa+6)%7)/7),2),"%y":$=>($.Ta+1900).toString().substring(2),"%Y":$=>$.Ta+1900,"%z":$=>{var X=0<=($=$.eb);return $=Math.abs($)/60,(X?"+":"-")+("0000"+($/60*100+$%60)).slice(-4)},"%Z":$=>$.hb,"%%":()=>"%"},x=x.replace(/%%/g,"\0\0"),ft)x.includes(_t)&&(x=x.replace(new RegExp(_t,"g"),ft[_t](S)));return _t=function($){var X=Array(jo($)+1);return Bo($,X,0,X.length),X}(x=x.replace(/\0\0/g,"%")),_t.length>y?0:(Js(_t,g),_t.length-1)}function Zs(g,y,x,S){return ma(g>>>0,y>>>0,x>>>0,S>>>0)}f||function(){for(var g=e.numThreads-1;g--;)Io();oe.unshift(()=>{ie++,function(y){f?y():Promise.all(ee.map(Eo)).then(y)}(()=>Dt())})}();var fl=[Ir,In,$o,Fo,Lo,zo,Xo,Ko,Jo,Yo,Zo,Qo,ti,ri,ni,ii,na,oa,la,ua,pa,da,ca,ha],M=function(){function g(x,S){return M=x.exports,M=function(){var E=M,N=Z=>()=>Z()>>>0,L=Z=>ct=>Z(ct)>>>0;return(E=Object.assign({},E)).Ba=N(E.Ba),E.Ca=L(E.Ca),E.emscripten_main_runtime_thread_id=N(E.emscripten_main_runtime_thread_id),E.Oa=L(E.Oa),E.Pa=N(E.Pa),E}(),_o.push(M.Ea),Po=M.Fa,te.unshift(M.$),Le=S,Dt(),M}var y=vn();if(ie++,e.instantiateWasm)try{return e.instantiateWasm(y,g)}catch(x){et(`Module.instantiateWasm callback failed with error: ${x}`),c(x)}return it||(it=e.locateFile?lt("ort-wasm-simd-threaded.wasm")?"ort-wasm-simd-threaded.wasm":e.locateFile?e.locateFile("ort-wasm-simd-threaded.wasm",C):C+"ort-wasm-simd-threaded.wasm":""),function(x,S){var E=it;return V||typeof WebAssembly.instantiateStreaming!="function"||lt(E)||Wt(E)||typeof fetch!="function"?Ye(E,x,S):fetch(E,{credentials:"same-origin"}).then(N=>WebAssembly.instantiateStreaming(N,x).then(S,function(L){return et(`wasm streaming compile failed: ${L}`),et("falling back to ArrayBuffer instantiation"),Ye(E,x,S)}))}(y,function(x){g(x.instance,x.module)}).catch(c),{}}();e._OrtInit=(g,y)=>(e._OrtInit=M.aa)(g,y),e._OrtGetLastError=(g,y)=>(e._OrtGetLastError=M.ba)(g,y),e._OrtCreateSessionOptions=(g,y,x,S,E,N,L,Z,ct,ft)=>(e._OrtCreateSessionOptions=M.ca)(g,y,x,S,E,N,L,Z,ct,ft),e._OrtAppendExecutionProvider=(g,y)=>(e._OrtAppendExecutionProvider=M.da)(g,y),e._OrtAddFreeDimensionOverride=(g,y,x)=>(e._OrtAddFreeDimensionOverride=M.ea)(g,y,x),e._OrtAddSessionConfigEntry=(g,y,x)=>(e._OrtAddSessionConfigEntry=M.fa)(g,y,x),e._OrtReleaseSessionOptions=g=>(e._OrtReleaseSessionOptions=M.ga)(g),e._OrtCreateSession=(g,y,x)=>(e._OrtCreateSession=M.ha)(g,y,x),e._OrtReleaseSession=g=>(e._OrtReleaseSession=M.ia)(g),e._OrtGetInputOutputCount=(g,y,x)=>(e._OrtGetInputOutputCount=M.ja)(g,y,x),e._OrtGetInputName=(g,y)=>(e._OrtGetInputName=M.ka)(g,y),e._OrtGetOutputName=(g,y)=>(e._OrtGetOutputName=M.la)(g,y),e._OrtFree=g=>(e._OrtFree=M.ma)(g),e._OrtCreateTensor=(g,y,x,S,E,N)=>(e._OrtCreateTensor=M.na)(g,y,x,S,E,N),e._OrtGetTensorData=(g,y,x,S,E)=>(e._OrtGetTensorData=M.oa)(g,y,x,S,E),e._OrtReleaseTensor=g=>(e._OrtReleaseTensor=M.pa)(g),e._OrtCreateRunOptions=(g,y,x,S)=>(e._OrtCreateRunOptions=M.qa)(g,y,x,S),e._OrtAddRunConfigEntry=(g,y,x)=>(e._OrtAddRunConfigEntry=M.ra)(g,y,x),e._OrtReleaseRunOptions=g=>(e._OrtReleaseRunOptions=M.sa)(g),e._OrtCreateBinding=g=>(e._OrtCreateBinding=M.ta)(g),e._OrtBindInput=(g,y,x)=>(e._OrtBindInput=M.ua)(g,y,x),e._OrtBindOutput=(g,y,x,S)=>(e._OrtBindOutput=M.va)(g,y,x,S),e._OrtClearBoundOutputs=g=>(e._OrtClearBoundOutputs=M.wa)(g),e._OrtReleaseBinding=g=>(e._OrtReleaseBinding=M.xa)(g),e._OrtRunWithBinding=(g,y,x,S,E)=>(e._OrtRunWithBinding=M.ya)(g,y,x,S,E),e._OrtRun=(g,y,x,S,E,N,L,Z)=>(e._OrtRun=M.za)(g,y,x,S,E,N,L,Z),e._OrtEndProfiling=g=>(e._OrtEndProfiling=M.Aa)(g);var ce=()=>(ce=M.Ba)();e._malloc=g=>(e._malloc=M.Ca)(g),e._free=g=>(e._free=M.Da)(g);var ar,Qr=(g,y,x,S,E,N)=>(Qr=M.Ga)(g,y,x,S,E,N),ba=()=>(ba=M.Ha)(),ya=(g,y,x,S,E)=>(ya=M.Ia)(g,y,x,S,E),tn=g=>(tn=M.Ja)(g),gr=g=>(gr=M.Ka)(g),wa=()=>(wa=M.La)(),va=(g,y)=>(va=M.Ma)(g,y),wr=g=>(wr=M.Na)(g),en=g=>(en=M.Oa)(g),rn=()=>(rn=M.Pa)();function xa(){0<ie||(f?(d(e),f||Ze(te),startWorker(e)):(Ze(oe),0<ie||ar||(ar=!0,e.calledRun=!0,at||(f||Ze(te),d(e),f||Ze(Ge)))))}return e.___start_em_js=838360,e.___stop_em_js=838421,e.stackSave=()=>rn(),e.stackRestore=g=>wr(g),e.stackAlloc=g=>en(g),e.UTF8ToString=be,e.stringToUTF8=we,e.lengthBytesUTF8=jo,Pt=function g(){ar||xa(),ar||(Pt=g)},xa(),l}),Og=Mp,((t=globalThis.self)==null?void 0:t.name)==="em-pthread"&&Mp()}),br,Sg,Ag,Pg,zp,Wp,Eg,Hp,Vr=O(()=>{var t,r;oo(),br=(_documentCurrentScript&&_documentCurrentScript.tagName.toUpperCase()==="SCRIPT"&&_documentCurrentScript.src||new URL("segmentation.js",document.baseURI).href)??(typeof document<"u"?(t=document.currentScript)==null?void 0:t.src:typeof self<"u"?(r=self.location)==null?void 0:r.href:void 0),Sg=typeof location>"u"?void 0:location.origin,Ag=(o,i)=>{try{let u=i??br;return(u?new URL(o,u):new URL(o)).origin===Sg}catch{return!1}},Pg=async o=>{let i=await(await fetch(o,{credentials:"same-origin"})).blob();return URL.createObjectURL(i)},zp=(Gp(),sn(Rp)).default,Wp=async()=>{if(!br)throw new Error("Failed to load proxy worker: cannot determine the script source URL.");if(Ag(br))return[void 0,zp()];let o=await Pg(br);return[o,zp(o)]},Eg=(Vp(),sn(Up)).default,Hp=async(o,i,u)=>[void 0,Eg]}),Xi,Ki,ho,qp,Dg,Lg,io,xt,Ke=O(()=>{Vr(),Ki=!1,ho=!1,qp=!1,Dg=()=>{if(typeof SharedArrayBuffer>"u")return!1;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}},io=async t=>{if(Ki)return Promise.resolve();if(ho)throw new Error("multiple calls to 'initializeWebAssembly()' detected.");if(qp)throw new Error("previous call to 'initializeWebAssembly()' failed.");ho=!0;let r=t.initTimeout,o=t.numThreads;if(!Lg())throw new Error("WebAssembly SIMD is not supported in the current environment.");let i=Dg();o>1&&!i&&(typeof self<"u"&&!self.crossOriginIsolated&&console.warn("env.wasm.numThreads is set to "+o+", but this will not work unless you enable crossOriginIsolated mode. See https://web.dev/cross-origin-isolation-guide/ for more info."),console.warn("WebAssembly multi-threading is not supported in the current environment. Falling back to single-threading."),t.numThreads=o=1);let u=t.wasmPaths,n=typeof u=="string"?u:void 0,a=u==null?void 0:u.mjs,d=(a==null?void 0:a.href)??a,c=u==null?void 0:u.wasm,e=(c==null?void 0:c.href)??c,l=t.wasmBinary,[s,h]=await Hp(d,n,o>1),f=!1,m=[];if(r>0&&m.push(new Promise(v=>{setTimeout(()=>{f=!0,v()},r)})),m.push(new Promise((v,_)=>{let I={numThreads:o};l?I.wasmBinary=l:(e||n)&&(I.locateFile=(T,P)=>e??(n??P)+T),h(I).then(T=>{ho=!1,Ki=!0,Xi=T,v(),s&&URL.revokeObjectURL(s)},T=>{ho=!1,qp=!0,_(T)})})),await Promise.race(m),f)throw new Error(`WebAssembly backend initializing failed due to timeout: ${r}ms`)},xt=()=>{if(Ki&&Xi)return Xi;throw new Error("WebAssembly is not initialized yet.")}}),Tt,Wr,ht,mo=O(()=>{Ke(),Tt=(t,r)=>{let o=xt(),i=o.lengthBytesUTF8(t)+1,u=o._malloc(i);return o.stringToUTF8(t,u,i),r.push(u),u},Wr=(t,r,o,i)=>{if(typeof t=="object"&&t!==null){if(o.has(t))throw new Error("Circular reference in options");o.add(t)}Object.entries(t).forEach(([u,n])=>{let a=r?r+u:u;if(typeof n=="object")Wr(n,a+".",o,i);else if(typeof n=="string"||typeof n=="number")i(a,n.toString());else if(typeof n=="boolean")i(a,n?"1":"0");else throw new Error(`Can't handle extra config type: ${typeof n}`)})},ht=t=>{let r=xt(),o=r.stackSave();try{let i=r.stackAlloc(8);r._OrtGetLastError(i,i+4);let u=r.HEAP32[i/4],n=r.HEAPU32[i/4+1],a=n?r.UTF8ToString(n):"";throw new Error(`${t} ERROR_CODE: ${u}, ERROR_MESSAGE: ${a}`)}finally{r.stackRestore(o)}}}),jp,Xp=O(()=>{Ke(),mo(),jp=t=>{let r=xt(),o=0,i=[],u=t||{};try{if((t==null?void 0:t.logSeverityLevel)===void 0)u.logSeverityLevel=2;else if(typeof t.logSeverityLevel!="number"||!Number.isInteger(t.logSeverityLevel)||t.logSeverityLevel<0||t.logSeverityLevel>4)throw new Error(`log serverity level is not valid: ${t.logSeverityLevel}`);if((t==null?void 0:t.logVerbosityLevel)===void 0)u.logVerbosityLevel=0;else if(typeof t.logVerbosityLevel!="number"||!Number.isInteger(t.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${t.logVerbosityLevel}`);(t==null?void 0:t.terminate)===void 0&&(u.terminate=!1);let n=0;return(t==null?void 0:t.tag)!==void 0&&(n=Tt(t.tag,i)),o=r._OrtCreateRunOptions(u.logSeverityLevel,u.logVerbosityLevel,!!u.terminate,n),o===0&&ht("Can't create run options."),(t==null?void 0:t.extra)!==void 0&&Wr(t.extra,"",new WeakSet,(a,d)=>{let c=Tt(a,i),e=Tt(d,i);r._OrtAddRunConfigEntry(o,c,e)!==0&&ht(`Can't set a run config entry: ${a} - ${d}.`)}),[o,i]}catch(n){throw o!==0&&r._OrtReleaseRunOptions(o),i.forEach(a=>r._free(a)),n}}}),$g,kg,Bg,Fg,Kp,Jp=O(()=>{Ke(),mo(),$g=t=>{switch(t){case"disabled":return 0;case"basic":return 1;case"extended":return 2;case"all":return 99;default:throw new Error(`unsupported graph optimization level: ${t}`)}},kg=t=>{switch(t){case"sequential":return 0;case"parallel":return 1;default:throw new Error(`unsupported execution mode: ${t}`)}},Bg=t=>{t.extra||(t.extra={}),t.extra.session||(t.extra.session={});let r=t.extra.session;r.use_ort_model_bytes_directly||(r.use_ort_model_bytes_directly="1"),t.executionProviders&&t.executionProviders.some(o=>(typeof o=="string"?o:o.name)==="webgpu")&&(t.enableMemPattern=!1)},Fg=(t,r,o)=>{for(let i of r){let u=typeof i=="string"?i:i.name;switch(u){case"webnn":if(u="WEBNN",typeof i!="string"){let a=i==null?void 0:i.deviceType;if(a){let d=Tt("deviceType",o),c=Tt(a,o);xt()._OrtAddSessionConfigEntry(t,d,c)!==0&&ht(`Can't set a session config entry: 'deviceType' - ${a}.`)}}break;case"webgpu":if(u="JS",typeof i!="string"){let a=i;if(a!=null&&a.preferredLayout){if(a.preferredLayout!=="NCHW"&&a.preferredLayout!=="NHWC")throw new Error(`preferredLayout must be either 'NCHW' or 'NHWC': ${a.preferredLayout}`);let d=Tt("preferredLayout",o),c=Tt(a.preferredLayout,o);xt()._OrtAddSessionConfigEntry(t,d,c)!==0&&ht(`Can't set a session config entry: 'preferredLayout' - ${a.preferredLayout}.`)}}break;case"wasm":case"cpu":continue;default:throw new Error(`not supported execution provider: ${u}`)}let n=Tt(u,o);xt()._OrtAppendExecutionProvider(t,n)!==0&&ht(`Can't append execution provider: ${u}.`)}},Kp=t=>{let r=xt(),o=0,i=[],u=t||{};Bg(u);try{let n=$g(u.graphOptimizationLevel??"all"),a=kg(u.executionMode??"sequential"),d=typeof u.logId=="string"?Tt(u.logId,i):0,c=u.logSeverityLevel??2;if(!Number.isInteger(c)||c<0||c>4)throw new Error(`log serverity level is not valid: ${c}`);let e=u.logVerbosityLevel??0;if(!Number.isInteger(e)||e<0||e>4)throw new Error(`log verbosity level is not valid: ${e}`);let l=typeof u.optimizedModelFilePath=="string"?Tt(u.optimizedModelFilePath,i):0;if(o=r._OrtCreateSessionOptions(n,!!u.enableCpuMemArena,!!u.enableMemPattern,a,!!u.enableProfiling,0,d,c,e,l),o===0&&ht("Can't create session options."),u.executionProviders&&Fg(o,u.executionProviders,i),u.enableGraphCapture!==void 0){if(typeof u.enableGraphCapture!="boolean")throw new Error(`enableGraphCapture must be a boolean value: ${u.enableGraphCapture}`);let s=Tt("enableGraphCapture",i),h=Tt(u.enableGraphCapture.toString(),i);r._OrtAddSessionConfigEntry(o,s,h)!==0&&ht(`Can't set a session config entry: 'enableGraphCapture' - ${u.enableGraphCapture}.`)}if(u.freeDimensionOverrides)for(let[s,h]of Object.entries(u.freeDimensionOverrides)){if(typeof s!="string")throw new Error(`free dimension override name must be a string: ${s}`);if(typeof h!="number"||!Number.isInteger(h)||h<0)throw new Error(`free dimension override value must be a non-negative integer: ${h}`);let f=Tt(s,i);r._OrtAddFreeDimensionOverride(o,f,h)!==0&&ht(`Can't set a free dimension override: ${s} - ${h}.`)}return u.extra!==void 0&&Wr(u.extra,"",new WeakSet,(s,h)=>{let f=Tt(s,i),m=Tt(h,i);r._OrtAddSessionConfigEntry(o,f,m)!==0&&ht(`Can't set a session config entry: ${s} - ${h}.`)}),[o,i]}catch(n){throw o!==0&&r._OrtReleaseSessionOptions(o),i.forEach(a=>r._free(a)),n}}}),Hr,Yp,qr,Zp,Qp,bo,go,td,Ji=O(()=>{Hr=t=>{switch(t){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;case"int4":return 22;case"uint4":return 21;default:throw new Error(`unsupported data type: ${t}`)}},Yp=t=>{switch(t){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";case 22:return"int4";case 21:return"uint4";default:throw new Error(`unsupported data type: ${t}`)}},qr=(t,r)=>{let o=[-1,4,1,1,2,2,4,8,-1,1,2,8,4,8,-1,-1,-1,-1,-1,-1,-1,.5,.5][t],i=typeof r=="number"?r:r.reduce((u,n)=>u*n,1);return o>0?Math.ceil(i*o):void 0},Zp=t=>{switch(t){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: ${t}`)}},Qp=t=>{switch(t){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: ${t}`)}},bo=t=>t==="float32"||t==="float16"||t==="int32"||t==="int64"||t==="uint32"||t==="uint8"||t==="bool"||t==="uint4"||t==="int4",go=t=>t==="float32"||t==="float16"||t==="int32"||t==="int64"||t==="uint32"||t==="uint64"||t==="int8"||t==="uint8"||t==="bool",td=t=>{switch(t){case"none":return 0;case"cpu":return 1;case"cpu-pinned":return 2;case"texture":return 3;case"gpu-buffer":return 4;case"ml-tensor":return 5;default:throw new Error(`unsupported data location: ${t}`)}}}),jr,Yi=O(()=>{oo(),jr=async t=>{if(typeof t=="string"){let r=await fetch(t);if(!r.ok)throw new Error(`failed to load external data file: ${t}`);let o=r.headers.get("Content-Length"),i=o?parseInt(o,10):0;if(i<1073741824)return new Uint8Array(await r.arrayBuffer());{if(!r.body)throw new Error(`failed to load external data file: ${t}, no response body.`);let u=r.body.getReader(),n;try{n=new ArrayBuffer(i)}catch(d){if(d instanceof RangeError){let c=Math.ceil(i/65536);n=new WebAssembly.Memory({initial:c,maximum:c}).buffer}else throw d}let a=0;for(;;){let{done:d,value:c}=await u.read();if(d)break;let e=c.byteLength;new Uint8Array(n,a,e).set(c),a+=e}return new Uint8Array(n,0,i)}}else return t instanceof Blob?new Uint8Array(await t.arrayBuffer()):t instanceof Uint8Array?t:new Uint8Array(t)}}),Cg,ao,so,yr,Ng,zr,uo,lo,ed,fo,co,po,qi=O(()=>{Xp(),Jp(),Ji(),Ke(),mo(),Yi(),Cg=(t,r)=>{xt()._OrtInit(t,r)!==0&&ht("Can't initialize onnxruntime.")},ao=async t=>{Cg(t.wasm.numThreads,Qp(t.logLevel))},so=async(t,r)=>{},yr=new Map,Ng=t=>{let r=xt(),o=r.stackSave();try{let i=r.stackAlloc(8);return r._OrtGetInputOutputCount(t,i,i+4)!==0&&ht("Can't get session input/output count."),[r.HEAP32[i/4],r.HEAP32[i/4+1]]}finally{r.stackRestore(o)}},zr=t=>{let r=xt(),o=r._malloc(t.byteLength);if(o===0)throw new Error(`Can't create a session. failed to allocate a buffer of size ${t.byteLength}.`);return r.HEAPU8.set(t,o),[o,t.byteLength]},uo=async(t,r)=>{var l;let o,i,u=xt();Array.isArray(t)?[o,i]=t:t.buffer===u.HEAPU8.buffer?[o,i]=[t.byteOffset,t.byteLength]:[o,i]=zr(t);let n=0,a=0,d=[],c=[],e=[];try{if([a,d]=Kp(r),(r==null?void 0:r.externalData)&&u.mountExternalData){let T=[];for(let P of r.externalData){let C=typeof P=="string"?P:P.path;T.push(jr(typeof P=="string"?P:P.data).then(V=>{u.mountExternalData(C,V)}))}await Promise.all(T)}for(let T of(r==null?void 0:r.executionProviders)??[])if((typeof T=="string"?T:T.name)==="webnn"){if(u.shouldTransferToMLTensor=!1,u.currentContext)throw new Error("WebNN execution provider is already set.");if(typeof T!="string"){let P=T,C=P==null?void 0:P.context,V=P==null?void 0:P.gpuDevice,gt=P==null?void 0:P.deviceType,pt=P==null?void 0:P.numThreads,Ft=P==null?void 0:P.powerPreference;C?u.currentContext=C:V?u.currentContext=await navigator.ml.createContext(V):u.currentContext=await navigator.ml.createContext({deviceType:gt,numThreads:pt,powerPreference:Ft})}else u.currentContext=await navigator.ml.createContext();break}n=await u._OrtCreateSession(o,i,a),n===0&&ht("Can't create a session."),u.currentContext&&(u.jsepRegisterMLContext(n,u.currentContext),u.currentContext=void 0,u.shouldTransferToMLTensor=!0);let[s,h]=Ng(n),f=!!(r!=null&&r.enableGraphCapture),m=[],v=[],_=[];for(let T=0;T<s;T++){let P=u._OrtGetInputName(n,T);P===0&&ht("Can't get an input name."),c.push(P),m.push(u.UTF8ToString(P))}for(let T=0;T<h;T++){let P=u._OrtGetOutputName(n,T);P===0&&ht("Can't get an output name."),e.push(P);let C=u.UTF8ToString(P);v.push(C)}return yr.set(n,[n,c,e,null,f,!1]),[n,m,v]}catch(s){throw c.forEach(h=>u._OrtFree(h)),e.forEach(h=>u._OrtFree(h)),n!==0&&u._OrtReleaseSession(n),s}finally{u._free(o),a!==0&&u._OrtReleaseSessionOptions(a),d.forEach(s=>u._free(s)),(l=u.unmountExternalData)==null||l.call(u)}},lo=t=>{var c;let r=xt(),o=yr.get(t);if(!o)throw new Error(`cannot release session. invalid session id: ${t}`);let[i,u,n,a,d]=o;a&&(d&&r._OrtClearBoundOutputs(a.handle),r._OrtReleaseBinding(a.handle)),(c=r.jsepOnReleaseSession)==null||c.call(r,t),u.forEach(e=>r._OrtFree(e)),n.forEach(e=>r._OrtFree(e)),r._OrtReleaseSession(i),yr.delete(t)},ed=(t,r,o,i,u,n=!1)=>{if(!t){r.push(0);return}let a=xt(),d=t[0],c=t[1],e=t[3],l,s;if(d==="string"&&(e==="gpu-buffer"||e==="ml-tensor"))throw new Error("String tensor is not supported on GPU.");if(n&&e!=="gpu-buffer")throw new Error(`External buffer must be provided for input/output index ${u} when enableGraphCapture is true.`);if(e==="gpu-buffer"){let m=t[2].gpuBuffer;s=qr(Hr(d),c);let v=a.jsepRegisterBuffer;if(!v)throw new Error('Tensor location "gpu-buffer" is not supported without using WebGPU.');l=v(i,u,m,s)}else if(e==="ml-tensor"){let m=t[2].mlTensor;s=qr(Hr(d),c);let v=a.jsepRegisterMLTensor;if(!v)throw new Error('Tensor location "ml-tensor" is not supported without using WebNN.');l=v(m,Hr(d),c)}else{let m=t[2];if(Array.isArray(m)){s=4*m.length,l=a._malloc(s),o.push(l);let v=l/4;for(let _=0;_<m.length;_++){if(typeof m[_]!="string")throw new TypeError(`tensor data at index ${_} is not a string`);a.HEAPU32[v++]=Tt(m[_],o)}}else s=m.byteLength,l=a._malloc(s),o.push(l),a.HEAPU8.set(new Uint8Array(m.buffer,m.byteOffset,s),l)}let h=a.stackSave(),f=a.stackAlloc(4*c.length);try{let m=f/4;c.forEach(_=>a.HEAP32[m++]=_);let v=a._OrtCreateTensor(Hr(d),l,s,f,c.length,td(e));v===0&&ht(`Can't create tensor for input/output. session=${i}, index=${u}.`),r.push(v)}finally{a.stackRestore(h)}},fo=async(t,r,o,i,u,n)=>{var et;let a=xt(),d=yr.get(t);if(!d)throw new Error(`cannot run inference. invalid session id: ${t}`);let c=d[0],e=d[1],l=d[2],s=d[3],h=d[4];d[5];let f=r.length,m=i.length,v=0,_=[],I=[],T=[],P=[],C=a.stackSave(),V=a.stackAlloc(f*4),gt=a.stackAlloc(f*4),pt=a.stackAlloc(m*4),Ft=a.stackAlloc(m*4);try{(et=a.jsepOnRunStart)==null||et.call(a,c),[v,_]=jp(n);for(let K=0;K<f;K++)ed(o[K],I,P,t,r[K],h);for(let K=0;K<m;K++)ed(u[K],T,P,t,f+i[K],h);let $t=V/4,De=gt/4,wt=pt/4,Le=Ft/4;for(let K=0;K<f;K++)a.HEAPU32[$t++]=I[K],a.HEAPU32[De++]=e[r[K]];for(let K=0;K<m;K++)a.HEAPU32[wt++]=T[K],a.HEAPU32[Le++]=l[i[K]];let Lt;Lt=await a._OrtRun(c,gt,V,f,Ft,m,pt,v),Lt!==0&&ht("failed to call OrtRun().");let vt=[];for(let K=0;K<m;K++){let Jt=a.HEAPU32[pt/4+K];if(Jt===T[K]){vt.push(u[K]);continue}let Re=a.stackSave(),Ot=a.stackAlloc(4*4),le=!1,at,st=0;try{a._OrtGetTensorData(Jt,Ot,Ot+4,Ot+8,Ot+12)!==0&&ht(`Can't access output tensor data on index ${K}.`);let oe=Ot/4,te=a.HEAPU32[oe++];st=a.HEAPU32[oe++];let Ge=a.HEAPU32[oe++],ie=a.HEAPU32[oe++],Pt=[];for(let it=0;it<ie;it++)Pt.push(a.HEAPU32[Ge/4+it]);a._OrtFree(Ge);let Dt=Pt.reduce((it,lt)=>it*lt,1);at=Yp(te);let Mt=s==null?void 0:s.outputPreferredLocations[i[K]];if(at==="string"){if(Mt==="gpu-buffer"||Mt==="ml-tensor")throw new Error("String tensor is not supported on GPU.");let it=[],lt=st/4;for(let Wt=0;Wt<Dt;Wt++){let fe=a.HEAPU32[lt++],Ye=Wt===Dt-1?void 0:a.HEAPU32[lt]-fe;it.push(a.UTF8ToString(fe,Ye))}vt.push([at,Pt,it,"cpu"])}else if(Mt==="gpu-buffer"&&Dt>0){let it=a.jsepGetBuffer;if(!it)throw new Error('preferredLocation "gpu-buffer" is not supported without using WebGPU.');let lt=it(st),Wt=qr(te,Dt);if(Wt===void 0||!bo(at))throw new Error(`Unsupported data type: ${at}`);le=!0,vt.push([at,Pt,{gpuBuffer:lt,download:a.jsepCreateDownloader(lt,Wt,at),dispose:()=>{a._OrtReleaseTensor(Jt)}},"gpu-buffer"])}else if(Mt==="ml-tensor"&&Dt>0){let it=a.jsepEnsureTensor;if(!it)throw new Error('preferredLocation "ml-tensor" is not supported without using WebNN.');if(qr(te,Dt)===void 0||!go(at))throw new Error(`Unsupported data type: ${at}`);let lt=await it(st,te,Pt,!1);le=!0,vt.push([at,Pt,{mlTensor:lt,download:a.jsepCreateMLTensorDownloader(st,at),dispose:()=>{a.jsepReleaseTensorId(st),a._OrtReleaseTensor(Jt)}},"ml-tensor"])}else{let it=Zp(at),lt=new it(Dt);new Uint8Array(lt.buffer,lt.byteOffset,lt.byteLength).set(a.HEAPU8.subarray(st,st+lt.byteLength)),vt.push([at,Pt,lt,"cpu"])}}finally{a.stackRestore(Re),at==="string"&&st&&a._free(st),le||a._OrtReleaseTensor(Jt)}}return s&&!h&&(a._OrtClearBoundOutputs(s.handle),yr.set(t,[c,e,l,s,h,!1])),vt}finally{a.stackRestore(C),I.forEach($t=>a._OrtReleaseTensor($t)),T.forEach($t=>a._OrtReleaseTensor($t)),P.forEach($t=>a._free($t)),v!==0&&a._OrtReleaseRunOptions(v),_.forEach($t=>a._free($t))}},co=t=>{let r=xt(),o=yr.get(t);if(!o)throw new Error("invalid session id");let i=o[0],u=r._OrtEndProfiling(i);u===0&&ht("Can't get an profile file name."),r._OrtFree(u)},po=t=>{let r=[];for(let o of t){let i=o[2];!Array.isArray(i)&&"buffer"in i&&r.push(i.buffer)}return r}}),Je,Kt,Xr,xo,To,yo,Zi,Qi,xr,Tr,Gg,rd,nd,od,id,ad,sd,ud,ta=O(()=>{Yt(),qi(),Ke(),Vr(),Je=()=>!!z.wasm.proxy&&typeof document<"u",Xr=!1,xo=!1,To=!1,Qi=new Map,xr=(t,r)=>{let o=Qi.get(t);o?o.push(r):Qi.set(t,[r])},Tr=()=>{if(Xr||!xo||To||!Kt)throw new Error("worker not ready")},Gg=t=>{switch(t.data.type){case"init-wasm":Xr=!1,t.data.err?(To=!0,Zi[1](t.data.err)):(xo=!0,Zi[0]()),yo&&(URL.revokeObjectURL(yo),yo=void 0);break;case"init-ep":case"copy-from":case"create":case"release":case"run":case"end-profiling":{let r=Qi.get(t.data.type);t.data.err?r.shift()[1](t.data.err):r.shift()[0](t.data.out);break}}},rd=async()=>{if(!xo){if(Xr)throw new Error("multiple calls to 'initWasm()' detected.");if(To)throw new Error("previous call to 'initWasm()' failed.");if(Xr=!0,Je())return new Promise((t,r)=>{Kt==null||Kt.terminate(),Wp().then(([o,i])=>{try{Kt=i,Kt.onerror=n=>r(n),Kt.onmessage=Gg,Zi=[t,r];let u={type:"init-wasm",in:z};Kt.postMessage(u),yo=o}catch(u){r(u)}},r)});try{await io(z.wasm),await ao(z),xo=!0}catch(t){throw To=!0,t}finally{Xr=!1}}},nd=async t=>{if(Je())return Tr(),new Promise((r,o)=>{xr("init-ep",[r,o]);let i={type:"init-ep",in:{epName:t,env:z}};Kt.postMessage(i)});await so(z,t)},od=async t=>Je()?(Tr(),new Promise((r,o)=>{xr("copy-from",[r,o]);let i={type:"copy-from",in:{buffer:t}};Kt.postMessage(i,[t.buffer])})):zr(t),id=async(t,r)=>{if(Je()){if(r!=null&&r.preferredOutputLocation)throw new Error('session option "preferredOutputLocation" is not supported for proxy.');return Tr(),new Promise((o,i)=>{xr("create",[o,i]);let u={type:"create",in:{model:t,options:{...r}}},n=[];t instanceof Uint8Array&&n.push(t.buffer),Kt.postMessage(u,n)})}else return uo(t,r)},ad=async t=>{if(Je())return Tr(),new Promise((r,o)=>{xr("release",[r,o]);let i={type:"release",in:t};Kt.postMessage(i)});lo(t)},sd=async(t,r,o,i,u,n)=>{if(Je()){if(o.some(a=>a[3]!=="cpu"))throw new Error("input tensor on GPU is not supported for proxy.");if(u.some(a=>a))throw new Error("pre-allocated output tensor is not supported for proxy.");return Tr(),new Promise((a,d)=>{xr("run",[a,d]);let c=o,e={type:"run",in:{sessionId:t,inputIndices:r,inputs:c,outputIndices:i,options:n}};Kt.postMessage(e,po(c))})}else return fo(t,r,o,i,u,n)},ud=async t=>{if(Je())return Tr(),new Promise((r,o)=>{xr("end-profiling",[r,o]);let i={type:"end-profiling",in:t};Kt.postMessage(i)});co(t)}}),ld,Mg,wo,fd=O(()=>{Yt(),ta(),Ji(),oo(),Yi(),ld=(t,r)=>{switch(t.location){case"cpu":return[t.type,t.dims,t.data,"cpu"];case"gpu-buffer":return[t.type,t.dims,{gpuBuffer:t.gpuBuffer},"gpu-buffer"];case"ml-tensor":return[t.type,t.dims,{mlTensor:t.mlTensor},"ml-tensor"];default:throw new Error(`invalid data location: ${t.location} for ${r()}`)}},Mg=t=>{switch(t[3]){case"cpu":return new yt(t[0],t[2],t[1]);case"gpu-buffer":{let r=t[0];if(!bo(r))throw new Error(`not supported data type: ${r} for deserializing GPU tensor`);let{gpuBuffer:o,download:i,dispose:u}=t[2];return yt.fromGpuBuffer(o,{dataType:r,dims:t[1],download:i,dispose:u})}case"ml-tensor":{let r=t[0];if(!go(r))throw new Error(`not supported data type: ${r} for deserializing MLTensor tensor`);let{mlTensor:o,download:i,dispose:u}=t[2];return yt.fromMLTensor(o,{dataType:r,dims:t[1],download:i,dispose:u})}default:throw new Error(`invalid data location: ${t[3]}`)}},wo=class{async fetchModelAndCopyToWasmMemory(t){return od(await jr(t))}async loadModel(t,r){Fe();let o;typeof t=="string"?o=await this.fetchModelAndCopyToWasmMemory(t):o=t,[this.sessionId,this.inputNames,this.outputNames]=await id(o,r),Ce()}async dispose(){return ad(this.sessionId)}async run(t,r,o){Fe();let i=[],u=[];Object.entries(t).forEach(s=>{let h=s[0],f=s[1],m=this.inputNames.indexOf(h);if(m===-1)throw new Error(`invalid input '${h}'`);i.push(f),u.push(m)});let n=[],a=[];Object.entries(r).forEach(s=>{let h=s[0],f=s[1],m=this.outputNames.indexOf(h);if(m===-1)throw new Error(`invalid output '${h}'`);n.push(f),a.push(m)});let d=i.map((s,h)=>ld(s,()=>`input "${this.inputNames[u[h]]}"`)),c=n.map((s,h)=>s?ld(s,()=>`output "${this.outputNames[a[h]]}"`):null),e=await sd(this.sessionId,u,d,a,c,o),l={};for(let s=0;s<e.length;s++)l[this.outputNames[a[s]]]=n[s]??Mg(e[s]);return Ce(),l}startProfiling(){}endProfiling(){ud(this.sessionId)}}}),pd={};Or(pd,{OnnxruntimeWebAssemblyBackend:()=>vo,initializeFlags:()=>cd,wasmBackend:()=>Ug});var cd,vo,Ug,dd=O(()=>{Yt(),ta(),fd(),Vr(),cd=()=>{if((typeof z.wasm.initTimeout!="number"||z.wasm.initTimeout<0)&&(z.wasm.initTimeout=0),z.wasm.simd===!1&&console.warn('Deprecated property "env.wasm.simd" is set to false. non-SIMD build is no longer provided, and this setting will be ignored.'),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)if(typeof self<"u"&&!self.crossOriginIsolated)z.wasm.numThreads=1;else{let t=typeof navigator>"u"?Co("node:os").cpus().length:navigator.hardwareConcurrency;z.wasm.numThreads=Math.min(4,Math.ceil((t||1)/2))}},vo=class{async init(t){cd(),await rd(),await nd(t)}async createInferenceSessionHandler(t,r){let o=new wo;return await o.loadModel(t,r),Promise.resolve(o)}},Ug=new vo});Yt(),Yt(),Yt();var Ds="1.20.1";{let t=(Fp(),sn(Bp)).onnxjsBackend;nr("webgl",t,-10)}{let t=(dd(),sn(pd)).wasmBackend;nr("cpu",t,10),nr("wasm",t,10)}Object.defineProperty(z.versions,"web",{value:Ds,enumerable:!0});/*! Bundled license information:
1805
+ ${e}`);return i}deleteShader(e){this.gl.deleteShader(e)}bindTextureToUniform(e,n,a){let i=this.gl;i.activeTexture(i.TEXTURE0+n),this.checkError(),i.bindTexture(i.TEXTURE_2D,e),this.checkError(),i.uniform1i(a,n),this.checkError()}draw(){this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4),this.checkError()}checkError(){if(z.debug){let e=this.gl,n=e.getError(),a="";switch(n){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: ${n.toString(16)}`}throw new Error(a)}}deleteTexture(e){this.gl.deleteTexture(e)}deleteProgram(e){this.gl.deleteProgram(e)}getEncoder(e,n,a=0){if(this.version===2)return new Pn(this.gl,n);switch(e){case"float":return a===1||this.isRenderFloat32Supported?new Br(this.gl,n):new Br(this.gl,n,this.textureHalfFloatExtension.HALF_FLOAT_OES);case"int":throw new Error("not implemented");case"byte":return new En(this.gl,n);default:throw new Error(`Invalid dataType: ${e}`)}}clearActiveTextures(){let e=this.gl;for(let n=0;n<this.maxTextureImageUnits;++n)e.activeTexture(e.TEXTURE0+n),e.bindTexture(e.TEXTURE_2D,null)}dispose(){if(this.disposed)return;let e=this.gl;e.bindFramebuffer(e.FRAMEBUFFER,null),e.deleteFramebuffer(this.framebuffer),e.bindBuffer(e.ARRAY_BUFFER,null),e.deleteBuffer(this.vertexbuffer),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null),e.finish(),this.disposed=!0}createDefaultGeometry(){return new Float32Array([-1,1,0,0,1,-1,-1,0,0,0,1,1,0,1,1,1,-1,0,1,0])}createVertexbuffer(){let e=this.gl,n=e.createBuffer();if(!n)throw new Error("createBuffer() returned null");let a=this.createDefaultGeometry();return e.bindBuffer(e.ARRAY_BUFFER,n),e.bufferData(e.ARRAY_BUFFER,a,e.STATIC_DRAW),this.checkError(),n}createFramebuffer(){let e=this.gl.createFramebuffer();if(!e)throw new Error("createFramebuffer returned null");return e}queryVitalParameters(){let e=this.gl;if(this.isFloatTextureAttachableToFrameBuffer=this.checkFloatTextureAttachableToFrameBuffer(),this.isRenderFloat32Supported=this.checkRenderFloat32(),this.isFloat32DownloadSupported=this.checkFloat32Download(),this.version===1&&!this.textureHalfFloatExtension&&!this.isRenderFloat32Supported)throw new Error("both float32 and float16 TextureType are not supported");this.isBlendSupported=!this.isRenderFloat32Supported||this.checkFloat32Blend(),this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),this.maxTextureImageUnits=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),this.version}getExtensions(){this.version===2?(this.colorBufferFloatExtension=this.gl.getExtension("EXT_color_buffer_float"),this.disjointTimerQueryWebgl2Extension=this.gl.getExtension("EXT_disjoint_timer_query_webgl2")):(this.textureFloatExtension=this.gl.getExtension("OES_texture_float"),this.textureHalfFloatExtension=this.gl.getExtension("OES_texture_half_float"))}checkFloatTextureAttachableToFrameBuffer(){let e=this.gl,n=e.createTexture();e.bindTexture(e.TEXTURE_2D,n);let a=this.version===2?e.RGBA32F:e.RGBA;e.texImage2D(e.TEXTURE_2D,0,a,1,1,0,e.RGBA,e.FLOAT,null);let i=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,i),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,n,0);let p=e.checkFramebufferStatus(e.FRAMEBUFFER)===e.FRAMEBUFFER_COMPLETE;return e.bindTexture(e.TEXTURE_2D,null),e.bindFramebuffer(e.FRAMEBUFFER,null),e.deleteTexture(n),e.deleteFramebuffer(i),p}checkRenderFloat32(){if(this.version===2){if(!this.colorBufferFloatExtension)return!1}else if(!this.textureFloatExtension)return!1;return this.isFloatTextureAttachableToFrameBuffer}checkFloat32Download(){if(this.version===2){if(!this.colorBufferFloatExtension)return!1}else if(!this.textureFloatExtension||!this.gl.getExtension("WEBGL_color_buffer_float"))return!1;return this.isFloatTextureAttachableToFrameBuffer}checkFloat32Blend(){let e=this.gl,n,a,i,p,o;try{n=e.createTexture(),a=e.createFramebuffer(),e.bindTexture(e.TEXTURE_2D,n);let s=this.version===2?e.RGBA32F:e.RGBA;return e.texImage2D(e.TEXTURE_2D,0,s,1,1,0,e.RGBA,e.FLOAT,null),e.bindFramebuffer(e.FRAMEBUFFER,a),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,n,0),e.enable(e.BLEND),i=e.createShader(e.VERTEX_SHADER),!i||(e.shaderSource(i,"void main(){}"),e.compileShader(i),p=e.createShader(e.FRAGMENT_SHADER),!p)||(e.shaderSource(p,"precision highp float;void main(){gl_FragColor=vec4(0.5);}"),e.compileShader(p),o=e.createProgram(),!o)?!1:(e.attachShader(o,i),e.attachShader(o,p),e.linkProgram(o),e.useProgram(o),e.drawArrays(e.POINTS,0,1),e.getError()===e.NO_ERROR)}finally{e.disable(e.BLEND),o&&e.deleteProgram(o),i&&e.deleteShader(i),p&&e.deleteShader(p),a&&(e.bindFramebuffer(e.FRAMEBUFFER,null),e.deleteFramebuffer(a)),n&&(e.bindTexture(e.TEXTURE_2D,null),e.deleteTexture(n))}}beginTimer(){if(this.version===2&&this.disjointTimerQueryWebgl2Extension){let e=this.gl,n=this.disjointTimerQueryWebgl2Extension,a=e.createQuery();return e.beginQuery(n.TIME_ELAPSED_EXT,a),a}else throw new Error("WebGL1 profiling currently not supported.")}endTimer(){if(this.version===2&&this.disjointTimerQueryWebgl2Extension){let e=this.gl,n=this.disjointTimerQueryWebgl2Extension;e.endQuery(n.TIME_ELAPSED_EXT);return}else throw new Error("WebGL1 profiling currently not supported")}isTimerResultAvailable(e){let n=!1,a=!1;if(this.version===2&&this.disjointTimerQueryWebgl2Extension){let i=this.gl,p=this.disjointTimerQueryWebgl2Extension;n=i.getQueryParameter(e,i.QUERY_RESULT_AVAILABLE),a=i.getParameter(p.GPU_DISJOINT_EXT)}else throw new Error("WebGL1 profiling currently not supported");return n&&!a}getTimerResult(e){let n=0;if(this.version===2){let a=this.gl;n=a.getQueryParameter(e,a.QUERY_RESULT),a.deleteQuery(e)}else throw new Error("WebGL1 profiling currently not supported");return n/1e6}async waitForQueryAndGetTime(e){return await li(()=>this.isTimerResultAvailable(e)),this.getTimerResult(e)}async createAndWaitForFence(){let e=this.createFence(this.gl);return this.pollFence(e)}createFence(e){let n,a=e,i=a.fenceSync(a.SYNC_GPU_COMMANDS_COMPLETE,0);return e.flush(),i===null?n=()=>!0:n=()=>{let p=a.clientWaitSync(i,0,0);return p===a.ALREADY_SIGNALED||p===a.CONDITION_SATISFIED},{query:i,isFencePassed:n}}async pollFence(e){return new Promise(n=>{this.addItemToPoll(()=>e.isFencePassed(),()=>n())})}pollItems(){let e=bg(this.itemsToPoll.map(n=>n.isDoneFn));for(let n=0;n<=e;++n){let{resolveFn:a}=this.itemsToPoll[n];a()}this.itemsToPoll=this.itemsToPoll.slice(e+1)}async addItemToPoll(e,n){this.itemsToPoll.push({isDoneFn:e,resolveFn:n}),!(this.itemsToPoll.length>1)&&await li(()=>(this.pollItems(),this.itemsToPoll.length===0))}}});function Gi(e){let n;if((!e||e==="webgl2")&&"webgl2"in mr?n=mr.webgl2:(!e||e==="webgl")&&"webgl"in mr&&(n=mr.webgl),!n)try{let i=yg();n=vp(i,e)}catch{let i=gg();n=vp(i,e)}e=e||n.version===1?"webgl":"webgl2";let a=n.gl;return mr[e]=n,a.isContextLost()?(delete mr[e],Gi(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),n)}function vp(e,n){let a={alpha:!1,depth:!1,antialias:!1,stencil:!1,preserveDrawingBuffer:!1,premultipliedAlpha:!1,failIfMajorPerformanceCaveat:!1},i,p=a;if((!n||n==="webgl2")&&(i=e.getContext("webgl2",p),i))try{return new Mr(i,2)}catch(o){tt.warning("GlContextFactory",`failed to create WebGLContext using contextId 'webgl2'. Error: ${o}`)}if((!n||n==="webgl")&&(i=e.getContext("webgl",p)||e.getContext("experimental-webgl",p),i))try{return new Mr(i,1)}catch(o){tt.warning("GlContextFactory",`failed to create WebGLContext using contextId 'webgl' or 'experimental-webgl'. Error: ${o}`)}throw new Error("WebGL is not supported")}function gg(){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 yg(){if(typeof OffscreenCanvas>"u")throw new TypeError("failed to create offscreen canvas: OffscreenCanvas is not supported");return new OffscreenCanvas(1,1)}var mr,Ip=O(()=>{Ut(),wp(),mr={}}),Yn,_p=O(()=>{Yt(),Ut(),Tp(),Ip(),Yn=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=Gi(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),tt.setWithEnv(z),z.webgl.context||Object.defineProperty(z.webgl,"context",{value:this.glContext.gl}),tt.verbose("WebGLBackend",`Created WebGLContext: ${typeof this.glContext} with matmulMaxBatchSize: ${this.matmulMaxBatchSize}; textureCacheMode: ${this.textureCacheMode}; pack: ${this.pack}; async: ${this.async}.`),!0}catch(e){return tt.warning("WebGLBackend",`Unable to initialize WebGLBackend. ${e}`),!1}}createSessionHandler(e){return new Jn(this,e)}dispose(){this.glContext.dispose()}}});async function Mi(e){if(e){let n=typeof e=="string"?[e]:e;for(let a of n){let i=Op.get(a);if(i)return i;let p=await Tg(a);if(p)return p}}else return Mi(["webgl"]);throw new Error("no available backend to use")}async function Tg(e){let n=xg;if(typeof n[e]<"u"&&wg(n[e])){let a=n[e],i=a.initialize();if(typeof i=="object"&&"then"in i&&(i=await i),i)return Op.set(e,a),a}}function wg(e){let n=e;return"initialize"in n&&typeof n.initialize=="function"&&"createSessionHandler"in n&&typeof n.createSessionHandler=="function"&&"dispose"in n&&typeof n.dispose=="function"}var Op,xg,Sp=O(()=>{_p(),Op=new Map,xg={webgl:new Yn}}),Ui,Zn,Ap=O(()=>{Ut(),Ui=class{constructor(e,n){this.op=e,this.node=n}},Zn=class{constructor(e,n,a){this.graph=e,this.profiler=a,this.initialize(n)}initialize(e){this.profiler.event("session","ExecutionPlan.initialize",()=>{let n=this.graph.getNodes();if(n.length!==e.length)throw new Error("The size of nodes and OPs do not match.");this._ops=e.map((a,i)=>new Ui(a,n[i])),this.reset(),this._starter=[],this._ops.forEach((a,i)=>{let p=!0;for(let o of a.node.inputs)if(!this._values[o]&&this.graph.getInputIndices().indexOf(o)===-1){p=!1;break}p&&this._starter.push(i)})})}reset(){this._values=this.graph.getValues().map(e=>e.tensor)}async execute(e,n){return this.profiler.event("session","ExecutionPlan.execute",async()=>{this.reset();let a=e.createInferenceHandler(),i=this.graph.getInputIndices();if(n.length!==i.length)throw new Error(`number of input tensors don't match the number of inputs to the model: actual: ${n.length} expected: ${i.length}`);n.forEach((r,u)=>{let l=i[u];this._values[l]=r});let p=this._starter.slice(0),o=this.graph.getValues(),s=this.graph.getNodes(),c=0;for(;c<p.length;){let r=p[c++],u=this._ops[r],l=u.node.inputs.map(v=>this._values[v]);if(l.indexOf(void 0)!==-1)throw new Error(`unresolved input detected: op: ${u.node}`);let f=l;tt.verbose("ExecPlan",`Running op:${u.node.name} (${f.map((v,S)=>`'${u.node.inputs[S]}': ${v.type}[${v.dims.join(",")}]`).join(", ")})`);let g=await this.profiler.event("node",u.node.name,async()=>u.op.impl(a,f,u.op.context));if(g.length!==u.node.outputs.length)throw new Error("the size of output does not match model definition.");g.forEach((v,S)=>{let P=u.node.outputs[S];if(this._values[P])throw new Error(`output [${P}] already has value: op:${u.node.name}`);this._values[P]=v});let b=new Set;g.forEach((v,S)=>{let P=u.node.outputs[S];for(let _ of o[P].to){let A=s[_],L=!0;for(let V of A.inputs)if(!this._values[V]){L=!1;break}L&&b.add(_)}}),p.push(...b)}let h=[];for(let r=0;r<this.graph.getOutputIndices().length;r++){let u=this.graph.getOutputIndices()[r],l=this._values[u];if(l===void 0)throw new Error(`required output [${u}] does not have value`);u===0?await l.getData():l.data,h.push(l)}return tt.verbose("ExecPlan","disposing of inferenceHandler"),a.dispose(),h})}}}),q,Xt,Ur,Pp=O(()=>{Pr(),q=rr(sr()),We(),Y(),Xt=F.experimental.fbs,Ur=class Ae{constructor(n){if(this._attributes=new Map,n!=null){for(let a of n)a instanceof q.onnx.AttributeProto?this._attributes.set(a.name,[Ae.getValue(a),Ae.getType(a)]):a instanceof Xt.Attribute&&this._attributes.set(a.name(),[Ae.getValue(a),Ae.getType(a)]);if(this._attributes.size<n.length)throw new Error("duplicated attribute names")}}set(n,a,i){this._attributes.set(n,[i,a])}delete(n){this._attributes.delete(n)}getFloat(n,a){return this.get(n,"float",a)}getInt(n,a){return this.get(n,"int",a)}getString(n,a){return this.get(n,"string",a)}getTensor(n,a){return this.get(n,"tensor",a)}getFloats(n,a){return this.get(n,"floats",a)}getInts(n,a){return this.get(n,"ints",a)}getStrings(n,a){return this.get(n,"strings",a)}getTensors(n,a){return this.get(n,"tensors",a)}get(n,a,i){let p=this._attributes.get(n);if(p===void 0){if(i!==void 0)return i;throw new Error(`required attribute not found: ${n}`)}if(p[1]!==a)throw new Error(`type mismatch: expected ${a} but got ${p[1]}`);return p[0]}static getType(n){let a=n instanceof q.onnx.AttributeProto?n.type:n.type();switch(a){case q.onnx.AttributeProto.AttributeType.FLOAT:return"float";case q.onnx.AttributeProto.AttributeType.INT:return"int";case q.onnx.AttributeProto.AttributeType.STRING:return"string";case q.onnx.AttributeProto.AttributeType.TENSOR:return"tensor";case q.onnx.AttributeProto.AttributeType.FLOATS:return"floats";case q.onnx.AttributeProto.AttributeType.INTS:return"ints";case q.onnx.AttributeProto.AttributeType.STRINGS:return"strings";case q.onnx.AttributeProto.AttributeType.TENSORS:return"tensors";default:throw new Error(`attribute type is not supported yet: ${q.onnx.AttributeProto.AttributeType[a]}`)}}static getValue(n){let a=n instanceof q.onnx.AttributeProto?n.type:n.type();if(a===q.onnx.AttributeProto.AttributeType.GRAPH||a===q.onnx.AttributeProto.AttributeType.GRAPHS)throw new Error("graph attribute is not supported yet");let i=this.getValueNoCheck(n);if(a===q.onnx.AttributeProto.AttributeType.INT&&Rt.isLong(i))return Rt.longToNumber(i);if(a===q.onnx.AttributeProto.AttributeType.INTS){let p=i,o=new Array(p.length);for(let s=0;s<p.length;s++){let c=p[s];o[s]=Rt.longToNumber(c)}return o}if(a===q.onnx.AttributeProto.AttributeType.TENSOR)return n instanceof q.onnx.AttributeProto?bt.fromProto(i):bt.fromOrtTensor(i);if(a===q.onnx.AttributeProto.AttributeType.TENSORS){if(n instanceof q.onnx.AttributeProto)return i.map(p=>bt.fromProto(p));if(n instanceof Xt.Attribute)return i.map(p=>bt.fromOrtTensor(p))}return a===q.onnx.AttributeProto.AttributeType.STRING&&n instanceof q.onnx.AttributeProto?kr(i):a===q.onnx.AttributeProto.AttributeType.STRINGS&&n instanceof q.onnx.AttributeProto?i.map(kr):i}static getValueNoCheck(n){return n instanceof q.onnx.AttributeProto?this.getValueNoCheckFromOnnxFormat(n):this.getValueNoCheckFromOrtFormat(n)}static getValueNoCheckFromOnnxFormat(n){switch(n.type){case q.onnx.AttributeProto.AttributeType.FLOAT:return n.f;case q.onnx.AttributeProto.AttributeType.INT:return n.i;case q.onnx.AttributeProto.AttributeType.STRING:return n.s;case q.onnx.AttributeProto.AttributeType.TENSOR:return n.t;case q.onnx.AttributeProto.AttributeType.GRAPH:return n.g;case q.onnx.AttributeProto.AttributeType.FLOATS:return n.floats;case q.onnx.AttributeProto.AttributeType.INTS:return n.ints;case q.onnx.AttributeProto.AttributeType.STRINGS:return n.strings;case q.onnx.AttributeProto.AttributeType.TENSORS:return n.tensors;case q.onnx.AttributeProto.AttributeType.GRAPHS:return n.graphs;default:throw new Error(`unsupported attribute type: ${q.onnx.AttributeProto.AttributeType[n.type]}`)}}static getValueNoCheckFromOrtFormat(n){switch(n.type()){case Xt.AttributeType.FLOAT:return n.f();case Xt.AttributeType.INT:return n.i();case Xt.AttributeType.STRING:return n.s();case Xt.AttributeType.TENSOR:return n.t();case Xt.AttributeType.GRAPH:return n.g();case Xt.AttributeType.FLOATS:return n.floatsArray();case Xt.AttributeType.INTS:{let a=[];for(let i=0;i<n.intsLength();i++)a.push(n.ints(i));return a}case Xt.AttributeType.STRINGS:{let a=[];for(let i=0;i<n.stringsLength();i++)a.push(n.strings(i));return a}case Xt.AttributeType.TENSORS:{let a=[];for(let i=0;i<n.tensorsLength();i++)a.push(n.tensors(i));return a}default:throw new Error(`unsupported attribute type: ${Xt.AttributeType[n.type()]}`)}}}}),zi,Qn,Wi,me,to,Vi,Ep=O(()=>{Pp(),Pr(),zi=rr(sr()),We(),Y(),Qn=F.experimental.fbs,Wi={from:(e,n)=>new Vi(e,n)},me=class{constructor(e){this._from=void 0,this._to=[],this.tensor=void 0,this.type=void 0,e&&(this.type=At.tensorValueTypeFromProto(e.type.tensorType))}get from(){return this._from}get to(){return this._to}},to=class{constructor(e,n){e instanceof zi.onnx.NodeProto?(this.name=e.name,this.opType=e.opType,this.attributes=new Ur(e.attribute)):e instanceof Qn.Node&&(this.name=n??e.name(),this.opType=e.opType(),this.attributes=new Ur(At.tensorAttributesFromORTFormat(e))),this.inputs=[],this.outputs=[],this.executeNode=!0}},Vi=class{constructor(e,n){if(!e)throw new TypeError("graph is empty");this.buildGraph(e),this.transformGraph(n),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 zi.onnx.GraphProto)this.buildGraphFromOnnxFormat(e);else if(e instanceof Qn.Graph)this.buildGraphFromOrtFormat(e);else throw new TypeError("Graph type is not supported.")}buildGraphFromOnnxFormat(e){let n=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 p of e.input){if(n.has(p.name))throw new Error(`duplicated input name: ${p.name}`);let o=this._allData.push(new me(p))-1;n.set(p.name,o),i.push(p.name)}if(!e.initializer)throw new Error("missing information in graph: initializer");for(let p of e.initializer){let o=n.get(p.name);if(o===void 0){let s=new me;s.type={shape:{dims:At.tensorDimsFromProto(p.dims)},tensorType:At.tensorDataTypeFromProto(p.dataType)},o=this._allData.push(s)-1,n.set(p.name,o)}this._allData[o]._from=-1,this._allData[o].tensor=bt.fromProto(p)}for(let p=0;p<this._allData.length;p++)this._allData[p].tensor||(this._allInputIndices.push(p),this._allInputNames.push(i[p]));if(!e.output)throw new Error("missing information in graph: output");for(let p of e.output){if(n.has(p.name))throw new Error(`duplicated output name: ${p.name}`);let o=this._allData.push(new me(p))-1;n.set(p.name,o),this._allOutputIndices.push(o),this._allOutputNames.push(p.name)}if(!e.node)throw new Error("missing information in graph: node");for(let p of e.node){if(!p.name)for(let s=0;;s++){let c=`unnamed_${p.opType}_${s}`;if(!a.has(c)){p.name=c;break}}if(a.has(p.name))throw new Error(`duplicated node name: ${p.name}`);let o=this._nodes.push(new to(p))-1;a.set(p.name,o)}for(let p=0;p<this._nodes.length;p++){let o=this._nodes[p],s=e.node[p];if(!s.output)throw new Error(`missing output for node: ${s.name}`);for(let c of s.output){let h=n.get(c);if(typeof h>"u"&&(h=this._allData.push(new me)-1,n.set(c,h)),o.outputs.push(h),this._allData[h]._from!==void 0)throw new Error(`multiple nodes output to one data value: ${h}`);if(this._allData[h]._from=p,s.opType==="Constant"){if(!s.attribute||s.attribute.length!==1||!s.attribute[0].t)throw new Error("missing attributes or missing tensor value in attributes for this Constant operator");if(!s.output||s.output.length!==1)throw new Error("missing output or incorrect number of outputs for this Constant operator");o.outputs.pop(),o.executeNode=!1,this._allData[h]._from=-1,this._allData[h].tensor=bt.fromProto(s.attribute[0].t)}}}for(let p=0;p<this._nodes.length;p++){let o=this._nodes[p],s=e.node[p];if(!s.input)throw new Error(`missing input for node: ${s.name}`);for(let c of s.input){let h=n.get(c);if(typeof h>"u"){if(c===""&&(s.input.length===3||s.input.length===4)&&s.opType==="Resize")continue;throw new Error(`unrecognized input '${c}' for node: ${s.name}`)}o.inputs.push(h),this._allData[h]._to.push(p)}}return!0}buildGraphFromOrtFormat(e){var p,o,s;let n=new Map;this._allData=[],this._allInputIndices=[],this._allInputNames=[],this._allOutputIndices=[],this._allOutputNames=[],this._nodes=[];let a=new Map,i=[];for(let c=0;c<e.inputsLength();c++){let h=e.inputs(c);if(n.has(h))throw new Error(`duplicated input name: ${h}`);for(let r=0;r<e.nodeArgsLength();r++)if(((p=e.nodeArgs(r))==null?void 0:p.name())===h){let u=new me;if(((s=(o=e.nodeArgs(r))==null?void 0:o.type())==null?void 0:s.valueType())!==Qn.TypeInfoValue.tensor_type)throw new Error("Unexpected value type for the nodeArg.");let l=e.nodeArgs(r).type().value(new Qn.TensorTypeAndShape),f=At.tensorDataTypeFromProto(l.elemType()),g=l.shape(),b=[];for(let S=0;S<g.dimLength();S++)b.push(Rt.longToNumber(g.dim(S).value().dimValue()));u.type={shape:{dims:b},tensorType:f};let v=this._allData.push(u)-1;n.set(h,v),i.push(h)}}for(let c=0;c<e.initializersLength();c++){let h=e.initializers(c),r=n.get(h.name());if(r===void 0){let u=new me,l=At.tensorDimsFromORTFormat(h),f=At.tensorDataTypeFromProto(h.dataType());u.type={shape:{dims:l},tensorType:f},r=this._allData.push(u)-1,n.set(h.name(),r)}this._allData[r]._from=-1,this._allData[r].tensor=bt.fromOrtTensor(h)}for(let c=0;c<this._allData.length;c++)this._allData[c].tensor||(this._allInputIndices.push(c),this._allInputNames.push(i[c]));for(let c=0;c<e.outputsLength();c++){let h=e.outputs(c);if(n.has(h))throw new Error(`duplicated output name: ${h}`);let r=this._allData.push(new me)-1;n.set(h,r),this._allOutputIndices.push(r),this._allOutputNames.push(h)}if(!e.nodes)throw new Error("missing information in graph: node");for(let c=0;c<e.nodesLength();c++){let h=e.nodes(c),r=h.name();if(!r)for(let l=0;r=`unnamed_${h.opType()}_${l}`,!!a.has(r);l++);if(a.has(r))throw new Error(`duplicated node name: ${r}`);let u=this._nodes.push(new to(h,r))-1;a.set(r,u)}for(let c=0;c<this._nodes.length;c++){let h=this._nodes[c],r=e.nodes(c);if(r==null)throw new Error(`No node exists at index ${c}`);if((r==null?void 0:r.outputsLength())===0)throw new Error(`missing output for node: ${r.name}`);for(let u=0;u<(r==null?void 0:r.outputsLength());u++){let l=r==null?void 0:r.outputs(u),f=n.get(l);if(typeof f>"u"&&(f=this._allData.push(new me)-1,n.set(l,f)),h.outputs.push(f),this._allData[f]._from!==void 0)throw new Error(`multiple nodes output to one data value: ${f}`);if(this._allData[f]._from=c,r.opType()==="Constant"){if(r.attributesLength()!==1||!r.attributes(0).t())throw new Error("missing attributes or missing tensor value in attributes for this Constant operator");if(r.outputsLength()!==1)throw new Error("missing output or incorrect number of outputs for this Constant operator");h.outputs.pop(),h.executeNode=!1,this._allData[f]._from=-1,this._allData[f].tensor=bt.fromOrtTensor(r.attributes(0).t())}}}for(let c=0;c<this._nodes.length;c++){let h=this._nodes[c],r=e.nodes(c);if(r.inputsLength()===0)throw new Error(`missing input for node: ${r.name}`);for(let u=0;u<r.inputsLength();u++){let l=r.inputs(u),f=n.get(l);if(typeof f>"u")throw new Error(`unrecognized input '${l}' for node: ${r.name()}`);h.inputs.push(f),this._allData[f]._to.push(c)}}}checkIsAcyclic(){let e=new Set;this._allInputIndices.forEach(i=>{this._allData[i]._to.forEach(p=>{e.add(p)})});let n=Array.from(e),a=new Array(this._nodes.length).fill("white");for(;n.length>0;){let i=n.pop();a[i]==="gray"?a[i]="black":(n.push(i),a[i]="gray",this._nodes[i].outputs.forEach(p=>{let o=this._allData[p];if(typeof o.tensor<"u")throw new Error("node outputs should not be initialized");if(o._from!==i)throw new Error("from property of the Value object doesn't match index of Node being processed");o._to.forEach(s=>{if(a[s]==="gray")throw new Error("model graph is cyclic");a[s]==="white"&&n.push(s)})}))}}transformGraph(e){this.removeAllIdentityNodes(),this.removeAllDropoutNodes(),this.fuseConvActivationNodes(),e&&e.transformGraph(this),this.finalizeGraph()}finalizeGraph(){let e=0,n=new Array(this._nodes.length,0),a=0;for(let i=0;i<this._nodes.length;i++)n[i]=a,this._nodes[i].executeNode?(a!==i&&(this._nodes[a]=this._nodes[i]),a++):this._nodes[i].outputs.forEach(p=>{this._allData[p]._from=-2});this._nodes.splice(a,this._nodes.length-a);for(let i=0;i<this._allData.length;i++){let p=this._allData[i];p._from!==void 0&&p._from!==-1&&p._from!==-2&&(p._from=n[p._from]);for(let o=0;o<p._to.length;o++)if(p._to[o]>=0)p._to[o]=n[p._to[o]];else throw new Error("Trying to update a removed node")}e=0;for(let i=0;i<this._allData.length;i++){if(this._allData[i].from===-2&&this._allOutputIndices.indexOf(i+e)===-1){e++,this._allData.splice(i,1),i--;continue}if(e>0){let p=-1;this._allData[i].from!==void 0&&this._allData[i].from!==-1?(p=this._nodes[this._allData[i].from].outputs.indexOf(i+e),p!==-1&&(this._nodes[this._allData[i].from].outputs[p]=i)):(p=this._allInputIndices.indexOf(i+e),p!==-1&&(this._allInputIndices[p]=i)),this._allData[i].to.forEach(o=>{p=this._nodes[o].inputs.indexOf(i+e),p!==-1&&(this._nodes[o].inputs[p]=i)}),this._allData[i].to.length===0&&(p=this._allOutputIndices.indexOf(i+e),p!==-1&&(this._allOutputIndices[p]=i))}}}deleteNode(e){let n=this._nodes[e];if(n.outputs.length>1){for(let s=1;s<n.outputs.length;s++)if(this._allData[n.outputs[s]].to.length>0)throw new Error("Node deletion with more than one output connected to other nodes is not supported. ")}n.executeNode=!1;let a=n.inputs[0],i=n.outputs[0],p=this._allData[i].to;for(let s=0;s<n.inputs.length;s++){let c=this._allData[n.inputs[s]].to.indexOf(e);if(c===-1)throw new Error("The Value object doesn't have the current Node in it's 'to' property ");this._allData[n.inputs[s]].to.splice(c,1)}this._allData[i]._to=[];let o=this._allOutputIndices.indexOf(i);if(o!==-1&&(this._allOutputIndices[o]=a),p&&p.length>0)for(let s of p){let c=this._nodes[s].inputs.indexOf(i);if(c===-1)throw new Error("The Node object doesn't have the output Value in it's 'inputs' property ");this._nodes[s].inputs[c]=a,this._allData[a].to.push(s)}}removeAllDropoutNodes(){let e=0;for(let n of this._nodes){if(n.opType==="Dropout"){if(n.inputs.length!==1)throw new Error("Dropout nodes should only contain one input. ");if(n.outputs.length!==1&&n.outputs.length!==2)throw new Error("Dropout nodes should contain either 1 or 2 output(s)");if(n.outputs.length===2&&this._allData[n.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 n of this._nodes)n.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 n=this._allData[e.outputs[0]]._to;if(n.length===1&&this.isActivation(this._nodes[n[0]])){let a=this._nodes[n[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",[Ve,ze])}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(n[0])}}}}}),Dp,vg,eo,Lp=O(()=>{wn(),Ep(),Pr(),Dp=rr(sr()),Y(),vg=F.experimental.fbs,eo=class{constructor(){}load(e,n,a){let i;if(!a)try{this.loadFromOnnxFormat(e,n);return}catch(p){if(a!==void 0)throw p;i=p}try{this.loadFromOrtFormat(e,n)}catch(p){throw a!==void 0?p:new Error(`Failed to load model as ONNX format: ${i}
1806
+ as ORT format: ${p}`)}}loadFromOnnxFormat(e,n){let a=Dp.onnx.ModelProto.decode(e);if(Rt.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:Rt.longToNumber(i.version)})),this._graph=Wi.from(a.graph,n)}loadFromOrtFormat(e,n){let a=new w.ByteBuffer(e),i=vg.InferenceSession.getRootAsInferenceSession(a).model();if(Rt.longToNumber(i.irVersion())<3)throw new Error("only support ONNX model with IR_VERSION>=3");this._opsets=[];for(let p=0;p<i.opsetImportLength();p++){let o=i.opsetImport(p);this._opsets.push({domain:o==null?void 0:o.domain(),version:Rt.longToNumber(o.version())})}this._graph=Wi.from(i.graph(),n)}get graph(){return this._graph}get opsets(){return this._opsets}}}),ro,$p=O(()=>{Sp(),Ap(),Ut(),Lp(),ro=class{constructor(e={}){this._initialized=!1,this.backendHint=e.backendHint,this.profiler=xn.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,n,a){await this.profiler.event("session","Session.loadModel",async()=>{let i=await Mi(this.backendHint);if(this.sessionHandler=i.createSessionHandler(this.context),this._model=new eo,typeof e=="string"){let p=e.endsWith(".ort");{let o=await(await fetch(e)).arrayBuffer();this.initialize(new Uint8Array(o),p)}}else if(ArrayBuffer.isView(e))this.initialize(e);else{let p=new Uint8Array(e,n||0,a||e.byteLength);this.initialize(p)}})}initialize(e,n){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,n),this.sessionHandler.onGraphInitialized&&this.sessionHandler.onGraphInitialized(this._model.graph),this.initializeOps(this._model.graph),this._executionPlan=new Zn(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 n=this.normalizeAndValidateInputs(e),a=await this._executionPlan.execute(this.sessionHandler,n);return this.createOutput(a)})}normalizeAndValidateInputs(e){let n=this._model.graph.getInputNames();if(Array.isArray(e)){if(e.length!==n.length)throw new Error(`incorrect input array length: expected ${n.length} but got ${e.length}`)}else{if(e.size!==n.length)throw new Error(`incorrect input map size: expected ${n.length} but got ${e.size}`);let a=new Array(e.size),i=0;for(let p=0;p<n.length;++p){let o=e.get(n[p]);if(!o)throw new Error(`missing input tensor for: '${name}'`);a[i++]=o}e=a}if(!this.context.graphInputTypes||this.context.graphInputTypes.length===0||!this.context.graphInputDims||this.context.graphInputDims.length===0){let a=this._model.graph.getInputIndices(),i=this._model.graph.getValues(),p=new Array(a.length);for(let o=0;o<a.length;++o){let s=i[a[o]];p[o]=s.type.shape.dims,this.context.graphInputTypes.push(s.type.tensorType),this.context.graphInputDims.push(e[o].dims)}this.validateInputTensorDims(p,e,!0)}else this.validateInputTensorDims(this.context.graphInputDims,e,!1);return this.validateInputTensorTypes(this.context.graphInputTypes,e),e}validateInputTensorTypes(e,n){for(let a=0;a<n.length;a++){let i=e[a],p=n[a].type;if(i!==p)throw new Error(`input tensor[${a}] check failed: expected type '${i}' but got ${p}`)}}validateInputTensorDims(e,n,a){for(let i=0;i<n.length;i++){let p=e[i],o=n[i].dims;if(!this.compareTensorDims(p,o,a))throw new Error(`input tensor[${i}] check failed: expected shape '[${p.join(",")}]' but got [${o.join(",")}]`)}}compareTensorDims(e,n,a){if(e.length!==n.length)return!1;for(let i=0;i<e.length;++i)if(e[i]!==n[i]&&(!a||e[i]!==0))return!1;return!0}createOutput(e){let n=this._model.graph.getOutputNames();if(e.length!==n.length)throw new Error("expected number of outputs do not match number of generated outputs");let a=new Map;for(let i=0;i<n.length;++i)a.set(n[i],e[i]);return a}initializeOps(e){let n=e.getNodes();this._ops=new Array(n.length);for(let a=0;a<n.length;a++)this._ops[a]=this.sessionHandler.resolve(n[a],this._model.opsets,e)}}}),no,kp=O(()=>{Yt(),We(),no=class{constructor(e){this.session=e,this.inputNames=this.session.inputNames,this.outputNames=this.session.outputNames}async dispose(){}async run(e,n,a){let i=new Map;for(let s in e)if(Object.hasOwnProperty.call(e,s)){let c=e[s];i.set(s,new bt(c.dims,c.type,void 0,void 0,c.data))}let p=await this.session.run(i),o={};return p.forEach((s,c)=>{o[c]=new yt(s.type,s.data,s.dims)}),o}startProfiling(){this.session.startProfiling()}endProfiling(){this.session.endProfiling()}}}),Bp={};Or(Bp,{onnxjsBackend:()=>Ig});var Hi,Ig,Fp=O(()=>{$p(),kp(),Hi=class{async init(){}async createInferenceSessionHandler(e,n){let a=new ro(n);return typeof e=="string"?await a.loadModel(e):await a.loadModel(e),new no(a)}},Ig=new Hi}),oo=O(()=>{}),Rp={};Or(Rp,{default:()=>_g});var Cp,Np,_g,Gp=O(()=>{var e;qi(),Ke(),Vr(),Cp="ort-wasm-proxy-worker",Np=((e=globalThis.self)==null?void 0:e.name)===Cp,Np&&(self.onmessage=n=>{let{type:a,in:i}=n.data;try{switch(a){case"init-wasm":io(i.wasm).then(()=>{ao(i).then(()=>{postMessage({type:a})},p=>{postMessage({type:a,err:p})})},p=>{postMessage({type:a,err:p})});break;case"init-ep":{let{epName:p,env:o}=i;so(o,p).then(()=>{postMessage({type:a})},s=>{postMessage({type:a,err:s})});break}case"copy-from":{let{buffer:p}=i,o=zr(p);postMessage({type:a,out:o});break}case"create":{let{model:p,options:o}=i;uo(p,o).then(s=>{postMessage({type:a,out:s})},s=>{postMessage({type:a,err:s})});break}case"release":lo(i),postMessage({type:a});break;case"run":{let{sessionId:p,inputIndices:o,inputs:s,outputIndices:c,options:h}=i;fo(p,o,s,c,new Array(c.length).fill(null),h).then(r=>{r.some(u=>u[3]!=="cpu")?postMessage({type:a,err:"Proxy does not support non-cpu tensor location."}):postMessage({type:a,out:r},po([...s,...r]))},r=>{postMessage({type:a,err:r})});break}case"end-profiling":co(i),postMessage({type:a});break;default:}}catch(p){postMessage({type:a,err:p})}}),_g=Np?null:n=>new Worker(n??br,{type:"module",name:Cp})}),Up={};Or(Up,{default:()=>Og});var ji,Mp,Og,Vp=O(()=>{var e;Mp=(ji=_documentCurrentScript&&_documentCurrentScript.tagName.toUpperCase()==="SCRIPT"&&_documentCurrentScript.src||new URL("segmentation.js",document.baseURI).href,async function(n={}){function a(){return gt.buffer!=wt.buffer&&at(),wt}function i(){return gt.buffer!=wt.buffer&&at(),X}function p(){return gt.buffer!=wt.buffer&&at(),Wt}function o(){return gt.buffer!=wt.buffer&&at(),Le}function s(){return gt.buffer!=wt.buffer&&at(),se}var c,h,r=Object.assign({},n),u=new Promise((m,y)=>{c=m,h=y}),l=typeof window=="object",f=typeof importScripts=="function",g=f&&self.name=="em-pthread";r.mountExternalData=(m,y)=>{m.startsWith("./")&&(m=m.substring(2)),(r.Ua||(r.Ua=new Map)).set(m,y)},r.unmountExternalData=()=>{delete r.Ua};var b,v,S=globalThis.SharedArrayBuffer??new WebAssembly.Memory({initial:0,maximum:0,shared:!0}).buffer.constructor,P=Object.assign({},r),_="./this.program",A=(m,y)=>{throw y},L="";(l||f)&&(f?L=self.location.href:typeof document<"u"&&document.currentScript&&(L=document.currentScript.src),ji&&(L=ji),L=L.startsWith("blob:")?"":L.substr(0,L.replace(/[?#].*/,"").lastIndexOf("/")+1),f&&(v=m=>{var y=new XMLHttpRequest;return y.open("GET",m,!1),y.responseType="arraybuffer",y.send(null),new Uint8Array(y.response)}),b=(m,y,x)=>{var E=new XMLHttpRequest;E.open("GET",m,!0),E.responseType="arraybuffer",E.onload=()=>{E.status==200||E.status==0&&E.response?y(E.response):x()},E.onerror=x,E.send(null)});var V,ft=console.log.bind(console),lt=console.error.bind(console),Nt=ft,Q=lt;if(Object.assign(r,P),P=null,g){let m=function(y){try{var x=y.data,E=x.cmd;if(E==="load"){let I=[];self.onmessage=N=>I.push(N),self.startWorker=()=>{postMessage({cmd:"loaded"});for(let N of I)m(N);self.onmessage=m};for(let N of x.handlers)r[N]&&!r[N].proxy||(r[N]=(...R)=>{postMessage({Za:"callHandler",kb:N,args:R})},N=="print"&&(Nt=r[N]),N=="printErr"&&(Q=r[N]));gt=x.wasmMemory,at(),Pt(x.wasmModule)}else if(E==="run"){Zr(x.pthread_ptr,0,0,1,0,0),Dr(x.pthread_ptr),Pa(),Oo(),$e||($e=!0);try{Aa(x.start_routine,x.arg)}catch(I){if(I!="unwind")throw I}}else E==="cancel"?ue()&&ar(-1):x.target!=="setimmediate"&&(E==="checkMailbox"?$e&&Qe():E&&(Q(`worker: received unknown command ${E}`),Q(x)))}catch(I){throw ma(),I}};var Pt,$e=!1;Q=function(...y){y=y.join(" "),console.error(y)},self.alert=function(...y){postMessage({Za:"alert",text:y.join(" "),nb:ue()})},r.instantiateWasm=(y,x)=>new Promise(E=>{Pt=I=>{I=new WebAssembly.Instance(I,on()),x(I),E()}}),self.onunhandledrejection=y=>{throw y.reason||y},self.onmessage=m}r.wasmBinary&&(V=r.wasmBinary);var gt,De,Ft,wt,X,Wt,Le,_t,se,it=!1;function at(){var m=gt.buffer;r.HEAP8=wt=new Int8Array(m),r.HEAP16=new Int16Array(m),r.HEAPU8=X=new Uint8Array(m),r.HEAPU16=new Uint16Array(m),r.HEAP32=Wt=new Int32Array(m),r.HEAPU32=Le=new Uint32Array(m),r.HEAPF32=new Float32Array(m),r.HEAPF64=se=new Float64Array(m),r.HEAP64=_t=new BigInt64Array(m),r.HEAPU64=new BigUint64Array(m)}if(!g){if(!((gt=new WebAssembly.Memory({initial:256,maximum:65536,shared:!0})).buffer instanceof S))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"),Error("bad memory");at()}var re=[],Jt=[],Re=[],oe=0,Ot=null;function $t(){if(--oe==0&&Ot){var m=Ot;Ot=null,m()}}function Lt(m){throw Q(m="Aborted("+m+")"),it=!0,Ft=1,m=new WebAssembly.RuntimeError(m+". Build with -sASSERTIONS for more info."),h(m),m}var nt,st=m=>m.startsWith("data:application/octet-stream;base64,"),Mt=m=>m.startsWith("file://");function ce(m){if(m==nt&&V)return new Uint8Array(V);if(v)return v(m);throw"both async and sync fetching of the wasm failed"}function Ge(m,y,x){return function(E){if(!V&&(l||f)){if(typeof fetch=="function"&&!Mt(E))return fetch(E,{credentials:"same-origin"}).then(I=>{if(!I.ok)throw`failed to load wasm binary file at '${E}'`;return I.arrayBuffer()}).catch(()=>ce(E));if(b)return new Promise((I,N)=>{b(E,R=>I(new Uint8Array(R)),N)})}return Promise.resolve().then(()=>ce(E))}(m).then(E=>WebAssembly.instantiate(E,y)).then(x,E=>{Q(`failed to asynchronously prepare wasm: ${E}`),Lt(E)})}function on(){return{a:{j:Ia,b:Da,E:Ao,g:ko,V:Fo,A:Bo,C:zo,W:Xo,T:Ko,L:Yo,S:Jo,o:Zo,B:Qo,y:ti,U:ri,z:ni,_:ka,Z:Na,P:Fa,w:Ca,F:La,k:ja,O:Dr,Y:Ra,I:Ba,J:Va,K:Ma,G:ra,H:na,v:za,q:Ua,l:Ga,p:Ha,e:qa,X:Wa,x:Xa,d:oa,f:Ka,i:Ya,u:Ja,t:Za,s:qs,Q:sa,R:la,D:Ir,h:ua,n:pa,M:da,m:ca,a:gt,r:Er,N:ga,c:Js}}}var vn={837620:(m,y,x,E,I)=>{if(r===void 0||!r.Ua)return 1;if((m=ge(m>>>0)).startsWith("./")&&(m=m.substring(2)),!(m=r.Ua.get(m)))return 2;if(E>>>=0,(y>>>=0)+(x>>>=0)>m.byteLength)return 3;try{let N=m.subarray(y,y+x);switch(I){case 0:i().set(N,E>>>0);break;case 1:r.mb(E,N);break;default:return 4}return 0}catch{return 4}},838303:()=>typeof wasmOffsetConverter<"u"};function Ia(){return typeof wasmOffsetConverter<"u"}function vr(m){this.name="ExitStatus",this.message=`Program terminated with exit(${m})`,this.status=m}var _r=m=>{m.terminate(),m.onmessage=()=>{}},_n=m=>{te.length==0&&(Eo(),So(te[0]));var y=te.pop();if(!y)return 6;ie.push(y),Dt[m.Ra]=y,y.Ra=m.Ra;var x={cmd:"run",start_routine:m.cb,arg:m.ab,pthread_ptr:m.Ra};return y.postMessage(x,m.ib),0},fe=0,Z=(m,y,...x)=>{for(var E=2*x.length,I=en(),N=tn(8*E),R=N>>>3,K=0;K<x.length;K++){var pt=x[K];typeof pt=="bigint"?(_t[R+2*K]=1n,_t[R+2*K+1]=pt):(_t[R+2*K]=0n,s()[R+2*K+1>>>0]=pt)}return m=ba(m,0,E,N,y),gr(I),m};function Er(m){if(g)return Z(0,1,m);if(Ft=m,!(0<fe)){for(var y of ie)_r(y);for(y of te)_r(y);te=[],ie=[],Dt=[],it=!0}A(m,new vr(m))}function On(m){if(g)return Z(1,0,m);Ir(m)}var Ir=m=>{if(Ft=m,g)throw On(m),"unwind";Er(m)},te=[],ie=[],In=[],Dt={},_o=m=>{var y=m.Ra;delete Dt[y],te.push(m),ie.splice(ie.indexOf(m),1),m.Ra=0,Qr(y)};function Oo(){In.forEach(m=>m())}var So=m=>new Promise(y=>{m.onmessage=I=>{var N=(I=I.data).cmd;if(I.targetThread&&I.targetThread!=ue()){var R=Dt[I.targetThread];R?R.postMessage(I,I.transferList):Q(`Internal error! Worker sent a message "${N}" to target pthread ${I.targetThread}, but that thread no longer exists!`)}else N==="checkMailbox"?Qe():N==="spawnThread"?_n(I):N==="cleanupThread"?_o(Dt[I.thread]):N==="killThread"?(I=I.thread,N=Dt[I],delete Dt[I],_r(N),Qr(I),ie.splice(ie.indexOf(N),1),N.Ra=0):N==="cancelThread"?Dt[I.thread].postMessage({cmd:"cancel"}):N==="loaded"?(m.loaded=!0,y(m)):N==="alert"?alert(`Thread ${I.threadId}: ${I.text}`):I.target==="setimmediate"?m.postMessage(I):N==="callHandler"?r[I.handler](...I.args):N&&Q(`worker sent an unknown command ${N}`)},m.onerror=I=>{throw Q(`worker sent an error! ${I.filename}:${I.lineno}: ${I.message}`),I};var x,E=[];for(x of[])r.hasOwnProperty(x)&&E.push(x);m.postMessage({cmd:"load",handlers:E,wasmMemory:gt,wasmModule:De})});function Eo(){var m=new Worker(new URL(_documentCurrentScript&&_documentCurrentScript.tagName.toUpperCase()==="SCRIPT"&&_documentCurrentScript.src||new URL("segmentation.js",document.baseURI).href),{type:"module",workerData:"em-pthread",name:"em-pthread"});te.push(m)}var Io,Ye=m=>{for(;0<m.length;)m.shift()(r)},Pa=()=>{var m=ue(),y=o()[m+52>>>2>>>0];m=o()[m+56>>>2>>>0],wa(y,y-m),gr(y)},Ze=[],Aa=(m,y)=>{fe=0;var x=Ze[m];x||(m>=Ze.length&&(Ze.length=m+1),Ze[m]=x=Io.get(m)),m=x(y),0<fe?Ft=m:ar(m)};class $a{constructor(y){this.Xa=y-24}}function Da(m,y,x){var E=new $a(m>>>=0);throw y>>>=0,x>>>=0,o()[E.Xa+16>>>2>>>0]=0,o()[E.Xa+4>>>2>>>0]=y,o()[E.Xa+8>>>2>>>0]=x,m}function Po(m,y,x,E){return g?Z(2,1,m,y,x,E):Ao(m,y,x,E)}function Ao(m,y,x,E){if(m>>>=0,y>>>=0,x>>>=0,E>>>=0,S===void 0)return Q("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var I=[];return g&&I.length===0?Po(m,y,x,E):(m={cb:x,Ra:m,ab:E,ib:I},g?(m.Za="spawnThread",postMessage(m,I),0):_n(m))}var $o=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,Do=(m,y,x)=>{var E=(y>>>=0)+x;for(x=y;m[x]&&!(x>=E);)++x;if(16<x-y&&m.buffer&&$o)return $o.decode(m.buffer instanceof S?m.slice(y,x):m.subarray(y,x));for(E="";y<x;){var I=m[y++];if(128&I){var N=63&m[y++];if((224&I)==192)E+=String.fromCharCode((31&I)<<6|N);else{var R=63&m[y++];65536>(I=(240&I)==224?(15&I)<<12|N<<6|R:(7&I)<<18|N<<12|R<<6|63&m[y++])?E+=String.fromCharCode(I):(I-=65536,E+=String.fromCharCode(55296|I>>10,56320|1023&I))}}else E+=String.fromCharCode(I)}return E},ge=(m,y)=>(m>>>=0)?Do(i(),m,y):"";function ko(m,y,x){return g?Z(3,1,m,y,x):0}function Fo(m,y){if(g)return Z(4,1,m,y)}var Lo=m=>{for(var y=0,x=0;x<m.length;++x){var E=m.charCodeAt(x);127>=E?y++:2047>=E?y+=2:55296<=E&&57343>=E?(y+=4,++x):y+=3}return y},jo=(m,y,x,E)=>{if(!(0<E))return 0;var I=x>>>=0;E=x+E-1;for(var N=0;N<m.length;++N){var R=m.charCodeAt(N);if(55296<=R&&57343>=R&&(R=65536+((1023&R)<<10)|1023&m.charCodeAt(++N)),127>=R){if(x>=E)break;y[x++>>>0]=R}else{if(2047>=R){if(x+1>=E)break;y[x++>>>0]=192|R>>6}else{if(65535>=R){if(x+2>=E)break;y[x++>>>0]=224|R>>12}else{if(x+3>=E)break;y[x++>>>0]=240|R>>18,y[x++>>>0]=128|R>>12&63}y[x++>>>0]=128|R>>6&63}y[x++>>>0]=128|63&R}}return y[x>>>0]=0,x-I},be=(m,y,x)=>jo(m,i(),y,x);function Bo(m,y){if(g)return Z(5,1,m,y)}function zo(m,y,x){if(g)return Z(6,1,m,y,x)}function Xo(m,y,x){return g?Z(7,1,m,y,x):0}function Ko(m,y){if(g)return Z(8,1,m,y)}function Yo(m,y,x){if(g)return Z(9,1,m,y,x)}function Jo(m,y,x,E){if(g)return Z(10,1,m,y,x,E)}function Zo(m,y,x,E){if(g)return Z(11,1,m,y,x,E)}function Qo(m,y,x,E){if(g)return Z(12,1,m,y,x,E)}function ti(m){if(g)return Z(13,1,m)}function ri(m,y){if(g)return Z(14,1,m,y)}function ni(m,y,x){if(g)return Z(15,1,m,y,x)}var ka=()=>{Lt("")},Na=()=>1;function Fa(m){Zr(m>>>0,!f,1,!l,131072,!1),Oo()}function Dr(m){m>>>=0,typeof Atomics.jb=="function"&&(Atomics.jb(p(),m>>>2,m).value.then(Qe),m+=128,Atomics.store(p(),m>>>2,1))}var Qe=()=>{var m=ue();if(m&&(Dr(m),m=ya,!it))try{if(m(),!(0<fe))try{g?ar(Ft):Ir(Ft)}catch(y){y instanceof vr||y=="unwind"||A(1,y)}}catch(y){y instanceof vr||y=="unwind"||A(1,y)}};function Ca(m,y){(m>>>=0)==y>>>0?setTimeout(Qe):g?postMessage({targetThread:m,cmd:"checkMailbox"}):(m=Dt[m])&&m.postMessage({cmd:"checkMailbox"})}var Lr=[];function La(m,y,x,E,I){for(y>>>=0,E/=2,Lr.length=E,x=I>>>0>>>3,I=0;I<E;I++)Lr[I]=_t[x+2*I]?_t[x+2*I+1]:s()[x+2*I+1>>>0];return(y?vn[y]:Zs[m])(...Lr)}function ja(m){m>>>=0,g?postMessage({cmd:"cleanupThread",thread:m}):_o(Dt[m])}function Ra(m){}function Ba(m,y){m=-9007199254740992>m||9007199254740992<m?NaN:Number(m),y>>>=0,m=new Date(1e3*m),p()[y>>>2>>>0]=m.getUTCSeconds(),p()[y+4>>>2>>>0]=m.getUTCMinutes(),p()[y+8>>>2>>>0]=m.getUTCHours(),p()[y+12>>>2>>>0]=m.getUTCDate(),p()[y+16>>>2>>>0]=m.getUTCMonth(),p()[y+20>>>2>>>0]=m.getUTCFullYear()-1900,p()[y+24>>>2>>>0]=m.getUTCDay(),m=(m.getTime()-Date.UTC(m.getUTCFullYear(),0,1,0,0,0,0))/864e5|0,p()[y+28>>>2>>>0]=m}var le=m=>m%4==0&&(m%100!=0||m%400==0),ii=[0,31,60,91,121,152,182,213,244,274,305,335],ea=[0,31,59,90,120,151,181,212,243,273,304,334];function Va(m,y){m=-9007199254740992>m||9007199254740992<m?NaN:Number(m),y>>>=0,m=new Date(1e3*m),p()[y>>>2>>>0]=m.getSeconds(),p()[y+4>>>2>>>0]=m.getMinutes(),p()[y+8>>>2>>>0]=m.getHours(),p()[y+12>>>2>>>0]=m.getDate(),p()[y+16>>>2>>>0]=m.getMonth(),p()[y+20>>>2>>>0]=m.getFullYear()-1900,p()[y+24>>>2>>>0]=m.getDay();var x=(le(m.getFullYear())?ii:ea)[m.getMonth()]+m.getDate()-1|0;p()[y+28>>>2>>>0]=x,p()[y+36>>>2>>>0]=-60*m.getTimezoneOffset(),x=new Date(m.getFullYear(),6,1).getTimezoneOffset();var E=new Date(m.getFullYear(),0,1).getTimezoneOffset();m=0|(x!=E&&m.getTimezoneOffset()==Math.min(E,x)),p()[y+32>>>2>>>0]=m}function Ma(m){m>>>=0;var y=new Date(p()[m+20>>>2>>>0]+1900,p()[m+16>>>2>>>0],p()[m+12>>>2>>>0],p()[m+8>>>2>>>0],p()[m+4>>>2>>>0],p()[m>>>2>>>0],0),x=p()[m+32>>>2>>>0],E=y.getTimezoneOffset(),I=new Date(y.getFullYear(),6,1).getTimezoneOffset(),N=new Date(y.getFullYear(),0,1).getTimezoneOffset(),R=Math.min(N,I);return 0>x?p()[m+32>>>2>>>0]=+(I!=N&&R==E):0<x!=(R==E)&&(I=Math.max(N,I),y.setTime(y.getTime()+6e4*((0<x?R:I)-E))),p()[m+24>>>2>>>0]=y.getDay(),x=(le(y.getFullYear())?ii:ea)[y.getMonth()]+y.getDate()-1|0,p()[m+28>>>2>>>0]=x,p()[m>>>2>>>0]=y.getSeconds(),p()[m+4>>>2>>>0]=y.getMinutes(),p()[m+8>>>2>>>0]=y.getHours(),p()[m+12>>>2>>>0]=y.getDate(),p()[m+16>>>2>>>0]=y.getMonth(),p()[m+20>>>2>>>0]=y.getYear(),m=y.getTime(),BigInt(isNaN(m)?-1:m/1e3)}function ra(m,y,x,E,I,N,R){return g?Z(16,1,m,y,x,E,I,N,R):-52}function na(m,y,x,E,I,N){if(g)return Z(17,1,m,y,x,E,I,N)}function za(m,y,x,E){m>>>=0,y>>>=0,x>>>=0,E>>>=0;var I=new Date().getFullYear(),N=new Date(I,0,1),R=new Date(I,6,1);I=N.getTimezoneOffset();var K=R.getTimezoneOffset(),pt=Math.max(I,K);o()[m>>>2>>>0]=60*pt,p()[y>>>2>>>0]=+(I!=K),N=(m=ct=>ct.toLocaleTimeString(void 0,{hour12:!1,timeZoneName:"short"}).split(" ")[1])(N),R=m(R),K<I?(be(N,x,17),be(R,E,17)):(be(N,E,17),be(R,x,17))}var Kr=[];function Ua(m,y,x){m>>>=0,y>>>=0,x>>>=0,Kr.length=0;for(var E;E=i()[y++>>>0];){var I=E!=105;x+=(I&=E!=112)&&x%8?4:0,Kr.push(E==112?o()[x>>>2>>>0]:E==106?_t[x>>>3]:E==105?p()[x>>>2>>>0]:s()[x>>>3>>>0]),x+=I?8:4}return vn[m](...Kr)}var Ga=()=>{},Ha=()=>Date.now();function qa(m,y){return Q(ge(m>>>0,y>>>0))}var oa,Wa=()=>{throw fe+=1,"unwind"};function Xa(){return 4294901760}oa=()=>performance.timeOrigin+performance.now();var Ka=()=>navigator.hardwareConcurrency;function Ya(){return Lt("Cannot use emscripten_pc_get_function without -sUSE_OFFSET_CONVERTER"),0}function Ja(m){m>>>=0;var y=i().length;if(m<=y||4294901760<m)return!1;for(var x=1;4>=x;x*=2){var E=y*(1+.2/x);E=Math.min(E,m+100663296);var I=Math;E=Math.max(m,E);t:{I=(I.min.call(I,4294901760,E+(65536-E%65536)%65536)-gt.buffer.byteLength+65535)/65536;try{gt.grow(I),at();var N=1;break t}catch{}N=void 0}if(N)return!0}return!1}var tr=()=>(Lt("Cannot use convertFrameToPC (needed by __builtin_return_address) without -sUSE_OFFSET_CONVERTER"),0),we={},ia=m=>{m.forEach(y=>{tr()})};function Za(){var m=Error().stack.toString().split(`
1807
+ `);return m[0]=="Error"&&m.shift(),ia(m),we.$a=tr(),we.bb=m,we.$a}function qs(m,y,x){if(m>>>=0,y>>>=0,we.$a==m)var E=we.bb;else(E=Error().stack.toString().split(`
1808
+ `))[0]=="Error"&&E.shift(),ia(E);for(var I=3;E[I]&&tr()!=m;)++I;for(m=0;m<x&&E[m+I];++m)p()[y+4*m>>>2>>>0]=tr();return m}var Yr,Jr={},aa=()=>{if(!Yr){var m,y={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",_};for(m in Jr)Jr[m]===void 0?delete y[m]:y[m]=Jr[m];var x=[];for(m in y)x.push(`${m}=${y[m]}`);Yr=x}return Yr};function sa(m,y){if(g)return Z(18,1,m,y);m>>>=0,y>>>=0;var x=0;return aa().forEach((E,I)=>{var N=y+x;for(I=o()[m+4*I>>>2>>>0]=N,N=0;N<E.length;++N)a()[I++>>>0]=E.charCodeAt(N);a()[I>>>0]=0,x+=E.length+1}),0}function la(m,y){if(g)return Z(19,1,m,y);m>>>=0,y>>>=0;var x=aa();o()[m>>>2>>>0]=x.length;var E=0;return x.forEach(I=>E+=I.length+1),o()[y>>>2>>>0]=E,0}function ua(m){return g?Z(20,1,m):52}function pa(m,y,x,E){return g?Z(21,1,m,y,x,E):52}function da(m,y,x,E){return g?Z(22,1,m,y,x,E):70}var Xs=[null,[],[]];function ca(m,y,x,E){if(g)return Z(23,1,m,y,x,E);y>>>=0,x>>>=0,E>>>=0;for(var I=0,N=0;N<x;N++){var R=o()[y>>>2>>>0],K=o()[y+4>>>2>>>0];y+=8;for(var pt=0;pt<K;pt++){var ct=i()[R+pt>>>0],vt=Xs[m];ct===0||ct===10?((m===1?Nt:Q)(Do(vt,0)),vt.length=0):vt.push(ct)}I+=K}return o()[E>>>2>>>0]=I,0}var ha=[31,29,31,30,31,30,31,31,30,31,30,31],fa=[31,28,31,30,31,30,31,31,30,31,30,31],Ks=(m,y)=>{a().set(m,y>>>0)};function ga(m,y,x,E){function I($,U,et){for($=typeof $=="number"?$.toString():$||"";$.length<U;)$=et[0]+$;return $}function N($,U){return I($,U,"0")}function R($,U){function et(_a){return 0>_a?-1:0<_a?1:0}var ae;return(ae=et($.getFullYear()-U.getFullYear()))===0&&(ae=et($.getMonth()-U.getMonth()))===0&&(ae=et($.getDate()-U.getDate())),ae}function K($){switch($.getDay()){case 0:return new Date($.getFullYear()-1,11,29);case 1:return $;case 2:return new Date($.getFullYear(),0,3);case 3:return new Date($.getFullYear(),0,2);case 4:return new Date($.getFullYear(),0,1);case 5:return new Date($.getFullYear()-1,11,31);case 6:return new Date($.getFullYear()-1,11,30)}}function pt($){var U=$.Sa;for($=new Date(new Date($.Ta+1900,0,1).getTime());0<U;){var et=$.getMonth(),ae=(le($.getFullYear())?ha:fa)[et];if(!(U>ae-$.getDate())){$.setDate($.getDate()+U);break}U-=ae-$.getDate()+1,$.setDate(1),11>et?$.setMonth(et+1):($.setMonth(0),$.setFullYear($.getFullYear()+1))}return et=new Date($.getFullYear()+1,0,4),U=K(new Date($.getFullYear(),0,4)),et=K(et),0>=R(U,$)?0>=R(et,$)?$.getFullYear()+1:$.getFullYear():$.getFullYear()-1}m>>>=0,y>>>=0,x>>>=0,E>>>=0;var ct=o()[E+40>>>2>>>0];for(var vt in E={gb:p()[E>>>2>>>0],fb:p()[E+4>>>2>>>0],Va:p()[E+8>>>2>>>0],Ya:p()[E+12>>>2>>>0],Wa:p()[E+16>>>2>>>0],Ta:p()[E+20>>>2>>>0],Qa:p()[E+24>>>2>>>0],Sa:p()[E+28>>>2>>>0],ob:p()[E+32>>>2>>>0],eb:p()[E+36>>>2>>>0],hb:ct?ge(ct):""},x=ge(x),ct={"%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"})x=x.replace(new RegExp(vt,"g"),ct[vt]);var xa="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),Ta="January February March April May June July August September October November December".split(" ");for(vt in ct={"%a":$=>xa[$.Qa].substring(0,3),"%A":$=>xa[$.Qa],"%b":$=>Ta[$.Wa].substring(0,3),"%B":$=>Ta[$.Wa],"%C":$=>N(($.Ta+1900)/100|0,2),"%d":$=>N($.Ya,2),"%e":$=>I($.Ya,2," "),"%g":$=>pt($).toString().substring(2),"%G":pt,"%H":$=>N($.Va,2),"%I":$=>(($=$.Va)==0?$=12:12<$&&($-=12),N($,2)),"%j":$=>{for(var U=0,et=0;et<=$.Wa-1;U+=(le($.Ta+1900)?ha:fa)[et++]);return N($.Ya+U,3)},"%m":$=>N($.Wa+1,2),"%M":$=>N($.fb,2),"%n":()=>`
1809
+ `,"%p":$=>0<=$.Va&&12>$.Va?"AM":"PM","%S":$=>N($.gb,2),"%t":()=>" ","%u":$=>$.Qa||7,"%U":$=>N(Math.floor(($.Sa+7-$.Qa)/7),2),"%V":$=>{var U=Math.floor(($.Sa+7-($.Qa+6)%7)/7);if(2>=($.Qa+371-$.Sa-2)%7&&U++,U)U==53&&((et=($.Qa+371-$.Sa)%7)==4||et==3&&le($.Ta)||(U=1));else{U=52;var et=($.Qa+7-$.Sa-1)%7;(et==4||et==5&&le($.Ta%400-1))&&U++}return N(U,2)},"%w":$=>$.Qa,"%W":$=>N(Math.floor(($.Sa+7-($.Qa+6)%7)/7),2),"%y":$=>($.Ta+1900).toString().substring(2),"%Y":$=>$.Ta+1900,"%z":$=>{var U=0<=($=$.eb);return $=Math.abs($)/60,(U?"+":"-")+("0000"+($/60*100+$%60)).slice(-4)},"%Z":$=>$.hb,"%%":()=>"%"},x=x.replace(/%%/g,"\0\0"),ct)x.includes(vt)&&(x=x.replace(new RegExp(vt,"g"),ct[vt](E)));return vt=function($){var U=Array(Lo($)+1);return jo($,U,0,U.length),U}(x=x.replace(/\0\0/g,"%")),vt.length>y?0:(Ks(vt,m),vt.length-1)}function Js(m,y,x,E){return ga(m>>>0,y>>>0,x>>>0,E>>>0)}g||function(){for(var m=r.numThreads-1;m--;)Eo();re.unshift(()=>{oe++,function(y){g?y():Promise.all(te.map(So)).then(y)}(()=>$t())})}();var Zs=[Er,On,Po,ko,Fo,Bo,zo,Xo,Ko,Yo,Jo,Zo,Qo,ti,ri,ni,ra,na,sa,la,ua,pa,da,ca],M=function(){function m(x,E){return M=x.exports,M=function(){var I=M,N=K=>()=>K()>>>0,R=K=>pt=>K(pt)>>>0;return(I=Object.assign({},I)).Ba=N(I.Ba),I.Ca=R(I.Ca),I.emscripten_main_runtime_thread_id=N(I.emscripten_main_runtime_thread_id),I.Oa=R(I.Oa),I.Pa=N(I.Pa),I}(),In.push(M.Ea),Io=M.Fa,Jt.unshift(M.$),De=E,$t(),M}var y=on();if(oe++,r.instantiateWasm)try{return r.instantiateWasm(y,m)}catch(x){Q(`Module.instantiateWasm callback failed with error: ${x}`),h(x)}return nt||(nt=r.locateFile?st("ort-wasm-simd-threaded.wasm")?"ort-wasm-simd-threaded.wasm":r.locateFile?r.locateFile("ort-wasm-simd-threaded.wasm",L):L+"ort-wasm-simd-threaded.wasm":""),function(x,E){var I=nt;return V||typeof WebAssembly.instantiateStreaming!="function"||st(I)||Mt(I)||typeof fetch!="function"?Ge(I,x,E):fetch(I,{credentials:"same-origin"}).then(N=>WebAssembly.instantiateStreaming(N,x).then(E,function(R){return Q(`wasm streaming compile failed: ${R}`),Q("falling back to ArrayBuffer instantiation"),Ge(I,x,E)}))}(y,function(x){m(x.instance,x.module)}).catch(h),{}}();r._OrtInit=(m,y)=>(r._OrtInit=M.aa)(m,y),r._OrtGetLastError=(m,y)=>(r._OrtGetLastError=M.ba)(m,y),r._OrtCreateSessionOptions=(m,y,x,E,I,N,R,K,pt,ct)=>(r._OrtCreateSessionOptions=M.ca)(m,y,x,E,I,N,R,K,pt,ct),r._OrtAppendExecutionProvider=(m,y)=>(r._OrtAppendExecutionProvider=M.da)(m,y),r._OrtAddFreeDimensionOverride=(m,y,x)=>(r._OrtAddFreeDimensionOverride=M.ea)(m,y,x),r._OrtAddSessionConfigEntry=(m,y,x)=>(r._OrtAddSessionConfigEntry=M.fa)(m,y,x),r._OrtReleaseSessionOptions=m=>(r._OrtReleaseSessionOptions=M.ga)(m),r._OrtCreateSession=(m,y,x)=>(r._OrtCreateSession=M.ha)(m,y,x),r._OrtReleaseSession=m=>(r._OrtReleaseSession=M.ia)(m),r._OrtGetInputOutputCount=(m,y,x)=>(r._OrtGetInputOutputCount=M.ja)(m,y,x),r._OrtGetInputName=(m,y)=>(r._OrtGetInputName=M.ka)(m,y),r._OrtGetOutputName=(m,y)=>(r._OrtGetOutputName=M.la)(m,y),r._OrtFree=m=>(r._OrtFree=M.ma)(m),r._OrtCreateTensor=(m,y,x,E,I,N)=>(r._OrtCreateTensor=M.na)(m,y,x,E,I,N),r._OrtGetTensorData=(m,y,x,E,I)=>(r._OrtGetTensorData=M.oa)(m,y,x,E,I),r._OrtReleaseTensor=m=>(r._OrtReleaseTensor=M.pa)(m),r._OrtCreateRunOptions=(m,y,x,E)=>(r._OrtCreateRunOptions=M.qa)(m,y,x,E),r._OrtAddRunConfigEntry=(m,y,x)=>(r._OrtAddRunConfigEntry=M.ra)(m,y,x),r._OrtReleaseRunOptions=m=>(r._OrtReleaseRunOptions=M.sa)(m),r._OrtCreateBinding=m=>(r._OrtCreateBinding=M.ta)(m),r._OrtBindInput=(m,y,x)=>(r._OrtBindInput=M.ua)(m,y,x),r._OrtBindOutput=(m,y,x,E)=>(r._OrtBindOutput=M.va)(m,y,x,E),r._OrtClearBoundOutputs=m=>(r._OrtClearBoundOutputs=M.wa)(m),r._OrtReleaseBinding=m=>(r._OrtReleaseBinding=M.xa)(m),r._OrtRunWithBinding=(m,y,x,E,I)=>(r._OrtRunWithBinding=M.ya)(m,y,x,E,I),r._OrtRun=(m,y,x,E,I,N,R,K)=>(r._OrtRun=M.za)(m,y,x,E,I,N,R,K),r._OrtEndProfiling=m=>(r._OrtEndProfiling=M.Aa)(m);var ue=()=>(ue=M.Ba)();r._malloc=m=>(r._malloc=M.Ca)(m),r._free=m=>(r._free=M.Da)(m);var er,Zr=(m,y,x,E,I,N)=>(Zr=M.Ga)(m,y,x,E,I,N),ma=()=>(ma=M.Ha)(),ba=(m,y,x,E,I)=>(ba=M.Ia)(m,y,x,E,I),Qr=m=>(Qr=M.Ja)(m),ar=m=>(ar=M.Ka)(m),ya=()=>(ya=M.La)(),wa=(m,y)=>(wa=M.Ma)(m,y),gr=m=>(gr=M.Na)(m),tn=m=>(tn=M.Oa)(m),en=()=>(en=M.Pa)();function va(){0<oe||(g?(c(r),g||Ye(Jt),startWorker(r)):(Ye(re),0<oe||er||(er=!0,r.calledRun=!0,it||(g||Ye(Jt),c(r),g||Ye(Re)))))}return r.___start_em_js=838360,r.___stop_em_js=838421,r.stackSave=()=>en(),r.stackRestore=m=>gr(m),r.stackAlloc=m=>tn(m),r.UTF8ToString=ge,r.stringToUTF8=be,r.lengthBytesUTF8=Lo,Ot=function m(){er||va(),er||(Ot=m)},va(),u}),Og=Mp,((e=globalThis.self)==null?void 0:e.name)==="em-pthread"&&Mp()}),br,Sg,Ag,Pg,zp,Wp,Eg,Hp,Vr=O(()=>{var e,n;oo(),br=(_documentCurrentScript&&_documentCurrentScript.tagName.toUpperCase()==="SCRIPT"&&_documentCurrentScript.src||new URL("segmentation.js",document.baseURI).href)??(typeof document<"u"?(e=document.currentScript)==null?void 0:e.src:typeof self<"u"?(n=self.location)==null?void 0:n.href:void 0),Sg=typeof location>"u"?void 0:location.origin,Ag=(a,i)=>{try{let p=i??br;return(p?new URL(a,p):new URL(a)).origin===Sg}catch{return!1}},Pg=async a=>{let i=await(await fetch(a,{credentials:"same-origin"})).blob();return URL.createObjectURL(i)},zp=(Gp(),sn(Rp)).default,Wp=async()=>{if(!br)throw new Error("Failed to load proxy worker: cannot determine the script source URL.");if(Ag(br))return[void 0,zp()];let a=await Pg(br);return[a,zp(a)]},Eg=(Vp(),sn(Up)).default,Hp=async(a,i,p)=>[void 0,Eg]}),Xi,Ki,ho,qp,Dg,Lg,io,xt,Ke=O(()=>{Vr(),Ki=!1,ho=!1,qp=!1,Dg=()=>{if(typeof SharedArrayBuffer>"u")return!1;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}},io=async e=>{if(Ki)return Promise.resolve();if(ho)throw new Error("multiple calls to 'initializeWebAssembly()' detected.");if(qp)throw new Error("previous call to 'initializeWebAssembly()' failed.");ho=!0;let n=e.initTimeout,a=e.numThreads;if(!Lg())throw new Error("WebAssembly SIMD is not supported in the current environment.");let i=Dg();a>1&&!i&&(typeof self<"u"&&!self.crossOriginIsolated&&console.warn("env.wasm.numThreads is set to "+a+", but this will not work unless you enable crossOriginIsolated mode. See https://web.dev/cross-origin-isolation-guide/ for more info."),console.warn("WebAssembly multi-threading is not supported in the current environment. Falling back to single-threading."),e.numThreads=a=1);let p=e.wasmPaths,o=typeof p=="string"?p:void 0,s=p==null?void 0:p.mjs,c=(s==null?void 0:s.href)??s,h=p==null?void 0:p.wasm,r=(h==null?void 0:h.href)??h,u=e.wasmBinary,[l,f]=await Hp(c,o,a>1),g=!1,b=[];if(n>0&&b.push(new Promise(v=>{setTimeout(()=>{g=!0,v()},n)})),b.push(new Promise((v,S)=>{let P={numThreads:a};u?P.wasmBinary=u:(r||o)&&(P.locateFile=(_,A)=>r??(o??A)+_),f(P).then(_=>{ho=!1,Ki=!0,Xi=_,v(),l&&URL.revokeObjectURL(l)},_=>{ho=!1,qp=!0,S(_)})})),await Promise.race(b),g)throw new Error(`WebAssembly backend initializing failed due to timeout: ${n}ms`)},xt=()=>{if(Ki&&Xi)return Xi;throw new Error("WebAssembly is not initialized yet.")}}),Tt,Wr,ht,mo=O(()=>{Ke(),Tt=(e,n)=>{let a=xt(),i=a.lengthBytesUTF8(e)+1,p=a._malloc(i);return a.stringToUTF8(e,p,i),n.push(p),p},Wr=(e,n,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(([p,o])=>{let s=n?n+p:p;if(typeof o=="object")Wr(o,s+".",a,i);else if(typeof o=="string"||typeof o=="number")i(s,o.toString());else if(typeof o=="boolean")i(s,o?"1":"0");else throw new Error(`Can't handle extra config type: ${typeof o}`)})},ht=e=>{let n=xt(),a=n.stackSave();try{let i=n.stackAlloc(8);n._OrtGetLastError(i,i+4);let p=n.HEAP32[i/4],o=n.HEAPU32[i/4+1],s=o?n.UTF8ToString(o):"";throw new Error(`${e} ERROR_CODE: ${p}, ERROR_MESSAGE: ${s}`)}finally{n.stackRestore(a)}}}),jp,Xp=O(()=>{Ke(),mo(),jp=e=>{let n=xt(),a=0,i=[],p=e||{};try{if((e==null?void 0:e.logSeverityLevel)===void 0)p.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)p.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&&(p.terminate=!1);let o=0;return(e==null?void 0:e.tag)!==void 0&&(o=Tt(e.tag,i)),a=n._OrtCreateRunOptions(p.logSeverityLevel,p.logVerbosityLevel,!!p.terminate,o),a===0&&ht("Can't create run options."),(e==null?void 0:e.extra)!==void 0&&Wr(e.extra,"",new WeakSet,(s,c)=>{let h=Tt(s,i),r=Tt(c,i);n._OrtAddRunConfigEntry(a,h,r)!==0&&ht(`Can't set a run config entry: ${s} - ${c}.`)}),[a,i]}catch(o){throw a!==0&&n._OrtReleaseRunOptions(a),i.forEach(s=>n._free(s)),o}}}),$g,kg,Bg,Fg,Kp,Jp=O(()=>{Ke(),mo(),$g=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}`)}},kg=e=>{switch(e){case"sequential":return 0;case"parallel":return 1;default:throw new Error(`unsupported execution mode: ${e}`)}},Bg=e=>{e.extra||(e.extra={}),e.extra.session||(e.extra.session={});let n=e.extra.session;n.use_ort_model_bytes_directly||(n.use_ort_model_bytes_directly="1"),e.executionProviders&&e.executionProviders.some(a=>(typeof a=="string"?a:a.name)==="webgpu")&&(e.enableMemPattern=!1)},Fg=(e,n,a)=>{for(let i of n){let p=typeof i=="string"?i:i.name;switch(p){case"webnn":if(p="WEBNN",typeof i!="string"){let s=i==null?void 0:i.deviceType;if(s){let c=Tt("deviceType",a),h=Tt(s,a);xt()._OrtAddSessionConfigEntry(e,c,h)!==0&&ht(`Can't set a session config entry: 'deviceType' - ${s}.`)}}break;case"webgpu":if(p="JS",typeof i!="string"){let s=i;if(s!=null&&s.preferredLayout){if(s.preferredLayout!=="NCHW"&&s.preferredLayout!=="NHWC")throw new Error(`preferredLayout must be either 'NCHW' or 'NHWC': ${s.preferredLayout}`);let c=Tt("preferredLayout",a),h=Tt(s.preferredLayout,a);xt()._OrtAddSessionConfigEntry(e,c,h)!==0&&ht(`Can't set a session config entry: 'preferredLayout' - ${s.preferredLayout}.`)}}break;case"wasm":case"cpu":continue;default:throw new Error(`not supported execution provider: ${p}`)}let o=Tt(p,a);xt()._OrtAppendExecutionProvider(e,o)!==0&&ht(`Can't append execution provider: ${p}.`)}},Kp=e=>{let n=xt(),a=0,i=[],p=e||{};Bg(p);try{let o=$g(p.graphOptimizationLevel??"all"),s=kg(p.executionMode??"sequential"),c=typeof p.logId=="string"?Tt(p.logId,i):0,h=p.logSeverityLevel??2;if(!Number.isInteger(h)||h<0||h>4)throw new Error(`log serverity level is not valid: ${h}`);let r=p.logVerbosityLevel??0;if(!Number.isInteger(r)||r<0||r>4)throw new Error(`log verbosity level is not valid: ${r}`);let u=typeof p.optimizedModelFilePath=="string"?Tt(p.optimizedModelFilePath,i):0;if(a=n._OrtCreateSessionOptions(o,!!p.enableCpuMemArena,!!p.enableMemPattern,s,!!p.enableProfiling,0,c,h,r,u),a===0&&ht("Can't create session options."),p.executionProviders&&Fg(a,p.executionProviders,i),p.enableGraphCapture!==void 0){if(typeof p.enableGraphCapture!="boolean")throw new Error(`enableGraphCapture must be a boolean value: ${p.enableGraphCapture}`);let l=Tt("enableGraphCapture",i),f=Tt(p.enableGraphCapture.toString(),i);n._OrtAddSessionConfigEntry(a,l,f)!==0&&ht(`Can't set a session config entry: 'enableGraphCapture' - ${p.enableGraphCapture}.`)}if(p.freeDimensionOverrides)for(let[l,f]of Object.entries(p.freeDimensionOverrides)){if(typeof l!="string")throw new Error(`free dimension override name must be a string: ${l}`);if(typeof f!="number"||!Number.isInteger(f)||f<0)throw new Error(`free dimension override value must be a non-negative integer: ${f}`);let g=Tt(l,i);n._OrtAddFreeDimensionOverride(a,g,f)!==0&&ht(`Can't set a free dimension override: ${l} - ${f}.`)}return p.extra!==void 0&&Wr(p.extra,"",new WeakSet,(l,f)=>{let g=Tt(l,i),b=Tt(f,i);n._OrtAddSessionConfigEntry(a,g,b)!==0&&ht(`Can't set a session config entry: ${l} - ${f}.`)}),[a,i]}catch(o){throw a!==0&&n._OrtReleaseSessionOptions(a),i.forEach(s=>n._free(s)),o}}}),Hr,Yp,qr,Zp,Qp,bo,go,td,Ji=O(()=>{Hr=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;case"int4":return 22;case"uint4":return 21;default:throw new Error(`unsupported data type: ${e}`)}},Yp=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";case 22:return"int4";case 21:return"uint4";default:throw new Error(`unsupported data type: ${e}`)}},qr=(e,n)=>{let a=[-1,4,1,1,2,2,4,8,-1,1,2,8,4,8,-1,-1,-1,-1,-1,-1,-1,.5,.5][e],i=typeof n=="number"?n:n.reduce((p,o)=>p*o,1);return a>0?Math.ceil(i*a):void 0},Zp=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}`)}},bo=e=>e==="float32"||e==="float16"||e==="int32"||e==="int64"||e==="uint32"||e==="uint8"||e==="bool"||e==="uint4"||e==="int4",go=e=>e==="float32"||e==="float16"||e==="int32"||e==="int64"||e==="uint32"||e==="uint64"||e==="int8"||e==="uint8"||e==="bool",td=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;case"ml-tensor":return 5;default:throw new Error(`unsupported data location: ${e}`)}}}),jr,Yi=O(()=>{oo(),jr=async e=>{if(typeof e=="string"){let n=await fetch(e);if(!n.ok)throw new Error(`failed to load external data file: ${e}`);let a=n.headers.get("Content-Length"),i=a?parseInt(a,10):0;if(i<1073741824)return new Uint8Array(await n.arrayBuffer());{if(!n.body)throw new Error(`failed to load external data file: ${e}, no response body.`);let p=n.body.getReader(),o;try{o=new ArrayBuffer(i)}catch(c){if(c instanceof RangeError){let h=Math.ceil(i/65536);o=new WebAssembly.Memory({initial:h,maximum:h}).buffer}else throw c}let s=0;for(;;){let{done:c,value:h}=await p.read();if(c)break;let r=h.byteLength;new Uint8Array(o,s,r).set(h),s+=r}return new Uint8Array(o,0,i)}}else return e instanceof Blob?new Uint8Array(await e.arrayBuffer()):e instanceof Uint8Array?e:new Uint8Array(e)}}),Cg,ao,so,yr,Ng,zr,uo,lo,ed,fo,co,po,qi=O(()=>{Xp(),Jp(),Ji(),Ke(),mo(),Yi(),Cg=(e,n)=>{xt()._OrtInit(e,n)!==0&&ht("Can't initialize onnxruntime.")},ao=async e=>{Cg(e.wasm.numThreads,Qp(e.logLevel))},so=async(e,n)=>{},yr=new Map,Ng=e=>{let n=xt(),a=n.stackSave();try{let i=n.stackAlloc(8);return n._OrtGetInputOutputCount(e,i,i+4)!==0&&ht("Can't get session input/output count."),[n.HEAP32[i/4],n.HEAP32[i/4+1]]}finally{n.stackRestore(a)}},zr=e=>{let n=xt(),a=n._malloc(e.byteLength);if(a===0)throw new Error(`Can't create a session. failed to allocate a buffer of size ${e.byteLength}.`);return n.HEAPU8.set(e,a),[a,e.byteLength]},uo=async(e,n)=>{var u;let a,i,p=xt();Array.isArray(e)?[a,i]=e:e.buffer===p.HEAPU8.buffer?[a,i]=[e.byteOffset,e.byteLength]:[a,i]=zr(e);let o=0,s=0,c=[],h=[],r=[];try{if([s,c]=Kp(n),(n==null?void 0:n.externalData)&&p.mountExternalData){let _=[];for(let A of n.externalData){let L=typeof A=="string"?A:A.path;_.push(jr(typeof A=="string"?A:A.data).then(V=>{p.mountExternalData(L,V)}))}await Promise.all(_)}for(let _ of(n==null?void 0:n.executionProviders)??[])if((typeof _=="string"?_:_.name)==="webnn"){if(p.shouldTransferToMLTensor=!1,p.currentContext)throw new Error("WebNN execution provider is already set.");if(typeof _!="string"){let A=_,L=A==null?void 0:A.context,V=A==null?void 0:A.gpuDevice,ft=A==null?void 0:A.deviceType,lt=A==null?void 0:A.numThreads,Nt=A==null?void 0:A.powerPreference;L?p.currentContext=L:V?p.currentContext=await navigator.ml.createContext(V):p.currentContext=await navigator.ml.createContext({deviceType:ft,numThreads:lt,powerPreference:Nt})}else p.currentContext=await navigator.ml.createContext();break}o=await p._OrtCreateSession(a,i,s),o===0&&ht("Can't create a session."),p.currentContext&&(p.jsepRegisterMLContext(o,p.currentContext),p.currentContext=void 0,p.shouldTransferToMLTensor=!0);let[l,f]=Ng(o),g=!!(n!=null&&n.enableGraphCapture),b=[],v=[],S=[];for(let _=0;_<l;_++){let A=p._OrtGetInputName(o,_);A===0&&ht("Can't get an input name."),h.push(A),b.push(p.UTF8ToString(A))}for(let _=0;_<f;_++){let A=p._OrtGetOutputName(o,_);A===0&&ht("Can't get an output name."),r.push(A);let L=p.UTF8ToString(A);v.push(L)}return yr.set(o,[o,h,r,null,g,!1]),[o,b,v]}catch(l){throw h.forEach(f=>p._OrtFree(f)),r.forEach(f=>p._OrtFree(f)),o!==0&&p._OrtReleaseSession(o),l}finally{p._free(a),s!==0&&p._OrtReleaseSessionOptions(s),c.forEach(l=>p._free(l)),(u=p.unmountExternalData)==null||u.call(p)}},lo=e=>{var h;let n=xt(),a=yr.get(e);if(!a)throw new Error(`cannot release session. invalid session id: ${e}`);let[i,p,o,s,c]=a;s&&(c&&n._OrtClearBoundOutputs(s.handle),n._OrtReleaseBinding(s.handle)),(h=n.jsepOnReleaseSession)==null||h.call(n,e),p.forEach(r=>n._OrtFree(r)),o.forEach(r=>n._OrtFree(r)),n._OrtReleaseSession(i),yr.delete(e)},ed=(e,n,a,i,p,o=!1)=>{if(!e){n.push(0);return}let s=xt(),c=e[0],h=e[1],r=e[3],u,l;if(c==="string"&&(r==="gpu-buffer"||r==="ml-tensor"))throw new Error("String tensor is not supported on GPU.");if(o&&r!=="gpu-buffer")throw new Error(`External buffer must be provided for input/output index ${p} when enableGraphCapture is true.`);if(r==="gpu-buffer"){let b=e[2].gpuBuffer;l=qr(Hr(c),h);let v=s.jsepRegisterBuffer;if(!v)throw new Error('Tensor location "gpu-buffer" is not supported without using WebGPU.');u=v(i,p,b,l)}else if(r==="ml-tensor"){let b=e[2].mlTensor;l=qr(Hr(c),h);let v=s.jsepRegisterMLTensor;if(!v)throw new Error('Tensor location "ml-tensor" is not supported without using WebNN.');u=v(b,Hr(c),h)}else{let b=e[2];if(Array.isArray(b)){l=4*b.length,u=s._malloc(l),a.push(u);let v=u/4;for(let S=0;S<b.length;S++){if(typeof b[S]!="string")throw new TypeError(`tensor data at index ${S} is not a string`);s.HEAPU32[v++]=Tt(b[S],a)}}else l=b.byteLength,u=s._malloc(l),a.push(u),s.HEAPU8.set(new Uint8Array(b.buffer,b.byteOffset,l),u)}let f=s.stackSave(),g=s.stackAlloc(4*h.length);try{let b=g/4;h.forEach(S=>s.HEAP32[b++]=S);let v=s._OrtCreateTensor(Hr(c),u,l,g,h.length,td(r));v===0&&ht(`Can't create tensor for input/output. session=${i}, index=${p}.`),n.push(v)}finally{s.stackRestore(f)}},fo=async(e,n,a,i,p,o)=>{var Q;let s=xt(),c=yr.get(e);if(!c)throw new Error(`cannot run inference. invalid session id: ${e}`);let h=c[0],r=c[1],u=c[2],l=c[3],f=c[4];c[5];let g=n.length,b=i.length,v=0,S=[],P=[],_=[],A=[],L=s.stackSave(),V=s.stackAlloc(g*4),ft=s.stackAlloc(g*4),lt=s.stackAlloc(b*4),Nt=s.stackAlloc(b*4);try{(Q=s.jsepOnRunStart)==null||Q.call(s,h),[v,S]=jp(o);for(let X=0;X<g;X++)ed(a[X],P,A,e,n[X],f);for(let X=0;X<b;X++)ed(p[X],_,A,e,g+i[X],f);let Pt=V/4,$e=ft/4,gt=lt/4,De=Nt/4;for(let X=0;X<g;X++)s.HEAPU32[Pt++]=P[X],s.HEAPU32[$e++]=r[n[X]];for(let X=0;X<b;X++)s.HEAPU32[gt++]=_[X],s.HEAPU32[De++]=u[i[X]];let Ft;Ft=await s._OrtRun(h,ft,V,g,Nt,b,lt,v),Ft!==0&&ht("failed to call OrtRun().");let wt=[];for(let X=0;X<b;X++){let Wt=s.HEAPU32[lt/4+X];if(Wt===_[X]){wt.push(p[X]);continue}let Le=s.stackSave(),_t=s.stackAlloc(4*4),se=!1,it,at=0;try{s._OrtGetTensorData(Wt,_t,_t+4,_t+8,_t+12)!==0&&ht(`Can't access output tensor data on index ${X}.`);let re=_t/4,Jt=s.HEAPU32[re++];at=s.HEAPU32[re++];let Re=s.HEAPU32[re++],oe=s.HEAPU32[re++],Ot=[];for(let nt=0;nt<oe;nt++)Ot.push(s.HEAPU32[Re/4+nt]);s._OrtFree(Re);let $t=Ot.reduce((nt,st)=>nt*st,1);it=Yp(Jt);let Lt=l==null?void 0:l.outputPreferredLocations[i[X]];if(it==="string"){if(Lt==="gpu-buffer"||Lt==="ml-tensor")throw new Error("String tensor is not supported on GPU.");let nt=[],st=at/4;for(let Mt=0;Mt<$t;Mt++){let ce=s.HEAPU32[st++],Ge=Mt===$t-1?void 0:s.HEAPU32[st]-ce;nt.push(s.UTF8ToString(ce,Ge))}wt.push([it,Ot,nt,"cpu"])}else if(Lt==="gpu-buffer"&&$t>0){let nt=s.jsepGetBuffer;if(!nt)throw new Error('preferredLocation "gpu-buffer" is not supported without using WebGPU.');let st=nt(at),Mt=qr(Jt,$t);if(Mt===void 0||!bo(it))throw new Error(`Unsupported data type: ${it}`);se=!0,wt.push([it,Ot,{gpuBuffer:st,download:s.jsepCreateDownloader(st,Mt,it),dispose:()=>{s._OrtReleaseTensor(Wt)}},"gpu-buffer"])}else if(Lt==="ml-tensor"&&$t>0){let nt=s.jsepEnsureTensor;if(!nt)throw new Error('preferredLocation "ml-tensor" is not supported without using WebNN.');if(qr(Jt,$t)===void 0||!go(it))throw new Error(`Unsupported data type: ${it}`);let st=await nt(at,Jt,Ot,!1);se=!0,wt.push([it,Ot,{mlTensor:st,download:s.jsepCreateMLTensorDownloader(at,it),dispose:()=>{s.jsepReleaseTensorId(at),s._OrtReleaseTensor(Wt)}},"ml-tensor"])}else{let nt=Zp(it),st=new nt($t);new Uint8Array(st.buffer,st.byteOffset,st.byteLength).set(s.HEAPU8.subarray(at,at+st.byteLength)),wt.push([it,Ot,st,"cpu"])}}finally{s.stackRestore(Le),it==="string"&&at&&s._free(at),se||s._OrtReleaseTensor(Wt)}}return l&&!f&&(s._OrtClearBoundOutputs(l.handle),yr.set(e,[h,r,u,l,f,!1])),wt}finally{s.stackRestore(L),P.forEach(Pt=>s._OrtReleaseTensor(Pt)),_.forEach(Pt=>s._OrtReleaseTensor(Pt)),A.forEach(Pt=>s._free(Pt)),v!==0&&s._OrtReleaseRunOptions(v),S.forEach(Pt=>s._free(Pt))}},co=e=>{let n=xt(),a=yr.get(e);if(!a)throw new Error("invalid session id");let i=a[0],p=n._OrtEndProfiling(i);p===0&&ht("Can't get an profile file name."),n._OrtFree(p)},po=e=>{let n=[];for(let a of e){let i=a[2];!Array.isArray(i)&&"buffer"in i&&n.push(i.buffer)}return n}}),Je,Kt,Xr,xo,To,yo,Zi,Qi,xr,Tr,Gg,rd,nd,od,id,ad,sd,ud,ta=O(()=>{Yt(),qi(),Ke(),Vr(),Je=()=>!!z.wasm.proxy&&typeof document<"u",Xr=!1,xo=!1,To=!1,Qi=new Map,xr=(e,n)=>{let a=Qi.get(e);a?a.push(n):Qi.set(e,[n])},Tr=()=>{if(Xr||!xo||To||!Kt)throw new Error("worker not ready")},Gg=e=>{switch(e.data.type){case"init-wasm":Xr=!1,e.data.err?(To=!0,Zi[1](e.data.err)):(xo=!0,Zi[0]()),yo&&(URL.revokeObjectURL(yo),yo=void 0);break;case"init-ep":case"copy-from":case"create":case"release":case"run":case"end-profiling":{let n=Qi.get(e.data.type);e.data.err?n.shift()[1](e.data.err):n.shift()[0](e.data.out);break}}},rd=async()=>{if(!xo){if(Xr)throw new Error("multiple calls to 'initWasm()' detected.");if(To)throw new Error("previous call to 'initWasm()' failed.");if(Xr=!0,Je())return new Promise((e,n)=>{Kt==null||Kt.terminate(),Wp().then(([a,i])=>{try{Kt=i,Kt.onerror=o=>n(o),Kt.onmessage=Gg,Zi=[e,n];let p={type:"init-wasm",in:z};Kt.postMessage(p),yo=a}catch(p){n(p)}},n)});try{await io(z.wasm),await ao(z),xo=!0}catch(e){throw To=!0,e}finally{Xr=!1}}},nd=async e=>{if(Je())return Tr(),new Promise((n,a)=>{xr("init-ep",[n,a]);let i={type:"init-ep",in:{epName:e,env:z}};Kt.postMessage(i)});await so(z,e)},od=async e=>Je()?(Tr(),new Promise((n,a)=>{xr("copy-from",[n,a]);let i={type:"copy-from",in:{buffer:e}};Kt.postMessage(i,[e.buffer])})):zr(e),id=async(e,n)=>{if(Je()){if(n!=null&&n.preferredOutputLocation)throw new Error('session option "preferredOutputLocation" is not supported for proxy.');return Tr(),new Promise((a,i)=>{xr("create",[a,i]);let p={type:"create",in:{model:e,options:{...n}}},o=[];e instanceof Uint8Array&&o.push(e.buffer),Kt.postMessage(p,o)})}else return uo(e,n)},ad=async e=>{if(Je())return Tr(),new Promise((n,a)=>{xr("release",[n,a]);let i={type:"release",in:e};Kt.postMessage(i)});lo(e)},sd=async(e,n,a,i,p,o)=>{if(Je()){if(a.some(s=>s[3]!=="cpu"))throw new Error("input tensor on GPU is not supported for proxy.");if(p.some(s=>s))throw new Error("pre-allocated output tensor is not supported for proxy.");return Tr(),new Promise((s,c)=>{xr("run",[s,c]);let h=a,r={type:"run",in:{sessionId:e,inputIndices:n,inputs:h,outputIndices:i,options:o}};Kt.postMessage(r,po(h))})}else return fo(e,n,a,i,p,o)},ud=async e=>{if(Je())return Tr(),new Promise((n,a)=>{xr("end-profiling",[n,a]);let i={type:"end-profiling",in:e};Kt.postMessage(i)});co(e)}}),ld,Mg,wo,fd=O(()=>{Yt(),ta(),Ji(),oo(),Yi(),ld=(e,n)=>{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"];case"ml-tensor":return[e.type,e.dims,{mlTensor:e.mlTensor},"ml-tensor"];default:throw new Error(`invalid data location: ${e.location} for ${n()}`)}},Mg=e=>{switch(e[3]){case"cpu":return new yt(e[0],e[2],e[1]);case"gpu-buffer":{let n=e[0];if(!bo(n))throw new Error(`not supported data type: ${n} for deserializing GPU tensor`);let{gpuBuffer:a,download:i,dispose:p}=e[2];return yt.fromGpuBuffer(a,{dataType:n,dims:e[1],download:i,dispose:p})}case"ml-tensor":{let n=e[0];if(!go(n))throw new Error(`not supported data type: ${n} for deserializing MLTensor tensor`);let{mlTensor:a,download:i,dispose:p}=e[2];return yt.fromMLTensor(a,{dataType:n,dims:e[1],download:i,dispose:p})}default:throw new Error(`invalid data location: ${e[3]}`)}},wo=class{async fetchModelAndCopyToWasmMemory(e){return od(await jr(e))}async loadModel(e,n){Fe();let a;typeof e=="string"?a=await this.fetchModelAndCopyToWasmMemory(e):a=e,[this.sessionId,this.inputNames,this.outputNames]=await id(a,n),Ce()}async dispose(){return ad(this.sessionId)}async run(e,n,a){Fe();let i=[],p=[];Object.entries(e).forEach(l=>{let f=l[0],g=l[1],b=this.inputNames.indexOf(f);if(b===-1)throw new Error(`invalid input '${f}'`);i.push(g),p.push(b)});let o=[],s=[];Object.entries(n).forEach(l=>{let f=l[0],g=l[1],b=this.outputNames.indexOf(f);if(b===-1)throw new Error(`invalid output '${f}'`);o.push(g),s.push(b)});let c=i.map((l,f)=>ld(l,()=>`input "${this.inputNames[p[f]]}"`)),h=o.map((l,f)=>l?ld(l,()=>`output "${this.outputNames[s[f]]}"`):null),r=await sd(this.sessionId,p,c,s,h,a),u={};for(let l=0;l<r.length;l++)u[this.outputNames[s[l]]]=o[l]??Mg(r[l]);return Ce(),u}startProfiling(){}endProfiling(){ud(this.sessionId)}}}),pd={};Or(pd,{OnnxruntimeWebAssemblyBackend:()=>vo,initializeFlags:()=>cd,wasmBackend:()=>Ug});var cd,vo,Ug,dd=O(()=>{Yt(),ta(),fd(),Vr(),cd=()=>{if((typeof z.wasm.initTimeout!="number"||z.wasm.initTimeout<0)&&(z.wasm.initTimeout=0),z.wasm.simd===!1&&console.warn('Deprecated property "env.wasm.simd" is set to false. non-SIMD build is no longer provided, and this setting will be ignored.'),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)if(typeof self<"u"&&!self.crossOriginIsolated)z.wasm.numThreads=1;else{let e=typeof navigator>"u"?Co("node:os").cpus().length:navigator.hardwareConcurrency;z.wasm.numThreads=Math.min(4,Math.ceil((e||1)/2))}},vo=class{async init(e){cd(),await rd(),await nd(e)}async createInferenceSessionHandler(e,n){let a=new wo;return await a.loadModel(e,n),Promise.resolve(a)}},Ug=new vo});Yt(),Yt(),Yt();var Ds="1.20.1";{let e=(Fp(),sn(Bp)).onnxjsBackend;nr("webgl",e,-10)}{let e=(dd(),sn(pd)).wasmBackend;nr("cpu",e,10),nr("wasm",e,10)}Object.defineProperty(z.versions,"web",{value:Ds,enumerable:!0});/*! Bundled license information:
1810
1810
 
1811
1811
  long/index.js:
1812
1812
  (**
@@ -1828,5 +1828,5 @@ as ORT format: ${u}`)}}loadFromOnnxFormat(t,r){let o=Dp.onnx.ModelProto.decode(t
1828
1828
  *
1829
1829
  * SPDX-License-Identifier: Apache-2.0
1830
1830
  *)
1831
- */const A=(t,r)=>!r||t.startsWith("http")?new URL(t).href:t?r.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):r;function b(t){if(t.startsWith("blob:"))return!0;try{return new URL(t),!0}catch{return!1}}async function U$1(t){const r=await caches.open("ladon-cache"),o=await r.match(t);if(o)return o.arrayBuffer();const i=await fetch(t);if(!i.ok)throw new Error(`Failed to fetch file: ${t}`);const u=i.headers.get("Content-Type")||"application/octet-stream";if(!u.includes("application/wasm")&&!u.includes("binary/octet-stream"))throw new Error(`Unexpected MIME type: ${u} for ${t}`);const n=await i.arrayBuffer(),a=new Response(n,{headers:{"Content-Type":u,"Content-Length":n.byteLength.toString()}});return await r.put(t,a),n}const k="ort-wasm-simd-threaded.wasm";class U{constructor(){this.modelSessions={},this.resolvedUriCache=new Map}async initializeWorker(r){if(typeof Worker>"u")throw new Error("[ladon-ts] web workers are not supported in this environment");const o=await this.resolveUri(r,r.mask.workerUri),i=await(await fetch(o,{cache:"force-cache"})).text();return this.workerUrl=URL.createObjectURL(new Blob([i],{type:"text/javascript"})),new Worker(this.workerUrl,{type:"module"})}terminateWorker(){this.worker&&(this.worker.terminate(),this.worker=void 0)}async loadModel(r){const{mask:o,executionProviders:i}=r;z.wasm.numThreads=1;const u=await this.resolveUri(r,r.wasmUri);if(u)try{z.wasm.wasmBinary=await U$1(u+k)}catch(d){console.warn("Failed to load or cache WASM file. Using WASM paths.",d),z.wasm.wasmPaths=u}const n=await this.resolveUri(r,o.modelUri);let a=this.modelSessions[n];if(!a){const d={executionProviders:i!=null&&i.length?i:["wasm"]};try{const c=await U$1(n);a=await Yd.create(c,d)}catch(c){console.warn("Failed to load or cache model file. Using model URL.",c),a=await Yd.create(n,d)}}return this.modelSessions[n]=a,await this.warmupModel(a,o.inputSize,o.modelRank),a}async preloadWorker(r){const o=await this.prepareWorkerConfig(r);this.worker=await this.initializeWorker(o),this.worker.postMessage({type:"preload",config:o})}async warmupModel(r,o={width:1280,height:720},i=3,u="float32"){const n=o.height*o.width,a=new Float32Array(i*n).fill(0),d=new yt(u,a,[1,i,o.height,o.width]),c={[r.inputNames[0]]:d};if(i===3){const e=new Float32Array(n).fill(0),l=new yt(u,e,[1,1,o.height,o.width]);c[r.inputNames[1]]=l}await r.run(c)}getModelSession(r){return this.modelSessions[r]}async resolveUri(r,o){if(!o)throw new Error("Asset URI is undefined.");if(this.resolvedUriCache.has(o))return this.resolvedUriCache.get(o);let i;if(b(o)?i=o:o.match(/\.[a-z0-9]+$/i)?typeof r.assetUrlResolver=="function"&&(i=await r.assetUrlResolver(o,r)):i=A(o,r.baseUrl),!i)throw new Error(`Failed to resolve asset URI: ${o}`);return this.resolvedUriCache.set(o,i),i}getWorker(){return this.worker}getWorkerUrl(){return this.workerUrl}async prepareWorkerConfig(r){const o={...r,mask:{...r.mask,modelUri:await this.resolveUri(r,r.mask.modelUri),workerUri:await this.resolveUri(r,r.mask.workerUri)},wasmUri:await this.resolveUri(r,r.wasmUri),assetUrlResolver:void 0};return JSON.parse(JSON.stringify(o))}}const p=new U;class R{constructor(r){this.config=r,this.lastMaskGenerationTime=0;const{height:o,width:i}=this.config.mask.outputSize;this.lastMask=new yt("float32",new Float32Array(o*i),[1,1,o,i]),this.lastResult={data:this.lastMask.data,facesAndLandmarks:{data:new Float32Array(0),dims:[]},gesture:new Float32Array(0),motion:0,timestamp:0,warm:!1}}preprocess(r,o){const{modelRank:i,inputSize:u,outputSize:n}=this.config.mask,{height:a,width:d}=u,c=a*d;this.output??(this.output=new Float32Array(c*i));const e=r.length/4;for(let h=0;h<3;h++)for(let f=0;f<e;f++)this.output[f+h*c]=r[f*4+(2-h)];const l=n.width/d,s=n.height/a;for(let h=0;h<d;h++){const f=Math.floor(h*l);for(let m=0;m<a;m++){const v=Math.floor(m*s),_=f+v*n.width,I=h+m*d+3*c,T=Math.min(Math.max(o[_],0),255);this.output[I]=T}}return this.output}getTimeSinceLastGeneration(){return Date.now()-this.lastMaskGenerationTime}async getLadonOutput(r,o){var i,u,n,a;if(!this.maskModel)throw new Error("[ladon-ts] - mask model not loaded.");if(this.getTimeSinceLastGeneration()<this.config.mask.generationIntervalMs)return{data:this.lastMask.data,facesAndLandmarks:this.lastResult.facesAndLandmarks,gesture:this.lastResult.gesture,motion:this.lastResult.motion,timestamp:this.lastResult.timestamp,warm:!1};this.lastMaskGenerationTime=Date.now();const d=new yt("float32",this.preprocess(r,this.lastMask.data),[1,this.config.mask.modelRank,this.config.mask.inputSize.height,this.config.mask.inputSize.width]),c=await this.maskModel.run({input:d});return this.lastMask=c.segmentation,this.lastResult={data:this.lastMask.data??new Float32Array(0),facesAndLandmarks:{data:((i=c.faces_and_landmarks)==null?void 0:i.data)??new Float32Array(0),dims:((u=c.faces_and_landmarks)==null?void 0:u.dims)??[]},gesture:((n=c.gesture)==null?void 0:n.data)??new Float32Array(0),motion:((a=c.motion)==null?void 0:a.data[0])??0,timestamp:o,warm:!0},this.lastResult}async load(){const r=await p.resolveUri(this.config,this.config.mask.modelUri);if(this.maskModel=p.getModelSession(r),this.maskModel??(this.maskModel=await p.loadModel(this.config)),!this.maskModel)throw new Error("Failed to load the ONNX model.")}isLoaded(){return!!this.maskModel}async postRender(r){}destroy(){}}let preloadPromise=null,generator,busy=!1;self.addEventListener("message",async t=>{const{type:r,config:o,image:i,timestamp:u}=t.data;try{switch(r){case"preload":o&&(preloadPromise=handlePreload(o),await preloadPromise);break;case"init":o&&(preloadPromise&&await preloadPromise,await handleInit(o));break;case"generate":i&&await handleGenerate(i,u);break;default:console.warn(`[ladon-ts] - worker generator - unknown message: ${JSON.stringify(t.data)}`)}}catch(n){console.error(`[ladon-ts] - worker generator - error handling message: ${n}`),postMessage({status:"error",error:n.message})}});async function handlePreload(t){await p.loadModel(t),postMessage({status:"preloaded"})}async function handleInit(t){generator=new R(t),await generator.load(),postMessage({status:"initialized"})}async function handleGenerate(t,r){if(busy)return;if(!generator||!generator.isLoaded()){console.warn("[ladon-ts] - Generator is not initialized");return}if(busy=!0,!t){console.warn("[ladon-ts] - No valid input provided for generation"),busy=!1;return}const o=await generator.getLadonOutput(t,r);o.warm&&postMessage({facesAndLandmarks:o.facesAndLandmarks,gesture:o.gesture,mask:o.data,motion:o.motion,timestamp:o.timestamp,status:"generated"}),setTimeout(()=>{busy=!1},0)}})();
1831
+ */function C(e){if(e.startsWith("blob:"))return!0;try{return new URL(e),!0}catch{return!1}}const T=(e,n)=>!n||e.startsWith("http")?new URL(e).href:e?n.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):n;class t{constructor(){this.resolvedUriCache=new Map}async resolveUri(n,a){if(!a)throw new Error("Asset URI is undefined.");if(this.resolvedUriCache.has(a))return this.resolvedUriCache.get(a);let i;if(C(a)?i=a:a.match(/\.[a-z0-9]+$/i)?typeof n.assetUrlResolver=="function"&&(i=await n.assetUrlResolver(a,n)):i=T(a,n.baseUrl),!i)throw new Error(`Failed to resolve asset URI: ${a}`);return this.resolvedUriCache.set(a,i),i}}const d=new t;async function loadAndCacheFile(e){const n=await caches.open("ladon-cache"),a=await n.match(e);if(a)return a.arrayBuffer();const i=await fetch(e);if(!i.ok)throw new Error(`Failed to fetch file: ${e}`);const p=i.headers.get("Content-Type")||"binary/octet-stream";if(!p.includes("application/wasm")&&!p.includes("binary/octet-stream"))throw new Error(`Unexpected MIME type: ${p} for ${e}`);const o=await i.arrayBuffer(),s=new Response(o,{headers:{"Content-Type":p,"Content-Length":o.byteLength.toString()}});return await n.put(e,s),o}const ONNX_WASM_FILENAME="ort-wasm-simd-threaded.wasm";class ModelManager{constructor(){this.modelSessions={}}async loadModel(n){const{mask:a,executionProviders:i}=n;z.wasm.numThreads=1;const p=await d.resolveUri(n,n.wasmUri);if(p)try{z.wasm.wasmBinary=await loadAndCacheFile(p+ONNX_WASM_FILENAME)}catch(c){console.warn("Failed to load or cache WASM file. Using WASM paths.",c),z.wasm.wasmPaths=p}const o=await d.resolveUri(n,a.modelUri);let s=this.modelSessions[o];if(!s){const h={executionProviders:i!=null&&i.length?i:["wasm"]};try{const r=await loadAndCacheFile(o);s=await Yd.create(r,h)}catch(r){console.warn("Failed to load or cache model file. Using model URL.",r),s=await Yd.create(o,h)}}return this.modelSessions[o]=s,await this.warmupModel(s,a.inputSize,a.modelRank),s}async warmupModel(n,a={width:1280,height:720},i=3,p="float32"){const o=a.height*a.width,s=new Float32Array(i*o).fill(0),c=new yt(p,s,[1,i,a.height,a.width]),h={[n.inputNames[0]]:c};if(i===3){const r=new Float32Array(o).fill(0),u=new yt(p,r,[1,1,a.height,a.width]);h[n.inputNames[1]]=u}await n.run(h)}getModelSession(n){return this.modelSessions[n]}}const modelManager=new ModelManager;class LadonGenerator{constructor(n){this.config=n,this.lastMaskGenerationTime=0;const{height:a,width:i}=this.config.mask.outputSize;this.lastMask=new yt("float32",new Float32Array(a*i),[1,1,a,i]),this.lastResult={data:this.lastMask.data,facesAndLandmarks:{data:new Float32Array(0),dims:[]},gesture:new Float32Array(0),motion:0,timestamp:0,warm:!1}}preprocess(n,a){const{modelRank:i,inputSize:p,outputSize:o}=this.config.mask,{height:s,width:c}=p,h=s*c;this.output??(this.output=new Float32Array(h*i));const r=n.length/4;for(let f=0;f<3;f++)for(let g=0;g<r;g++)this.output[g+f*h]=n[g*4+(2-f)];const u=o.width/c,l=o.height/s;for(let f=0;f<c;f++){const g=Math.floor(f*u);for(let b=0;b<s;b++){const v=Math.floor(b*l),S=g+v*o.width,P=f+b*c+3*h,_=Math.min(Math.max(a[S],0),255);this.output[P]=_}}return this.output}getTimeSinceLastGeneration(){return Date.now()-this.lastMaskGenerationTime}async getLadonOutput(n,a){var o,s,c,h;if(!this.maskModel)throw new Error("[ladon-ts] - mask model not loaded.");if(this.getTimeSinceLastGeneration()<this.config.mask.generationIntervalMs)return{data:this.lastMask.data,facesAndLandmarks:this.lastResult.facesAndLandmarks,gesture:this.lastResult.gesture,motion:this.lastResult.motion,timestamp:this.lastResult.timestamp,warm:!1};this.lastMaskGenerationTime=Date.now();const i=new yt("float32",this.preprocess(n,this.lastMask.data),[1,this.config.mask.modelRank,this.config.mask.inputSize.height,this.config.mask.inputSize.width]),p=await this.maskModel.run({input:i});return this.lastMask=p.segmentation,this.lastResult={data:this.lastMask.data??new Float32Array(0),facesAndLandmarks:{data:((o=p.faces_and_landmarks)==null?void 0:o.data)??new Float32Array(0),dims:((s=p.faces_and_landmarks)==null?void 0:s.dims)??[]},gesture:((c=p.gesture)==null?void 0:c.data)??new Float32Array(0),motion:((h=p.motion)==null?void 0:h.data[0])??0,timestamp:a,warm:!0},this.lastResult}async load(){const n=await d.resolveUri(this.config,this.config.mask.modelUri);if(this.maskModel=modelManager.getModelSession(n),this.maskModel??(this.maskModel=await modelManager.loadModel(this.config)),!this.maskModel)throw new Error("Failed to load the ONNX model.")}isLoaded(){return!!this.maskModel}async postRender(n){}destroy(){}}let preloadPromise=null,generator,busy=!1;self.addEventListener("message",async e=>{const{type:n,config:a,image:i,timestamp:p}=e.data;try{switch(n){case"preload":a&&(preloadPromise=handlePreload(a),await preloadPromise);break;case"init":a&&(preloadPromise&&await preloadPromise,await handleInit(a));break;case"generate":i&&await handleGenerate(i,p);break;default:console.warn(`[ladon-ts] - worker generator - unknown message: ${JSON.stringify(e.data)}`)}}catch(o){console.error(`[ladon-ts] - worker generator - error handling message: ${o}`),postMessage({status:"error",error:o.message})}});async function handlePreload(e){await modelManager.loadModel(e),postMessage({status:"preloaded"})}async function handleInit(e){generator=new LadonGenerator(e),await generator.load(),postMessage({status:"initialized"})}async function handleGenerate(e,n){if(busy)return;if(!generator||!generator.isLoaded()){console.warn("[ladon-ts] - Generator is not initialized");return}if(busy=!0,!e){console.warn("[ladon-ts] - No valid input provided for generation"),busy=!1;return}const a=await generator.getLadonOutput(e,n);a.warm&&postMessage({facesAndLandmarks:a.facesAndLandmarks,gesture:a.gesture,mask:a.data,motion:a.motion,timestamp:a.timestamp,status:"generated"}),setTimeout(()=>{busy=!1},0)}})();
1832
1832
  //# sourceMappingURL=segmentation.js.map