@webex/ladon-ts 5.4.1 → 5.4.3
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.
- package/CHANGELOG.md +177 -163
- package/LICENSE +5 -5
- package/README.md +34 -36
- package/build/module/index.d.ts +10 -10
- package/build/module/lib/config-builder.d.ts +179 -180
- package/build/module/lib/config-types.d.ts +101 -101
- package/build/module/lib/config.d.ts +28 -29
- package/build/module/lib/generator.d.ts +73 -74
- package/build/module/lib/pipeline.d.ts +82 -83
- package/build/module/lib/preload.d.ts +7 -8
- package/build/module/lib/renderer/blur-renderer.d.ts +17 -18
- package/build/module/lib/renderer/ladon-renderer.d.ts +5 -6
- package/build/module/lib/renderer/passthrough-renderer.d.ts +10 -11
- package/build/module/lib/renderer/replacement-renderer.d.ts +14 -15
- package/build/module/lib/renderer/webgl-renderer.d.ts +23 -24
- package/build/module/lib/renderer.d.ts +5 -5
- package/build/module/lib/shared-resource-manager.d.ts +92 -92
- package/build/module/lib/shared-resource-manager.js +25 -26
- package/build/module/lib/shared-resource-manager.js.map +1 -1
- package/build/module/lib/util.d.ts +64 -64
- package/build/module/lib/version.d.ts +1 -1
- package/build/module/lib/version.js +1 -1
- package/build/module/lib/version.js.map +1 -1
- package/build/worker/segmentation.js +253 -248
- package/build/worker/segmentation.js.map +1 -0
- package/package.json +102 -95
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cisco Ladon-TS
|
|
3
|
+
* Copyright (c) Cisco Systems, Inc. All rights reserved.
|
|
4
|
+
* Build timestamp: March 26, 2025 at 05:23:34 PM UTC
|
|
5
|
+
*/
|
|
1
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)};/*!
|
|
2
7
|
* ONNX Runtime Web v1.20.1
|
|
3
8
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
9
|
* Licensed under the MIT License.
|
|
5
|
-
*/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(d=>typeof d=="string"?d:d.name),i=o.length===0?ke:o,u,n=[],a=new Set;for(let d of i){let e=await Jd(d);typeof e=="string"?n.push({name:d,err:e}):(u||(u=e),u===e&&a.add(d))}if(!u)throw new Error(`no available backend found. ERR: ${n.map(d=>`[${d.name}] ${d.err}`).join(", ")}`);for(let{name:d,err:e}of n)o.includes(d)&&console.warn(`removing requested execution provider "${d}" from session options because it is not available: ${e}`);let p=r.filter(d=>a.has(typeof d=="string"?d:d.name));return[u,new Proxy(t,{get:(d,e)=>e==="executionProviders"?p:Reflect.get(d,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",p=r==null?void 0:r.norm,d,e;p===void 0||p.mean===void 0?d=[255,255,255,255]:typeof p.mean=="number"?d=[p.mean,p.mean,p.mean,p.mean]:(d=[p.mean[0],p.mean[1],p.mean[2],0],p.mean[3]!==void 0&&(d[3]=p.mean[3])),p===void 0||p.bias===void 0?e=[0,0,0,0]:typeof p.bias=="number"?e=[p.bias,p.bias,p.bias,p.bias]:(e=[p.bias[0],p.bias[1],p.bias[2],0],p.bias[3]!==void 0&&(e[3]=p.bias[3]));let l=n*u,s=0,c=l,h=l*2,m=-1;a==="RGBA"?(s=0,c=l,h=l*2,m=l*3):a==="RGB"?(s=0,c=l,h=l*2):a==="RBG"&&(s=0,h=l,c=l*2);for(let v=0;v<n;v++)for(let _=0;_<u;_++){let I=(t.data[s++]-e[0])*d[0],T=(t.data[c++]-e[1])*d[1],P=(t.data[h++]-e[2])*d[2],C=m===-1?255:(t.data[m++]-e[3])*d[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 p=r!==void 0&&r.format!==void 0?r.format:"RGB",d=r==null?void 0:r.norm,e,l;d===void 0||d.mean===void 0?e=[255,255,255,255]:typeof d.mean=="number"?e=[d.mean,d.mean,d.mean,d.mean]:(e=[d.mean[0],d.mean[1],d.mean[2],255],d.mean[3]!==void 0&&(e[3]=d.mean[3])),d===void 0||d.bias===void 0?l=[0,0,0,0]:typeof d.bias=="number"?l=[d.bias,d.bias,d.bias,d.bias]:(l=[d.bias[0],d.bias[1],d.bias[2],0],d.bias[3]!==void 0&&(l[3]=d.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 c=4,h=0,m=1,v=2,_=3,I=0,T=s,P=s*2,C=-1;p==="RGBA"?(I=0,T=s,P=s*2,C=s*3):p==="RGB"?(I=0,T=s,P=s*2):p==="RBG"&&(I=0,P=s,T=s*2),i=o.createImageData(u,n);for(let V=0;V<n*u;h+=c,m+=c,v+=c,_+=c,V++)i.data[h]=(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 p=r.format!==void 0?r.format:"RGBA",d=r.tensorFormat!==void 0&&r.tensorFormat!==void 0?r.tensorFormat:"RGB",e=o*i,l=d==="RGBA"?new Float32Array(e*4):new Float32Array(e*3),s=4,c=0,h=1,m=2,v=3,_=0,I=e,T=e*2,P=-1;p==="RGB"&&(s=3,c=0,h=1,m=2,v=-1),d==="RGBA"?P=e*3:d==="RBG"?(_=0,T=e,I=e*2):d==="BGR"&&(T=0,I=e,_=e*2);for(let C=0;C<e;C++,c+=s,m+=s,h+=s,v+=s)l[_++]=(t[c]+a[0])/n[0],l[I++]=(t[h]+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 d==="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,p=r??{},d=()=>{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=d();l.width=t.width,l.height=t.height;let s=e(l);if(s!=null){let c=t.height,h=t.width;if(r!==void 0&&r.resizedHeight!==void 0&&r.resizedWidth!==void 0&&(c=r.resizedHeight,h=r.resizedWidth),r!==void 0){if(p=r,r.tensorFormat!==void 0)throw new Error("Image input config format must be RGBA for HTMLImageElement");p.tensorFormat="RGBA",p.height=c,p.width=h}else p.tensorFormat="RGBA",p.height=c,p.width=h;s.drawImage(t,0,0),a=s.getImageData(0,0,h,c).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&&(p=r),p.format="RGBA",p.height=l,p.width=s,r!==void 0){let c=d();c.width=s,c.height=l;let h=e(c);if(h!=null)h.putImageData(t,0,0),a=h.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=d();l.width=t.width,l.height=t.height;let s=e(l);if(s!=null){let c=t.height,h=t.width;return s.drawImage(t,0,0,h,c),a=s.getImageData(0,0,h,c).data,p.height=c,p.width=h,Ro(a,p)}else throw new Error("Can not access image data")}else{if(n)return new Promise((l,s)=>{let c=d(),h=e(c);if(!t||!h)return s();let m=new Image;m.crossOrigin="Anonymous",m.src=t,m.onload=()=>{c.width=m.width,c.height=m.height,h.drawImage(m,0,0,c.width,c.height);let v=h.getImageData(0,0,c.width,c.height);p.height=c.height,p.width=c.width,l(Ro(v.data,p))}});throw new Error("Input data provided is not supported - aborted tensor creation")}if(a!==void 0)return Ro(a,p);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,p;if(typeof t=="string")if(i=t,p=o,t==="string"){if(!Array.isArray(r))throw new TypeError("A string tensor's data must be a string array.");a=r}else{let d=Be.get(t);if(d===void 0)throw new TypeError(`Unsupported tensor type: ${t}.`);if(Array.isArray(r)){if(t==="float16"&&d===Uint16Array||t==="uint4"||t==="int4")throw new TypeError(`Creating a ${t} tensor from number array is not supported. Please use ${d.name} as data.`);t==="uint64"||t==="int64"?a=d.from(r,BigInt):a=d.from(r)}else if(r instanceof d)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 ${d}`)}else if(p=r,Array.isArray(t)){if(t.length===0)throw new TypeError("Tensor type cannot be inferred from an empty array.");let d=typeof t[0];if(d==="string")i="string",a=t;else if(d==="boolean")i="bool",a=Uint8Array.from(t);else throw new TypeError(`Invalid element type of data array: ${d}.`)}else if(t instanceof Uint8ClampedArray)i="uint8",a=Uint8Array.from(t);else{let d=Sr.get(t.constructor);if(d===void 0)throw new TypeError(`Unsupported type for tensor data: ${t.constructor}.`);i=d,a=t}if(p===void 0)p=[a.length];else if(!Array.isArray(p))throw new TypeError("A tensor's dims must be a number array");u=p,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 c=o[s];(c===null||c instanceof yt)&&(e=!0,a=!1,u[s]=c)}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 p=await this.handler.run(r,u,n),d={};for(let e in p)if(Object.hasOwnProperty.call(p,e)){let l=p[e];l instanceof yt?d[e]=l:d[e]=new yt(l.type,l.data,l.dims)}return Ce(),d}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,c=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(c=r.byteLength-s,typeof i=="number"){if(c=i,!Number.isSafeInteger(c))throw new RangeError("'byteLength' must be an integer.");if(c<=0||s+c>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,c)}else throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");let[p,d]=await ln(a),e=await p.createInferenceSessionHandler(n,d);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,p]=await ln(n);if(a.createTrainingSessionHandler){let d=await a.createTrainingSessionHandler(r.checkpointState,r.trainModel,i,u,p);return new Ea(d,!!r.optimizerModel,!!r.evalModel)}else throw new Error(Zd)}typeNarrowingForRunStep(r,o,i,u,n){let a={},p={};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 d=!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.");d=!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)p=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 c=u[s];(c===null||c instanceof yt)&&(e=!0,d=!1,a[s]=c)}if(e){if(typeof n=="object"&&n!==null)p=n;else if(typeof n<"u")throw new TypeError("'options' must be an object.")}else p=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(d)for(let e of o)a[e]=null;return[a,p]}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={},p("",e||{})}t.reset=a;function p(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=p;function d(e){let l={};e.logLevel&&(l.minimalSeverity=e.logLevel),p("",l)}t.setWithEnv=d})(_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((p,d)=>{a.then(async e=>{u&&await u.end(),p(e)},async e=>{u&&await u.end(),d(e)})});if(!n&&u){let p=u.end();if(p&&typeof p.then=="function")return new Promise((d,e)=>{p.then(()=>{d(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],p=i[3],d=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:p,opInit:d}}}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 p=Math.min(8,t.length-a),d=parseInt(t.substring(a,a+p),o);if(p<8){var e=zt(Tn(o,p));n=n.mul(e).add(zt(d))}else n=n.mul(u),n=n.add(zt(d))}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 p=n.div(u),d=n.sub(p.mul(u)).toInt()>>>0,e=d.toString(t);if(n=p,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,p=t.low>>>16,d=t.low&65535,e=0,l=0,s=0,c=0;return c+=u+d,s+=c>>>16,c&=65535,s+=i+p,l+=s>>>16,s&=65535,l+=o+a,e+=l>>>16,l&=65535,e+=r+n,e&=65535,J(s<<16|c,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,p=t.high&65535,d=t.low>>>16,e=t.low&65535,l=0,s=0,c=0,h=0;return h+=n*e,c+=h>>>16,h&=65535,c+=u*e,s+=c>>>16,c&=65535,c+=n*d,s+=c>>>16,c&=65535,s+=i*e,l+=s>>>16,s&=65535,s+=u*d,l+=s>>>16,s&=65535,s+=n*p,l+=s>>>16,s&=65535,l+=o*e+i*d+u*p+n*a,l&=65535,J(c<<16|h,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),p=a<=48?1:Tn(2,a-48),d=zt(o),e=d.mul(t);e.isNegative()||e.gt(i);)o-=p,d=zt(o,this.unsigned),e=d.mul(t);d.isZero()&&(d=or),u=u.add(d),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 p=this.bb.capacity()-this.vtables[r];if(u==this.bb.readInt16(p)){for(var d=w.SIZEOF_SHORT;d<u;d+=w.SIZEOF_SHORT)if(this.bb.readInt16(a+d)!=this.bb.readInt16(p+d))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,p=this.bb.bytes();o<r.length;o++)p[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 p=this.readUint8(t+u++);if(a<224)n=(a&31)<<6|p&63;else{var d=this.readUint8(t+u++);if(a<240)n=(a&15)<<12|(p&63)<<6|d&63;else{var e=this.readUint8(t+u++);n=(a&7)<<18|(p&63)<<12|(d&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 p=this.bb.__offset(this.bb_pos,4);return p?(a||new t.experimental.fbs.Dimension).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+p)+n*4),this.bb):null}dimLength(){let n=this.bb.__offset(this.bb_pos,4);return n?this.bb.__vector_len(this.bb_pos+n):0}static startShape(n){n.startObject(1)}static addDim(n,a){n.addFieldOffset(0,a,0)}static createDimVector(n,a){n.startVector(4,a.length,4);for(let p=a.length-1;p>=0;p--)n.addOffset(a[p]);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,p){return i.startDimension(n),i.addValue(n,a),i.addDenotation(n,p),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,p,d){return i.startDimensionValue(n),i.addDimType(n,a),i.addDimValue(n,p),i.addDimParam(n,d),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,p){return i.startTensorTypeAndShape(n),i.addElemType(n,a),i.addShape(n,p),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,p){return i.startMapType(n),i.addKeyType(n,a),i.addValueType(n,p),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,p,d){return n.prep(4,12),n.writeInt32(d),n.writeInt32(p),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 p=this.bb.__offset(this.bb_pos,6);return p?(a||new t.experimental.fbs.EdgeEnd).__init(this.bb.__vector(this.bb_pos+p)+n*12,this.bb):null}inputEdgesLength(){let n=this.bb.__offset(this.bb_pos,6);return n?this.bb.__vector_len(this.bb_pos+n):0}outputEdges(n,a){let p=this.bb.__offset(this.bb_pos,8);return p?(a||new t.experimental.fbs.EdgeEnd).__init(this.bb.__vector(this.bb_pos+p)+n*12,this.bb):null}outputEdgesLength(){let n=this.bb.__offset(this.bb_pos,8);return n?this.bb.__vector_len(this.bb_pos+n):0}static startNodeEdge(n){n.startObject(3)}static addNodeIndex(n,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,p,d){return i.startNodeEdge(n),i.addNodeIndex(n,a),i.addInputEdges(n,p),i.addOutputEdges(n,d),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 p=this.bb.__offset(this.bb_pos,20);return p?this.bb.__string(this.bb.__vector(this.bb_pos+p)+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 p=this.bb.__offset(this.bb_pos,22);return p?this.bb.__string(this.bb.__vector(this.bb_pos+p)+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 p=this.bb.__offset(this.bb_pos,24);return p?(a||new t.experimental.fbs.Attribute).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+p)+n*4),this.bb):null}attributesLength(){let n=this.bb.__offset(this.bb_pos,24);return n?this.bb.__vector_len(this.bb_pos+n):0}inputArgCounts(n){let 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 p=this.bb.__offset(this.bb_pos,28);return p?this.bb.__string(this.bb.__vector(this.bb_pos+p)+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 p=a.length-1;p>=0;p--)n.addOffset(a[p]);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 p=a.length-1;p>=0;p--)n.addOffset(a[p]);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 p=a.length-1;p>=0;p--)n.addOffset(a[p]);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 p=a.length-1;p>=0;p--)n.addInt32(a[p]);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 p=a.length-1;p>=0;p--)n.addOffset(a[p]);return n.endVector()}static startImplicitInputsVector(n,a){n.startVector(4,a,4)}static endNode(n){return n.endObject()}static createNode(n,a,p,d,e,l,s,c,h,m,v,_,I,T){return i.startNode(n),i.addName(n,a),i.addDocString(n,p),i.addDomain(n,d),i.addSinceVersion(n,e),i.addIndex(n,l),i.addOpType(n,s),i.addType(n,c),i.addExecutionProviderType(n,h),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,p,d){return i.startValueInfo(n),i.addName(n,a),i.addDocString(n,p),i.addType(n,d),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,p,d){return i.startTypeInfo(n),i.addDenotation(n,a),i.addValueType(n,p),i.addValue(n,d),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,p){return i.startOperatorSetId(n),i.addDomain(n,a),i.addVersion(n,p),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 p=this.bb.__offset(this.bb_pos,14);return p?this.bb.__string(this.bb.__vector(this.bb_pos+p)+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 p=a.length-1;p>=0;p--)n.addInt64(a[p]);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 p=a.length-1;p>=0;p--)n.addInt8(a[p]);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 p=a.length-1;p>=0;p--)n.addOffset(a[p]);return n.endVector()}static startStringDataVector(n,a){n.startVector(4,a,4)}static endTensor(n){return n.endObject()}static createTensor(n,a,p,d,e,l,s){return i.startTensor(n),i.addName(n,a),i.addDocString(n,p),i.addDims(n,d),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 p=a.length-1;p>=0;p--)n.addInt64(a[p]);return n.endVector()}static startDimsVector(n,a){n.startVector(8,a,8)}static endSparseTensor(n){return n.endObject()}static createSparseTensor(n,a,p,d){return i.startSparseTensor(n),i.addValues(n,a),i.addIndices(n,p),i.addDims(n,d),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 p=this.bb.__offset(this.bb_pos,24);return p?this.bb.__string(this.bb.__vector(this.bb_pos+p)+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 p=this.bb.__offset(this.bb_pos,26);return p?(a||new t.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+p)+n*4),this.bb):null}tensorsLength(){let n=this.bb.__offset(this.bb_pos,26);return n?this.bb.__vector_len(this.bb_pos+n):0}graphs(n,a){let p=this.bb.__offset(this.bb_pos,28);return p?(a||new t.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+p)+n*4),this.bb):null}graphsLength(){let n=this.bb.__offset(this.bb_pos,28);return n?this.bb.__vector_len(this.bb_pos+n):0}static startAttribute(n){n.startObject(13)}static addName(n,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 p=a.length-1;p>=0;p--)n.addFloat32(a[p]);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 p=a.length-1;p>=0;p--)n.addInt64(a[p]);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 p=a.length-1;p>=0;p--)n.addOffset(a[p]);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 p=a.length-1;p>=0;p--)n.addOffset(a[p]);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 p=a.length-1;p>=0;p--)n.addOffset(a[p]);return n.endVector()}static startGraphsVector(n,a){n.startVector(4,a,4)}static endAttribute(n){return n.endObject()}static createAttribute(n,a,p,d,e,l,s,c,h,m,v,_,I,T){return i.startAttribute(n),i.addName(n,a),i.addDocString(n,p),i.addType(n,d),i.addF(n,e),i.addI(n,l),i.addS(n,s),i.addT(n,c),i.addG(n,h),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 p=this.bb.__offset(this.bb_pos,4);return p?(a||new t.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+p)+n*4),this.bb):null}initializersLength(){let n=this.bb.__offset(this.bb_pos,4);return n?this.bb.__vector_len(this.bb_pos+n):0}nodeArgs(n,a){let p=this.bb.__offset(this.bb_pos,6);return p?(a||new t.experimental.fbs.ValueInfo).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+p)+n*4),this.bb):null}nodeArgsLength(){let n=this.bb.__offset(this.bb_pos,6);return n?this.bb.__vector_len(this.bb_pos+n):0}nodes(n,a){let p=this.bb.__offset(this.bb_pos,8);return p?(a||new t.experimental.fbs.Node).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+p)+n*4),this.bb):null}nodesLength(){let n=this.bb.__offset(this.bb_pos,8);return n?this.bb.__vector_len(this.bb_pos+n):0}maxNodeIndex(){let n=this.bb.__offset(this.bb_pos,10);return n?this.bb.readUint32(this.bb_pos+n):0}nodeEdges(n,a){let p=this.bb.__offset(this.bb_pos,12);return p?(a||new t.experimental.fbs.NodeEdge).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+p)+n*4),this.bb):null}nodeEdgesLength(){let n=this.bb.__offset(this.bb_pos,12);return n?this.bb.__vector_len(this.bb_pos+n):0}inputs(n,a){let p=this.bb.__offset(this.bb_pos,14);return p?this.bb.__string(this.bb.__vector(this.bb_pos+p)+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 p=this.bb.__offset(this.bb_pos,16);return p?this.bb.__string(this.bb.__vector(this.bb_pos+p)+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 p=this.bb.__offset(this.bb_pos,18);return p?(a||new t.experimental.fbs.SparseTensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+p)+n*4),this.bb):null}sparseInitializersLength(){let n=this.bb.__offset(this.bb_pos,18);return n?this.bb.__vector_len(this.bb_pos+n):0}static startGraph(n){n.startObject(8)}static addInitializers(n,a){n.addFieldOffset(0,a,0)}static createInitializersVector(n,a){n.startVector(4,a.length,4);for(let p=a.length-1;p>=0;p--)n.addOffset(a[p]);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 p=a.length-1;p>=0;p--)n.addOffset(a[p]);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 p=a.length-1;p>=0;p--)n.addOffset(a[p]);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 p=a.length-1;p>=0;p--)n.addOffset(a[p]);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 p=a.length-1;p>=0;p--)n.addOffset(a[p]);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 p=a.length-1;p>=0;p--)n.addOffset(a[p]);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 p=a.length-1;p>=0;p--)n.addOffset(a[p]);return n.endVector()}static startSparseInitializersVector(n,a){n.startVector(4,a,4)}static endGraph(n){return n.endObject()}static createGraph(n,a,p,d,e,l,s,c,h){return i.startGraph(n),i.addInitializers(n,a),i.addNodeArgs(n,p),i.addNodes(n,d),i.addMaxNodeIndex(n,e),i.addNodeEdges(n,l),i.addInputs(n,s),i.addOutputs(n,c),i.addSparseInitializers(n,h),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 p=this.bb.__offset(this.bb_pos,6);return p?(a||new t.experimental.fbs.OperatorSetId).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+p)+n*4),this.bb):null}opsetImportLength(){let n=this.bb.__offset(this.bb_pos,6);return n?this.bb.__vector_len(this.bb_pos+n):0}producerName(n){let 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 p=a.length-1;p>=0;p--)n.addOffset(a[p]);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,p,d,e,l,s,c,h,m){return i.startModel(n),i.addIrVersion(n,a),i.addOpsetImport(n,p),i.addProducerName(n,d),i.addProducerVersion(n,e),i.addDomain(n,l),i.addModelVersion(n,s),i.addDocString(n,c),i.addGraph(n,h),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 p=a.length-1;p>=0;p--)n.addInt32(a[p]);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 p=a.length-1;p>=0;p--)n.addInt64(a[p]);return n.endVector()}static startKernelDefHashesVector(n,a){n.startVector(8,a,8)}static endKernelCreateInfos(n){return n.endObject()}static createKernelCreateInfos(n,a,p){return i.startKernelCreateInfos(n),i.addNodeIndices(n,a),i.addKernelDefHashes(n,p),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,p){return i.startSubGraphSessionState(n),i.addGraphId(n,a),i.addSessionState(n,p),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 p=this.bb.__offset(this.bb_pos,6);return p?(a||new t.experimental.fbs.SubGraphSessionState).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+p)+n*4),this.bb):null}subGraphSessionStatesLength(){let n=this.bb.__offset(this.bb_pos,6);return n?this.bb.__vector_len(this.bb_pos+n):0}static startSessionState(n){n.startObject(2)}static addKernels(n,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 p=a.length-1;p>=0;p--)n.addOffset(a[p]);return n.endVector()}static startSubGraphSessionStatesVector(n,a){n.startVector(4,a,4)}static endSessionState(n){return n.endObject()}static createSessionState(n,a,p){return i.startSessionState(n),i.addKernels(n,a),i.addSubGraphSessionStates(n,p),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,p,d){return i.startInferenceSession(n),i.addOrtVersion(n,a),i.addModel(n,p),i.addSessionState(n,d),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,p=2,d=!0;p<arguments.length;)n[a++]=arguments[p++];return new Promise(function(e,l){n[a]=function(s){if(d)if(d=!1,s)l(s);else{for(var c=new Array(arguments.length-1),h=0;h<c.length;)c[h++]=arguments[h];e.apply(null,c)}};try{i.apply(u||null,n)}catch(s){d&&(d=!1,l(s))}})}}),Ys=mt(t=>{var r=t;r.length=function(a){var p=a.length;if(!p)return 0;for(var d=0;--p%4>1&&a.charAt(p)==="=";)++d;return Math.ceil(a.length*3)/4-d};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,p,d){for(var e=null,l=[],s=0,c=0,h;p<d;){var m=a[p++];switch(c){case 0:l[s++]=o[m>>2],h=(m&3)<<4,c=1;break;case 1:l[s++]=o[h|m>>4],h=(m&15)<<2,c=2;break;case 2:l[s++]=o[h|m>>6],l[s++]=o[m&63],c=0;break}s>8191&&((e||(e=[])).push(String.fromCharCode.apply(String,l)),s=0)}return c&&(l[s++]=o[h],l[s++]=61,c===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,p,d){for(var e=d,l=0,s,c=0;c<a.length;){var h=a.charCodeAt(c++);if(h===61&&l>1)break;if((h=i[h])===void 0)throw Error(n);switch(l){case 0:s=h,l=1;break;case 1:p[d++]=s<<2|(h&48)>>4,s=h,l=2;break;case 2:p[d++]=(s&15)<<4|(h&60)>>2,s=h,l=3;break;case 3:p[d++]=(s&3)<<6|h,l=0;break}}if(l===1)throw Error(n);return d-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(p){return typeof Float32Array<"u"?function(){var d=new Float32Array([-0]),e=new Uint8Array(d.buffer),l=e[3]===128;function s(v,_,I){d[0]=v,_[I]=e[0],_[I+1]=e[1],_[I+2]=e[2],_[I+3]=e[3]}function c(v,_,I){d[0]=v,_[I]=e[3],_[I+1]=e[2],_[I+2]=e[1],_[I+3]=e[0]}p.writeFloatLE=l?s:c,p.writeFloatBE=l?c:s;function h(v,_){return e[0]=v[_],e[1]=v[_+1],e[2]=v[_+2],e[3]=v[_+3],d[0]}function m(v,_){return e[3]=v[_],e[2]=v[_+1],e[1]=v[_+2],e[0]=v[_+3],d[0]}p.readFloatLE=l?h:m,p.readFloatBE=l?m:h}():function(){function d(l,s,c,h){var m=s<0?1:0;if(m&&(s=-s),s===0)l(1/s>0?0:2147483648,c,h);else if(isNaN(s))l(2143289344,c,h);else if(s>34028234663852886e22)l((m<<31|2139095040)>>>0,c,h);else if(s<11754943508222875e-54)l((m<<31|Math.round(s/1401298464324817e-60))>>>0,c,h);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,c,h)}}p.writeFloatLE=d.bind(null,i),p.writeFloatBE=d.bind(null,u);function e(l,s,c){var h=l(s,c),m=(h>>31)*2+1,v=h>>>23&255,_=h&8388607;return v===255?_?NaN:m*(1/0):v===0?m*1401298464324817e-60*_:m*Math.pow(2,v-150)*(_+8388608)}p.readFloatLE=e.bind(null,n),p.readFloatBE=e.bind(null,a)}(),typeof Float64Array<"u"?function(){var d=new Float64Array([-0]),e=new Uint8Array(d.buffer),l=e[7]===128;function s(v,_,I){d[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 c(v,_,I){d[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]}p.writeDoubleLE=l?s:c,p.writeDoubleBE=l?c:s;function h(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],d[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],d[0]}p.readDoubleLE=l?h:m,p.readDoubleBE=l?m:h}():function(){function d(l,s,c,h,m,v){var _=h<0?1:0;if(_&&(h=-h),h===0)l(0,m,v+s),l(1/h>0?0:2147483648,m,v+c);else if(isNaN(h))l(0,m,v+s),l(2146959360,m,v+c);else if(h>17976931348623157e292)l(0,m,v+s),l((_<<31|2146435072)>>>0,m,v+c);else{var I;if(h<22250738585072014e-324)I=h/5e-324,l(I>>>0,m,v+s),l((_<<31|I/4294967296)>>>0,m,v+c);else{var T=Math.floor(Math.log(h)/Math.LN2);T===1024&&(T=1023),I=h*Math.pow(2,-T),l(I*4503599627370496>>>0,m,v+s),l((_<<31|T+1023<<20|I*1048576&1048575)>>>0,m,v+c)}}}p.writeDoubleLE=d.bind(null,i,0,4),p.writeDoubleBE=d.bind(null,u,4,0);function e(l,s,c,h,m){var v=l(h,m+s),_=l(h,m+c),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)}p.readDoubleLE=e.bind(null,n,0,4),p.readDoubleBE=e.bind(null,a,4,0)}(),p}function i(p,d,e){d[e]=p&255,d[e+1]=p>>>8&255,d[e+2]=p>>>16&255,d[e+3]=p>>>24}function u(p,d,e){d[e]=p>>>24,d[e+1]=p>>>16&255,d[e+2]=p>>>8&255,d[e+3]=p&255}function n(p,d){return(p[d]|p[d+1]<<8|p[d+2]<<16|p[d+3]<<24)>>>0}function a(p,d){return(p[d]<<24|p[d+1]<<16|p[d+2]<<8|p[d+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,p=[],d=0,e;i<u;)e=o[i++],e<128?p[d++]=e:e>191&&e<224?p[d++]=(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,p[d++]=55296+(e>>10),p[d++]=56320+(e&1023)):p[d++]=(e&15)<<12|(o[i++]&63)<<6|o[i++]&63,d>8191&&((a||(a=[])).push(String.fromCharCode.apply(String,p)),d=0);return a?(d&&a.push(String.fromCharCode.apply(String,p.slice(0,d))),a.join("")):String.fromCharCode.apply(String,p.slice(0,d))},r.write=function(o,i,u){for(var n=u,a,p,d=0;d<o.length;++d)a=o.charCodeAt(d),a<128?i[u++]=a:a<2048?(i[u++]=a>>6|192,i[u++]=a&63|128):(a&64512)===55296&&((p=o.charCodeAt(d+1))&64512)===56320?(a=65536+((a&1023)<<10)+(p&1023),++d,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,p=a>>>1,d=null,e=a;return function(l){if(l<1||l>p)return i(l);e+l>a&&(d=i(a),e=0);var s=u.call(d,e,e+=l);return e&7&&(e=(e|7)+1),s}}}),du=mt((t,r)=>{r.exports=i;var o=Se();function i(p,d){this.lo=p>>>0,this.hi=d>>>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(p){if(p===0)return u;var d=p<0;d&&(p=-p);var e=p>>>0,l=(p-e)/4294967296>>>0;return d&&(l=~l>>>0,e=~e>>>0,++e>4294967295&&(e=0,++l>4294967295&&(l=0))),new i(e,l)},i.from=function(p){if(typeof p=="number")return i.fromNumber(p);if(o.isString(p))if(o.Long)p=o.Long.fromString(p);else return i.fromNumber(parseInt(p,10));return p.low||p.high?new i(p.low>>>0,p.high>>>0):u},i.prototype.toNumber=function(p){if(!p&&this.hi>>>31){var d=~this.lo+1>>>0,e=~this.hi>>>0;return d||(e=e+1>>>0),-(d+e*4294967296)}return this.lo+this.hi*4294967296},i.prototype.toLong=function(p){return o.Long?new o.Long(this.lo|0,this.hi|0,!!p):{low:this.lo|0,high:this.hi|0,unsigned:!!p}};var a=String.prototype.charCodeAt;i.fromHash=function(p){return p===n?u:new i((a.call(p,0)|a.call(p,1)<<8|a.call(p,2)<<16|a.call(p,3)<<24)>>>0,(a.call(p,4)|a.call(p,5)<<8|a.call(p,6)<<16|a.call(p,7)<<24)>>>0)},i.prototype.toHash=function(){return String.fromCharCode(this.lo&255,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,this.hi&255,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},i.prototype.zzEncode=function(){var p=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^p)>>>0,this.lo=(this.lo<<1^p)>>>0,this},i.prototype.zzDecode=function(){var p=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^p)>>>0,this.hi=(this.hi>>>1^p)>>>0,this},i.prototype.length=function(){var p=this.lo,d=(this.lo>>>28|this.hi<<4)>>>0,e=this.hi>>>24;return e===0?d===0?p<16384?p<128?1:2:p<2097152?3:4:d<16384?d<128?5:6:d<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 p=Object.keys(n),d=0;d<p.length;++d)(u[p[d]]===void 0||!a)&&(u[p[d]]=n[p[d]]);return u}r.merge=o,r.lcFirst=function(u){return u.charAt(0).toLowerCase()+u.substring(1)};function i(u){function n(a,p){if(!(this instanceof n))return new n(a,p);Object.defineProperty(this,"message",{get:function(){return a}}),Error.captureStackTrace?Error.captureStackTrace(this,n):Object.defineProperty(this,"stack",{value:new Error().stack||""}),p&&o(this,p)}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 p=Object.keys(this),d=p.length-1;d>-1;--d)if(n[p[d]]===1&&this[p[d]]!==void 0&&this[p[d]]!==null)return p[d]}},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 p(T,P,C){this.fn=T,this.len=P,this.next=void 0,this.val=C}function d(){}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 p(d,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 p(T,P,C),this.len+=P,this};function c(T,P,C){P[C]=T&255}function h(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(p.prototype),m.prototype.fn=h,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(c,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(c,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(c,1,0)},l.prototype.fork=function(){return this.states=new e(this),this.head=this.tail=new p(d,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 p(d,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,p,d){p.set(a,d)}:function(a,p,d){if(a.copy)a.copy(p,d,0,a.length);else for(var e=0;e<a.length;)p[d++]=a[e++]}},u.prototype.bytes=function(a){i.isString(a)&&(a=i._Buffer_from(a,"base64"));var p=a.length>>>0;return this.uint32(p),p&&this._push(u.writeBytesBuffer,p,a),this};function n(a,p,d){a.length<40?i.utf8.write(a,p,d):p.utf8Write?p.utf8Write(a,d):p.write(a,d)}u.prototype.string=function(a){var p=i.Buffer.byteLength(a);return this.uint32(p),p&&this._push(n,p,a),this},u._configure()}),oi=mt((t,r)=>{r.exports=p;var o=Se(),i,u=o.LongBits,n=o.utf8;function a(h,m){return RangeError("index out of range: "+h.pos+" + "+(m||1)+" > "+h.len)}function p(h){this.buf=h,this.pos=0,this.len=h.length}var d=typeof Uint8Array<"u"?function(h){if(h instanceof Uint8Array||Array.isArray(h))return new p(h);throw Error("illegal buffer")}:function(h){if(Array.isArray(h))return new p(h);throw Error("illegal buffer")},e=function(){return o.Buffer?function(h){return(p.create=function(m){return o.Buffer.isBuffer(m)?new i(m):d(m)})(h)}:d};p.create=e(),p.prototype._slice=o.Array.prototype.subarray||o.Array.prototype.slice,p.prototype.uint32=function(){var h=4294967295;return function(){if(h=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(h=(h|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(h=(h|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(h=(h|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(h=(h|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return h;if((this.pos+=5)>this.len)throw this.pos=this.len,a(this,10);return h}}(),p.prototype.int32=function(){return this.uint32()|0},p.prototype.sint32=function(){var h=this.uint32();return h>>>1^-(h&1)|0};function l(){var h=new u(0,0),m=0;if(this.len-this.pos>4){for(;m<4;++m)if(h.lo=(h.lo|(this.buf[this.pos]&127)<<m*7)>>>0,this.buf[this.pos++]<128)return h;if(h.lo=(h.lo|(this.buf[this.pos]&127)<<28)>>>0,h.hi=(h.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return h;m=0}else{for(;m<3;++m){if(this.pos>=this.len)throw a(this);if(h.lo=(h.lo|(this.buf[this.pos]&127)<<m*7)>>>0,this.buf[this.pos++]<128)return h}return h.lo=(h.lo|(this.buf[this.pos++]&127)<<m*7)>>>0,h}if(this.len-this.pos>4){for(;m<5;++m)if(h.hi=(h.hi|(this.buf[this.pos]&127)<<m*7+3)>>>0,this.buf[this.pos++]<128)return h}else for(;m<5;++m){if(this.pos>=this.len)throw a(this);if(h.hi=(h.hi|(this.buf[this.pos]&127)<<m*7+3)>>>0,this.buf[this.pos++]<128)return h}throw Error("invalid varint encoding")}p.prototype.bool=function(){return this.uint32()!==0};function s(h,m){return(h[m-4]|h[m-3]<<8|h[m-2]<<16|h[m-1]<<24)>>>0}p.prototype.fixed32=function(){if(this.pos+4>this.len)throw a(this,4);return s(this.buf,this.pos+=4)},p.prototype.sfixed32=function(){if(this.pos+4>this.len)throw a(this,4);return s(this.buf,this.pos+=4)|0};function c(){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))}p.prototype.float=function(){if(this.pos+4>this.len)throw a(this,4);var h=o.float.readFloatLE(this.buf,this.pos);return this.pos+=4,h},p.prototype.double=function(){if(this.pos+8>this.len)throw a(this,4);var h=o.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,h},p.prototype.bytes=function(){var h=this.uint32(),m=this.pos,v=this.pos+h;if(v>this.len)throw a(this,h);if(this.pos+=h,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)},p.prototype.string=function(){var h=this.bytes();return n.read(h,0,h.length)},p.prototype.skip=function(h){if(typeof h=="number"){if(this.pos+h>this.len)throw a(this,h);this.pos+=h}else do if(this.pos>=this.len)throw a(this);while(this.buf[this.pos++]&128);return this},p.prototype.skipType=function(h){switch(h){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(h=this.uint32()&7)!==4;)this.skipType(h);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+h+" at offset "+this.pos)}return this},p._configure=function(h){i=h,p.create=e(),i._configure();var m=o.Long?"toLong":"toNumber";o.merge(p.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 c.call(this)[m](!0)},sfixed64:function(){return c.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,p,d,e){if(!d)throw TypeError("request must be specified");var l=this;if(!e)return o.asPromise(u,l,n,a,p,d);if(!l.rpcImpl){setTimeout(function(){e(Error("already ended"))},0);return}try{return l.rpcImpl(n,a[l.requestDelimited?"encodeDelimited":"encode"](d).finish(),function(s,c){if(s)return l.emit("error",s,n),e(s);if(c===null){l.end(!0);return}if(!(c instanceof p))try{c=p[l.responseDelimited?"decodeDelimited":"decode"](c)}catch(h){return l.emit("error",h,n),e(h)}return l.emit("data",c,n),e(null,c)})}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 p={};return p.Version=function(){var d={},e=Object.create(d);return e[d[0]="_START_VERSION"]=0,e[d[1]="IR_VERSION_2017_10_10"]=1,e[d[2]="IR_VERSION_2017_10_30"]=2,e[d[3]="IR_VERSION_2017_11_3"]=3,e[d[4]="IR_VERSION_2019_1_22"]=4,e[d[5]="IR_VERSION_2019_3_18"]=5,e[d[6]="IR_VERSION_2019_9_19"]=6,e[d[7]="IR_VERSION_2020_5_8"]=7,e[d[8]="IR_VERSION_2021_7_30"]=8,e[d[9]="IR_VERSION"]=9,e}(),p.AttributeProto=function(){function d(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 d.prototype.name="",d.prototype.refAttrName="",d.prototype.docString="",d.prototype.type=0,d.prototype.f=0,d.prototype.i=n.Long?n.Long.fromBits(0,0,!1):0,d.prototype.s=n.newBuffer([]),d.prototype.t=null,d.prototype.g=null,d.prototype.sparseTensor=null,d.prototype.tp=null,d.prototype.floats=n.emptyArray,d.prototype.ints=n.emptyArray,d.prototype.strings=n.emptyArray,d.prototype.tensors=n.emptyArray,d.prototype.graphs=n.emptyArray,d.prototype.sparseTensors=n.emptyArray,d.prototype.typeProtos=n.emptyArray,d.create=function(e){return new d(e)},d.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},d.encodeDelimited=function(e,l){return this.encode(e,l).ldelim()},d.decode=function(e,l){e instanceof i||(e=i.create(e));for(var s=l===void 0?e.len:e.pos+l,c=new a.onnx.AttributeProto;e.pos<s;){var h=e.uint32();switch(h>>>3){case 1:{c.name=e.string();break}case 21:{c.refAttrName=e.string();break}case 13:{c.docString=e.string();break}case 20:{c.type=e.int32();break}case 2:{c.f=e.float();break}case 3:{c.i=e.int64();break}case 4:{c.s=e.bytes();break}case 5:{c.t=a.onnx.TensorProto.decode(e,e.uint32());break}case 6:{c.g=a.onnx.GraphProto.decode(e,e.uint32());break}case 22:{c.sparseTensor=a.onnx.SparseTensorProto.decode(e,e.uint32());break}case 14:{c.tp=a.onnx.TypeProto.decode(e,e.uint32());break}case 7:{if(c.floats&&c.floats.length||(c.floats=[]),(h&7)===2)for(var m=e.uint32()+e.pos;e.pos<m;)c.floats.push(e.float());else c.floats.push(e.float());break}case 8:{if(c.ints&&c.ints.length||(c.ints=[]),(h&7)===2)for(var m=e.uint32()+e.pos;e.pos<m;)c.ints.push(e.int64());else c.ints.push(e.int64());break}case 9:{c.strings&&c.strings.length||(c.strings=[]),c.strings.push(e.bytes());break}case 10:{c.tensors&&c.tensors.length||(c.tensors=[]),c.tensors.push(a.onnx.TensorProto.decode(e,e.uint32()));break}case 11:{c.graphs&&c.graphs.length||(c.graphs=[]),c.graphs.push(a.onnx.GraphProto.decode(e,e.uint32()));break}case 23:{c.sparseTensors&&c.sparseTensors.length||(c.sparseTensors=[]),c.sparseTensors.push(a.onnx.SparseTensorProto.decode(e,e.uint32()));break}case 15:{c.typeProtos&&c.typeProtos.length||(c.typeProtos=[]),c.typeProtos.push(a.onnx.TypeProto.decode(e,e.uint32()));break}default:e.skipType(h&7);break}}return c},d.decodeDelimited=function(e){return e instanceof i||(e=new i(e)),this.decode(e,e.uint32())},d.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},d.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},d.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 c=new n.Long(0,0,!1);s.i=l.longs===String?c.toString():l.longs===Number?c.toNumber():c}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 h=0;h<e.floats.length;++h)s.floats[h]=l.json&&!isFinite(e.floats[h])?String(e.floats[h]):e.floats[h]}if(e.ints&&e.ints.length){s.ints=[];for(var h=0;h<e.ints.length;++h)typeof e.ints[h]=="number"?s.ints[h]=l.longs===String?String(e.ints[h]):e.ints[h]:s.ints[h]=l.longs===String?n.Long.prototype.toString.call(e.ints[h]):l.longs===Number?new n.LongBits(e.ints[h].low>>>0,e.ints[h].high>>>0).toNumber():e.ints[h]}if(e.strings&&e.strings.length){s.strings=[];for(var h=0;h<e.strings.length;++h)s.strings[h]=l.bytes===String?n.base64.encode(e.strings[h],0,e.strings[h].length):l.bytes===Array?Array.prototype.slice.call(e.strings[h]):e.strings[h]}if(e.tensors&&e.tensors.length){s.tensors=[];for(var h=0;h<e.tensors.length;++h)s.tensors[h]=a.onnx.TensorProto.toObject(e.tensors[h],l)}if(e.graphs&&e.graphs.length){s.graphs=[];for(var h=0;h<e.graphs.length;++h)s.graphs[h]=a.onnx.GraphProto.toObject(e.graphs[h],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 h=0;h<e.typeProtos.length;++h)s.typeProtos[h]=a.onnx.TypeProto.toObject(e.typeProtos[h],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 h=0;h<e.sparseTensors.length;++h)s.sparseTensors[h]=a.onnx.SparseTensorProto.toObject(e.sparseTensors[h],l)}return s},d.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},d.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/onnx.AttributeProto"},d.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}(),d}(),p.ValueInfoProto=function(){function d(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 d.prototype.name="",d.prototype.type=null,d.prototype.docString="",d.create=function(e){return new d(e)},d.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},d.encodeDelimited=function(e,l){return this.encode(e,l).ldelim()},d.decode=function(e,l){e instanceof i||(e=i.create(e));for(var s=l===void 0?e.len:e.pos+l,c=new a.onnx.ValueInfoProto;e.pos<s;){var h=e.uint32();switch(h>>>3){case 1:{c.name=e.string();break}case 2:{c.type=a.onnx.TypeProto.decode(e,e.uint32());break}case 3:{c.docString=e.string();break}default:e.skipType(h&7);break}}return c},d.decodeDelimited=function(e){return e instanceof i||(e=new i(e)),this.decode(e,e.uint32())},d.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},d.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},d.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},d.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},d.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/onnx.ValueInfoProto"},d}(),p.NodeProto=function(){function d(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 d.prototype.input=n.emptyArray,d.prototype.output=n.emptyArray,d.prototype.name="",d.prototype.opType="",d.prototype.domain="",d.prototype.attribute=n.emptyArray,d.prototype.docString="",d.create=function(e){return new d(e)},d.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},d.encodeDelimited=function(e,l){return this.encode(e,l).ldelim()},d.decode=function(e,l){e instanceof i||(e=i.create(e));for(var s=l===void 0?e.len:e.pos+l,c=new a.onnx.NodeProto;e.pos<s;){var h=e.uint32();switch(h>>>3){case 1:{c.input&&c.input.length||(c.input=[]),c.input.push(e.string());break}case 2:{c.output&&c.output.length||(c.output=[]),c.output.push(e.string());break}case 3:{c.name=e.string();break}case 4:{c.opType=e.string();break}case 7:{c.domain=e.string();break}case 5:{c.attribute&&c.attribute.length||(c.attribute=[]),c.attribute.push(a.onnx.AttributeProto.decode(e,e.uint32()));break}case 6:{c.docString=e.string();break}default:e.skipType(h&7);break}}return c},d.decodeDelimited=function(e){return e instanceof i||(e=new i(e)),this.decode(e,e.uint32())},d.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},d.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},d.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 c=0;c<e.input.length;++c)s.input[c]=e.input[c]}if(e.output&&e.output.length){s.output=[];for(var c=0;c<e.output.length;++c)s.output[c]=e.output[c]}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 c=0;c<e.attribute.length;++c)s.attribute[c]=a.onnx.AttributeProto.toObject(e.attribute[c],l)}return e.docString!=null&&e.hasOwnProperty("docString")&&(s.docString=e.docString),e.domain!=null&&e.hasOwnProperty("domain")&&(s.domain=e.domain),s},d.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},d.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/onnx.NodeProto"},d}(),p.TrainingInfoProto=function(){function d(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 d.prototype.initialization=null,d.prototype.algorithm=null,d.prototype.initializationBinding=n.emptyArray,d.prototype.updateBinding=n.emptyArray,d.create=function(e){return new d(e)},d.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},d.encodeDelimited=function(e,l){return this.encode(e,l).ldelim()},d.decode=function(e,l){e instanceof i||(e=i.create(e));for(var s=l===void 0?e.len:e.pos+l,c=new a.onnx.TrainingInfoProto;e.pos<s;){var h=e.uint32();switch(h>>>3){case 1:{c.initialization=a.onnx.GraphProto.decode(e,e.uint32());break}case 2:{c.algorithm=a.onnx.GraphProto.decode(e,e.uint32());break}case 3:{c.initializationBinding&&c.initializationBinding.length||(c.initializationBinding=[]),c.initializationBinding.push(a.onnx.StringStringEntryProto.decode(e,e.uint32()));break}case 4:{c.updateBinding&&c.updateBinding.length||(c.updateBinding=[]),c.updateBinding.push(a.onnx.StringStringEntryProto.decode(e,e.uint32()));break}default:e.skipType(h&7);break}}return c},d.decodeDelimited=function(e){return e instanceof i||(e=new i(e)),this.decode(e,e.uint32())},d.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},d.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},d.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 c=0;c<e.initializationBinding.length;++c)s.initializationBinding[c]=a.onnx.StringStringEntryProto.toObject(e.initializationBinding[c],l)}if(e.updateBinding&&e.updateBinding.length){s.updateBinding=[];for(var c=0;c<e.updateBinding.length;++c)s.updateBinding[c]=a.onnx.StringStringEntryProto.toObject(e.updateBinding[c],l)}return s},d.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},d.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/onnx.TrainingInfoProto"},d}(),p.ModelProto=function(){function d(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 d.prototype.irVersion=n.Long?n.Long.fromBits(0,0,!1):0,d.prototype.opsetImport=n.emptyArray,d.prototype.producerName="",d.prototype.producerVersion="",d.prototype.domain="",d.prototype.modelVersion=n.Long?n.Long.fromBits(0,0,!1):0,d.prototype.docString="",d.prototype.graph=null,d.prototype.metadataProps=n.emptyArray,d.prototype.trainingInfo=n.emptyArray,d.prototype.functions=n.emptyArray,d.create=function(e){return new d(e)},d.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},d.encodeDelimited=function(e,l){return this.encode(e,l).ldelim()},d.decode=function(e,l){e instanceof i||(e=i.create(e));for(var s=l===void 0?e.len:e.pos+l,c=new a.onnx.ModelProto;e.pos<s;){var h=e.uint32();switch(h>>>3){case 1:{c.irVersion=e.int64();break}case 8:{c.opsetImport&&c.opsetImport.length||(c.opsetImport=[]),c.opsetImport.push(a.onnx.OperatorSetIdProto.decode(e,e.uint32()));break}case 2:{c.producerName=e.string();break}case 3:{c.producerVersion=e.string();break}case 4:{c.domain=e.string();break}case 5:{c.modelVersion=e.int64();break}case 6:{c.docString=e.string();break}case 7:{c.graph=a.onnx.GraphProto.decode(e,e.uint32());break}case 14:{c.metadataProps&&c.metadataProps.length||(c.metadataProps=[]),c.metadataProps.push(a.onnx.StringStringEntryProto.decode(e,e.uint32()));break}case 20:{c.trainingInfo&&c.trainingInfo.length||(c.trainingInfo=[]),c.trainingInfo.push(a.onnx.TrainingInfoProto.decode(e,e.uint32()));break}case 25:{c.functions&&c.functions.length||(c.functions=[]),c.functions.push(a.onnx.FunctionProto.decode(e,e.uint32()));break}default:e.skipType(h&7);break}}return c},d.decodeDelimited=function(e){return e instanceof i||(e=new i(e)),this.decode(e,e.uint32())},d.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},d.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},d.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 c=new n.Long(0,0,!1);s.irVersion=l.longs===String?c.toString():l.longs===Number?c.toNumber():c}else s.irVersion=l.longs===String?"0":0;if(s.producerName="",s.producerVersion="",s.domain="",n.Long){var c=new n.Long(0,0,!1);s.modelVersion=l.longs===String?c.toString():l.longs===Number?c.toNumber():c}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 h=0;h<e.opsetImport.length;++h)s.opsetImport[h]=a.onnx.OperatorSetIdProto.toObject(e.opsetImport[h],l)}if(e.metadataProps&&e.metadataProps.length){s.metadataProps=[];for(var h=0;h<e.metadataProps.length;++h)s.metadataProps[h]=a.onnx.StringStringEntryProto.toObject(e.metadataProps[h],l)}if(e.trainingInfo&&e.trainingInfo.length){s.trainingInfo=[];for(var h=0;h<e.trainingInfo.length;++h)s.trainingInfo[h]=a.onnx.TrainingInfoProto.toObject(e.trainingInfo[h],l)}if(e.functions&&e.functions.length){s.functions=[];for(var h=0;h<e.functions.length;++h)s.functions[h]=a.onnx.FunctionProto.toObject(e.functions[h],l)}return s},d.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},d.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/onnx.ModelProto"},d}(),p.StringStringEntryProto=function(){function d(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 d.prototype.key="",d.prototype.value="",d.create=function(e){return new d(e)},d.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},d.encodeDelimited=function(e,l){return this.encode(e,l).ldelim()},d.decode=function(e,l){e instanceof i||(e=i.create(e));for(var s=l===void 0?e.len:e.pos+l,c=new a.onnx.StringStringEntryProto;e.pos<s;){var h=e.uint32();switch(h>>>3){case 1:{c.key=e.string();break}case 2:{c.value=e.string();break}default:e.skipType(h&7);break}}return c},d.decodeDelimited=function(e){return e instanceof i||(e=new i(e)),this.decode(e,e.uint32())},d.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},d.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},d.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},d.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},d.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/onnx.StringStringEntryProto"},d}(),p.TensorAnnotation=function(){function d(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 d.prototype.tensorName="",d.prototype.quantParameterTensorNames=n.emptyArray,d.create=function(e){return new d(e)},d.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},d.encodeDelimited=function(e,l){return this.encode(e,l).ldelim()},d.decode=function(e,l){e instanceof i||(e=i.create(e));for(var s=l===void 0?e.len:e.pos+l,c=new a.onnx.TensorAnnotation;e.pos<s;){var h=e.uint32();switch(h>>>3){case 1:{c.tensorName=e.string();break}case 2:{c.quantParameterTensorNames&&c.quantParameterTensorNames.length||(c.quantParameterTensorNames=[]),c.quantParameterTensorNames.push(a.onnx.StringStringEntryProto.decode(e,e.uint32()));break}default:e.skipType(h&7);break}}return c},d.decodeDelimited=function(e){return e instanceof i||(e=new i(e)),this.decode(e,e.uint32())},d.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},d.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},d.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 c=0;c<e.quantParameterTensorNames.length;++c)s.quantParameterTensorNames[c]=a.onnx.StringStringEntryProto.toObject(e.quantParameterTensorNames[c],l)}return s},d.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},d.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/onnx.TensorAnnotation"},d}(),p.GraphProto=function(){function d(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 d.prototype.node=n.emptyArray,d.prototype.name="",d.prototype.initializer=n.emptyArray,d.prototype.sparseInitializer=n.emptyArray,d.prototype.docString="",d.prototype.input=n.emptyArray,d.prototype.output=n.emptyArray,d.prototype.valueInfo=n.emptyArray,d.prototype.quantizationAnnotation=n.emptyArray,d.create=function(e){return new d(e)},d.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},d.encodeDelimited=function(e,l){return this.encode(e,l).ldelim()},d.decode=function(e,l){e instanceof i||(e=i.create(e));for(var s=l===void 0?e.len:e.pos+l,c=new a.onnx.GraphProto;e.pos<s;){var h=e.uint32();switch(h>>>3){case 1:{c.node&&c.node.length||(c.node=[]),c.node.push(a.onnx.NodeProto.decode(e,e.uint32()));break}case 2:{c.name=e.string();break}case 5:{c.initializer&&c.initializer.length||(c.initializer=[]),c.initializer.push(a.onnx.TensorProto.decode(e,e.uint32()));break}case 15:{c.sparseInitializer&&c.sparseInitializer.length||(c.sparseInitializer=[]),c.sparseInitializer.push(a.onnx.SparseTensorProto.decode(e,e.uint32()));break}case 10:{c.docString=e.string();break}case 11:{c.input&&c.input.length||(c.input=[]),c.input.push(a.onnx.ValueInfoProto.decode(e,e.uint32()));break}case 12:{c.output&&c.output.length||(c.output=[]),c.output.push(a.onnx.ValueInfoProto.decode(e,e.uint32()));break}case 13:{c.valueInfo&&c.valueInfo.length||(c.valueInfo=[]),c.valueInfo.push(a.onnx.ValueInfoProto.decode(e,e.uint32()));break}case 14:{c.quantizationAnnotation&&c.quantizationAnnotation.length||(c.quantizationAnnotation=[]),c.quantizationAnnotation.push(a.onnx.TensorAnnotation.decode(e,e.uint32()));break}default:e.skipType(h&7);break}}return c},d.decodeDelimited=function(e){return e instanceof i||(e=new i(e)),this.decode(e,e.uint32())},d.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},d.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},d.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 c=0;c<e.node.length;++c)s.node[c]=a.onnx.NodeProto.toObject(e.node[c],l)}if(e.name!=null&&e.hasOwnProperty("name")&&(s.name=e.name),e.initializer&&e.initializer.length){s.initializer=[];for(var c=0;c<e.initializer.length;++c)s.initializer[c]=a.onnx.TensorProto.toObject(e.initializer[c],l)}if(e.docString!=null&&e.hasOwnProperty("docString")&&(s.docString=e.docString),e.input&&e.input.length){s.input=[];for(var c=0;c<e.input.length;++c)s.input[c]=a.onnx.ValueInfoProto.toObject(e.input[c],l)}if(e.output&&e.output.length){s.output=[];for(var c=0;c<e.output.length;++c)s.output[c]=a.onnx.ValueInfoProto.toObject(e.output[c],l)}if(e.valueInfo&&e.valueInfo.length){s.valueInfo=[];for(var c=0;c<e.valueInfo.length;++c)s.valueInfo[c]=a.onnx.ValueInfoProto.toObject(e.valueInfo[c],l)}if(e.quantizationAnnotation&&e.quantizationAnnotation.length){s.quantizationAnnotation=[];for(var c=0;c<e.quantizationAnnotation.length;++c)s.quantizationAnnotation[c]=a.onnx.TensorAnnotation.toObject(e.quantizationAnnotation[c],l)}if(e.sparseInitializer&&e.sparseInitializer.length){s.sparseInitializer=[];for(var c=0;c<e.sparseInitializer.length;++c)s.sparseInitializer[c]=a.onnx.SparseTensorProto.toObject(e.sparseInitializer[c],l)}return s},d.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},d.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/onnx.GraphProto"},d}(),p.TensorProto=function(){function d(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 d.prototype.dims=n.emptyArray,d.prototype.dataType=0,d.prototype.segment=null,d.prototype.floatData=n.emptyArray,d.prototype.int32Data=n.emptyArray,d.prototype.stringData=n.emptyArray,d.prototype.int64Data=n.emptyArray,d.prototype.name="",d.prototype.docString="",d.prototype.rawData=n.newBuffer([]),d.prototype.externalData=n.emptyArray,d.prototype.dataLocation=0,d.prototype.doubleData=n.emptyArray,d.prototype.uint64Data=n.emptyArray,d.create=function(e){return new d(e)},d.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},d.encodeDelimited=function(e,l){return this.encode(e,l).ldelim()},d.decode=function(e,l){e instanceof i||(e=i.create(e));for(var s=l===void 0?e.len:e.pos+l,c=new a.onnx.TensorProto;e.pos<s;){var h=e.uint32();switch(h>>>3){case 1:{if(c.dims&&c.dims.length||(c.dims=[]),(h&7)===2)for(var m=e.uint32()+e.pos;e.pos<m;)c.dims.push(e.int64());else c.dims.push(e.int64());break}case 2:{c.dataType=e.int32();break}case 3:{c.segment=a.onnx.TensorProto.Segment.decode(e,e.uint32());break}case 4:{if(c.floatData&&c.floatData.length||(c.floatData=[]),(h&7)===2)for(var m=e.uint32()+e.pos;e.pos<m;)c.floatData.push(e.float());else c.floatData.push(e.float());break}case 5:{if(c.int32Data&&c.int32Data.length||(c.int32Data=[]),(h&7)===2)for(var m=e.uint32()+e.pos;e.pos<m;)c.int32Data.push(e.int32());else c.int32Data.push(e.int32());break}case 6:{c.stringData&&c.stringData.length||(c.stringData=[]),c.stringData.push(e.bytes());break}case 7:{if(c.int64Data&&c.int64Data.length||(c.int64Data=[]),(h&7)===2)for(var m=e.uint32()+e.pos;e.pos<m;)c.int64Data.push(e.int64());else c.int64Data.push(e.int64());break}case 8:{c.name=e.string();break}case 12:{c.docString=e.string();break}case 9:{c.rawData=e.bytes();break}case 13:{c.externalData&&c.externalData.length||(c.externalData=[]),c.externalData.push(a.onnx.StringStringEntryProto.decode(e,e.uint32()));break}case 14:{c.dataLocation=e.int32();break}case 10:{if(c.doubleData&&c.doubleData.length||(c.doubleData=[]),(h&7)===2)for(var m=e.uint32()+e.pos;e.pos<m;)c.doubleData.push(e.double());else c.doubleData.push(e.double());break}case 11:{if(c.uint64Data&&c.uint64Data.length||(c.uint64Data=[]),(h&7)===2)for(var m=e.uint32()+e.pos;e.pos<m;)c.uint64Data.push(e.uint64());else c.uint64Data.push(e.uint64());break}default:e.skipType(h&7);break}}return c},d.decodeDelimited=function(e){return e instanceof i||(e=new i(e)),this.decode(e,e.uint32())},d.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},d.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},d.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 c=0;c<e.dims.length;++c)typeof e.dims[c]=="number"?s.dims[c]=l.longs===String?String(e.dims[c]):e.dims[c]:s.dims[c]=l.longs===String?n.Long.prototype.toString.call(e.dims[c]):l.longs===Number?new n.LongBits(e.dims[c].low>>>0,e.dims[c].high>>>0).toNumber():e.dims[c]}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 c=0;c<e.floatData.length;++c)s.floatData[c]=l.json&&!isFinite(e.floatData[c])?String(e.floatData[c]):e.floatData[c]}if(e.int32Data&&e.int32Data.length){s.int32Data=[];for(var c=0;c<e.int32Data.length;++c)s.int32Data[c]=e.int32Data[c]}if(e.stringData&&e.stringData.length){s.stringData=[];for(var c=0;c<e.stringData.length;++c)s.stringData[c]=l.bytes===String?n.base64.encode(e.stringData[c],0,e.stringData[c].length):l.bytes===Array?Array.prototype.slice.call(e.stringData[c]):e.stringData[c]}if(e.int64Data&&e.int64Data.length){s.int64Data=[];for(var c=0;c<e.int64Data.length;++c)typeof e.int64Data[c]=="number"?s.int64Data[c]=l.longs===String?String(e.int64Data[c]):e.int64Data[c]:s.int64Data[c]=l.longs===String?n.Long.prototype.toString.call(e.int64Data[c]):l.longs===Number?new n.LongBits(e.int64Data[c].low>>>0,e.int64Data[c].high>>>0).toNumber():e.int64Data[c]}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 c=0;c<e.doubleData.length;++c)s.doubleData[c]=l.json&&!isFinite(e.doubleData[c])?String(e.doubleData[c]):e.doubleData[c]}if(e.uint64Data&&e.uint64Data.length){s.uint64Data=[];for(var c=0;c<e.uint64Data.length;++c)typeof e.uint64Data[c]=="number"?s.uint64Data[c]=l.longs===String?String(e.uint64Data[c]):e.uint64Data[c]:s.uint64Data[c]=l.longs===String?n.Long.prototype.toString.call(e.uint64Data[c]):l.longs===Number?new n.LongBits(e.uint64Data[c].low>>>0,e.uint64Data[c].high>>>0).toNumber(!0):e.uint64Data[c]}if(e.docString!=null&&e.hasOwnProperty("docString")&&(s.docString=e.docString),e.externalData&&e.externalData.length){s.externalData=[];for(var c=0;c<e.externalData.length;++c)s.externalData[c]=a.onnx.StringStringEntryProto.toObject(e.externalData[c],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},d.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},d.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/onnx.TensorProto"},d.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}(),d.Segment=function(){function e(l){if(l)for(var s=Object.keys(l),c=0;c<s.length;++c)l[s[c]]!=null&&(this[s[c]]=l[s[c]])}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 c=s===void 0?l.len:l.pos+s,h=new a.onnx.TensorProto.Segment;l.pos<c;){var m=l.uint32();switch(m>>>3){case 1:{h.begin=l.int64();break}case 2:{h.end=l.int64();break}default:l.skipType(m&7);break}}return h},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 c={};if(s.defaults){if(n.Long){var h=new n.Long(0,0,!1);c.begin=s.longs===String?h.toString():s.longs===Number?h.toNumber():h}else c.begin=s.longs===String?"0":0;if(n.Long){var h=new n.Long(0,0,!1);c.end=s.longs===String?h.toString():s.longs===Number?h.toNumber():h}else c.end=s.longs===String?"0":0}return l.begin!=null&&l.hasOwnProperty("begin")&&(typeof l.begin=="number"?c.begin=s.longs===String?String(l.begin):l.begin:c.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"?c.end=s.longs===String?String(l.end):l.end:c.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),c},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}(),d.DataLocation=function(){var e={},l=Object.create(e);return l[e[0]="DEFAULT"]=0,l[e[1]="EXTERNAL"]=1,l}(),d}(),p.SparseTensorProto=function(){function d(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 d.prototype.values=null,d.prototype.indices=null,d.prototype.dims=n.emptyArray,d.create=function(e){return new d(e)},d.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},d.encodeDelimited=function(e,l){return this.encode(e,l).ldelim()},d.decode=function(e,l){e instanceof i||(e=i.create(e));for(var s=l===void 0?e.len:e.pos+l,c=new a.onnx.SparseTensorProto;e.pos<s;){var h=e.uint32();switch(h>>>3){case 1:{c.values=a.onnx.TensorProto.decode(e,e.uint32());break}case 2:{c.indices=a.onnx.TensorProto.decode(e,e.uint32());break}case 3:{if(c.dims&&c.dims.length||(c.dims=[]),(h&7)===2)for(var m=e.uint32()+e.pos;e.pos<m;)c.dims.push(e.int64());else c.dims.push(e.int64());break}default:e.skipType(h&7);break}}return c},d.decodeDelimited=function(e){return e instanceof i||(e=new i(e)),this.decode(e,e.uint32())},d.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},d.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},d.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 c=0;c<e.dims.length;++c)typeof e.dims[c]=="number"?s.dims[c]=l.longs===String?String(e.dims[c]):e.dims[c]:s.dims[c]=l.longs===String?n.Long.prototype.toString.call(e.dims[c]):l.longs===Number?new n.LongBits(e.dims[c].low>>>0,e.dims[c].high>>>0).toNumber():e.dims[c]}return s},d.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},d.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/onnx.SparseTensorProto"},d}(),p.TensorShapeProto=function(){function d(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 d.prototype.dim=n.emptyArray,d.create=function(e){return new d(e)},d.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},d.encodeDelimited=function(e,l){return this.encode(e,l).ldelim()},d.decode=function(e,l){e instanceof i||(e=i.create(e));for(var s=l===void 0?e.len:e.pos+l,c=new a.onnx.TensorShapeProto;e.pos<s;){var h=e.uint32();switch(h>>>3){case 1:{c.dim&&c.dim.length||(c.dim=[]),c.dim.push(a.onnx.TensorShapeProto.Dimension.decode(e,e.uint32()));break}default:e.skipType(h&7);break}}return c},d.decodeDelimited=function(e){return e instanceof i||(e=new i(e)),this.decode(e,e.uint32())},d.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},d.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},d.toObject=function(e,l){l||(l={});var s={};if((l.arrays||l.defaults)&&(s.dim=[]),e.dim&&e.dim.length){s.dim=[];for(var c=0;c<e.dim.length;++c)s.dim[c]=a.onnx.TensorShapeProto.Dimension.toObject(e.dim[c],l)}return s},d.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},d.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/onnx.TensorShapeProto"},d.Dimension=function(){function e(s){if(s)for(var c=Object.keys(s),h=0;h<c.length;++h)s[c[h]]!=null&&(this[c[h]]=s[c[h]])}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,c){return c||(c=u.create()),s.dimValue!=null&&Object.hasOwnProperty.call(s,"dimValue")&&c.uint32(8).int64(s.dimValue),s.dimParam!=null&&Object.hasOwnProperty.call(s,"dimParam")&&c.uint32(18).string(s.dimParam),s.denotation!=null&&Object.hasOwnProperty.call(s,"denotation")&&c.uint32(26).string(s.denotation),c},e.encodeDelimited=function(s,c){return this.encode(s,c).ldelim()},e.decode=function(s,c){s instanceof i||(s=i.create(s));for(var h=c===void 0?s.len:s.pos+c,m=new a.onnx.TensorShapeProto.Dimension;s.pos<h;){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 c={};if(s.dimValue!=null&&s.hasOwnProperty("dimValue")&&(c.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(c.value===1)return"value: multiple values";if(c.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 c=new a.onnx.TensorShapeProto.Dimension;return s.dimValue!=null&&(n.Long?(c.dimValue=n.Long.fromValue(s.dimValue)).unsigned=!1:typeof s.dimValue=="string"?c.dimValue=parseInt(s.dimValue,10):typeof s.dimValue=="number"?c.dimValue=s.dimValue:typeof s.dimValue=="object"&&(c.dimValue=new n.LongBits(s.dimValue.low>>>0,s.dimValue.high>>>0).toNumber())),s.dimParam!=null&&(c.dimParam=String(s.dimParam)),s.denotation!=null&&(c.denotation=String(s.denotation)),c},e.toObject=function(s,c){c||(c={});var h={};return c.defaults&&(h.denotation=""),s.dimValue!=null&&s.hasOwnProperty("dimValue")&&(typeof s.dimValue=="number"?h.dimValue=c.longs===String?String(s.dimValue):s.dimValue:h.dimValue=c.longs===String?n.Long.prototype.toString.call(s.dimValue):c.longs===Number?new n.LongBits(s.dimValue.low>>>0,s.dimValue.high>>>0).toNumber():s.dimValue,c.oneofs&&(h.value="dimValue")),s.dimParam!=null&&s.hasOwnProperty("dimParam")&&(h.dimParam=s.dimParam,c.oneofs&&(h.value="dimParam")),s.denotation!=null&&s.hasOwnProperty("denotation")&&(h.denotation=s.denotation),h},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}(),d}(),p.TypeProto=function(){function d(l){if(l)for(var s=Object.keys(l),c=0;c<s.length;++c)l[s[c]]!=null&&(this[s[c]]=l[s[c]])}d.prototype.tensorType=null,d.prototype.sequenceType=null,d.prototype.mapType=null,d.prototype.optionalType=null,d.prototype.sparseTensorType=null,d.prototype.denotation="";var e;return Object.defineProperty(d.prototype,"value",{get:n.oneOfGetter(e=["tensorType","sequenceType","mapType","optionalType","sparseTensorType"]),set:n.oneOfSetter(e)}),d.create=function(l){return new d(l)},d.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},d.encodeDelimited=function(l,s){return this.encode(l,s).ldelim()},d.decode=function(l,s){l instanceof i||(l=i.create(l));for(var c=s===void 0?l.len:l.pos+s,h=new a.onnx.TypeProto;l.pos<c;){var m=l.uint32();switch(m>>>3){case 1:{h.tensorType=a.onnx.TypeProto.Tensor.decode(l,l.uint32());break}case 4:{h.sequenceType=a.onnx.TypeProto.Sequence.decode(l,l.uint32());break}case 5:{h.mapType=a.onnx.TypeProto.Map.decode(l,l.uint32());break}case 9:{h.optionalType=a.onnx.TypeProto.Optional.decode(l,l.uint32());break}case 8:{h.sparseTensorType=a.onnx.TypeProto.SparseTensor.decode(l,l.uint32());break}case 6:{h.denotation=l.string();break}default:l.skipType(m&7);break}}return h},d.decodeDelimited=function(l){return l instanceof i||(l=new i(l)),this.decode(l,l.uint32())},d.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 c=a.onnx.TypeProto.Tensor.verify(l.tensorType);if(c)return"tensorType."+c}}if(l.sequenceType!=null&&l.hasOwnProperty("sequenceType")){if(s.value===1)return"value: multiple values";s.value=1;{var c=a.onnx.TypeProto.Sequence.verify(l.sequenceType);if(c)return"sequenceType."+c}}if(l.mapType!=null&&l.hasOwnProperty("mapType")){if(s.value===1)return"value: multiple values";s.value=1;{var c=a.onnx.TypeProto.Map.verify(l.mapType);if(c)return"mapType."+c}}if(l.optionalType!=null&&l.hasOwnProperty("optionalType")){if(s.value===1)return"value: multiple values";s.value=1;{var c=a.onnx.TypeProto.Optional.verify(l.optionalType);if(c)return"optionalType."+c}}if(l.sparseTensorType!=null&&l.hasOwnProperty("sparseTensorType")){if(s.value===1)return"value: multiple values";s.value=1;{var c=a.onnx.TypeProto.SparseTensor.verify(l.sparseTensorType);if(c)return"sparseTensorType."+c}}return l.denotation!=null&&l.hasOwnProperty("denotation")&&!n.isString(l.denotation)?"denotation: string expected":null},d.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},d.toObject=function(l,s){s||(s={});var c={};return s.defaults&&(c.denotation=""),l.tensorType!=null&&l.hasOwnProperty("tensorType")&&(c.tensorType=a.onnx.TypeProto.Tensor.toObject(l.tensorType,s),s.oneofs&&(c.value="tensorType")),l.sequenceType!=null&&l.hasOwnProperty("sequenceType")&&(c.sequenceType=a.onnx.TypeProto.Sequence.toObject(l.sequenceType,s),s.oneofs&&(c.value="sequenceType")),l.mapType!=null&&l.hasOwnProperty("mapType")&&(c.mapType=a.onnx.TypeProto.Map.toObject(l.mapType,s),s.oneofs&&(c.value="mapType")),l.denotation!=null&&l.hasOwnProperty("denotation")&&(c.denotation=l.denotation),l.sparseTensorType!=null&&l.hasOwnProperty("sparseTensorType")&&(c.sparseTensorType=a.onnx.TypeProto.SparseTensor.toObject(l.sparseTensorType,s),s.oneofs&&(c.value="sparseTensorType")),l.optionalType!=null&&l.hasOwnProperty("optionalType")&&(c.optionalType=a.onnx.TypeProto.Optional.toObject(l.optionalType,s),s.oneofs&&(c.value="optionalType")),c},d.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},d.getTypeUrl=function(l){return l===void 0&&(l="type.googleapis.com"),l+"/onnx.TypeProto"},d.Tensor=function(){function l(s){if(s)for(var c=Object.keys(s),h=0;h<c.length;++h)s[c[h]]!=null&&(this[c[h]]=s[c[h]])}return l.prototype.elemType=0,l.prototype.shape=null,l.create=function(s){return new l(s)},l.encode=function(s,c){return c||(c=u.create()),s.elemType!=null&&Object.hasOwnProperty.call(s,"elemType")&&c.uint32(8).int32(s.elemType),s.shape!=null&&Object.hasOwnProperty.call(s,"shape")&&a.onnx.TensorShapeProto.encode(s.shape,c.uint32(18).fork()).ldelim(),c},l.encodeDelimited=function(s,c){return this.encode(s,c).ldelim()},l.decode=function(s,c){s instanceof i||(s=i.create(s));for(var h=c===void 0?s.len:s.pos+c,m=new a.onnx.TypeProto.Tensor;s.pos<h;){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 c=a.onnx.TensorShapeProto.verify(s.shape);if(c)return"shape."+c}return null},l.fromObject=function(s){if(s instanceof a.onnx.TypeProto.Tensor)return s;var c=new a.onnx.TypeProto.Tensor;if(s.elemType!=null&&(c.elemType=s.elemType|0),s.shape!=null){if(typeof s.shape!="object")throw TypeError(".onnx.TypeProto.Tensor.shape: object expected");c.shape=a.onnx.TensorShapeProto.fromObject(s.shape)}return c},l.toObject=function(s,c){c||(c={});var h={};return c.defaults&&(h.elemType=0,h.shape=null),s.elemType!=null&&s.hasOwnProperty("elemType")&&(h.elemType=s.elemType),s.shape!=null&&s.hasOwnProperty("shape")&&(h.shape=a.onnx.TensorShapeProto.toObject(s.shape,c)),h},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}(),d.Sequence=function(){function l(s){if(s)for(var c=Object.keys(s),h=0;h<c.length;++h)s[c[h]]!=null&&(this[c[h]]=s[c[h]])}return l.prototype.elemType=null,l.create=function(s){return new l(s)},l.encode=function(s,c){return c||(c=u.create()),s.elemType!=null&&Object.hasOwnProperty.call(s,"elemType")&&a.onnx.TypeProto.encode(s.elemType,c.uint32(10).fork()).ldelim(),c},l.encodeDelimited=function(s,c){return this.encode(s,c).ldelim()},l.decode=function(s,c){s instanceof i||(s=i.create(s));for(var h=c===void 0?s.len:s.pos+c,m=new a.onnx.TypeProto.Sequence;s.pos<h;){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 c=a.onnx.TypeProto.verify(s.elemType);if(c)return"elemType."+c}return null},l.fromObject=function(s){if(s instanceof a.onnx.TypeProto.Sequence)return s;var c=new a.onnx.TypeProto.Sequence;if(s.elemType!=null){if(typeof s.elemType!="object")throw TypeError(".onnx.TypeProto.Sequence.elemType: object expected");c.elemType=a.onnx.TypeProto.fromObject(s.elemType)}return c},l.toObject=function(s,c){c||(c={});var h={};return c.defaults&&(h.elemType=null),s.elemType!=null&&s.hasOwnProperty("elemType")&&(h.elemType=a.onnx.TypeProto.toObject(s.elemType,c)),h},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}(),d.Map=function(){function l(s){if(s)for(var c=Object.keys(s),h=0;h<c.length;++h)s[c[h]]!=null&&(this[c[h]]=s[c[h]])}return l.prototype.keyType=0,l.prototype.valueType=null,l.create=function(s){return new l(s)},l.encode=function(s,c){return c||(c=u.create()),s.keyType!=null&&Object.hasOwnProperty.call(s,"keyType")&&c.uint32(8).int32(s.keyType),s.valueType!=null&&Object.hasOwnProperty.call(s,"valueType")&&a.onnx.TypeProto.encode(s.valueType,c.uint32(18).fork()).ldelim(),c},l.encodeDelimited=function(s,c){return this.encode(s,c).ldelim()},l.decode=function(s,c){s instanceof i||(s=i.create(s));for(var h=c===void 0?s.len:s.pos+c,m=new a.onnx.TypeProto.Map;s.pos<h;){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 c=a.onnx.TypeProto.verify(s.valueType);if(c)return"valueType."+c}return null},l.fromObject=function(s){if(s instanceof a.onnx.TypeProto.Map)return s;var c=new a.onnx.TypeProto.Map;if(s.keyType!=null&&(c.keyType=s.keyType|0),s.valueType!=null){if(typeof s.valueType!="object")throw TypeError(".onnx.TypeProto.Map.valueType: object expected");c.valueType=a.onnx.TypeProto.fromObject(s.valueType)}return c},l.toObject=function(s,c){c||(c={});var h={};return c.defaults&&(h.keyType=0,h.valueType=null),s.keyType!=null&&s.hasOwnProperty("keyType")&&(h.keyType=s.keyType),s.valueType!=null&&s.hasOwnProperty("valueType")&&(h.valueType=a.onnx.TypeProto.toObject(s.valueType,c)),h},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}(),d.Optional=function(){function l(s){if(s)for(var c=Object.keys(s),h=0;h<c.length;++h)s[c[h]]!=null&&(this[c[h]]=s[c[h]])}return l.prototype.elemType=null,l.create=function(s){return new l(s)},l.encode=function(s,c){return c||(c=u.create()),s.elemType!=null&&Object.hasOwnProperty.call(s,"elemType")&&a.onnx.TypeProto.encode(s.elemType,c.uint32(10).fork()).ldelim(),c},l.encodeDelimited=function(s,c){return this.encode(s,c).ldelim()},l.decode=function(s,c){s instanceof i||(s=i.create(s));for(var h=c===void 0?s.len:s.pos+c,m=new a.onnx.TypeProto.Optional;s.pos<h;){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 c=a.onnx.TypeProto.verify(s.elemType);if(c)return"elemType."+c}return null},l.fromObject=function(s){if(s instanceof a.onnx.TypeProto.Optional)return s;var c=new a.onnx.TypeProto.Optional;if(s.elemType!=null){if(typeof s.elemType!="object")throw TypeError(".onnx.TypeProto.Optional.elemType: object expected");c.elemType=a.onnx.TypeProto.fromObject(s.elemType)}return c},l.toObject=function(s,c){c||(c={});var h={};return c.defaults&&(h.elemType=null),s.elemType!=null&&s.hasOwnProperty("elemType")&&(h.elemType=a.onnx.TypeProto.toObject(s.elemType,c)),h},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}(),d.SparseTensor=function(){function l(s){if(s)for(var c=Object.keys(s),h=0;h<c.length;++h)s[c[h]]!=null&&(this[c[h]]=s[c[h]])}return l.prototype.elemType=0,l.prototype.shape=null,l.create=function(s){return new l(s)},l.encode=function(s,c){return c||(c=u.create()),s.elemType!=null&&Object.hasOwnProperty.call(s,"elemType")&&c.uint32(8).int32(s.elemType),s.shape!=null&&Object.hasOwnProperty.call(s,"shape")&&a.onnx.TensorShapeProto.encode(s.shape,c.uint32(18).fork()).ldelim(),c},l.encodeDelimited=function(s,c){return this.encode(s,c).ldelim()},l.decode=function(s,c){s instanceof i||(s=i.create(s));for(var h=c===void 0?s.len:s.pos+c,m=new a.onnx.TypeProto.SparseTensor;s.pos<h;){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 c=a.onnx.TensorShapeProto.verify(s.shape);if(c)return"shape."+c}return null},l.fromObject=function(s){if(s instanceof a.onnx.TypeProto.SparseTensor)return s;var c=new a.onnx.TypeProto.SparseTensor;if(s.elemType!=null&&(c.elemType=s.elemType|0),s.shape!=null){if(typeof s.shape!="object")throw TypeError(".onnx.TypeProto.SparseTensor.shape: object expected");c.shape=a.onnx.TensorShapeProto.fromObject(s.shape)}return c},l.toObject=function(s,c){c||(c={});var h={};return c.defaults&&(h.elemType=0,h.shape=null),s.elemType!=null&&s.hasOwnProperty("elemType")&&(h.elemType=s.elemType),s.shape!=null&&s.hasOwnProperty("shape")&&(h.shape=a.onnx.TensorShapeProto.toObject(s.shape,c)),h},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}(),d}(),p.OperatorSetIdProto=function(){function d(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 d.prototype.domain="",d.prototype.version=n.Long?n.Long.fromBits(0,0,!1):0,d.create=function(e){return new d(e)},d.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},d.encodeDelimited=function(e,l){return this.encode(e,l).ldelim()},d.decode=function(e,l){e instanceof i||(e=i.create(e));for(var s=l===void 0?e.len:e.pos+l,c=new a.onnx.OperatorSetIdProto;e.pos<s;){var h=e.uint32();switch(h>>>3){case 1:{c.domain=e.string();break}case 2:{c.version=e.int64();break}default:e.skipType(h&7);break}}return c},d.decodeDelimited=function(e){return e instanceof i||(e=new i(e)),this.decode(e,e.uint32())},d.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},d.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},d.toObject=function(e,l){l||(l={});var s={};if(l.defaults)if(s.domain="",n.Long){var c=new n.Long(0,0,!1);s.version=l.longs===String?c.toString():l.longs===Number?c.toNumber():c}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},d.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},d.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/onnx.OperatorSetIdProto"},d}(),p.OperatorStatus=function(){var d={},e=Object.create(d);return e[d[0]="EXPERIMENTAL"]=0,e[d[1]="STABLE"]=1,e}(),p.FunctionProto=function(){function d(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 d.prototype.name="",d.prototype.input=n.emptyArray,d.prototype.output=n.emptyArray,d.prototype.attribute=n.emptyArray,d.prototype.attributeProto=n.emptyArray,d.prototype.node=n.emptyArray,d.prototype.docString="",d.prototype.opsetImport=n.emptyArray,d.prototype.domain="",d.create=function(e){return new d(e)},d.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},d.encodeDelimited=function(e,l){return this.encode(e,l).ldelim()},d.decode=function(e,l){e instanceof i||(e=i.create(e));for(var s=l===void 0?e.len:e.pos+l,c=new a.onnx.FunctionProto;e.pos<s;){var h=e.uint32();switch(h>>>3){case 1:{c.name=e.string();break}case 4:{c.input&&c.input.length||(c.input=[]),c.input.push(e.string());break}case 5:{c.output&&c.output.length||(c.output=[]),c.output.push(e.string());break}case 6:{c.attribute&&c.attribute.length||(c.attribute=[]),c.attribute.push(e.string());break}case 11:{c.attributeProto&&c.attributeProto.length||(c.attributeProto=[]),c.attributeProto.push(a.onnx.AttributeProto.decode(e,e.uint32()));break}case 7:{c.node&&c.node.length||(c.node=[]),c.node.push(a.onnx.NodeProto.decode(e,e.uint32()));break}case 8:{c.docString=e.string();break}case 9:{c.opsetImport&&c.opsetImport.length||(c.opsetImport=[]),c.opsetImport.push(a.onnx.OperatorSetIdProto.decode(e,e.uint32()));break}case 10:{c.domain=e.string();break}default:e.skipType(h&7);break}}return c},d.decodeDelimited=function(e){return e instanceof i||(e=new i(e)),this.decode(e,e.uint32())},d.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},d.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},d.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 c=0;c<e.input.length;++c)s.input[c]=e.input[c]}if(e.output&&e.output.length){s.output=[];for(var c=0;c<e.output.length;++c)s.output[c]=e.output[c]}if(e.attribute&&e.attribute.length){s.attribute=[];for(var c=0;c<e.attribute.length;++c)s.attribute[c]=e.attribute[c]}if(e.node&&e.node.length){s.node=[];for(var c=0;c<e.node.length;++c)s.node[c]=a.onnx.NodeProto.toObject(e.node[c],l)}if(e.docString!=null&&e.hasOwnProperty("docString")&&(s.docString=e.docString),e.opsetImport&&e.opsetImport.length){s.opsetImport=[];for(var c=0;c<e.opsetImport.length;++c)s.opsetImport[c]=a.onnx.OperatorSetIdProto.toObject(e.opsetImport[c],l)}if(e.domain!=null&&e.hasOwnProperty("domain")&&(s.domain=e.domain),e.attributeProto&&e.attributeProto.length){s.attributeProto=[];for(var c=0;c<e.attributeProto.length;++c)s.attributeProto[c]=a.onnx.AttributeProto.toObject(e.attributeProto[c],l)}return s},d.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},d.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/onnx.FunctionProto"},d}(),p}(),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),p=new Array(a);if(i){if(u<2||n<2)return;let d=ai.calcMatMulShape([r[u-2],r[u-1]],[o[n-2],o[n-1]]);if(d===void 0)return;[p[a-2],p[a-1]]=d}for(let d=i?3:1;d<=a;d++){let e=u-d<0?1:r[u-d],l=n-d<0?1:o[n-d];if(e!==l&&e>1&&l>1)return;p[a-d]=Math.max(e,l)}return p}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 p=B.size(a),d=u?r:new bt(a,n||r.type);if(a.length===0)d.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),c=0,h=0,m=!1,v=!1;r.dims.length===0&&(c=r.get([]),m=!0),o.dims.length===0&&(h=o.get([]),v=!0);let _;for(let I=0;I<p;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),c=r.get(l)),v||(Oe.fillIndex(e,o.dims,s),h=o.get(s)),d.set(e,i(c,h))}}return d}}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,p=r[a]||1;(o[o.length-1-n]||1)>1&&p===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,p;r?(n=t[1],a=t[0]):(n=t[0],a=t[1]);let d=-1;if(i?(p=o[0],d=1):(p=o[1],d=0),o[d]!==a)throw new Error("dimension mismatch");if(n<=0||p<=0||a<=0)throw new Error("invalid shape specified");if(u&&!kt.isValidBroadcast(u,[n,p]))throw new Error("gemm: invalid bias shape for broadcast");return[n,p,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 d=0;d<i;d++){if(o[d]<-1)throw new Error("a dimension in shape hints cannot be less than -1");if(o[d]===-1){if(n!==-1)throw new Error("at most one dimension in shape hints can be -1");n=d}else{if(o[d]===0){if(d>=r.length)throw new Error("the dimension with value zero exceeds the dimension size of the input tensor");u[d]=r[d]}else u[d]=o[d];a*=u[d]}}let p=re.size(r);if(n!==-1){if(p%a!==0)throw new Error(`the input tensor cannot be reshaped to the requested shape. Input shape: [${r}] Output shape: [${o}]`);u[n]=p/a}else if(a!==p)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 p=0;p<i.length;++p){p!==0&&a.push(a[p-1]+i[p-1]);let d=r.slice();d[o]=i[p],n.push(d)}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 p=0;p<o.length-2;p++)p>=i.length?i.push(o[p+2]):i[p]=o[p+2];for(let p=0;p<i.length;p++)if(p<u.length){if(u[p]<0)throw new Error("strides should be greater than or equal to 1")}else u.push(1);for(let p=0;p<i.length;p++)if(p<n.length){if(n[p]<0)throw new Error("dilations should be greater than or equal to 1")}else n.push(1);for(let p=0;p<i.length*2;p++)if(p<a.length){if(a[p]<0)throw new Error("pad should be greater than or equal to 1")}else a.push(0);for(let p=0;p<i.length;p++){if(i[p]<=0)throw new Error("kernel shapes need to be greater than 0");if(a[p]>=i[p]||a[p+i.length]>=i[p])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 p=0;p<r.length-2;p++)Ie.adjustPadAndReturnShape(r[p+2],o[p],i[p],u[p],n,p,p+r.length-2,a)}}static computePoolOutputShape(r,o,i,u,n,a,p){if(o.length<=0)throw new Error("input shape must be of size greater than 0");let d=[o[0],o[1]];return Ie.computeShapeHelper(r,o,d,i,u,n,a,p),d}static computeConvOutputShape(r,o,i,u,n,a,p){if(r.length<=0||o.length<=0)throw new Error("invalid input tensor dims or invalid filter tensor dims");let d=[r[0],o[0]];return Ie.computeShapeHelper(!1,r,d,i,u,n,a,p),d}static computeShapeHelper(r,o,i,u,n,a,p,d){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],p,e,e+o.length-2,d))}static adjustPadAndReturnShape(r,o,i,u,n,a,p,d){let e=i*(u-1)+1;if(d&&d!=="NOTSET")switch(d){case"VALID":return n[a]=0,n[p]=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(d==="SAME_LOWER"?(l+1)/2:l/2),n[p]=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[p]-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 p=this.size,d=i===void 0&&u===void 0&&n===void 0;if(n!==void 0&&n.length!==p)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");d&&(this.cache=new Array(p))}else{if(n!==void 0){let e=ju(o);if(!(n instanceof e))throw new TypeError(`cache should be type ${e.name}`)}if(d){let e=new ArrayBuffer(p*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),p=Wu(r.dataType),d=r.rawData.byteLength/p;if(r.rawData.byteLength%p!==0)throw new Error("invalid buffer length");if(n.length!==d)throw new Error("buffer length mismatch");for(let e=0;e<d;e++){let l=Hu(a,r.dataType,e*p);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 p=0;p<n.length;p++){let d=n[p];xe.isLong(d)?a[p]=ui(d,r.dataType):a[p]=d}}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()),p=Wu(r.dataType()),d=r.rawDataLength()/p;if(r.rawDataLength()%p!==0)throw new Error("invalid buffer length");if(n.length!==d)throw new Error("buffer length mismatch");for(let e=0;e<d;e++){let l=Hu(a,r.dataType(),e*p);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=(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}
|
|
6
11
|
precision highp float;
|
|
7
12
|
${r.attribute} vec3 position;
|
|
8
13
|
${r.attribute} vec2 textureCoord;
|
|
@@ -52,7 +57,7 @@
|
|
|
52
57
|
vec4 result = vec4(process(indices));
|
|
53
58
|
${o.output} = result;
|
|
54
59
|
}
|
|
55
|
-
`}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
|
|
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`
|
|
56
61
|
float getChannel(vec4 frag, int dim) {
|
|
57
62
|
int modCoord = imod(dim, 2);
|
|
58
63
|
return modCoord == 0 ? frag.r : frag.g;
|
|
@@ -66,31 +71,31 @@
|
|
|
66
71
|
}
|
|
67
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),
|
|
68
73
|
rc + 1 >= ${t[0]} ? 0. : getA(rc + 1),
|
|
69
|
-
0, 0`;let i="r, c",u="r, cp1",n="rp1, c",a="rp1, cp1",
|
|
70
|
-
rEdge ? 0. : getA(${
|
|
71
|
-
cEdge ? 0. : getA(${
|
|
72
|
-
rEdge || cEdge ? 0. : getA(${
|
|
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?"":`
|
|
73
78
|
int r = ${r[t-2]};
|
|
74
79
|
int c = ${r[t-1]};
|
|
75
80
|
int rp1 = ${r[t-2]} + 1;
|
|
76
81
|
int cp1 = ${r[t-1]} + 1;
|
|
77
82
|
bool rEdge = rp1 >= ${i};
|
|
78
83
|
bool cEdge = cp1 >= ${o};
|
|
79
|
-
`}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),
|
|
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=`
|
|
80
85
|
void main() {
|
|
81
86
|
${a} rc = getOutputCoords();
|
|
82
87
|
|
|
83
88
|
if(${l}) {
|
|
84
89
|
${o.output} = vec4(0);
|
|
85
90
|
} else {
|
|
86
|
-
${
|
|
91
|
+
${c}
|
|
87
92
|
|
|
88
93
|
${o.output} = vec4(${s});
|
|
89
94
|
}
|
|
90
95
|
}
|
|
91
|
-
`;return{...Zu,hasMain:!0,output:{dims:r.dims,type:r.type,textureType:2},shaderSource:
|
|
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`
|
|
92
97
|
ivec3 inputCoordsFromReshapedOutCoords(int index) {
|
|
93
|
-
${r.map((u,n)=>{let a=`int ${o[n]} = ${i} / ${u}`,
|
|
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("")}
|
|
94
99
|
return ivec3(b, r, c);
|
|
95
100
|
}
|
|
96
101
|
`}function Sh(t){let r=B.computeStrides(t);return`
|
|
@@ -109,7 +114,7 @@
|
|
|
109
114
|
result[${e}] = getChannel(getA(inputRC.x, inputRC.y, inputRC.z), innerDims);
|
|
110
115
|
|
|
111
116
|
${e>0?"}":""}
|
|
112
|
-
`}let
|
|
117
|
+
`}let d=G(t.session.backend.glContext.version),c=`
|
|
113
118
|
${Oh(u)}
|
|
114
119
|
${Sh(n)}
|
|
115
120
|
${de()}
|
|
@@ -124,9 +129,9 @@
|
|
|
124
129
|
int cols = ${n[1]};
|
|
125
130
|
|
|
126
131
|
${a}
|
|
127
|
-
${
|
|
132
|
+
${d.output} = result;
|
|
128
133
|
}
|
|
129
|
-
`;return{...o,output:{dims:n,type:r.type,textureType:2},shaderSource:
|
|
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=`
|
|
130
135
|
const float FLOAT_MAX = 1.70141184e38;
|
|
131
136
|
const float FLOAT_MIN = 1.17549435e-38;
|
|
132
137
|
|
|
@@ -173,17 +178,17 @@
|
|
|
173
178
|
void main() {
|
|
174
179
|
float value = ${i.texture2D}(X,TexCoords).r;
|
|
175
180
|
${i.output} = encodeAsUint8(value);
|
|
176
|
-
}`,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(),
|
|
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=`
|
|
177
182
|
${a}
|
|
178
183
|
void main() {
|
|
179
184
|
${n} rc = getOutputCoords();
|
|
180
185
|
|
|
181
186
|
// Sample the texture with the coords to get the rgba channel value.
|
|
182
|
-
vec4 packedInput = getA(${
|
|
187
|
+
vec4 packedInput = getA(${d});
|
|
183
188
|
|
|
184
|
-
${e.output} = vec4(getChannel(packedInput, ${
|
|
189
|
+
${e.output} = vec4(getChannel(packedInput, ${c}), 0, 0, 0);
|
|
185
190
|
}
|
|
186
|
-
`;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,
|
|
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=`
|
|
187
192
|
float process(int[${u}] indices) {
|
|
188
193
|
vec2 position = offsetToCoords(indices[1], ${n}, ${a});
|
|
189
194
|
float scale = getColorAsFloat(${i.texture2D}(Scale, position));
|
|
@@ -192,7 +197,7 @@
|
|
|
192
197
|
float b = getColorAsFloat(${i.texture2D}(B, position));
|
|
193
198
|
|
|
194
199
|
return scale * ( (_A(indices) - mean) / sqrt(variance + float(${o.epsilon})) ) + b;
|
|
195
|
-
}`;return{...pl,output:{dims:r[0].dims,type:r[0].type,textureType:0},shaderSource:
|
|
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:`
|
|
196
201
|
float ${t}(float a, float b) {
|
|
197
202
|
return a + b;
|
|
198
203
|
}
|
|
@@ -302,7 +307,7 @@
|
|
|
302
307
|
vec4 ${r}(vec4 v1, vec4 v2) {
|
|
303
308
|
return ${t}(v1, v2);
|
|
304
309
|
}
|
|
305
|
-
`,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,
|
|
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?`
|
|
306
311
|
${o.body}
|
|
307
312
|
void main() {
|
|
308
313
|
vec4 a = getAAtOutCoords();
|
|
@@ -312,62 +317,62 @@
|
|
|
312
317
|
}`:`
|
|
313
318
|
${o.body}
|
|
314
319
|
float process(int indices[${s}]) {
|
|
315
|
-
int aindices[${
|
|
316
|
-
int bindices[${
|
|
320
|
+
int aindices[${h}];
|
|
321
|
+
int bindices[${f}];
|
|
317
322
|
${m}
|
|
318
323
|
${v}
|
|
319
324
|
return ${o.name}(_A(aindices), _B(bindices));
|
|
320
|
-
}`;return{name:o.name,inputNames:["A","B"],inputTypes:[u,u],output:{dims:a,type:i,textureType:u},shaderSource:I,hasMain:
|
|
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=`
|
|
321
326
|
${o.body}
|
|
322
327
|
void main() {
|
|
323
|
-
vec4 v1 = ${
|
|
324
|
-
vec4 v2 = ${
|
|
328
|
+
vec4 v1 = ${c.texture2D}(A, TexCoords);
|
|
329
|
+
vec4 v2 = ${c.texture2D}(B, TexCoords);
|
|
325
330
|
vec4 result = ${o.name}(v1, v2);
|
|
326
|
-
${
|
|
331
|
+
${c.output} = result;
|
|
327
332
|
}
|
|
328
|
-
`;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,
|
|
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]}) {
|
|
329
334
|
return getChannel(
|
|
330
335
|
getX0(${v}), vec2(${m.join()}));
|
|
331
|
-
}`;for(let V=1;V<
|
|
332
|
-
if (${
|
|
336
|
+
}`;for(let V=1;V<h.length;V++){let gt=h[V-1];_+=`
|
|
337
|
+
if (${f} < ${h[V]} && ${f} >= ${h[V-1]}) {
|
|
333
338
|
return getChannel(
|
|
334
|
-
getX${V}(${kn(s,
|
|
335
|
-
vec2(${kn(m,
|
|
336
|
-
}`}let I=
|
|
339
|
+
getX${V}(${kn(s,f,gt)}),
|
|
340
|
+
vec2(${kn(m,f,gt)}));
|
|
341
|
+
}`}let I=h.length,T=h[h.length-1];_+=`
|
|
337
342
|
return getChannel(
|
|
338
|
-
getX${I}(${kn(s,
|
|
339
|
-
vec2(${kn(m,
|
|
343
|
+
getX${I}(${kn(s,f,T)}),
|
|
344
|
+
vec2(${kn(m,f,T)}));`;let P=G(t.session.backend.glContext.version),C=`
|
|
340
345
|
${e}
|
|
341
346
|
float getValue(${s.map(V=>"int "+V)}) {
|
|
342
347
|
${_}
|
|
343
348
|
}
|
|
344
349
|
|
|
345
350
|
void main() {
|
|
346
|
-
${
|
|
351
|
+
${c} coords = getOutputCoords();
|
|
347
352
|
int lastDim = coords.${s[a-1]};
|
|
348
353
|
coords.${s[a-1]} = coords.${s[a-2]};
|
|
349
354
|
coords.${s[a-2]} = lastDim;
|
|
350
355
|
|
|
351
|
-
vec4 result = vec4(getValue(${
|
|
356
|
+
vec4 result = vec4(getValue(${d}), 0., 0., 0.);
|
|
352
357
|
|
|
353
|
-
${
|
|
354
|
-
if (${
|
|
355
|
-
result.g = getValue(${
|
|
358
|
+
${d[a-1]} = ${d[a-1]} + 1;
|
|
359
|
+
if (${d[a-1]} < ${n[a-1]}) {
|
|
360
|
+
result.g = getValue(${d});
|
|
356
361
|
}
|
|
357
362
|
|
|
358
|
-
${
|
|
359
|
-
if (${
|
|
360
|
-
result.a = getValue(${
|
|
363
|
+
${d[a-2]} = ${d[a-2]} + 1;
|
|
364
|
+
if (${d[a-2]} < ${n[a-2]}) {
|
|
365
|
+
result.a = getValue(${d});
|
|
361
366
|
}
|
|
362
367
|
|
|
363
|
-
${
|
|
364
|
-
if (${
|
|
365
|
-
${
|
|
366
|
-
result.b = getValue(${
|
|
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});
|
|
367
372
|
}
|
|
368
373
|
${P.output} = result;
|
|
369
374
|
}
|
|
370
|
-
`;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
|
|
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=`
|
|
371
376
|
${l}
|
|
372
377
|
${s}
|
|
373
378
|
${e}
|
|
@@ -379,7 +384,7 @@
|
|
|
379
384
|
}
|
|
380
385
|
|
|
381
386
|
return fetchDataFromCorrectTexture(textureIndex, indices);
|
|
382
|
-
}`;return{...r,output:{dims:n,type:o[0].type,textureType:0},shaderSource:
|
|
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) {
|
|
383
388
|
${t.map((r,o)=>`if(index<${r}) {return ${o};}
|
|
384
389
|
`).join("")}
|
|
385
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(`
|
|
@@ -478,7 +483,7 @@
|
|
|
478
483
|
v = ${i.name}_(v);
|
|
479
484
|
${n.output} = v;
|
|
480
485
|
}
|
|
481
|
-
`,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(),
|
|
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=`
|
|
482
487
|
const ivec2 strides = ivec2(${i.strides[0]}, ${i.strides[1]});
|
|
483
488
|
const ivec2 pads = ivec2(${i.pads[0]}, ${i.pads[1]});
|
|
484
489
|
${l}
|
|
@@ -487,7 +492,7 @@
|
|
|
487
492
|
int batch = coords.x;
|
|
488
493
|
int output_channel = coords.y;
|
|
489
494
|
ivec2 xRCCorner = coords.zw * strides - pads;
|
|
490
|
-
int group_id = output_channel / ${
|
|
495
|
+
int group_id = output_channel / ${d};
|
|
491
496
|
|
|
492
497
|
float value = 0.0;
|
|
493
498
|
for (int wInChannel = 0; wInChannel < ${a[1]}; wInChannel++) {
|
|
@@ -515,23 +520,23 @@
|
|
|
515
520
|
${s}
|
|
516
521
|
${e.output} = vec4(value, .0, .0, .0);
|
|
517
522
|
}
|
|
518
|
-
`;return{...o,output:{dims:
|
|
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+=`
|
|
519
524
|
blockIndex = rc.x + ${T};
|
|
520
525
|
pos = rc.y + ${I};
|
|
521
526
|
|
|
522
527
|
if(blockIndex < ${s[1]} && pos < ${s[0]}) {
|
|
523
528
|
offsetY = int(blockIndex / (${u[l-1]})) * ${n.strides[0]} -
|
|
524
529
|
${n.pads[0]};
|
|
525
|
-
d0 = offsetY + ${n.dilations[0]} * (imod(pos, ${
|
|
530
|
+
d0 = offsetY + ${n.dilations[0]} * (imod(pos, ${h}) / ${d[2]});
|
|
526
531
|
|
|
527
|
-
if(d0 < ${a[
|
|
532
|
+
if(d0 < ${a[c]} && d0 >= 0) {
|
|
528
533
|
offsetX = imod(blockIndex, ${u[l-1]}) * ${n.strides[1]} -
|
|
529
534
|
${n.pads[1]};
|
|
530
|
-
d1 = offsetX + ${n.dilations[1]} * imod(imod(pos, ${
|
|
535
|
+
d1 = offsetX + ${n.dilations[1]} * imod(imod(pos, ${h}), ${d[2]});
|
|
531
536
|
|
|
532
537
|
if(d1 < ${a[e]} && d1 >= 0) {
|
|
533
538
|
|
|
534
|
-
ch = int(float(pos)/ ${
|
|
539
|
+
ch = int(float(pos)/ ${h}.);
|
|
535
540
|
innerDims = vec2(d0, d1);
|
|
536
541
|
result[${I*2+T}] = getChannel(
|
|
537
542
|
getA(0, ch, int(innerDims.x),
|
|
@@ -541,7 +546,7 @@
|
|
|
541
546
|
}
|
|
542
547
|
|
|
543
548
|
`;let _=`
|
|
544
|
-
${
|
|
549
|
+
${f}
|
|
545
550
|
|
|
546
551
|
void main() {
|
|
547
552
|
ivec2 rc = getOutputCoords();
|
|
@@ -551,10 +556,10 @@
|
|
|
551
556
|
${v}
|
|
552
557
|
${m.output} = result;
|
|
553
558
|
}
|
|
554
|
-
`;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),
|
|
555
|
-
${d}
|
|
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=`
|
|
556
560
|
${c}
|
|
557
|
-
|
|
561
|
+
${h}
|
|
562
|
+
float process(int indices[${f}]) {
|
|
558
563
|
int a[${m}];
|
|
559
564
|
int b[${v}];
|
|
560
565
|
bcastMatmulIndices_A(indices, a);
|
|
@@ -569,7 +574,7 @@
|
|
|
569
574
|
${s}
|
|
570
575
|
${e}
|
|
571
576
|
return value;
|
|
572
|
-
}`;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,
|
|
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(`
|
|
573
578
|
`),l=B.size(o)===1,s="vec4(outputValue.xx, outputValue.yy)";return l&&(s="vec4(outputValue.x)"),u?`
|
|
574
579
|
vec4 getBiasForMatmul() {
|
|
575
580
|
${t} coords = getOutputCoords();
|
|
@@ -581,8 +586,8 @@ float getBiasForMatmul() {
|
|
|
581
586
|
${t} coords = getOutputCoords();
|
|
582
587
|
${e}
|
|
583
588
|
return getBias(coords.x);
|
|
584
|
-
}`}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,
|
|
585
|
-
`),_=m.map(T=>`coords.${r[T+
|
|
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(`
|
|
586
591
|
`),I=`int lastDim = coords.${r[l-1]};
|
|
587
592
|
coords.${r[l-1]} = coords.${r[l-2]};
|
|
588
593
|
coords.${r[l-2]} = lastDim;`;return`
|
|
@@ -600,7 +605,7 @@ vec4 getBAtOutCoordsMatmul(int i) {
|
|
|
600
605
|
${_}
|
|
601
606
|
vec4 outputValue = getB(${n});
|
|
602
607
|
return outputValue;
|
|
603
|
-
}`}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,
|
|
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 =
|
|
604
609
|
getOutputCoords(); int lastDim = rc.${I[_-1]}; rc.${I[_-1]} =
|
|
605
610
|
rc.${I[_-2]}; rc.${I[_-2]} = lastDim;
|
|
606
611
|
`,et=`
|
|
@@ -621,7 +626,7 @@ vec4 getBAtOutCoordsMatmul(int i) {
|
|
|
621
626
|
${n}
|
|
622
627
|
${P}
|
|
623
628
|
${m.output} = value;
|
|
624
|
-
}`;return{...r,output:{dims:
|
|
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=`
|
|
625
630
|
const int XC = ${a[1]};
|
|
626
631
|
const int XH = ${a[2]};
|
|
627
632
|
const int XW = ${a[3]};
|
|
@@ -636,7 +641,7 @@ vec4 getBAtOutCoordsMatmul(int i) {
|
|
|
636
641
|
const int KHKW = KH*KW;
|
|
637
642
|
const int XCKHKW = XC * KHKW;
|
|
638
643
|
const int outputChannels = 4;
|
|
639
|
-
vec4 process(int indices[${
|
|
644
|
+
vec4 process(int indices[${c}]) {
|
|
640
645
|
int b = indices[0]; // batch size
|
|
641
646
|
int oh = indices[1] * strideH - padH; //output height
|
|
642
647
|
int ow = indices[2] * strideW - padW; //output width
|
|
@@ -665,7 +670,7 @@ vec4 getBAtOutCoordsMatmul(int i) {
|
|
|
665
670
|
}
|
|
666
671
|
return value;
|
|
667
672
|
}
|
|
668
|
-
`;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,
|
|
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=`
|
|
669
674
|
${I}
|
|
670
675
|
float process(int indices[${m}]) {
|
|
671
676
|
int b[1];
|
|
@@ -675,10 +680,10 @@ float process(int indices[${m}]) {
|
|
|
675
680
|
im2col[1] = indices[2];
|
|
676
681
|
im2col[2] = indices[3];
|
|
677
682
|
int im2colOffset = im2col[0] * ${s[0]} + im2col[1] * ${s[1]} + im2col[2] * ${s[2]};
|
|
678
|
-
int kernelOffset = indices[1] * ${
|
|
683
|
+
int kernelOffset = indices[1] * ${d[1]};
|
|
679
684
|
float value = ${v};
|
|
680
685
|
for (int i = 0; i < ${_}; ++i) {
|
|
681
|
-
vec2 im2colCoords = offsetToCoords(im2colOffset, ${
|
|
686
|
+
vec2 im2colCoords = offsetToCoords(im2colOffset, ${h}, ${f});
|
|
682
687
|
vec2 kernelCoords = offsetToCoords(kernelOffset, ${e}, ${l});
|
|
683
688
|
value += dot(${P.texture2D}(Im2Col, im2colCoords), ${P.texture2D}(K, kernelCoords));
|
|
684
689
|
++im2colOffset;
|
|
@@ -686,7 +691,7 @@ float process(int indices[${m}]) {
|
|
|
686
691
|
}
|
|
687
692
|
${T}
|
|
688
693
|
return value;
|
|
689
|
-
}`;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),
|
|
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=`
|
|
690
695
|
const ivec2 strides = ivec2(${i.strides[0]}, ${i.strides[1]});
|
|
691
696
|
const ivec2 pads = ivec2(${i.pads[0]}, ${i.pads[1]});
|
|
692
697
|
${s}
|
|
@@ -697,12 +702,12 @@ float process(int indices[${m}]) {
|
|
|
697
702
|
|
|
698
703
|
ivec2 loc = coords.zw + pads;
|
|
699
704
|
|
|
700
|
-
int group_id = output_channel / ${
|
|
701
|
-
int wOutChannel = output_channel - group_id * ${
|
|
705
|
+
int group_id = output_channel / ${d};
|
|
706
|
+
int wOutChannel = output_channel - group_id * ${d};
|
|
702
707
|
|
|
703
708
|
float value = ${u};
|
|
704
|
-
for (int inChannelOffset = 0; inChannelOffset < ${
|
|
705
|
-
int input_channel = group_id * ${
|
|
709
|
+
for (int inChannelOffset = 0; inChannelOffset < ${c}; inChannelOffset++) {
|
|
710
|
+
int input_channel = group_id * ${c} + inChannelOffset;
|
|
706
711
|
for (int wWOff = 0; wWOff < ${a[2]}; wWOff++) {
|
|
707
712
|
for (int wHOff = 0; wHOff < ${a[3]}; wHOff++) {
|
|
708
713
|
ivec2 wOff = ivec2(wWOff * ${i.dilations[0]}, wHOff * ${i.dilations[1]});
|
|
@@ -720,27 +725,27 @@ float process(int indices[${m}]) {
|
|
|
720
725
|
}
|
|
721
726
|
}
|
|
722
727
|
}
|
|
723
|
-
${
|
|
728
|
+
${h}
|
|
724
729
|
${l.output} = vec4(value, .0, .0, .0);
|
|
725
730
|
}
|
|
726
|
-
`;return{...o,output:{dims:e,type:r[0].type,textureType:0},shaderSource:
|
|
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=`
|
|
727
732
|
${ib("perm",o,n)}
|
|
728
733
|
float process(int indices[${n}]) {
|
|
729
734
|
int a[${n}];
|
|
730
735
|
perm(a, indices);
|
|
731
736
|
return _A(a);
|
|
732
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(`
|
|
733
|
-
`)},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]],
|
|
734
|
-
float process(int outputIdx[${
|
|
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}]) {
|
|
735
740
|
int inputIdx[${e}];
|
|
736
741
|
int indexDataIdx[${l}];
|
|
737
742
|
indexDataIdx[0] = 0;
|
|
738
|
-
${
|
|
743
|
+
${d.join(`
|
|
739
744
|
`)}
|
|
740
745
|
int idx = int(_B(indexDataIdx));
|
|
741
746
|
inputIdx[${i}] = idx < 0 ? idx + ${u[i]} : idx;
|
|
742
747
|
return _A(inputIdx);
|
|
743
|
-
}`;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),
|
|
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=`
|
|
744
749
|
float process(int indices[${l}]) {
|
|
745
750
|
int a[${l}];
|
|
746
751
|
int b[${l}];
|
|
@@ -748,19 +753,19 @@ float process(int indices[${m}]) {
|
|
|
748
753
|
|
|
749
754
|
copyVec(indices, a);
|
|
750
755
|
copyVec(indices, b);
|
|
751
|
-
${
|
|
756
|
+
${h}
|
|
752
757
|
|
|
753
758
|
float value = 0.0;
|
|
754
|
-
for (int k=0; k<${
|
|
759
|
+
for (int k=0; k<${c}; ++k) {
|
|
755
760
|
a[${l-1}] = k;
|
|
756
761
|
b[${l-2}] = k;
|
|
757
762
|
${e}
|
|
758
763
|
}
|
|
759
764
|
|
|
760
765
|
value = value * alpha;
|
|
761
|
-
${
|
|
766
|
+
${f}
|
|
762
767
|
return value;
|
|
763
|
-
}`;return{...t,output:{dims:
|
|
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=`
|
|
764
769
|
${xb(i.bias.length)}
|
|
765
770
|
float process(int indices[${n}]) {
|
|
766
771
|
return _X(indices) * scale + getBias(bias, indices[1]);
|
|
@@ -794,10 +799,10 @@ float process(int indices[${m}]) {
|
|
|
794
799
|
v.g = temp / float(${u});
|
|
795
800
|
|
|
796
801
|
return v;
|
|
797
|
-
}`;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,
|
|
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=`
|
|
798
803
|
vec4 get_MeanAndVariance(int[2] mv) {
|
|
799
804
|
int offset = indicesToOffset_MeanAndVariance(mv);
|
|
800
|
-
vec2 coords = offsetToCoords(offset, ${
|
|
805
|
+
vec2 coords = offsetToCoords(offset, ${c}, ${e});
|
|
801
806
|
return ${n.texture2D}(MeanAndVariance, coords);
|
|
802
807
|
}
|
|
803
808
|
|
|
@@ -815,7 +820,7 @@ float process(int indices[${m}]) {
|
|
|
815
820
|
float b = _B(sb);
|
|
816
821
|
|
|
817
822
|
return scale * (_X(indices) - mean) / sqrt(variance + epsilon) + b;
|
|
818
|
-
}`;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})`,
|
|
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=`
|
|
819
824
|
float process(int indices[${i}]) {
|
|
820
825
|
int c = indices[1];
|
|
821
826
|
float x = _X(indices);
|
|
@@ -829,67 +834,67 @@ float process(int indices[${m}]) {
|
|
|
829
834
|
square_sum += j * j;
|
|
830
835
|
}
|
|
831
836
|
}
|
|
832
|
-
return x / pow(${
|
|
837
|
+
return x / pow(${d} + ${a} * square_sum, ${c});
|
|
833
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=`
|
|
834
839
|
${Fb(t,r,o)}
|
|
835
840
|
float process(int[${u}] indices) {
|
|
836
841
|
return padA(indices);
|
|
837
|
-
}`;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
|
|
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+=`
|
|
838
843
|
k = m[${e}] - ${n[e]};
|
|
839
844
|
if (k < 0) return constant;
|
|
840
845
|
if (k >= ${r[e]}) return constant;
|
|
841
846
|
offset += k * ${o[e]};
|
|
842
847
|
`;return`
|
|
843
|
-
float padA(int m[${
|
|
848
|
+
float padA(int m[${d}]) {
|
|
844
849
|
const float constant = float(${a});
|
|
845
850
|
int offset = 0;
|
|
846
851
|
int k = 0;
|
|
847
|
-
${
|
|
852
|
+
${c}
|
|
848
853
|
vec2 coords = offsetToCoords(offset, ${i}, ${u});
|
|
849
854
|
float value = getColorAsFloat(${t.texture2D}(A, coords));
|
|
850
855
|
return value;
|
|
851
856
|
}
|
|
852
|
-
`},Nb=(t,r,o,i,u,n)=>{let a=r.length,
|
|
853
|
-
k = m[${
|
|
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]};
|
|
854
859
|
if (k < 0) { k = -k; }
|
|
855
860
|
{
|
|
856
|
-
const int _2n_1 = ${2*(r[
|
|
861
|
+
const int _2n_1 = ${2*(r[c]-1)};
|
|
857
862
|
k = int( mod( float(k), float(_2n_1) ) ) ;
|
|
858
|
-
if(k >= ${r[
|
|
863
|
+
if(k >= ${r[c]}) { k = _2n_1 - k; }
|
|
859
864
|
}
|
|
860
|
-
offset += k * ${o[
|
|
865
|
+
offset += k * ${o[c]};
|
|
861
866
|
`;return`
|
|
862
867
|
float padA(int m[${a}]) {
|
|
863
868
|
int offset = 0;
|
|
864
869
|
int k = 0;
|
|
865
|
-
${
|
|
870
|
+
${d}
|
|
866
871
|
vec2 coords = offsetToCoords(offset, ${i}, ${u});
|
|
867
872
|
float value = getColorAsFloat(${t.texture2D}(A, coords));
|
|
868
873
|
return value;
|
|
869
874
|
}
|
|
870
|
-
`},Rb=(t,r,o,i,u,n)=>{let a=r.length,
|
|
871
|
-
k = m[${
|
|
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]};
|
|
872
877
|
if (k < 0) k = 0;
|
|
873
|
-
if (k >= ${r[
|
|
874
|
-
offset += k * ${o[
|
|
878
|
+
if (k >= ${r[c]}) k = ${r[c]-1};
|
|
879
|
+
offset += k * ${o[c]};
|
|
875
880
|
`;return`
|
|
876
881
|
float padA(int m[${a}]) {
|
|
877
882
|
int offset = 0;
|
|
878
883
|
int k = 0;
|
|
879
|
-
${
|
|
884
|
+
${d}
|
|
880
885
|
vec2 coords = offsetToCoords(offset, ${i}, ${u});
|
|
881
886
|
float value = getColorAsFloat(${t.texture2D}(A, coords));
|
|
882
887
|
return value;
|
|
883
888
|
}
|
|
884
|
-
`}}),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),
|
|
885
|
-
${fc(t[0].dims,u,
|
|
886
|
-
`;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),
|
|
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=`
|
|
887
892
|
value = max(_X(x), value);
|
|
888
|
-
`,
|
|
889
|
-
${fc(t[0].dims,u,a,
|
|
890
|
-
`;return{...r,output:{dims:n,type:t[0].type,textureType:0},shaderSource:
|
|
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=`
|
|
891
896
|
for (int i = 0; i < ${a}; i++) {
|
|
892
|
-
x[${n} - 1] = indices[${n} - 1] * ${
|
|
897
|
+
x[${n} - 1] = indices[${n} - 1] * ${d} - ${c} + i;
|
|
893
898
|
if (x[${n} - 1] < 0 || x[${n} - 1] >= ${l}) {
|
|
894
899
|
pad++;
|
|
895
900
|
continue;
|
|
@@ -897,19 +902,19 @@ float process(int indices[${m}]) {
|
|
|
897
902
|
${o}
|
|
898
903
|
}`:s=`
|
|
899
904
|
for (int i = 0; i < ${a}; i++) {
|
|
900
|
-
x[${n} - 1] = indices[${n} - 1] * ${
|
|
905
|
+
x[${n} - 1] = indices[${n} - 1] * ${d} - ${c} + i;
|
|
901
906
|
${o}
|
|
902
|
-
}`,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?
|
|
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=`
|
|
903
908
|
for (int j = 0; j < ${m}; j++) {
|
|
904
909
|
x[${n} - 2] = indices[${n} - 2] * ${v} - ${_} + j;
|
|
905
910
|
if (x[${n} - 2] < 0 || x[${n} - 2] >= ${T}) {
|
|
906
911
|
pad+= ${a};
|
|
907
912
|
continue;
|
|
908
913
|
}
|
|
909
|
-
`:
|
|
914
|
+
`:h=`
|
|
910
915
|
for (int j = 0; j < ${m}; j++) {
|
|
911
916
|
x[${n} - 2] = indices[${n} - 2] * ${v} - ${_} + j;
|
|
912
|
-
`,
|
|
917
|
+
`,f=`
|
|
913
918
|
}
|
|
914
919
|
`}return`
|
|
915
920
|
float process(int indices[${n}]) {
|
|
@@ -918,13 +923,13 @@ float process(int indices[${m}]) {
|
|
|
918
923
|
|
|
919
924
|
float value = ${u};
|
|
920
925
|
int pad = 0;
|
|
921
|
-
${c}
|
|
922
|
-
${s}
|
|
923
926
|
${h}
|
|
927
|
+
${s}
|
|
928
|
+
${f}
|
|
924
929
|
${i}
|
|
925
930
|
return value;
|
|
926
931
|
}
|
|
927
|
-
`}else{let a=B.size(r.kernelShape),
|
|
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?_=`
|
|
928
933
|
if (x[j] >= inputDims[j] || x[j] < 0) {
|
|
929
934
|
pad++;
|
|
930
935
|
isPad = true;
|
|
@@ -941,15 +946,15 @@ float process(int indices[${m}]) {
|
|
|
941
946
|
float process(int indices[${n}]) {
|
|
942
947
|
int x[${n}];
|
|
943
948
|
copyVec(indices, x);
|
|
944
|
-
int offset[${
|
|
949
|
+
int offset[${c}];
|
|
945
950
|
int pads[${e}];
|
|
946
951
|
int inputDims[${n}];
|
|
947
|
-
int kernelStrides[${
|
|
948
|
-
int strides[${
|
|
949
|
-
${
|
|
952
|
+
int kernelStrides[${c}];
|
|
953
|
+
int strides[${c}];
|
|
954
|
+
${h}
|
|
950
955
|
${s}
|
|
951
956
|
${m}
|
|
952
|
-
${
|
|
957
|
+
${f}
|
|
953
958
|
|
|
954
959
|
float value = ${u};
|
|
955
960
|
int pad = 0;
|
|
@@ -957,9 +962,9 @@ float process(int indices[${m}]) {
|
|
|
957
962
|
for (int i = 0; i < ${a}; i++) {
|
|
958
963
|
offsetToIndices(i, kernelStrides, offset);
|
|
959
964
|
isPad = false;
|
|
960
|
-
for (int j = ${n} - ${
|
|
961
|
-
x[j] = indices[j] * strides[j - ${n} + ${
|
|
962
|
-
+ offset[j - ${n} + ${
|
|
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];
|
|
963
968
|
${_}
|
|
964
969
|
}
|
|
965
970
|
${i}
|
|
@@ -978,43 +983,43 @@ float process(int indices[${m}]) {
|
|
|
978
983
|
offset -= indices[i] * strides[i];
|
|
979
984
|
}
|
|
980
985
|
indices[${t} - 1] = offset;
|
|
981
|
-
}`}),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=[],
|
|
982
|
-
for(int j${
|
|
983
|
-
inputIdx[${
|
|
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};
|
|
984
989
|
${s}
|
|
985
|
-
}`):(
|
|
990
|
+
}`):(c.push(`inputIdx[${f}] = outputIdx[${a.length}];`),a.push(r[0].dims[f]));let h=`
|
|
986
991
|
float process(int outputIdx[${a.length||1}]) {
|
|
987
992
|
float value; // final result
|
|
988
|
-
int inputIdx[${
|
|
989
|
-
${
|
|
993
|
+
int inputIdx[${d}]; // addressing input data
|
|
994
|
+
${c.join(`
|
|
990
995
|
`)}
|
|
991
996
|
${l[0]} // init ops for reduce max/min
|
|
992
997
|
${s}
|
|
993
998
|
${l[2]} // final computation for reduce mean
|
|
994
999
|
return value;
|
|
995
|
-
}`;return{...n,output:{dims:a,type:r[0].type,textureType:0},shaderSource:
|
|
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(`
|
|
996
1001
|
`)}
|
|
997
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(`
|
|
998
1003
|
`)}
|
|
999
|
-
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
|
|
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=`
|
|
1000
1005
|
int output_pitches[${e}];
|
|
1001
1006
|
int input_pitches[${e}];
|
|
1002
|
-
`;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],
|
|
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+=`
|
|
1003
1008
|
output_pitches[${v}] = ${l[v]};
|
|
1004
1009
|
input_pitches[${v}] = ${s[v]};
|
|
1005
|
-
`;let
|
|
1010
|
+
`;let f=`
|
|
1006
1011
|
float getInputFloat(int index) {
|
|
1007
1012
|
vec2 coords = offsetToCoords(index, ${u}, ${n});
|
|
1008
1013
|
float value = getColorAsFloat(${i.texture2D}(X, coords));
|
|
1009
1014
|
return value;
|
|
1010
1015
|
}
|
|
1011
1016
|
`,m=o.mode==="nearest"?`
|
|
1012
|
-
${
|
|
1017
|
+
${f}
|
|
1013
1018
|
float process(int indices[${e}]) {
|
|
1014
1019
|
int input_index = 0;
|
|
1015
|
-
int output_index = coordsToOffset(TexCoords, ${
|
|
1020
|
+
int output_index = coordsToOffset(TexCoords, ${d}, ${c});
|
|
1016
1021
|
|
|
1017
|
-
${
|
|
1022
|
+
${h}
|
|
1018
1023
|
|
|
1019
1024
|
int d, m;
|
|
1020
1025
|
for (int dim = 0; dim < ${e}; ++dim) {
|
|
@@ -1032,12 +1037,12 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(t,r,o)=>Xe(
|
|
|
1032
1037
|
|
|
1033
1038
|
return getInputFloat(input_index);
|
|
1034
1039
|
}`:e===4?`
|
|
1035
|
-
${
|
|
1040
|
+
${f}
|
|
1036
1041
|
float process(int indices[4]) {
|
|
1037
1042
|
int input_index = 0;
|
|
1038
|
-
int output_index = coordsToOffset(TexCoords, ${
|
|
1043
|
+
int output_index = coordsToOffset(TexCoords, ${d}, ${c});
|
|
1039
1044
|
|
|
1040
|
-
${
|
|
1045
|
+
${h}
|
|
1041
1046
|
|
|
1042
1047
|
int m;
|
|
1043
1048
|
int index_of_dim0, index_of_dim1, index_of_dim2, index_of_dim3;
|
|
@@ -1086,12 +1091,12 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(t,r,o)=>Xe(
|
|
|
1086
1091
|
float y1 = x10 + float(y_offset) * (x11 - x10) / float(scales[2]);
|
|
1087
1092
|
return y0 + float(x_offset) * (y1 - y0) / float(scales[3]);
|
|
1088
1093
|
}`:`
|
|
1089
|
-
${
|
|
1094
|
+
${f}
|
|
1090
1095
|
float process(int indices[2]) {
|
|
1091
1096
|
int input_index = 0;
|
|
1092
|
-
int output_index = coordsToOffset(TexCoords, ${
|
|
1097
|
+
int output_index = coordsToOffset(TexCoords, ${d}, ${c});
|
|
1093
1098
|
|
|
1094
|
-
${
|
|
1099
|
+
${h}
|
|
1095
1100
|
|
|
1096
1101
|
int m;
|
|
1097
1102
|
int index_of_dim0, index_of_dim1;
|
|
@@ -1135,7 +1140,7 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(t,r,o)=>Xe(
|
|
|
1135
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() {
|
|
1136
1141
|
vec4 v = ${i.texture2D}(X, TexCoords);
|
|
1137
1142
|
${i.output} = v;
|
|
1138
|
-
}`};let a=n.length;if(a<2)throw new Error(`output dimension should be at least 2, but got ${a}`);let
|
|
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=`
|
|
1139
1144
|
vec4 getSourceFracIndex(ivec4 coords) {
|
|
1140
1145
|
return vec4(coords) / scaleWHWH;
|
|
1141
1146
|
}
|
|
@@ -1147,16 +1152,16 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(t,r,o)=>Xe(
|
|
|
1147
1152
|
vec4 getSourceFracIndex(ivec4 coords) {
|
|
1148
1153
|
vec4 fcoords = vec4(coords);
|
|
1149
1154
|
return vec4(
|
|
1150
|
-
${
|
|
1151
|
-
${
|
|
1152
|
-
${
|
|
1153
|
-
${
|
|
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
|
|
1154
1159
|
);
|
|
1155
1160
|
}
|
|
1156
1161
|
`;break;case"align_corners":m=`
|
|
1157
1162
|
vec4 getSourceFracIndex(ivec4 coords) {
|
|
1158
|
-
vec4 resized = vec4(${
|
|
1159
|
-
${
|
|
1163
|
+
vec4 resized = vec4(${c}.0 - 1.0, ${d}.0 - 1.0, ${c}.0 - 1.0,
|
|
1164
|
+
${d}.0 - 1.0);
|
|
1160
1165
|
vec4 original = vec4(${s}.0 - 1.0, ${l}.0 - 1.0, ${s}.0 - 1.0,
|
|
1161
1166
|
${l}.0 - 1.0);
|
|
1162
1167
|
vec4 new_scale = original / resized;
|
|
@@ -1164,7 +1169,7 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(t,r,o)=>Xe(
|
|
|
1164
1169
|
}
|
|
1165
1170
|
`;break;default:throw new Error(`resize (packed) does not support coordinateTransformMode: '${o.coordinateTransformMode}'`)}let v=Bt(a),_=de(),I=`
|
|
1166
1171
|
const vec2 inputWH = vec2(${l}.0, ${s}.0);
|
|
1167
|
-
const vec4 scaleWHWH = vec4(float(${
|
|
1172
|
+
const vec4 scaleWHWH = vec4(float(${h}), float(${f}), float(${h}), float(${f}));
|
|
1168
1173
|
${_}
|
|
1169
1174
|
${m}
|
|
1170
1175
|
float getAValue(int x10, int r, int c, int d) {
|
|
@@ -1188,8 +1193,8 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(t,r,o)=>Xe(
|
|
|
1188
1193
|
ivec4 x10 = ivec4(max(sourceFrac.zy, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.zy)));
|
|
1189
1194
|
ivec4 x11 = ivec4(max(sourceFrac.zw, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.zw)));
|
|
1190
1195
|
|
|
1191
|
-
bool hasNextRow = rc.w < ${
|
|
1192
|
-
bool hasNextCol = rc.z < ${
|
|
1196
|
+
bool hasNextRow = rc.w < ${d-1};
|
|
1197
|
+
bool hasNextCol = rc.z < ${c-1};
|
|
1193
1198
|
|
|
1194
1199
|
// pack x00, x01, x10, x11's top-left corner into one vec4 structure
|
|
1195
1200
|
vec4 topLeft = vec4(
|
|
@@ -1229,28 +1234,28 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(t,r,o)=>Xe(
|
|
|
1229
1234
|
|
|
1230
1235
|
${i.output} = vec4(newValue);
|
|
1231
1236
|
}
|
|
1232
|
-
`;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
|
|
1233
|
-
float process(int outputIdx[${
|
|
1234
|
-
${
|
|
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(`
|
|
1235
1240
|
`)}
|
|
1236
1241
|
return _A(outputIdx);
|
|
1237
|
-
}`;return{...Bi,output:{dims:
|
|
1238
|
-
float process(int[${
|
|
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) {
|
|
1239
1244
|
int logical_row_start_offset = indices[0] * ${i};
|
|
1240
1245
|
|
|
1241
|
-
float max = getColorAsFloat(${
|
|
1246
|
+
float max = getColorAsFloat(${c.texture2D}(A, offsetToCoords(logical_row_start_offset, ${n},
|
|
1242
1247
|
${a} )));
|
|
1243
1248
|
for(int i=1; i<${i}; ++i)
|
|
1244
1249
|
{
|
|
1245
|
-
float current = getColorAsFloat(${
|
|
1250
|
+
float current = getColorAsFloat(${c.texture2D}(A, offsetToCoords(logical_row_start_offset + i,
|
|
1246
1251
|
${n}, ${a})));
|
|
1247
1252
|
if(current > max)
|
|
1248
1253
|
max = current;
|
|
1249
1254
|
}
|
|
1250
1255
|
|
|
1251
1256
|
return max;
|
|
1252
|
-
}`;return{...Fc,output:{dims:u,type:r.type,textureType:0},shaderSource:e}},Qb=(t,r,o,i,u,n)=>{let[a,
|
|
1253
|
-
float process(int[${
|
|
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) {
|
|
1254
1259
|
int logical_row_start_offset = indices[0] * ${i};
|
|
1255
1260
|
|
|
1256
1261
|
float norm_factor = 0.0;
|
|
@@ -1258,15 +1263,15 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(t,r,o)=>Xe(
|
|
|
1258
1263
|
for(int i=0; i<${i}; ++i)
|
|
1259
1264
|
{
|
|
1260
1265
|
norm_factor += exp(getColorAsFloat(${e.texture2D}(A, offsetToCoords(logical_row_start_offset + i,
|
|
1261
|
-
${a}, ${
|
|
1266
|
+
${a}, ${d}))) - max);
|
|
1262
1267
|
}
|
|
1263
1268
|
|
|
1264
1269
|
return norm_factor;
|
|
1265
|
-
}`;return{...Cc,output:{dims:n,type:r.type,textureType:0},shaderSource:l}},tg=(t,r,o,i,u,n)=>{let[a,
|
|
1266
|
-
float process(int[${
|
|
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) {
|
|
1267
1272
|
|
|
1268
1273
|
// get offset of current logical tensor index from the 2-D texture coordinates (TexCoords)
|
|
1269
|
-
int offset = coordsToOffset(TexCoords, ${a}, ${
|
|
1274
|
+
int offset = coordsToOffset(TexCoords, ${a}, ${d});
|
|
1270
1275
|
|
|
1271
1276
|
//determine the logical row for this index
|
|
1272
1277
|
int logical_row_index[1];
|
|
@@ -1281,31 +1286,31 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(t,r,o)=>Xe(
|
|
|
1281
1286
|
return 0.0;
|
|
1282
1287
|
|
|
1283
1288
|
return exp(_A(indices) - _Max(logical_row_index)) / norm_factor;
|
|
1284
|
-
}`;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),
|
|
1285
|
-
float process(int indices[${
|
|
1286
|
-
indices[${i}] += ${
|
|
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};
|
|
1287
1292
|
return _A(indices);
|
|
1288
1293
|
}
|
|
1289
|
-
`;return{...Hc,cacheHint:`${o.cacheKey}:${u}`,output:{dims:
|
|
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=`
|
|
1290
1295
|
void main() {
|
|
1291
|
-
vec4 result = ${r.map((a,
|
|
1296
|
+
vec4 result = ${r.map((a,d)=>`${i.texture2D}(X${d},TexCoords)`).join(" + ")};
|
|
1292
1297
|
${i.output} = result;
|
|
1293
1298
|
}
|
|
1294
|
-
`;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
|
|
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=`
|
|
1295
1300
|
float process(int outputIdx[${a}]) {
|
|
1296
1301
|
int inputIdx[${a}];
|
|
1297
1302
|
${n.join(`
|
|
1298
1303
|
`)}
|
|
1299
1304
|
return _A(inputIdx);
|
|
1300
1305
|
}
|
|
1301
|
-
`;return{...o,output:{dims:u,type:r[0].type,textureType:0},shaderSource:
|
|
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]};
|
|
1302
1307
|
`)}),l=`${s}
|
|
1303
|
-
${l}`,l=l.replace("return",`${
|
|
1308
|
+
${l}`,l=l.replace("return",`${d} = `);let h=`
|
|
1304
1309
|
${e}
|
|
1305
1310
|
{
|
|
1306
1311
|
${l}
|
|
1307
1312
|
}
|
|
1308
|
-
`;t=t.replace(o[0],
|
|
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(`
|
|
1309
1314
|
vec2 ${t}(int offset, int width, int height) {
|
|
1310
1315
|
int t = offset / width;
|
|
1311
1316
|
int s = offset - t*width;
|
|
@@ -1377,10 +1382,10 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(t,r,o)=>Xe(
|
|
|
1377
1382
|
|
|
1378
1383
|
return ivec3(b, r, c);
|
|
1379
1384
|
}
|
|
1380
|
-
`;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="",
|
|
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=`
|
|
1381
1386
|
int b${e} = index / ${n};
|
|
1382
1387
|
index -= b${e} * ${n};
|
|
1383
|
-
`+a,
|
|
1388
|
+
`+a,d=`b${e}, `+d;let c=`
|
|
1384
1389
|
ivec${t.length} getOutputCoords() {
|
|
1385
1390
|
ivec2 resTexRC = ivec2(TexCoords.xy *
|
|
1386
1391
|
vec2(${o[0]}, ${o[1]}));
|
|
@@ -1395,9 +1400,9 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(t,r,o)=>Xe(
|
|
|
1395
1400
|
int r = imod(index, ${i}) * 2;
|
|
1396
1401
|
int c = 2 * (index / ${i});
|
|
1397
1402
|
|
|
1398
|
-
return ivec${t.length}(${
|
|
1403
|
+
return ivec${t.length}(${d});
|
|
1399
1404
|
}
|
|
1400
|
-
`;return new k$1(
|
|
1405
|
+
`;return new k$1(c)}getOutputUnpacked1DCoords(t,r){let o=`
|
|
1401
1406
|
int getOutputCoords() {
|
|
1402
1407
|
ivec2 resTexRC = ivec2(TexCoords.xy *
|
|
1403
1408
|
vec2(${r[0]}, ${r[1]}));
|
|
@@ -1412,7 +1417,7 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(t,r,o)=>Xe(
|
|
|
1412
1417
|
int c = index - r * ${t[1]};
|
|
1413
1418
|
return ivec2(r, c);
|
|
1414
1419
|
}
|
|
1415
|
-
`;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
|
|
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=`
|
|
1416
1421
|
ivec3 getOutputCoords() {
|
|
1417
1422
|
ivec2 resTexRC = ivec2(TexCoords.xy *
|
|
1418
1423
|
vec2(${r[0]}, ${r[1]}));
|
|
@@ -1420,7 +1425,7 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(t,r,o)=>Xe(
|
|
|
1420
1425
|
${a}
|
|
1421
1426
|
return ivec3(r, c, d);
|
|
1422
1427
|
}
|
|
1423
|
-
`,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
|
|
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=`
|
|
1424
1429
|
ivec4 getOutputCoords() {
|
|
1425
1430
|
ivec2 resTexRC = ivec2(TexCoords.xy *
|
|
1426
1431
|
vec2(${r[0]}, ${r[1]}));
|
|
@@ -1428,7 +1433,7 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(t,r,o)=>Xe(
|
|
|
1428
1433
|
${a}
|
|
1429
1434
|
return ivec4(r, c, d, d2);
|
|
1430
1435
|
}
|
|
1431
|
-
`,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
|
|
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=`
|
|
1432
1437
|
ivec5 getOutputCoords() {
|
|
1433
1438
|
ivec2 resTexRC = ivec2(TexCoords.xy *
|
|
1434
1439
|
vec2(${r[0]}, ${r[1]}));
|
|
@@ -1436,7 +1441,7 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(t,r,o)=>Xe(
|
|
|
1436
1441
|
${a}
|
|
1437
1442
|
return ivec5(r, c, d, d2, d3);
|
|
1438
1443
|
}
|
|
1439
|
-
`,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
|
|
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=`
|
|
1440
1445
|
ivec6 getOutputCoords() {
|
|
1441
1446
|
ivec2 resTexRC = ivec2(TexCoords.xy *
|
|
1442
1447
|
vec2(${r[0]}, ${r[1]}));
|
|
@@ -1478,31 +1483,31 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(t,r,o)=>Xe(
|
|
|
1478
1483
|
`),r="sampleTexture";let o=G(this.context.glContext.version);return t[r]=new k$1(`
|
|
1479
1484
|
float sampleTexture(sampler2D textureSampler, vec2 uv) {
|
|
1480
1485
|
return ${o.texture2D}(textureSampler, uv).r;
|
|
1481
|
-
}`),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),
|
|
1482
|
-
`);let m="";
|
|
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=`
|
|
1483
1488
|
return vec4(outputValue.xy, outputValue.xy);
|
|
1484
|
-
`;else if(_&&!I)
|
|
1489
|
+
`;else if(_&&!I)c===1?v=`
|
|
1485
1490
|
return vec4(outputValue.x, outputValue.x, 0., 0.);
|
|
1486
1491
|
`:v=`
|
|
1487
1492
|
return vec4(outputValue.x);
|
|
1488
|
-
`;else if(e.length){let C=
|
|
1489
|
-
int lastDim = coords.${
|
|
1490
|
-
coords.${
|
|
1491
|
-
coords.${
|
|
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;
|
|
1492
1497
|
`,P=`
|
|
1493
1498
|
vec4 ${t}() {
|
|
1494
1499
|
${l} coords = getOutputCoords();
|
|
1495
1500
|
${T}
|
|
1496
|
-
${
|
|
1501
|
+
${h}
|
|
1497
1502
|
vec4 outputValue = ${a}(${m});
|
|
1498
1503
|
${v}
|
|
1499
1504
|
}
|
|
1500
|
-
`;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,
|
|
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=`
|
|
1501
1506
|
float ${t}() {
|
|
1502
1507
|
return sampleTexture(${i}, TexCoords);
|
|
1503
1508
|
}
|
|
1504
|
-
`;return new k$1(T,["coordinates.sampleTexture"])}let s=Bt(
|
|
1505
|
-
`);let _="";
|
|
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=`
|
|
1506
1511
|
float ${t}() {
|
|
1507
1512
|
${s} coords = getOutputCoords();
|
|
1508
1513
|
${m}
|
|
@@ -1516,23 +1521,23 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(t,r,o)=>Xe(
|
|
|
1516
1521
|
vec2 uv = packedUVfrom1D(
|
|
1517
1522
|
${u[0]}, ${u[1]}, index);
|
|
1518
1523
|
return ${n.texture2D}(${r}, uv);
|
|
1519
|
-
}`;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],
|
|
1520
|
-
vec2 uv = (vec2(col, row) + halfCR) / vec2(${
|
|
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);
|
|
1521
1526
|
return ${n.texture2D}(${r}, uv);
|
|
1522
|
-
}`;return new k$1(s)}let
|
|
1523
|
-
vec2 uv = packedUVfrom2D(${
|
|
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);
|
|
1524
1529
|
return ${n.texture2D}(${r}, uv);
|
|
1525
|
-
}`;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
|
|
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}
|
|
1526
1531
|
vec4 ${t}(int b, int row, int col) {
|
|
1527
|
-
return ${t}(${fr(v,
|
|
1528
|
-
} `;return new k$1(T,I.dependencies)}let
|
|
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) {
|
|
1529
1534
|
vec2 uv = packedUVfrom3D(
|
|
1530
|
-
${
|
|
1531
|
-
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),
|
|
1532
|
-
int index = ${
|
|
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};
|
|
1533
1538
|
int texR = index / ${e};
|
|
1534
1539
|
int texC = index - texR * ${e};
|
|
1535
|
-
vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${e}, ${
|
|
1540
|
+
vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${e}, ${c});
|
|
1536
1541
|
return ${a.texture2D}(${r}, uv);
|
|
1537
1542
|
}`;return new k$1(m)}getUnpackedSamplerScalar(t,r,o){let[i,u]=[o.width,o.height];if(i===1&&u===1){let a=`
|
|
1538
1543
|
float ${t}() {
|
|
@@ -1563,26 +1568,26 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(t,r,o)=>Xe(
|
|
|
1563
1568
|
vec2 uv = uvFromFlat(${i}, ${u}, index);
|
|
1564
1569
|
return sampleTexture(${r}, uv);
|
|
1565
1570
|
}
|
|
1566
|
-
`;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],
|
|
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=`
|
|
1567
1572
|
float ${t}(int row, int col) {
|
|
1568
|
-
vec2 uv = (vec2(row, col) + halfCR) / vec2(${s}.0, ${
|
|
1573
|
+
vec2 uv = (vec2(row, col) + halfCR) / vec2(${s}.0, ${h}.0);
|
|
1569
1574
|
return sampleTexture(${r}, uv);
|
|
1570
1575
|
}
|
|
1571
|
-
`;return new k$1(
|
|
1572
|
-
${this.getUnpackedSamplerFromInput(t,r,
|
|
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}
|
|
1573
1578
|
float ${t}(int row, int col) {
|
|
1574
|
-
return ${t}(${fr(
|
|
1579
|
+
return ${t}(${fr(f,a)});
|
|
1575
1580
|
}
|
|
1576
|
-
`;return new k$1(m,["coordinates.sampleTexture"])}let
|
|
1581
|
+
`;return new k$1(m,["coordinates.sampleTexture"])}let c=u[1],e=u[0];if(e===1){let s=`
|
|
1577
1582
|
float ${t}(int row, int col) {
|
|
1578
|
-
int offset_${r} = coordsToOffset(TexCoords, ${
|
|
1583
|
+
int offset_${r} = coordsToOffset(TexCoords, ${c}, ${e});
|
|
1579
1584
|
float index = dot(vec3(row, col, offset_${r}), vec3(${i[1]}, 1, 1));
|
|
1580
|
-
vec2 uv = vec2(0.5, (index + 0.5) / ${
|
|
1585
|
+
vec2 uv = vec2(0.5, (index + 0.5) / ${c}.0);
|
|
1581
1586
|
return sampleTexture(${r}, uv);
|
|
1582
1587
|
}
|
|
1583
|
-
`;return new k$1(s,["coordinates.sampleTexture","coordinates.coordsToOffset"])}if(
|
|
1588
|
+
`;return new k$1(s,["coordinates.sampleTexture","coordinates.coordsToOffset"])}if(c===1){let s=`
|
|
1584
1589
|
float ${t}(int row, int col) {
|
|
1585
|
-
int offset_${r} = coordsToOffset(TexCoords, ${
|
|
1590
|
+
int offset_${r} = coordsToOffset(TexCoords, ${c}, ${e});
|
|
1586
1591
|
float index = dot(vec3(row, col, offset_${r}), vec3(${i[1]}, 1, 1));
|
|
1587
1592
|
vec2 uv = vec2((index + 0.5) / ${e}.0, 0.5);
|
|
1588
1593
|
return sampleTexture(${r}, uv);
|
|
@@ -1590,13 +1595,13 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(t,r,o)=>Xe(
|
|
|
1590
1595
|
`;return new k$1(s,["coordinates.sampleTexture","coordinates.coordsToOffset"])}let l=`
|
|
1591
1596
|
float ${t}(int row, int col) {
|
|
1592
1597
|
int index = col * ${i[1]} + row;
|
|
1593
|
-
vec2 uv = uvFromFlat(${
|
|
1598
|
+
vec2 uv = uvFromFlat(${c}, ${e}, index);
|
|
1594
1599
|
return sampleTexture(${r}, uv);
|
|
1595
1600
|
}
|
|
1596
|
-
`;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:
|
|
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=`
|
|
1597
1602
|
${v.routineBody}
|
|
1598
1603
|
float ${t}(int batch, int row, int col) {
|
|
1599
|
-
return ${t}(${fr(
|
|
1604
|
+
return ${t}(${fr(f,_)});
|
|
1600
1605
|
}
|
|
1601
1606
|
`;return new k$1(I,v.dependencies)}let e=o.width,l=o.height,s=`
|
|
1602
1607
|
float ${t}(int depth, int row, int col) {
|
|
@@ -1605,42 +1610,42 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(t,r,o)=>Xe(
|
|
|
1605
1610
|
vec2 uv = uvFromFlat(${e}, ${l}, index);
|
|
1606
1611
|
return sampleTexture(${r}, uv);
|
|
1607
1612
|
}
|
|
1608
|
-
`;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,
|
|
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=`
|
|
1609
1614
|
float ${t}(int row, int col, int depth, int depth2) {
|
|
1610
1615
|
int index = row * ${a} + col * ${n} +
|
|
1611
1616
|
depth2 * ${u} + depth;
|
|
1612
|
-
vec2 uv = uvFromFlat(${
|
|
1617
|
+
vec2 uv = uvFromFlat(${d}, ${c}, index);
|
|
1613
1618
|
return sampleTexture(${r}, uv);
|
|
1614
1619
|
}
|
|
1615
|
-
`;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,
|
|
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 _=`
|
|
1616
1621
|
${this.getUnpackedSamplerFromInput(t,r,v).routineBody}
|
|
1617
1622
|
float ${t}(int row, int col, int depth, int depth2, int depth3) {
|
|
1618
1623
|
return ${t}(${fr(m,e)});
|
|
1619
1624
|
}
|
|
1620
|
-
`;return new k$1(_,["coordinates.sampleTexture","coordinates.uvFromFlat"])}let l=o.width,s=o.height,
|
|
1625
|
+
`;return new k$1(_,["coordinates.sampleTexture","coordinates.uvFromFlat"])}let l=o.width,s=o.height,h=`
|
|
1621
1626
|
float ${t}(int row, int col, int depth, int depth2, int depth3) {
|
|
1622
|
-
int index = row * ${
|
|
1627
|
+
int index = row * ${d} + col * ${a} + depth * ${n} +
|
|
1623
1628
|
depth3 * ${u} + depth2;
|
|
1624
1629
|
vec2 uv = uvFromFlat(${l}, ${s}, index);
|
|
1625
1630
|
return sampleTexture(${r}, uv);
|
|
1626
1631
|
}
|
|
1627
|
-
`;return new k$1(
|
|
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=`
|
|
1628
1633
|
${this.getUnpackedSamplerFromInput(t,r,_).routineBody}
|
|
1629
1634
|
float ${t}(int row, int col, int depth,
|
|
1630
1635
|
int depth2, int depth3, int depth4) {
|
|
1631
1636
|
return ${t}(${fr(v,l)});
|
|
1632
1637
|
}
|
|
1633
|
-
`;return new k$1(I,["coordinates.sampleTexture","coordinates.uvFromFlat"])}let s=o.width,
|
|
1638
|
+
`;return new k$1(I,["coordinates.sampleTexture","coordinates.uvFromFlat"])}let s=o.width,h=o.height,f=`
|
|
1634
1639
|
float ${t}(int row, int col, int depth,
|
|
1635
1640
|
int depth2, int depth3, int depth4) {
|
|
1636
|
-
int index = row * ${
|
|
1641
|
+
int index = row * ${c} + col * ${d} + depth * ${a} +
|
|
1637
1642
|
depth2 * ${n} + depth3 * ${u} + depth4;
|
|
1638
|
-
vec2 uv = uvFromFlat(${s}, ${
|
|
1643
|
+
vec2 uv = uvFromFlat(${s}, ${h}, index);
|
|
1639
1644
|
return sampleTexture(${r}, uv);
|
|
1640
1645
|
}
|
|
1641
|
-
`;return new k$1(
|
|
1642
|
-
c[${
|
|
1643
|
-
offset -= c[${
|
|
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(`
|
|
1644
1649
|
c[${r-1}] = offset;`);let a=`
|
|
1645
1650
|
void toVec(vec2 texCoords, out int c[${r}]) {
|
|
1646
1651
|
int offset = coordsToOffset(texCoords, ${i}, ${u});
|
|
@@ -1702,21 +1707,21 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(t,r,o)=>Xe(
|
|
|
1702
1707
|
float getColorAsFloat(vec4 color) {
|
|
1703
1708
|
return decode(color);
|
|
1704
1709
|
}
|
|
1705
|
-
`,["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,
|
|
1706
|
-
realIndices[${s}] = int( mod(float(bcastedIndices[${
|
|
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) );
|
|
1707
1712
|
`;let l=`
|
|
1708
|
-
void ${
|
|
1713
|
+
void ${c} (int bcastedIndices[${r}], out int realIndices[${a}]) {
|
|
1709
1714
|
${e}
|
|
1710
1715
|
}
|
|
1711
|
-
`;o[
|
|
1712
|
-
realIndices[${s}] = int( mod(float(bcastedIndices[${
|
|
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) );
|
|
1713
1718
|
`;let l=`
|
|
1714
|
-
void ${
|
|
1719
|
+
void ${c}(int bcastedIndices[${r}], out int realIndices[${a}]) {
|
|
1715
1720
|
${e}
|
|
1716
1721
|
realIndices[${a-1}] = bcastedIndices[${r-1}];
|
|
1717
1722
|
realIndices[${a-2}] = bcastedIndices[${r-2}];
|
|
1718
1723
|
}
|
|
1719
|
-
`;o[
|
|
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+=`
|
|
1720
1725
|
offset += indices[${n}] * ${i[n]};
|
|
1721
1726
|
`;return`
|
|
1722
1727
|
int ${r}(int indices[${o}]) {
|
|
@@ -1724,18 +1729,18 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(t,r,o)=>Xe(
|
|
|
1724
1729
|
${u}
|
|
1725
1730
|
return offset;
|
|
1726
1731
|
}
|
|
1727
|
-
`}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,
|
|
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(`
|
|
1728
1733
|
indices[${n}] = offset / ${i[n]};`),u.push(`
|
|
1729
1734
|
offset -= indices[${n}] * ${i[n]};`);return u.push(`
|
|
1730
1735
|
indices[${o-1}] = offset;`),`
|
|
1731
1736
|
void ${r}(int offset, out int indices[${o}]) {
|
|
1732
1737
|
${u.join("")}
|
|
1733
1738
|
}
|
|
1734
|
-
`}incrementIndices(){let r={};return this.context.programInfo.inputNames.forEach((o,i)=>{let u=this.context.inputTextureLayouts[i].shape,n=u.length,a=`incrementIndices_${o}`,
|
|
1735
|
-
shape[${e}] = ${u[e]};`;let
|
|
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=`
|
|
1736
1741
|
void ${a}(int axis, out int indices[${n}]) {
|
|
1737
1742
|
int shape[${n}];
|
|
1738
|
-
${
|
|
1743
|
+
${d};
|
|
1739
1744
|
for(int i = ${n} -1 ; i >= 0; --i) {
|
|
1740
1745
|
if(i > axis) continue;
|
|
1741
1746
|
indices[i] += 1;
|
|
@@ -1745,8 +1750,8 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(t,r,o)=>Xe(
|
|
|
1745
1750
|
indices[i] = 0;
|
|
1746
1751
|
}
|
|
1747
1752
|
}
|
|
1748
|
-
`;r[a]=new k$1(
|
|
1749
|
-
dest[${
|
|
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}];
|
|
1750
1755
|
`;let a=`
|
|
1751
1756
|
void ${u}(int src[${t}], out int dest[${t}]) {
|
|
1752
1757
|
${n}
|
|
@@ -1787,7 +1792,7 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(t,r,o)=>Xe(
|
|
|
1787
1792
|
int getVecItem(int m[${t}], int index) {
|
|
1788
1793
|
${r}
|
|
1789
1794
|
}
|
|
1790
|
-
`;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
|
|
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}
|
|
1791
1796
|
${Ju(this.context.glContext.version,this.context.outputTextureLayout.shape.length)}`),r=up(r),`${Ku(this.context.glContext.version)}
|
|
1792
1797
|
${this.getUniforms(t.inputNames,t.variables)}
|
|
1793
1798
|
${this.getImports(r)}
|
|
@@ -1795,13 +1800,13 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(t,r,o)=>Xe(
|
|
|
1795
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(`
|
|
1796
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:
|
|
1797
1802
|
${t}
|
|
1798
|
-
`);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:
|
|
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)}
|
|
1799
1804
|
Shader source:
|
|
1800
|
-
${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(),p=0;for(;p<u.length;){let e=u[p++],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 c=s;tt.verbose("ExecPlan",`Running op:${l.node.name} (${c.map((v,_)=>`'${l.node.inputs[_]}': ${v.type}[${v.dims.join(",")}]`).join(", ")})`);let h=await this.profiler.event("node",l.node.name,async()=>l.op.impl(o,c,l.op.context));if(h.length!==l.node.outputs.length)throw new Error("the size of output does not match model definition.");h.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;h.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 d=[];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,d.push(s)}return tt.verbose("ExecPlan","disposing of inferenceHandler"),o.dispose(),d})}}}),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 p=u[a];n[a]=Rt.longToNumber(p)}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 p=`unnamed_${u.opType}_${a}`;if(!o.has(p)){u.name=p;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 p of a.output){let d=r.get(p);if(typeof d>"u"&&(d=this._allData.push(new me)-1,r.set(p,d)),n.outputs.push(d),this._allData[d]._from!==void 0)throw new Error(`multiple nodes output to one data value: ${d}`);if(this._allData[d]._from=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[d]._from=-1,this._allData[d].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 p of a.input){let d=r.get(p);if(typeof d>"u"){if(p===""&&(a.input.length===3||a.input.length===4)&&a.opType==="Resize")continue;throw new Error(`unrecognized input '${p}' for node: ${a.name}`)}n.inputs.push(d),this._allData[d]._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 p=0;p<t.inputsLength();p++){let d=t.inputs(p);if(r.has(d))throw new Error(`duplicated input name: ${d}`);for(let e=0;e<t.nodeArgsLength();e++)if(((u=t.nodeArgs(e))==null?void 0:u.name())===d){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),c=At.tensorDataTypeFromProto(s.elemType()),h=s.shape(),m=[];for(let _=0;_<h.dimLength();_++)m.push(Rt.longToNumber(h.dim(_).value().dimValue()));l.type={shape:{dims:m},tensorType:c};let v=this._allData.push(l)-1;r.set(d,v),i.push(d)}}for(let p=0;p<t.initializersLength();p++){let d=t.initializers(p),e=r.get(d.name());if(e===void 0){let l=new me,s=At.tensorDimsFromORTFormat(d),c=At.tensorDataTypeFromProto(d.dataType());l.type={shape:{dims:s},tensorType:c},e=this._allData.push(l)-1,r.set(d.name(),e)}this._allData[e]._from=-1,this._allData[e].tensor=bt.fromOrtTensor(d)}for(let p=0;p<this._allData.length;p++)this._allData[p].tensor||(this._allInputIndices.push(p),this._allInputNames.push(i[p]));for(let p=0;p<t.outputsLength();p++){let d=t.outputs(p);if(r.has(d))throw new Error(`duplicated output name: ${d}`);let e=this._allData.push(new me)-1;r.set(d,e),this._allOutputIndices.push(e),this._allOutputNames.push(d)}if(!t.nodes)throw new Error("missing information in graph: node");for(let p=0;p<t.nodesLength();p++){let d=t.nodes(p),e=d.name();if(!e)for(let s=0;e=`unnamed_${d.opType()}_${s}`,!!o.has(e);s++);if(o.has(e))throw new Error(`duplicated node name: ${e}`);let l=this._nodes.push(new to(d,e))-1;o.set(e,l)}for(let p=0;p<this._nodes.length;p++){let d=this._nodes[p],e=t.nodes(p);if(e==null)throw new Error(`No node exists at index ${p}`);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),c=r.get(s);if(typeof c>"u"&&(c=this._allData.push(new me)-1,r.set(s,c)),d.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=p,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");d.outputs.pop(),d.executeNode=!1,this._allData[c]._from=-1,this._allData[c].tensor=bt.fromOrtTensor(e.attributes(0).t())}}}for(let p=0;p<this._nodes.length;p++){let d=this._nodes[p],e=t.nodes(p);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),c=r.get(s);if(typeof c>"u")throw new Error(`unrecognized input '${s}' for node: ${e.name()}`);d.inputs.push(c),this._allData[c]._to.push(p)}}}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 p=this._allData[r.inputs[a]].to.indexOf(t);if(p===-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(p,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 p=this._nodes[a].inputs.indexOf(i);if(p===-1)throw new Error("The Node object doesn't have the output Value in it's 'inputs' property ");this._nodes[a].inputs[p]=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}
|
|
1801
|
-
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 p=t[a];i.set(a,new bt(p.dims,p.type,void 0,void 0,p.data))}let u=await this.session.run(i),n={};return u.forEach((a,p)=>{n[p]=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:p,options:d}=i;fo(u,n,a,p,new Array(p.length).fill(null),d).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 p,d,e=Object.assign({},r),l=new Promise((g,y)=>{p=g,d=y}),s=typeof window=="object",c=typeof importScripts=="function",h=c&&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||c)&&(c?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),c&&(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,h){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(!h){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."),d(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||c)){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:Ua,G:na,H:oa,v:Ma,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(h)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(h)return Q(1,0,g);Dr(g)}var Dr=g=>{if(Lt=g,h)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 h?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 h&&E.length===0?$o(g,y,x,S):(g={cb:x,Ra:g,ab:S,ib:E},h?(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 h?Q(3,1,g,y,x):0}function Lo(g,y){if(h)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(h)return Q(5,1,g,y)}function Xo(g,y,x){if(h)return Q(6,1,g,y,x)}function Ko(g,y,x){return h?Q(7,1,g,y,x):0}function Jo(g,y){if(h)return Q(8,1,g,y)}function Yo(g,y,x){if(h)return Q(9,1,g,y,x)}function Zo(g,y,x,S){if(h)return Q(10,1,g,y,x,S)}function Qo(g,y,x,S){if(h)return Q(11,1,g,y,x,S)}function ti(g,y,x,S){if(h)return Q(12,1,g,y,x,S)}function ri(g){if(h)return Q(13,1,g)}function ni(g,y){if(h)return Q(14,1,g,y)}function ii(g,y,x){if(h)return Q(15,1,g,y,x)}var Na=()=>{Mt("")},Fa=()=>1;function Ca(g){Qr(g>>>0,!c,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{h?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):h?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,h?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 Ua(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 h?Q(16,1,g,y,x,S,E,N,L):-52}function oa(g,y,x,S,E,N){if(h)return Q(17,1,g,y,x,S,E,N)}function Ma(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(`
|
|
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(`
|
|
1802
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(`
|
|
1803
|
-
`))[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(
|
|
1804
|
-
`,"%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)}h||function(){for(var g=e.numThreads-1;g--;)Io();oe.unshift(()=>{ie++,function(y){h?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}`),d(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":new URL("/ort-wasm-simd-threaded.wasm",_documentCurrentScript&&_documentCurrentScript.tagName.toUpperCase()==="SCRIPT"&&_documentCurrentScript.src||new URL("segmentation.js",document.baseURI).href).href),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(d),{}}();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||(h?(p(e),h||Ze(te),startWorker(e)):(Ze(oe),0<ie||ar||(ar=!0,e.calledRun=!0,at||(h||Ze(te),p(e),h||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,p=(a==null?void 0:a.href)??a,d=u==null?void 0:u.wasm,e=(d==null?void 0:d.href)??d,l=t.wasmBinary,[s,c]=await Hp(p,n,o>1),h=!1,m=[];if(r>0&&m.push(new Promise(v=>{setTimeout(()=>{h=!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),c(I).then(T=>{ho=!1,Ki=!0,Xi=T,v(),s&&URL.revokeObjectURL(s)},T=>{ho=!1,qp=!0,_(T)})})),await Promise.race(m),h)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,p)=>{let d=Tt(a,i),e=Tt(p,i);r._OrtAddRunConfigEntry(o,d,e)!==0&&ht(`Can't set a run config entry: ${a} - ${p}.`)}),[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 p=Tt("deviceType",o),d=Tt(a,o);xt()._OrtAddSessionConfigEntry(t,p,d)!==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 p=Tt("preferredLayout",o),d=Tt(a.preferredLayout,o);xt()._OrtAddSessionConfigEntry(t,p,d)!==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"),p=typeof u.logId=="string"?Tt(u.logId,i):0,d=u.logSeverityLevel??2;if(!Number.isInteger(d)||d<0||d>4)throw new Error(`log serverity level is not valid: ${d}`);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,p,d,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),c=Tt(u.enableGraphCapture.toString(),i);r._OrtAddSessionConfigEntry(o,s,c)!==0&&ht(`Can't set a session config entry: 'enableGraphCapture' - ${u.enableGraphCapture}.`)}if(u.freeDimensionOverrides)for(let[s,c]of Object.entries(u.freeDimensionOverrides)){if(typeof s!="string")throw new Error(`free dimension override name must be a string: ${s}`);if(typeof c!="number"||!Number.isInteger(c)||c<0)throw new Error(`free dimension override value must be a non-negative integer: ${c}`);let h=Tt(s,i);r._OrtAddFreeDimensionOverride(o,h,c)!==0&&ht(`Can't set a free dimension override: ${s} - ${c}.`)}return u.extra!==void 0&&Wr(u.extra,"",new WeakSet,(s,c)=>{let h=Tt(s,i),m=Tt(c,i);r._OrtAddSessionConfigEntry(o,h,m)!==0&&ht(`Can't set a session config entry: ${s} - ${c}.`)}),[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(p){if(p instanceof RangeError){let d=Math.ceil(i/65536);n=new WebAssembly.Memory({initial:d,maximum:d}).buffer}else throw p}let a=0;for(;;){let{done:p,value:d}=await u.read();if(p)break;let e=d.byteLength;new Uint8Array(n,a,e).set(d),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,p=[],d=[],e=[];try{if([a,p]=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,c]=Ng(n),h=!!(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."),d.push(P),m.push(u.UTF8ToString(P))}for(let T=0;T<c;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,d,e,null,h,!1]),[n,m,v]}catch(s){throw d.forEach(c=>u._OrtFree(c)),e.forEach(c=>u._OrtFree(c)),n!==0&&u._OrtReleaseSession(n),s}finally{u._free(o),a!==0&&u._OrtReleaseSessionOptions(a),p.forEach(s=>u._free(s)),(l=u.unmountExternalData)==null||l.call(u)}},lo=t=>{var d;let r=xt(),o=yr.get(t);if(!o)throw new Error(`cannot release session. invalid session id: ${t}`);let[i,u,n,a,p]=o;a&&(p&&r._OrtClearBoundOutputs(a.handle),r._OrtReleaseBinding(a.handle)),(d=r.jsepOnReleaseSession)==null||d.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(),p=t[0],d=t[1],e=t[3],l,s;if(p==="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(p),d);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(p),d);let v=a.jsepRegisterMLTensor;if(!v)throw new Error('Tensor location "ml-tensor" is not supported without using WebNN.');l=v(m,Hr(p),d)}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 c=a.stackSave(),h=a.stackAlloc(4*d.length);try{let m=h/4;d.forEach(_=>a.HEAP32[m++]=_);let v=a._OrtCreateTensor(Hr(p),l,s,h,d.length,td(e));v===0&&ht(`Can't create tensor for input/output. session=${i}, index=${u}.`),r.push(v)}finally{a.stackRestore(c)}},fo=async(t,r,o,i,u,n)=>{var et;let a=xt(),p=yr.get(t);if(!p)throw new Error(`cannot run inference. invalid session id: ${t}`);let d=p[0],e=p[1],l=p[2],s=p[3],c=p[4];p[5];let h=r.length,m=i.length,v=0,_=[],I=[],T=[],P=[],C=a.stackSave(),V=a.stackAlloc(h*4),gt=a.stackAlloc(h*4),pt=a.stackAlloc(m*4),Ft=a.stackAlloc(m*4);try{(et=a.jsepOnRunStart)==null||et.call(a,d),[v,_]=jp(n);for(let K=0;K<h;K++)ed(o[K],I,P,t,r[K],c);for(let K=0;K<m;K++)ed(u[K],T,P,t,h+i[K],c);let $t=V/4,De=gt/4,wt=pt/4,Le=Ft/4;for(let K=0;K<h;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(d,gt,V,h,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&&!c&&(a._OrtClearBoundOutputs(s.handle),yr.set(t,[d,e,l,s,c,!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,p)=>{xr("run",[a,p]);let d=o,e={type:"run",in:{sessionId:t,inputIndices:r,inputs:d,outputIndices:i,options:n}};Kt.postMessage(e,po(d))})}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 c=s[0],h=s[1],m=this.inputNames.indexOf(c);if(m===-1)throw new Error(`invalid input '${c}'`);i.push(h),u.push(m)});let n=[],a=[];Object.entries(r).forEach(s=>{let c=s[0],h=s[1],m=this.outputNames.indexOf(c);if(m===-1)throw new Error(`invalid output '${c}'`);n.push(h),a.push(m)});let p=i.map((s,c)=>ld(s,()=>`input "${this.inputNames[u[c]]}"`)),d=n.map((s,c)=>s?ld(s,()=>`output "${this.outputNames[a[c]]}"`):null),e=await sd(this.sessionId,u,p,a,d,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:
|
|
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
1810
|
|
|
1806
1811
|
long/index.js:
|
|
1807
1812
|
(**
|
|
@@ -1823,5 +1828,5 @@ as ORT format: ${u}`)}}loadFromOnnxFormat(t,r){let o=Dp.onnx.ModelProto.decode(t
|
|
|
1823
1828
|
*
|
|
1824
1829
|
* SPDX-License-Identifier: Apache-2.0
|
|
1825
1830
|
*)
|
|
1826
|
-
*/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(
|
|
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 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&&await handlePreload(o);break;case"init":o&&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}`)}});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)}})();
|
|
1827
1832
|
//# sourceMappingURL=segmentation.js.map
|