@intelliweave/embedded 1.6.45
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/custom.d.ts +20 -0
- package/dist/component/component.d.ts +709 -0
- package/dist/component/component.js +375 -0
- package/dist/intelliweave-wordpress.zip +0 -0
- package/dist/node/node.d.ts +1109 -0
- package/dist/node/node.js +26 -0
- package/dist/react/react.d.ts +664 -0
- package/dist/react/react.js +375 -0
- package/dist/script-tag/chunk-FSRPMVAS.js +1 -0
- package/dist/script-tag/ort-wasm-simd-threaded.wasm +0 -0
- package/dist/script-tag/ort.bundle.min-5QOPZPPI.js +1834 -0
- package/dist/script-tag/script-tag.d.ts +2 -0
- package/dist/script-tag/script-tag.js +413 -0
- package/dist/webpack/index.d.ts +1306 -0
- package/dist/webpack/index.js +377 -0
- package/package.json +70 -0
|
@@ -0,0 +1,1834 @@
|
|
|
1
|
+
import{a as le}from"./chunk-FSRPMVAS.js";var lh=Object.create,Kr=Object.defineProperty,ph=Object.getOwnPropertyDescriptor,ch=Object.getOwnPropertyNames,dh=Object.getPrototypeOf,hh=Object.prototype.hasOwnProperty,fh=(t=>typeof le<"u"?le:typeof Proxy<"u"?new Proxy(t,{get:(r,n)=>(typeof le<"u"?le:r)[n]}):t)(function(t){if(typeof le<"u")return le.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')}),I=(t,r)=>()=>(t&&(r=t(t=0)),r),nt=(t,r)=>()=>(r||t((r={exports:{}}).exports,r),r.exports),gr=(t,r)=>{for(var n in r)Kr(t,n,{get:r[n],enumerable:!0})},Hu=(t,r,n,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let p of ch(r))!hh.call(t,p)&&p!==n&&Kr(t,p,{get:()=>r[p],enumerable:!(s=ph(r,p))||s.enumerable});return t},Ie=(t,r,n)=>(n=t!=null?lh(dh(t)):{},Hu(r||!t||!t.__esModule?Kr(n,"default",{value:t,enumerable:!0}):n,t)),zr=t=>Hu(Kr({},"__esModule",{value:!0}),t),Me,Zt,cr,da,Vo,Mo=I(()=>{"use strict";Me=new Map,Zt=[],cr=(t,r,n)=>{if(r&&typeof r.init=="function"&&typeof r.createInferenceSessionHandler=="function"){let s=Me.get(t);if(s===void 0)Me.set(t,{backend:r,priority:n});else{if(s.priority>n)return;if(s.priority===n&&s.backend!==r)throw new Error(`cannot register backend "${t}" using priority ${n}`)}if(n>=0){let p=Zt.indexOf(t);p!==-1&&Zt.splice(p,1);for(let l=0;l<Zt.length;l++)if(Me.get(Zt[l]).priority<=n){Zt.splice(l,0,t);return}Zt.push(t)}return}throw new TypeError("not a valid backend")},da=async t=>{let r=Me.get(t);if(!r)return"backend not found.";if(r.initialized)return r.backend;if(r.aborted)return r.error;{let n=!!r.initPromise;try{return n||(r.initPromise=r.backend.init(t)),await r.initPromise,r.initialized=!0,r.backend}catch(s){return n||(r.error=`${s}`,r.aborted=!0),r.error}finally{delete r.initPromise}}},Vo=async t=>{let r=t.executionProviders||[],n=r.map(a=>typeof a=="string"?a:a.name),s=n.length===0?Zt:n,p,l=[],c=new Set;for(let a of s){let e=await da(a);typeof e=="string"?l.push({name:a,err:e}):(p||(p=e),p===e&&c.add(a))}if(!p)throw new Error(`no available backend found. ERR: ${l.map(a=>`[${a.name}] ${a.err}`).join(", ")}`);for(let{name:a,err:e}of l)n.includes(a)&&console.warn(`removing requested execution provider "${a}" from session options because it is not available: ${e}`);let o=r.filter(a=>c.has(typeof a=="string"?a:a.name));return[p,new Proxy(t,{get:(a,e)=>e==="executionProviders"?o:Reflect.get(a,e)})]}}),gh=I(()=>{"use strict";Mo()}),qu,mh=I(()=>{"use strict";qu="1.20.0"}),fn,Dt,Wu=I(()=>{"use strict";mh(),fn="warning",Dt={wasm:{},webgl:{},webgpu:{},versions:{common:qu},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}`);fn=t}},get logLevel(){return fn}},Object.defineProperty(Dt,"logLevel",{enumerable:!0})}),j,bh=I(()=>{"use strict";Wu(),j=Dt}),Xu,Ku,yh=I(()=>{"use strict";Xu=(t,r)=>{let n=typeof document<"u"?document.createElement("canvas"):new OffscreenCanvas(1,1);n.width=t.dims[3],n.height=t.dims[2];let s=n.getContext("2d");if(s!=null){let p,l;r?.tensorLayout!==void 0&&r.tensorLayout==="NHWC"?(p=t.dims[2],l=t.dims[3]):(p=t.dims[3],l=t.dims[2]);let c=r?.format!==void 0?r.format:"RGB",o=r?.norm,a,e;o===void 0||o.mean===void 0?a=[255,255,255,255]:typeof o.mean=="number"?a=[o.mean,o.mean,o.mean,o.mean]:(a=[o.mean[0],o.mean[1],o.mean[2],0],o.mean[3]!==void 0&&(a[3]=o.mean[3])),o===void 0||o.bias===void 0?e=[0,0,0,0]:typeof o.bias=="number"?e=[o.bias,o.bias,o.bias,o.bias]:(e=[o.bias[0],o.bias[1],o.bias[2],0],o.bias[3]!==void 0&&(e[3]=o.bias[3]));let u=l*p,i=0,d=u,h=u*2,m=-1;c==="RGBA"?(i=0,d=u,h=u*2,m=u*3):c==="RGB"?(i=0,d=u,h=u*2):c==="RBG"&&(i=0,h=u,d=u*2);for(let b=0;b<l;b++)for(let x=0;x<p;x++){let E=(t.data[i++]-e[0])*a[0],w=(t.data[d++]-e[1])*a[1],S=(t.data[h++]-e[2])*a[2],$=m===-1?255:(t.data[m++]-e[3])*a[3];s.fillStyle="rgba("+E+","+w+","+S+","+$+")",s.fillRect(x,b,1,1)}if("toDataURL"in n)return n.toDataURL();throw new Error("toDataURL is not supported")}else throw new Error("Can not access image data")},Ku=(t,r)=>{let n=typeof document<"u"?document.createElement("canvas").getContext("2d"):new OffscreenCanvas(1,1).getContext("2d"),s;if(n!=null){let p,l,c;r?.tensorLayout!==void 0&&r.tensorLayout==="NHWC"?(p=t.dims[2],l=t.dims[1],c=t.dims[3]):(p=t.dims[3],l=t.dims[2],c=t.dims[1]);let o=r!==void 0&&r.format!==void 0?r.format:"RGB",a=r?.norm,e,u;a===void 0||a.mean===void 0?e=[255,255,255,255]:typeof a.mean=="number"?e=[a.mean,a.mean,a.mean,a.mean]:(e=[a.mean[0],a.mean[1],a.mean[2],255],a.mean[3]!==void 0&&(e[3]=a.mean[3])),a===void 0||a.bias===void 0?u=[0,0,0,0]:typeof a.bias=="number"?u=[a.bias,a.bias,a.bias,a.bias]:(u=[a.bias[0],a.bias[1],a.bias[2],0],a.bias[3]!==void 0&&(u[3]=a.bias[3]));let i=l*p;if(r!==void 0&&(r.format!==void 0&&c===4&&r.format!=="RGBA"||c===3&&r.format!=="RGB"&&r.format!=="BGR"))throw new Error("Tensor format doesn't match input tensor dims");let d=4,h=0,m=1,b=2,x=3,E=0,w=i,S=i*2,$=-1;o==="RGBA"?(E=0,w=i,S=i*2,$=i*3):o==="RGB"?(E=0,w=i,S=i*2):o==="RBG"&&(E=0,S=i,w=i*2),s=n.createImageData(p,l);for(let F=0;F<l*p;h+=d,m+=d,b+=d,x+=d,F++)s.data[h]=(t.data[E++]-u[0])*e[0],s.data[m]=(t.data[w++]-u[1])*e[1],s.data[b]=(t.data[S++]-u[2])*e[2],s.data[x]=$===-1?255:(t.data[$++]-u[3])*e[3]}else throw new Error("Can not access image data");return s}}),Nr,Zu,Ju,Yu,Qu,tl,wh=I(()=>{"use strict";zo(),Nr=(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:n,width:s}=r,p=r.norm??{mean:255,bias:0},l,c;typeof p.mean=="number"?l=[p.mean,p.mean,p.mean,p.mean]:l=[p.mean[0],p.mean[1],p.mean[2],p.mean[3]??255],typeof p.bias=="number"?c=[p.bias,p.bias,p.bias,p.bias]:c=[p.bias[0],p.bias[1],p.bias[2],p.bias[3]??0];let o=r.format!==void 0?r.format:"RGBA",a=r.tensorFormat!==void 0&&r.tensorFormat!==void 0?r.tensorFormat:"RGB",e=n*s,u=a==="RGBA"?new Float32Array(e*4):new Float32Array(e*3),i=4,d=0,h=1,m=2,b=3,x=0,E=e,w=e*2,S=-1;o==="RGB"&&(i=3,d=0,h=1,m=2,b=-1),a==="RGBA"?S=e*3:a==="RBG"?(x=0,w=e,E=e*2):a==="BGR"&&(w=0,E=e,x=e*2);for(let $=0;$<e;$++,d+=i,m+=i,h+=i,b+=i)u[x++]=(t[d]+c[0])/l[0],u[E++]=(t[h]+c[1])/l[1],u[w++]=(t[m]+c[2])/l[2],S!==-1&&b!==-1&&(u[S++]=(t[b]+c[3])/l[3]);return a==="RGBA"?new It("float32",u,[1,4,n,s]):new It("float32",u,[1,3,n,s])},Zu=async(t,r)=>{let n=typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement,s=typeof ImageData<"u"&&t instanceof ImageData,p=typeof ImageBitmap<"u"&&t instanceof ImageBitmap,l=typeof t=="string",c,o=r??{},a=()=>{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=u=>typeof HTMLCanvasElement<"u"&&u instanceof HTMLCanvasElement||u instanceof OffscreenCanvas?u.getContext("2d"):null;if(n){let u=a();u.width=t.width,u.height=t.height;let i=e(u);if(i!=null){let d=t.height,h=t.width;if(r!==void 0&&r.resizedHeight!==void 0&&r.resizedWidth!==void 0&&(d=r.resizedHeight,h=r.resizedWidth),r!==void 0){if(o=r,r.tensorFormat!==void 0)throw new Error("Image input config format must be RGBA for HTMLImageElement");o.tensorFormat="RGBA",o.height=d,o.width=h}else o.tensorFormat="RGBA",o.height=d,o.width=h;i.drawImage(t,0,0),c=i.getImageData(0,0,h,d).data}else throw new Error("Can not access image data")}else if(s){let u,i;if(r!==void 0&&r.resizedWidth!==void 0&&r.resizedHeight!==void 0?(u=r.resizedHeight,i=r.resizedWidth):(u=t.height,i=t.width),r!==void 0&&(o=r),o.format="RGBA",o.height=u,o.width=i,r!==void 0){let d=a();d.width=i,d.height=u;let h=e(d);if(h!=null)h.putImageData(t,0,0),c=h.getImageData(0,0,i,u).data;else throw new Error("Can not access image data")}else c=t.data}else if(p){if(r===void 0)throw new Error("Please provide image config with format for Imagebitmap");let u=a();u.width=t.width,u.height=t.height;let i=e(u);if(i!=null){let d=t.height,h=t.width;return i.drawImage(t,0,0,h,d),c=i.getImageData(0,0,h,d).data,o.height=d,o.width=h,Nr(c,o)}else throw new Error("Can not access image data")}else{if(l)return new Promise((u,i)=>{let d=a(),h=e(d);if(!t||!h)return i();let m=new Image;m.crossOrigin="Anonymous",m.src=t,m.onload=()=>{d.width=m.width,d.height=m.height,h.drawImage(m,0,0,d.width,d.height);let b=h.getImageData(0,0,d.width,d.height);o.height=d.height,o.width=d.width,u(Nr(b.data,o))}});throw new Error("Input data provided is not supported - aborted tensor creation")}if(c!==void 0)return Nr(c,o);throw new Error("Input data provided is not supported - aborted tensor creation")},Ju=(t,r)=>{let{width:n,height:s,download:p,dispose:l}=r,c=[1,s,n,4];return new It({location:"texture",type:"float32",texture:t,dims:c,download:p,dispose:l})},Yu=(t,r)=>{let{dataType:n,dims:s,download:p,dispose:l}=r;return new It({location:"gpu-buffer",type:n??"float32",gpuBuffer:t,dims:s,download:p,dispose:l})},Qu=(t,r)=>{let{dataType:n,dims:s,download:p,dispose:l}=r;return new It({location:"ml-tensor",type:n??"float32",mlTensor:t,dims:s,download:p,dispose:l})},tl=(t,r,n)=>new It({location:"cpu-pinned",type:t,data:r,dims:n??[r.length]})}),me,Ye,gn,el,vh=I(()=>{"use strict";me=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array],["int4",Uint8Array],["uint4",Uint8Array]]),Ye=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]),gn=!1,el=()=>{if(!gn){gn=!0;let t=typeof BigInt64Array<"u"&&BigInt64Array.from,r=typeof BigUint64Array<"u"&&BigUint64Array.from,n=typeof Float16Array<"u"&&Float16Array.from;t&&(me.set("int64",BigInt64Array),Ye.set(BigInt64Array,"int64")),r&&(me.set("uint64",BigUint64Array),Ye.set(BigUint64Array,"uint64")),n?(me.set("float16",Float16Array),Ye.set(Float16Array,"float16")):me.set("float16",Uint16Array)}}}),rl,nl,xh=I(()=>{"use strict";zo(),rl=t=>{let r=1;for(let n=0;n<t.length;n++){let s=t[n];if(typeof s!="number"||!Number.isSafeInteger(s))throw new TypeError(`dims[${n}] must be an integer, got: ${s}`);if(s<0)throw new RangeError(`dims[${n}] must be a non-negative integer, got: ${s}`);r*=s}return r},nl=(t,r)=>{switch(t.location){case"cpu":return new It(t.type,t.data,r);case"cpu-pinned":return new It({location:"cpu-pinned",data:t.data,type:t.type,dims:r});case"texture":return new It({location:"texture",texture:t.texture,type:t.type,dims:r});case"gpu-buffer":return new It({location:"gpu-buffer",gpuBuffer:t.gpuBuffer,type:t.type,dims:r});case"ml-tensor":return new It({location:"ml-tensor",mlTensor:t.mlTensor,type:t.type,dims:r});default:throw new Error(`tensorReshape: tensor location ${t.location} is not supported`)}}}),It,zo=I(()=>{"use strict";yh(),wh(),vh(),xh(),It=class{constructor(t,r,n){el();let s,p;if(typeof t=="object"&&"location"in t)switch(this.dataLocation=t.location,s=t.type,p=t.dims,t.location){case"cpu-pinned":{let c=me.get(s);if(!c)throw new TypeError(`unsupported type "${s}" to create tensor from pinned buffer`);if(!(t.data instanceof c))throw new TypeError(`buffer should be of type ${c.name}`);this.cpuData=t.data;break}case"texture":{if(s!=="float32")throw new TypeError(`unsupported type "${s}" to create tensor from texture`);this.gpuTextureData=t.texture,this.downloader=t.download,this.disposer=t.dispose;break}case"gpu-buffer":{if(s!=="float32"&&s!=="float16"&&s!=="int32"&&s!=="int64"&&s!=="uint32"&&s!=="uint8"&&s!=="bool"&&s!=="uint4"&&s!=="int4")throw new TypeError(`unsupported type "${s}" to create tensor from gpu buffer`);this.gpuBufferData=t.gpuBuffer,this.downloader=t.download,this.disposer=t.dispose;break}case"ml-tensor":{if(s!=="float32"&&s!=="float16"&&s!=="int32"&&s!=="int64"&&s!=="uint32"&&s!=="uint64"&&s!=="int8"&&s!=="uint8"&&s!=="bool")throw new TypeError(`unsupported type "${s}" 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 c,o;if(typeof t=="string")if(s=t,o=n,t==="string"){if(!Array.isArray(r))throw new TypeError("A string tensor's data must be a string array.");c=r}else{let a=me.get(t);if(a===void 0)throw new TypeError(`Unsupported tensor type: ${t}.`);if(Array.isArray(r)){if(t==="float16"&&a===Uint16Array||t==="uint4"||t==="int4")throw new TypeError(`Creating a ${t} tensor from number array is not supported. Please use ${a.name} as data.`);t==="uint64"||t==="int64"?c=a.from(r,BigInt):c=a.from(r)}else if(r instanceof a)c=r;else if(r instanceof Uint8ClampedArray)if(t==="uint8")c=Uint8Array.from(r);else throw new TypeError("A Uint8ClampedArray tensor's data must be type of uint8");else throw new TypeError(`A ${s} tensor's data must be type of ${a}`)}else if(o=r,Array.isArray(t)){if(t.length===0)throw new TypeError("Tensor type cannot be inferred from an empty array.");let a=typeof t[0];if(a==="string")s="string",c=t;else if(a==="boolean")s="bool",c=Uint8Array.from(t);else throw new TypeError(`Invalid element type of data array: ${a}.`)}else if(t instanceof Uint8ClampedArray)s="uint8",c=Uint8Array.from(t);else{let a=Ye.get(t.constructor);if(a===void 0)throw new TypeError(`Unsupported type for tensor data: ${t.constructor}.`);s=a,c=t}if(o===void 0)o=[c.length];else if(!Array.isArray(o))throw new TypeError("A tensor's dims must be a number array");p=o,this.cpuData=c,this.dataLocation="cpu"}let l=rl(p);if(this.cpuData&&l!==this.cpuData.length&&!((s==="uint4"||s==="int4")&&Math.ceil(l/2)===this.cpuData.length))throw new Error(`Tensor's size(${l}) does not match data length(${this.cpuData.length}).`);this.type=s,this.dims=p,this.size=l}static async fromImage(t,r){return Zu(t,r)}static fromTexture(t,r){return Ju(t,r)}static fromGpuBuffer(t,r){return Yu(t,r)}static fromMLTensor(t,r){return Qu(t,r)}static fromPinnedBuffer(t,r,n){return tl(t,r,n)}toDataURL(t){return Xu(this,t)}toImageData(t){return Ku(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 nl(this,t)}}}),ft,Uo=I(()=>{"use strict";zo(),ft=It}),no,mn,Pe,Ae,ol=I(()=>{"use strict";Wu(),no=(t,r)=>{(typeof Dt.trace>"u"?!Dt.wasm.trace:!Dt.trace)||console.timeStamp(`${t}::ORT::${r}`)},mn=(t,r)=>{let n=new Error().stack?.split(/\r\n|\r|\n/g)||[],s=!1;for(let p=0;p<n.length;p++){if(s&&!n[p].includes("TRACE_FUNC")){let l=`FUNC_${t}::${n[p].trim().split(" ")[1]}`;r&&(l+=`::${r}`),no("CPU",l);return}n[p].includes("TRACE_FUNC")&&(s=!0)}},Pe=t=>{(typeof Dt.trace>"u"?!Dt.wasm.trace:!Dt.trace)||mn("BEGIN",t)},Ae=t=>{(typeof Dt.trace>"u"?!Dt.wasm.trace:!Dt.trace)||mn("END",t)}}),il,Th=I(()=>{"use strict";Mo(),Uo(),ol(),il=class al{constructor(r){this.handler=r}async run(r,n,s){Pe();let p={},l={};if(typeof r!="object"||r===null||r instanceof ft||Array.isArray(r))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let c=!0;if(typeof n=="object"){if(n===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(n instanceof ft)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(n)){if(n.length===0)throw new TypeError("'fetches' cannot be an empty array.");c=!1;for(let e of n){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}.`);p[e]=null}if(typeof s=="object"&&s!==null)l=s;else if(typeof s<"u")throw new TypeError("'options' must be an object.")}else{let e=!1,u=Object.getOwnPropertyNames(n);for(let i of this.outputNames)if(u.indexOf(i)!==-1){let d=n[i];(d===null||d instanceof ft)&&(e=!0,c=!1,p[i]=d)}if(e){if(typeof s=="object"&&s!==null)l=s;else if(typeof s<"u")throw new TypeError("'options' must be an object.")}else l=n}}else if(typeof n<"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(c)for(let e of this.outputNames)p[e]=null;let o=await this.handler.run(r,p,l),a={};for(let e in o)if(Object.hasOwnProperty.call(o,e)){let u=o[e];u instanceof ft?a[e]=u:a[e]=new ft(u.type,u.data,u.dims)}return Ae(),a}async release(){return this.handler.dispose()}static async create(r,n,s,p){Pe();let l,c={};if(typeof r=="string"){if(l=r,typeof n=="object"&&n!==null)c=n;else if(typeof n<"u")throw new TypeError("'options' must be an object.")}else if(r instanceof Uint8Array){if(l=r,typeof n=="object"&&n!==null)c=n;else if(typeof n<"u")throw new TypeError("'options' must be an object.")}else if(r instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&r instanceof SharedArrayBuffer){let u=r,i=0,d=r.byteLength;if(typeof n=="object"&&n!==null)c=n;else if(typeof n=="number"){if(i=n,!Number.isSafeInteger(i))throw new RangeError("'byteOffset' must be an integer.");if(i<0||i>=u.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${u.byteLength}).`);if(d=r.byteLength-i,typeof s=="number"){if(d=s,!Number.isSafeInteger(d))throw new RangeError("'byteLength' must be an integer.");if(d<=0||i+d>u.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${u.byteLength-i}].`);if(typeof p=="object"&&p!==null)c=p;else if(typeof p<"u")throw new TypeError("'options' must be an object.")}else if(typeof s<"u")throw new TypeError("'byteLength' must be a number.")}else if(typeof n<"u")throw new TypeError("'options' must be an object.");l=new Uint8Array(u,i,d)}else throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");let[o,a]=await Vo(c),e=await o.createInferenceSessionHandler(l,a);return Ae(),new al(e)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}}}),sl,_h=I(()=>{"use strict";Th(),sl=il}),Sh=I(()=>{"use strict"}),Oh=I(()=>{"use strict"}),Eh=I(()=>{"use strict"}),Ih=I(()=>{"use strict"}),ha,ul,Ph=I(()=>{"use strict";Mo(),Uo(),ha="Training backend could not be resolved. Make sure you're using the correct configuration & WebAssembly files.",ul=class ll{constructor(r,n,s){this.handler=r,this.hasOptimizerModel=n,this.hasEvalModel=s}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,n){let s=r.evalModel||"",p=r.optimizerModel||"",l=n||{},[c,o]=await Vo(l);if(c.createTrainingSessionHandler){let a=await c.createTrainingSessionHandler(r.checkpointState,r.trainModel,s,p,o);return new ll(a,!!r.optimizerModel,!!r.evalModel)}else throw new Error(ha)}typeNarrowingForRunStep(r,n,s,p,l){let c={},o={};if(typeof s!="object"||s===null||s instanceof ft||Array.isArray(s))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let a=!0;if(typeof p=="object"){if(p===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(p instanceof ft)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(p)){if(p.length===0)throw new TypeError("'fetches' cannot be an empty array.");a=!1;for(let e of p){if(typeof e!="string")throw new TypeError("'fetches' must be a string array or an object.");if(n.indexOf(e)===-1)throw new RangeError(`'fetches' contains invalid output name: ${e}.`);c[e]=null}if(typeof l=="object"&&l!==null)o=l;else if(typeof l<"u")throw new TypeError("'options' must be an object.")}else{let e=!1,u=Object.getOwnPropertyNames(p);for(let i of n)if(u.indexOf(i)!==-1){let d=p[i];(d===null||d instanceof ft)&&(e=!0,a=!1,c[i]=d)}if(e){if(typeof l=="object"&&l!==null)o=l;else if(typeof l<"u")throw new TypeError("'options' must be an object.")}else o=p}}else if(typeof p<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let e of r)if(typeof s[e]>"u")throw new Error(`input '${e}' is missing in 'feeds'.`);if(a)for(let e of n)c[e]=null;return[c,o]}convertHandlerReturnTypeToMapOfTensors(r){let n={};for(let s in r)if(Object.hasOwnProperty.call(r,s)){let p=r[s];p instanceof ft?n[s]=p:n[s]=new ft(p.type,p.data,p.dims)}return n}async lazyResetGrad(){await this.handler.lazyResetGrad()}async runTrainStep(r,n,s){let[p,l]=this.typeNarrowingForRunStep(this.trainingInputNames,this.trainingOutputNames,r,n,s),c=await this.handler.runTrainStep(r,p,l);return this.convertHandlerReturnTypeToMapOfTensors(c)}async runOptimizerStep(r){if(this.hasOptimizerModel)await this.handler.runOptimizerStep(r||{});else throw new Error("This TrainingSession has no OptimizerModel loaded.")}async runEvalStep(r,n,s){if(this.hasEvalModel){let[p,l]=this.typeNarrowingForRunStep(this.evalInputNames,this.evalOutputNames,r,n,s),c=await this.handler.runEvalStep(r,p,l);return this.convertHandlerReturnTypeToMapOfTensors(c)}else throw new Error("This TrainingSession has no EvalModel loaded.")}async getParametersSize(r=!0){return this.handler.getParametersSize(r)}async loadParametersBuffer(r,n=!0){let s=await this.getParametersSize(n);if(r.length!==4*s)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,n)}async getContiguousParameters(r=!0){return this.handler.getContiguousParameters(r)}async release(){return this.handler.dispose()}}}),pl,Ah=I(()=>{"use strict";Ph(),pl=ul}),cl={};gr(cl,{InferenceSession:()=>sl,TRACE:()=>no,TRACE_FUNC_BEGIN:()=>Pe,TRACE_FUNC_END:()=>Ae,Tensor:()=>ft,TrainingSession:()=>pl,env:()=>j,registerBackend:()=>cr});var zt=I(()=>{"use strict";gh(),bh(),_h(),Uo(),Sh(),Oh(),ol(),Eh(),Ih(),Ah()});function be(t,r,n,s){if(r===void 0)return $h(t);if(n===void 0)kr(t,r,1);else if(typeof n=="number"&&s===void 0)kr(t,r,n);else if(typeof n=="string"&&s===void 0)kr(t,n,1,r);else if(typeof n=="string"&&typeof s=="number")kr(t,n,s,r);else throw new TypeError("input is valid")}function $h(t){return{verbose:be.verbose.bind(null,t),info:be.info.bind(null,t),warning:be.warning.bind(null,t),error:be.error.bind(null,t),fatal:be.fatal.bind(null,t)}}function kr(t,r,n,s){let p=Ee[s||""]||Ee[""];oo[t]<oo[p.minimalSeverity]||(p.logDateTime&&(r=`${new Date().toISOString()}|${r}`),p.logSourceLocation,dl[p.provider].log(t,r,s))}var fa,ga,oo,dl,bn,Ee,tt,yn,wn,hl,ze,Rt=I(()=>{"use strict";fa=class{log(t,r,n){}},ga=class{log(t,r,n){console.log(`${this.color(t)} ${n?"\x1B[35m"+n+"\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}`)}}},oo={verbose:1e3,info:2e3,warning:4e3,error:5e3,fatal:6e3},dl={none:new fa,console:new ga},bn={provider:"console",minimalSeverity:"warning",logDateTime:!0,logSourceLocation:!1},Ee={"":bn},(t=>{function r(e,u){t("verbose",e,u)}t.verbose=r;function n(e,u){t("info",e,u)}t.info=n;function s(e,u){t("warning",e,u)}t.warning=s;function p(e,u){t("error",e,u)}t.error=p;function l(e,u){t("fatal",e,u)}t.fatal=l;function c(e){Ee={},o("",e||{})}t.reset=c;function o(e,u){if(e==="*")c(u);else{let i=Ee[e]||bn;Ee[e]={provider:u.provider||i.provider,minimalSeverity:u.minimalSeverity||i.minimalSeverity,logDateTime:u.logDateTime===void 0?i.logDateTime:u.logDateTime,logSourceLocation:u.logSourceLocation===void 0?i.logSourceLocation:u.logSourceLocation}}}t.set=o;function a(e){let u={};e.logLevel&&(u.minimalSeverity=e.logLevel),o("",u)}t.setWithEnv=a})(be||(be={})),tt=be,yn=class{constructor(t,r,n,s,p,l){this.category=t,this.name=r,this.startTime=n,this.endCallback=s,this.timer=p,this.ctx=l}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)}},wn=class{constructor(t,r,n,s){this.category=t,this.name=r,this.startTime=n,this.endTime=s}},hl=class{constructor(t,r,n){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=n===void 0?5e3:n}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=ze(),this._flushPointer=0}stop(){for(this._started=!1;this._flushPointer<this._timingEvents.length;this._flushPointer++)this.logOneEvent(this._timingEvents[this._flushPointer])}event(t,r,n,s){let p=this._started?this.begin(t,r,s):void 0,l=!1,c=n();if(c&&typeof c.then=="function")return l=!0,new Promise((o,a)=>{c.then(async e=>{p&&await p.end(),o(e)},async e=>{p&&await p.end(),a(e)})});if(!l&&p){let o=p.end();if(o&&typeof o.then=="function")return new Promise((a,e)=>{o.then(()=>{a(c)},u=>{e(u)})})}return c}begin(t,r,n){if(!this._started)throw new Error("profiler is not started yet");if(n===void 0){let s=ze();return this.flush(s),new yn(t,r,s,p=>this.endSync(p))}else{let s=n.beginTimer();return new yn(t,r,0,async p=>this.end(p),s,n)}}async end(t){let r=await t.checkTimer();this._timingEvents.length<this._maxNumberEvents&&(this._timingEvents.push(new wn(t.category,t.name,t.startTime,r)),this.flush(r))}endSync(t){let r=ze();this._timingEvents.length<this._maxNumberEvents&&(this._timingEvents.push(new wn(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=ze()}}get started(){return this._started}},ze=typeof performance<"u"&&performance.now?()=>performance.now():Date.now});function Dh(t,r,n){for(let s of n){let p=s[0],l=s[1],c=s[2],o=s[3],a=s[4];if(t.opType===p){for(let e of r)if((e.domain===l||e.domain==="ai.onnx"&&l==="")&&Nh(e.version,c))return{opImpl:o,opInit:a}}}throw new TypeError(`cannot resolve operator '${t.opType}' with opsets: ${r.map(s=>`${s.domain||"ai.onnx"} v${s.version}`).join(", ")}`)}function Nh(t,r){if(r.endsWith("+")){let n=Number.parseInt(r.substring(0,r.length-1),10);return!isNaN(n)&&n<=t}else if(r.split("-").length===2){let n=r.split("-"),s=Number.parseInt(n[0],10),p=Number.parseInt(n[1],10);return!isNaN(s)&&!isNaN(p)&&s<=t&&t<=p}else return Number.parseInt(r,10)===t}var kh=I(()=>{"use strict"}),Fh=nt(t=>{"use strict";t.__esModule=!0;var r=function(){function n(s){if(!s)throw new TypeError("Invalid argument; `value` has no value.");this.value=n.EMPTY,s&&n.isGuid(s)&&(this.value=s)}return n.isGuid=function(s){var p=s.toString();return s&&(s instanceof n||n.validator.test(p))},n.create=function(){return new n([n.gen(2),n.gen(1),n.gen(1),n.gen(1),n.gen(3)].join("-"))},n.createEmpty=function(){return new n("emptyguid")},n.parse=function(s){return new n(s)},n.raw=function(){return[n.gen(2),n.gen(1),n.gen(1),n.gen(1),n.gen(3)].join("-")},n.gen=function(s){for(var p="",l=0;l<s;l++)p+=((1+Math.random())*65536|0).toString(16).substring(1);return p},n.prototype.equals=function(s){return n.isGuid(s)&&this.value===s.toString()},n.prototype.isEmpty=function(){return this.value===n.EMPTY},n.prototype.toString=function(){return this.value},n.prototype.toJSON=function(){return{value:this.value}},n.validator=new RegExp("^[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$","i"),n.EMPTY="00000000-0000-0000-0000-000000000000",n}();t.Guid=r});function W(t,r,n){this.low=t|0,this.high=r|0,this.unsigned=!!n}function dt(t){return(t&&t.__isLong__)===!0}function ma(t){var r=Math.clz32(t&-t);return t?31-r:r}function pe(t,r){var n,s,p;return r?(t>>>=0,(p=0<=t&&t<256)&&(s=ao[t],s)?s:(n=M(t,0,!0),p&&(ao[t]=n),n)):(t|=0,(p=-128<=t&&t<128)&&(s=io[t],s)?s:(n=M(t,t<0?-1:0,!1),p&&(io[t]=n),n))}function kt(t,r){if(isNaN(t))return r?Bt:Nt;if(r){if(t<0)return Bt;if(t>=so)return po}else{if(t<=-uo)return mt;if(t+1>=uo)return lo}return t<0?kt(-t,r).neg():M(t%ye|0,t/ye|0,r)}function M(t,r,n){return new W(t,r,n)}function Go(t,r,n){if(t.length===0)throw Error("empty string");if(typeof r=="number"?(n=r,r=!1):r=!!r,t==="NaN"||t==="Infinity"||t==="+Infinity"||t==="-Infinity")return r?Bt:Nt;if(n=n||10,n<2||36<n)throw RangeError("radix");var s;if((s=t.indexOf("-"))>0)throw Error("interior hyphen");if(s===0)return Go(t.substring(1),r,n).neg();for(var p=kt(sr(n,8)),l=Nt,c=0;c<t.length;c+=8){var o=Math.min(8,t.length-c),a=parseInt(t.substring(c,c+o),n);if(o<8){var e=kt(sr(n,o));l=l.mul(e).add(kt(a))}else l=l.mul(p),l=l.add(kt(a))}return l.unsigned=r,l}function Lt(t,r){return typeof t=="number"?kt(t,r):typeof t=="string"?Go(t,r):M(t.low,t.high,typeof r=="boolean"?r:t.unsigned)}var _t,io,ao,sr,vn,ba,ye,so,uo,xn,Nt,Bt,ce,Tn,Fr,lo,po,mt,A,ee,fl=I(()=>{_t=null;try{_t=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{}W.prototype.__isLong__,Object.defineProperty(W.prototype,"__isLong__",{value:!0}),W.isLong=dt,io={},ao={},W.fromInt=pe,W.fromNumber=kt,W.fromBits=M,sr=Math.pow,W.fromString=Go,W.fromValue=Lt,vn=65536,ba=1<<24,ye=vn*vn,so=ye*ye,uo=so/2,xn=pe(ba),Nt=pe(0),W.ZERO=Nt,Bt=pe(0,!0),W.UZERO=Bt,ce=pe(1),W.ONE=ce,Tn=pe(1,!0),W.UONE=Tn,Fr=pe(-1),W.NEG_ONE=Fr,lo=M(-1,2147483647,!1),W.MAX_VALUE=lo,po=M(-1,-1,!0),W.MAX_UNSIGNED_VALUE=po,mt=M(0,-2147483648,!1),W.MIN_VALUE=mt,A=W.prototype,A.toInt=function(){return this.unsigned?this.low>>>0:this.low},A.toNumber=function(){return this.unsigned?(this.high>>>0)*ye+(this.low>>>0):this.high*ye+(this.low>>>0)},A.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(mt)){var r=kt(t),n=this.div(r),s=n.mul(r).sub(this);return n.toString(t)+s.toInt().toString(t)}else return"-"+this.neg().toString(t);for(var p=kt(sr(t,6),this.unsigned),l=this,c="";;){var o=l.div(p),a=l.sub(o.mul(p)).toInt()>>>0,e=a.toString(t);if(l=o,l.isZero())return e+c;for(;e.length<6;)e="0"+e;c=""+e+c}},A.getHighBits=function(){return this.high},A.getHighBitsUnsigned=function(){return this.high>>>0},A.getLowBits=function(){return this.low},A.getLowBitsUnsigned=function(){return this.low>>>0},A.getNumBitsAbs=function(){if(this.isNegative())return this.eq(mt)?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},A.isZero=function(){return this.high===0&&this.low===0},A.eqz=A.isZero,A.isNegative=function(){return!this.unsigned&&this.high<0},A.isPositive=function(){return this.unsigned||this.high>=0},A.isOdd=function(){return(this.low&1)===1},A.isEven=function(){return(this.low&1)===0},A.equals=function(t){return dt(t)||(t=Lt(t)),this.unsigned!==t.unsigned&&this.high>>>31===1&&t.high>>>31===1?!1:this.high===t.high&&this.low===t.low},A.eq=A.equals,A.notEquals=function(t){return!this.eq(t)},A.neq=A.notEquals,A.ne=A.notEquals,A.lessThan=function(t){return this.comp(t)<0},A.lt=A.lessThan,A.lessThanOrEqual=function(t){return this.comp(t)<=0},A.lte=A.lessThanOrEqual,A.le=A.lessThanOrEqual,A.greaterThan=function(t){return this.comp(t)>0},A.gt=A.greaterThan,A.greaterThanOrEqual=function(t){return this.comp(t)>=0},A.gte=A.greaterThanOrEqual,A.ge=A.greaterThanOrEqual,A.compare=function(t){if(dt(t)||(t=Lt(t)),this.eq(t))return 0;var r=this.isNegative(),n=t.isNegative();return r&&!n?-1:!r&&n?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},A.comp=A.compare,A.negate=function(){return!this.unsigned&&this.eq(mt)?mt:this.not().add(ce)},A.neg=A.negate,A.add=function(t){dt(t)||(t=Lt(t));var r=this.high>>>16,n=this.high&65535,s=this.low>>>16,p=this.low&65535,l=t.high>>>16,c=t.high&65535,o=t.low>>>16,a=t.low&65535,e=0,u=0,i=0,d=0;return d+=p+a,i+=d>>>16,d&=65535,i+=s+o,u+=i>>>16,i&=65535,u+=n+c,e+=u>>>16,u&=65535,e+=r+l,e&=65535,M(i<<16|d,e<<16|u,this.unsigned)},A.subtract=function(t){return dt(t)||(t=Lt(t)),this.add(t.neg())},A.sub=A.subtract,A.multiply=function(t){if(this.isZero())return this;if(dt(t)||(t=Lt(t)),_t){var r=_t.mul(this.low,this.high,t.low,t.high);return M(r,_t.get_high(),this.unsigned)}if(t.isZero())return this.unsigned?Bt:Nt;if(this.eq(mt))return t.isOdd()?mt:Nt;if(t.eq(mt))return this.isOdd()?mt:Nt;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(xn)&&t.lt(xn))return kt(this.toNumber()*t.toNumber(),this.unsigned);var n=this.high>>>16,s=this.high&65535,p=this.low>>>16,l=this.low&65535,c=t.high>>>16,o=t.high&65535,a=t.low>>>16,e=t.low&65535,u=0,i=0,d=0,h=0;return h+=l*e,d+=h>>>16,h&=65535,d+=p*e,i+=d>>>16,d&=65535,d+=l*a,i+=d>>>16,d&=65535,i+=s*e,u+=i>>>16,i&=65535,i+=p*a,u+=i>>>16,i&=65535,i+=l*o,u+=i>>>16,i&=65535,u+=n*e+s*a+p*o+l*c,u&=65535,M(d<<16|h,u<<16|i,this.unsigned)},A.mul=A.multiply,A.divide=function(t){if(dt(t)||(t=Lt(t)),t.isZero())throw Error("division by zero");if(_t){if(!this.unsigned&&this.high===-2147483648&&t.low===-1&&t.high===-1)return this;var r=(this.unsigned?_t.div_u:_t.div_s)(this.low,this.high,t.low,t.high);return M(r,_t.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?Bt:Nt;var n,s,p;if(this.unsigned){if(t.unsigned||(t=t.toUnsigned()),t.gt(this))return Bt;if(t.gt(this.shru(1)))return Tn;p=Bt}else{if(this.eq(mt)){if(t.eq(ce)||t.eq(Fr))return mt;if(t.eq(mt))return ce;var l=this.shr(1);return n=l.div(t).shl(1),n.eq(Nt)?t.isNegative()?ce:Fr:(s=this.sub(t.mul(n)),p=n.add(s.div(t)),p)}else if(t.eq(mt))return this.unsigned?Bt:Nt;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();p=Nt}for(s=this;s.gte(t);){n=Math.max(1,Math.floor(s.toNumber()/t.toNumber()));for(var c=Math.ceil(Math.log(n)/Math.LN2),o=c<=48?1:sr(2,c-48),a=kt(n),e=a.mul(t);e.isNegative()||e.gt(s);)n-=o,a=kt(n,this.unsigned),e=a.mul(t);a.isZero()&&(a=ce),p=p.add(a),s=s.sub(e)}return p},A.div=A.divide,A.modulo=function(t){if(dt(t)||(t=Lt(t)),_t){var r=(this.unsigned?_t.rem_u:_t.rem_s)(this.low,this.high,t.low,t.high);return M(r,_t.get_high(),this.unsigned)}return this.sub(this.div(t).mul(t))},A.mod=A.modulo,A.rem=A.modulo,A.not=function(){return M(~this.low,~this.high,this.unsigned)},A.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32},A.clz=A.countLeadingZeros,A.countTrailingZeros=function(){return this.low?ma(this.low):ma(this.high)+32},A.ctz=A.countTrailingZeros,A.and=function(t){return dt(t)||(t=Lt(t)),M(this.low&t.low,this.high&t.high,this.unsigned)},A.or=function(t){return dt(t)||(t=Lt(t)),M(this.low|t.low,this.high|t.high,this.unsigned)},A.xor=function(t){return dt(t)||(t=Lt(t)),M(this.low^t.low,this.high^t.high,this.unsigned)},A.shiftLeft=function(t){return dt(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?M(this.low<<t,this.high<<t|this.low>>>32-t,this.unsigned):M(0,this.low<<t-32,this.unsigned)},A.shl=A.shiftLeft,A.shiftRight=function(t){return dt(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?M(this.low>>>t|this.high<<32-t,this.high>>t,this.unsigned):M(this.high>>t-32,this.high>=0?0:-1,this.unsigned)},A.shr=A.shiftRight,A.shiftRightUnsigned=function(t){return dt(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?M(this.low>>>t|this.high<<32-t,this.high>>>t,this.unsigned):t===32?M(this.high,0,this.unsigned):M(this.high>>>t-32,0,this.unsigned)},A.shru=A.shiftRightUnsigned,A.shr_u=A.shiftRightUnsigned,A.rotateLeft=function(t){var r;return dt(t)&&(t=t.toInt()),(t&=63)===0?this:t===32?M(this.high,this.low,this.unsigned):t<32?(r=32-t,M(this.low<<t|this.high>>>r,this.high<<t|this.low>>>r,this.unsigned)):(t-=32,r=32-t,M(this.high<<t|this.low>>>r,this.low<<t|this.high>>>r,this.unsigned))},A.rotl=A.rotateLeft,A.rotateRight=function(t){var r;return dt(t)&&(t=t.toInt()),(t&=63)===0?this:t===32?M(this.high,this.low,this.unsigned):t<32?(r=32-t,M(this.high<<r|this.low>>>t,this.low<<r|this.high>>>t,this.unsigned)):(t-=32,r=32-t,M(this.low<<r|this.high>>>t,this.high<<r|this.low>>>t,this.unsigned))},A.rotr=A.rotateRight,A.toSigned=function(){return this.unsigned?M(this.low,this.high,!1):this},A.toUnsigned=function(){return this.unsigned?this:M(this.low,this.high,!0)},A.toBytes=function(t){return t?this.toBytesLE():this.toBytesBE()},A.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]},A.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]},W.fromBytes=function(t,r,n){return n?W.fromBytesLE(t,r):W.fromBytesBE(t,r)},W.fromBytesLE=function(t,r){return new W(t[0]|t[1]<<8|t[2]<<16|t[3]<<24,t[4]|t[5]<<8|t[6]<<16|t[7]<<24,r)},W.fromBytesBE=function(t,r){return new W(t[4]<<24|t[5]<<16|t[6]<<8|t[7],t[0]<<24|t[1]<<16|t[2]<<8|t[3],r)},ee=W}),T,Ho=I(()=>{T={},T.Offset,T.Table,T.SIZEOF_SHORT=2,T.SIZEOF_INT=4,T.FILE_IDENTIFIER_LENGTH=4,T.SIZE_PREFIX_LENGTH=4,T.Encoding={UTF8_BYTES:1,UTF16_STRING:2},T.int32=new Int32Array(2),T.float32=new Float32Array(T.int32.buffer),T.float64=new Float64Array(T.int32.buffer),T.isLittleEndian=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1,T.Long=function(t,r){this.low=t|0,this.high=r|0},T.Long.create=function(t,r){return t==0&&r==0?T.Long.ZERO:new T.Long(t,r)},T.Long.prototype.toFloat64=function(){return(this.low>>>0)+this.high*4294967296},T.Long.prototype.equals=function(t){return this.low==t.low&&this.high==t.high},T.Long.ZERO=new T.Long(0,0),T.Builder=function(t){if(t)var r=t;else var r=1024;this.bb=T.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},T.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},T.Builder.prototype.forceDefaults=function(t){this.force_defaults=t},T.Builder.prototype.dataBuffer=function(){return this.bb},T.Builder.prototype.asUint8Array=function(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())},T.Builder.prototype.prep=function(t,r){t>this.minalign&&(this.minalign=t);for(var n=~(this.bb.capacity()-this.space+r)+1&t-1;this.space<n+t+r;){var s=this.bb.capacity();this.bb=T.Builder.growByteBuffer(this.bb),this.space+=this.bb.capacity()-s}this.pad(n)},T.Builder.prototype.pad=function(t){for(var r=0;r<t;r++)this.bb.writeInt8(--this.space,0)},T.Builder.prototype.writeInt8=function(t){this.bb.writeInt8(this.space-=1,t)},T.Builder.prototype.writeInt16=function(t){this.bb.writeInt16(this.space-=2,t)},T.Builder.prototype.writeInt32=function(t){this.bb.writeInt32(this.space-=4,t)},T.Builder.prototype.writeInt64=function(t){this.bb.writeInt64(this.space-=8,t)},T.Builder.prototype.writeFloat32=function(t){this.bb.writeFloat32(this.space-=4,t)},T.Builder.prototype.writeFloat64=function(t){this.bb.writeFloat64(this.space-=8,t)},T.Builder.prototype.addInt8=function(t){this.prep(1,0),this.writeInt8(t)},T.Builder.prototype.addInt16=function(t){this.prep(2,0),this.writeInt16(t)},T.Builder.prototype.addInt32=function(t){this.prep(4,0),this.writeInt32(t)},T.Builder.prototype.addInt64=function(t){this.prep(8,0),this.writeInt64(t)},T.Builder.prototype.addFloat32=function(t){this.prep(4,0),this.writeFloat32(t)},T.Builder.prototype.addFloat64=function(t){this.prep(8,0),this.writeFloat64(t)},T.Builder.prototype.addFieldInt8=function(t,r,n){(this.force_defaults||r!=n)&&(this.addInt8(r),this.slot(t))},T.Builder.prototype.addFieldInt16=function(t,r,n){(this.force_defaults||r!=n)&&(this.addInt16(r),this.slot(t))},T.Builder.prototype.addFieldInt32=function(t,r,n){(this.force_defaults||r!=n)&&(this.addInt32(r),this.slot(t))},T.Builder.prototype.addFieldInt64=function(t,r,n){(this.force_defaults||!r.equals(n))&&(this.addInt64(r),this.slot(t))},T.Builder.prototype.addFieldFloat32=function(t,r,n){(this.force_defaults||r!=n)&&(this.addFloat32(r),this.slot(t))},T.Builder.prototype.addFieldFloat64=function(t,r,n){(this.force_defaults||r!=n)&&(this.addFloat64(r),this.slot(t))},T.Builder.prototype.addFieldOffset=function(t,r,n){(this.force_defaults||r!=n)&&(this.addOffset(r),this.slot(t))},T.Builder.prototype.addFieldStruct=function(t,r,n){r!=n&&(this.nested(r),this.slot(t))},T.Builder.prototype.nested=function(t){if(t!=this.offset())throw new Error("FlatBuffers: struct must be serialized inline.")},T.Builder.prototype.notNested=function(){if(this.isNested)throw new Error("FlatBuffers: object serialization must not be nested.")},T.Builder.prototype.slot=function(t){this.vtable[t]=this.offset()},T.Builder.prototype.offset=function(){return this.bb.capacity()-this.space},T.Builder.growByteBuffer=function(t){var r=t.capacity();if(r&3221225472)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");var n=r<<1,s=T.ByteBuffer.allocate(n);return s.setPosition(n-r),s.bytes().set(t.bytes(),n-r),s},T.Builder.prototype.addOffset=function(t){this.prep(T.SIZEOF_INT,0),this.writeInt32(this.offset()-t+T.SIZEOF_INT)},T.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()},T.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 n=r+1;r>=0;r--)this.addInt16(this.vtable[r]!=0?t-this.vtable[r]:0);var s=2;this.addInt16(t-this.object_start);var p=(n+s)*T.SIZEOF_SHORT;this.addInt16(p);var l=0,c=this.space;t:for(r=0;r<this.vtables.length;r++){var o=this.bb.capacity()-this.vtables[r];if(p==this.bb.readInt16(o)){for(var a=T.SIZEOF_SHORT;a<p;a+=T.SIZEOF_SHORT)if(this.bb.readInt16(c+a)!=this.bb.readInt16(o+a))continue t;l=this.vtables[r];break}}return l?(this.space=this.bb.capacity()-t,this.bb.writeInt32(this.space,l-t)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-t,this.offset()-t)),this.isNested=!1,t},T.Builder.prototype.finish=function(t,r,n){var s=n?T.SIZE_PREFIX_LENGTH:0;if(r){var p=r;if(this.prep(this.minalign,T.SIZEOF_INT+T.FILE_IDENTIFIER_LENGTH+s),p.length!=T.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+T.FILE_IDENTIFIER_LENGTH);for(var l=T.FILE_IDENTIFIER_LENGTH-1;l>=0;l--)this.writeInt8(p.charCodeAt(l))}this.prep(this.minalign,T.SIZEOF_INT+s),this.addOffset(t),s&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)},T.Builder.prototype.finishSizePrefixed=function(t,r){this.finish(t,r,!0)},T.Builder.prototype.requiredField=function(t,r){var n=this.bb.capacity()-t,s=n-this.bb.readInt32(n),p=this.bb.readInt16(s+r)!=0;if(!p)throw new Error("FlatBuffers: field "+r+" must be set")},T.Builder.prototype.startVector=function(t,r,n){this.notNested(),this.vector_num_elems=r,this.prep(T.SIZEOF_INT,t*r),this.prep(n,t*r)},T.Builder.prototype.endVector=function(){return this.writeInt32(this.vector_num_elems),this.offset()},T.Builder.prototype.createString=function(t){if(t instanceof Uint8Array)var r=t;else for(var r=[],n=0;n<t.length;){var s,p=t.charCodeAt(n++);if(p<55296||p>=56320)s=p;else{var l=t.charCodeAt(n++);s=(p<<10)+l+-56613888}s<128?r.push(s):(s<2048?r.push(s>>6&31|192):(s<65536?r.push(s>>12&15|224):r.push(s>>18&7|240,s>>12&63|128),r.push(s>>6&63|128)),r.push(s&63|128))}this.addInt8(0),this.startVector(1,r.length,1),this.bb.setPosition(this.space-=r.length);for(var n=0,c=this.space,o=this.bb.bytes();n<r.length;n++)o[c++]=r[n];return this.endVector()},T.Builder.prototype.createLong=function(t,r){return T.Long.create(t,r)},T.ByteBuffer=function(t){this.bytes_=t,this.position_=0},T.ByteBuffer.allocate=function(t){return new T.ByteBuffer(new Uint8Array(t))},T.ByteBuffer.prototype.clear=function(){this.position_=0},T.ByteBuffer.prototype.bytes=function(){return this.bytes_},T.ByteBuffer.prototype.position=function(){return this.position_},T.ByteBuffer.prototype.setPosition=function(t){this.position_=t},T.ByteBuffer.prototype.capacity=function(){return this.bytes_.length},T.ByteBuffer.prototype.readInt8=function(t){return this.readUint8(t)<<24>>24},T.ByteBuffer.prototype.readUint8=function(t){return this.bytes_[t]},T.ByteBuffer.prototype.readInt16=function(t){return this.readUint16(t)<<16>>16},T.ByteBuffer.prototype.readUint16=function(t){return this.bytes_[t]|this.bytes_[t+1]<<8},T.ByteBuffer.prototype.readInt32=function(t){return this.bytes_[t]|this.bytes_[t+1]<<8|this.bytes_[t+2]<<16|this.bytes_[t+3]<<24},T.ByteBuffer.prototype.readUint32=function(t){return this.readInt32(t)>>>0},T.ByteBuffer.prototype.readInt64=function(t){return new T.Long(this.readInt32(t),this.readInt32(t+4))},T.ByteBuffer.prototype.readUint64=function(t){return new T.Long(this.readUint32(t),this.readUint32(t+4))},T.ByteBuffer.prototype.readFloat32=function(t){return T.int32[0]=this.readInt32(t),T.float32[0]},T.ByteBuffer.prototype.readFloat64=function(t){return T.int32[T.isLittleEndian?0:1]=this.readInt32(t),T.int32[T.isLittleEndian?1:0]=this.readInt32(t+4),T.float64[0]},T.ByteBuffer.prototype.writeInt8=function(t,r){this.bytes_[t]=r},T.ByteBuffer.prototype.writeUint8=function(t,r){this.bytes_[t]=r},T.ByteBuffer.prototype.writeInt16=function(t,r){this.bytes_[t]=r,this.bytes_[t+1]=r>>8},T.ByteBuffer.prototype.writeUint16=function(t,r){this.bytes_[t]=r,this.bytes_[t+1]=r>>8},T.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},T.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},T.ByteBuffer.prototype.writeInt64=function(t,r){this.writeInt32(t,r.low),this.writeInt32(t+4,r.high)},T.ByteBuffer.prototype.writeUint64=function(t,r){this.writeUint32(t,r.low),this.writeUint32(t+4,r.high)},T.ByteBuffer.prototype.writeFloat32=function(t,r){T.float32[0]=r,this.writeInt32(t,T.int32[0])},T.ByteBuffer.prototype.writeFloat64=function(t,r){T.float64[0]=r,this.writeInt32(t,T.int32[T.isLittleEndian?0:1]),this.writeInt32(t+4,T.int32[T.isLittleEndian?1:0])},T.ByteBuffer.prototype.getBufferIdentifier=function(){if(this.bytes_.length<this.position_+T.SIZEOF_INT+T.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");for(var t="",r=0;r<T.FILE_IDENTIFIER_LENGTH;r++)t+=String.fromCharCode(this.readInt8(this.position_+T.SIZEOF_INT+r));return t},T.ByteBuffer.prototype.__offset=function(t,r){var n=t-this.readInt32(t);return r<this.readInt16(n)?this.readInt16(n+r):0},T.ByteBuffer.prototype.__union=function(t,r){return t.bb_pos=r+this.readInt32(r),t.bb=this,t},T.ByteBuffer.prototype.__string=function(t,r){t+=this.readInt32(t);var n=this.readInt32(t),s="",p=0;if(t+=T.SIZEOF_INT,r===T.Encoding.UTF8_BYTES)return this.bytes_.subarray(t,t+n);for(;p<n;){var l,c=this.readUint8(t+p++);if(c<192)l=c;else{var o=this.readUint8(t+p++);if(c<224)l=(c&31)<<6|o&63;else{var a=this.readUint8(t+p++);if(c<240)l=(c&15)<<12|(o&63)<<6|a&63;else{var e=this.readUint8(t+p++);l=(c&7)<<18|(o&63)<<12|(a&63)<<6|e&63}}}l<65536?s+=String.fromCharCode(l):(l-=65536,s+=String.fromCharCode((l>>10)+55296,(l&1023)+56320))}return s},T.ByteBuffer.prototype.__indirect=function(t){return t+this.readInt32(t)},T.ByteBuffer.prototype.__vector=function(t){return t+this.readInt32(t)+T.SIZEOF_INT},T.ByteBuffer.prototype.__vector_len=function(t){return this.readInt32(t+this.readInt32(t))},T.ByteBuffer.prototype.__has_identifier=function(t){if(t.length!=T.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+T.FILE_IDENTIFIER_LENGTH);for(var r=0;r<T.FILE_IDENTIFIER_LENGTH;r++)if(t.charCodeAt(r)!=this.readInt8(this.position_+T.SIZEOF_INT+r))return!1;return!0},T.ByteBuffer.prototype.createLong=function(t,r){return T.Long.create(t,r)}}),H,Zr=I(()=>{"use strict";Ho(),(t=>{let r;(n=>{let s;(p=>{let l;(c=>(c[c.UNDEFINED=0]="UNDEFINED",c[c.FLOAT=1]="FLOAT",c[c.INT=2]="INT",c[c.STRING=3]="STRING",c[c.TENSOR=4]="TENSOR",c[c.GRAPH=5]="GRAPH",c[c.FLOATS=6]="FLOATS",c[c.INTS=7]="INTS",c[c.STRINGS=8]="STRINGS",c[c.TENSORS=9]="TENSORS",c[c.GRAPHS=10]="GRAPHS",c[c.SPARSE_TENSOR=11]="SPARSE_TENSOR",c[c.SPARSE_TENSORS=12]="SPARSE_TENSORS"))(l=p.AttributeType||(p.AttributeType={}))})(s=n.fbs||(n.fbs={}))})(r=t.experimental||(t.experimental={}))})(H||(H={})),(t=>{let r;(n=>{let s;(p=>{let l;(c=>(c[c.UNKNOWN=0]="UNKNOWN",c[c.VALUE=1]="VALUE",c[c.PARAM=2]="PARAM"))(l=p.DimensionValueType||(p.DimensionValueType={}))})(s=n.fbs||(n.fbs={}))})(r=t.experimental||(t.experimental={}))})(H||(H={})),(t=>{let r;(n=>{let s;(p=>{let l;(c=>(c[c.UNDEFINED=0]="UNDEFINED",c[c.FLOAT=1]="FLOAT",c[c.UINT8=2]="UINT8",c[c.INT8=3]="INT8",c[c.UINT16=4]="UINT16",c[c.INT16=5]="INT16",c[c.INT32=6]="INT32",c[c.INT64=7]="INT64",c[c.STRING=8]="STRING",c[c.BOOL=9]="BOOL",c[c.FLOAT16=10]="FLOAT16",c[c.DOUBLE=11]="DOUBLE",c[c.UINT32=12]="UINT32",c[c.UINT64=13]="UINT64",c[c.COMPLEX64=14]="COMPLEX64",c[c.COMPLEX128=15]="COMPLEX128",c[c.BFLOAT16=16]="BFLOAT16",c[c.FLOAT8E4M3FN=17]="FLOAT8E4M3FN",c[c.FLOAT8E4M3FNUZ=18]="FLOAT8E4M3FNUZ",c[c.FLOAT8E5M2=19]="FLOAT8E5M2",c[c.FLOAT8E5M2FNUZ=20]="FLOAT8E5M2FNUZ"))(l=p.TensorDataType||(p.TensorDataType={}))})(s=n.fbs||(n.fbs={}))})(r=t.experimental||(t.experimental={}))})(H||(H={})),(t=>{let r;(n=>{let s;(p=>{let l;(c=>(c[c.Primitive=0]="Primitive",c[c.Fused=1]="Fused"))(l=p.NodeType||(p.NodeType={}))})(s=n.fbs||(n.fbs={}))})(r=t.experimental||(t.experimental={}))})(H||(H={})),(t=>{let r;(n=>{let s;(p=>{let l;(c=>(c[c.NONE=0]="NONE",c[c.tensor_type=1]="tensor_type",c[c.sequence_type=2]="sequence_type",c[c.map_type=3]="map_type"))(l=p.TypeInfoValue||(p.TypeInfoValue={}))})(s=n.fbs||(n.fbs={}))})(r=t.experimental||(t.experimental={}))})(H||(H={})),(t=>{let r;(n=>{let s;(p=>{class l{constructor(){this.bb=null,this.bb_pos=0}__init(o,a){return this.bb_pos=o,this.bb=a,this}static getRootAsShape(o,a){return(a||new l).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsShape(o,a){return o.setPosition(o.position()+T.SIZE_PREFIX_LENGTH),(a||new l).__init(o.readInt32(o.position())+o.position(),o)}dim(o,a){let e=this.bb.__offset(this.bb_pos,4);return e?(a||new t.experimental.fbs.Dimension).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+e)+o*4),this.bb):null}dimLength(){let o=this.bb.__offset(this.bb_pos,4);return o?this.bb.__vector_len(this.bb_pos+o):0}static startShape(o){o.startObject(1)}static addDim(o,a){o.addFieldOffset(0,a,0)}static createDimVector(o,a){o.startVector(4,a.length,4);for(let e=a.length-1;e>=0;e--)o.addOffset(a[e]);return o.endVector()}static startDimVector(o,a){o.startVector(4,a,4)}static endShape(o){return o.endObject()}static createShape(o,a){return l.startShape(o),l.addDim(o,a),l.endShape(o)}}p.Shape=l})(s=n.fbs||(n.fbs={}))})(r=t.experimental||(t.experimental={}))})(H||(H={})),(t=>{let r;(n=>{let s;(p=>{class l{constructor(){this.bb=null,this.bb_pos=0}__init(o,a){return this.bb_pos=o,this.bb=a,this}static getRootAsDimension(o,a){return(a||new l).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsDimension(o,a){return o.setPosition(o.position()+T.SIZE_PREFIX_LENGTH),(a||new l).__init(o.readInt32(o.position())+o.position(),o)}value(o){let a=this.bb.__offset(this.bb_pos,4);return a?(o||new t.experimental.fbs.DimensionValue).__init(this.bb.__indirect(this.bb_pos+a),this.bb):null}denotation(o){let a=this.bb.__offset(this.bb_pos,6);return a?this.bb.__string(this.bb_pos+a,o):null}static startDimension(o){o.startObject(2)}static addValue(o,a){o.addFieldOffset(0,a,0)}static addDenotation(o,a){o.addFieldOffset(1,a,0)}static endDimension(o){return o.endObject()}static createDimension(o,a,e){return l.startDimension(o),l.addValue(o,a),l.addDenotation(o,e),l.endDimension(o)}}p.Dimension=l})(s=n.fbs||(n.fbs={}))})(r=t.experimental||(t.experimental={}))})(H||(H={})),(t=>{let r;(n=>{let s;(p=>{class l{constructor(){this.bb=null,this.bb_pos=0}__init(o,a){return this.bb_pos=o,this.bb=a,this}static getRootAsDimensionValue(o,a){return(a||new l).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsDimensionValue(o,a){return o.setPosition(o.position()+T.SIZE_PREFIX_LENGTH),(a||new l).__init(o.readInt32(o.position())+o.position(),o)}dimType(){let o=this.bb.__offset(this.bb_pos,4);return o?this.bb.readInt8(this.bb_pos+o):0}dimValue(){let o=this.bb.__offset(this.bb_pos,6);return o?this.bb.readInt64(this.bb_pos+o):this.bb.createLong(0,0)}dimParam(o){let a=this.bb.__offset(this.bb_pos,8);return a?this.bb.__string(this.bb_pos+a,o):null}static startDimensionValue(o){o.startObject(3)}static addDimType(o,a){o.addFieldInt8(0,a,0)}static addDimValue(o,a){o.addFieldInt64(1,a,o.createLong(0,0))}static addDimParam(o,a){o.addFieldOffset(2,a,0)}static endDimensionValue(o){return o.endObject()}static createDimensionValue(o,a,e,u){return l.startDimensionValue(o),l.addDimType(o,a),l.addDimValue(o,e),l.addDimParam(o,u),l.endDimensionValue(o)}}p.DimensionValue=l})(s=n.fbs||(n.fbs={}))})(r=t.experimental||(t.experimental={}))})(H||(H={})),(t=>{let r;(n=>{let s;(p=>{class l{constructor(){this.bb=null,this.bb_pos=0}__init(o,a){return this.bb_pos=o,this.bb=a,this}static getRootAsTensorTypeAndShape(o,a){return(a||new l).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsTensorTypeAndShape(o,a){return o.setPosition(o.position()+T.SIZE_PREFIX_LENGTH),(a||new l).__init(o.readInt32(o.position())+o.position(),o)}elemType(){let o=this.bb.__offset(this.bb_pos,4);return o?this.bb.readInt32(this.bb_pos+o):0}shape(o){let a=this.bb.__offset(this.bb_pos,6);return a?(o||new t.experimental.fbs.Shape).__init(this.bb.__indirect(this.bb_pos+a),this.bb):null}static startTensorTypeAndShape(o){o.startObject(2)}static addElemType(o,a){o.addFieldInt32(0,a,0)}static addShape(o,a){o.addFieldOffset(1,a,0)}static endTensorTypeAndShape(o){return o.endObject()}static createTensorTypeAndShape(o,a,e){return l.startTensorTypeAndShape(o),l.addElemType(o,a),l.addShape(o,e),l.endTensorTypeAndShape(o)}}p.TensorTypeAndShape=l})(s=n.fbs||(n.fbs={}))})(r=t.experimental||(t.experimental={}))})(H||(H={})),(t=>{let r;(n=>{let s;(p=>{class l{constructor(){this.bb=null,this.bb_pos=0}__init(o,a){return this.bb_pos=o,this.bb=a,this}static getRootAsMapType(o,a){return(a||new l).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsMapType(o,a){return o.setPosition(o.position()+T.SIZE_PREFIX_LENGTH),(a||new l).__init(o.readInt32(o.position())+o.position(),o)}keyType(){let o=this.bb.__offset(this.bb_pos,4);return o?this.bb.readInt32(this.bb_pos+o):0}valueType(o){let a=this.bb.__offset(this.bb_pos,6);return a?(o||new t.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+a),this.bb):null}static startMapType(o){o.startObject(2)}static addKeyType(o,a){o.addFieldInt32(0,a,0)}static addValueType(o,a){o.addFieldOffset(1,a,0)}static endMapType(o){return o.endObject()}static createMapType(o,a,e){return l.startMapType(o),l.addKeyType(o,a),l.addValueType(o,e),l.endMapType(o)}}p.MapType=l})(s=n.fbs||(n.fbs={}))})(r=t.experimental||(t.experimental={}))})(H||(H={})),(t=>{let r;(n=>{let s;(p=>{class l{constructor(){this.bb=null,this.bb_pos=0}__init(o,a){return this.bb_pos=o,this.bb=a,this}static getRootAsSequenceType(o,a){return(a||new l).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsSequenceType(o,a){return o.setPosition(o.position()+T.SIZE_PREFIX_LENGTH),(a||new l).__init(o.readInt32(o.position())+o.position(),o)}elemType(o){let a=this.bb.__offset(this.bb_pos,4);return a?(o||new t.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+a),this.bb):null}static startSequenceType(o){o.startObject(1)}static addElemType(o,a){o.addFieldOffset(0,a,0)}static endSequenceType(o){return o.endObject()}static createSequenceType(o,a){return l.startSequenceType(o),l.addElemType(o,a),l.endSequenceType(o)}}p.SequenceType=l})(s=n.fbs||(n.fbs={}))})(r=t.experimental||(t.experimental={}))})(H||(H={})),(t=>{let r;(n=>{let s;(p=>{class l{constructor(){this.bb=null,this.bb_pos=0}__init(o,a){return this.bb_pos=o,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(o,a,e,u){return o.prep(4,12),o.writeInt32(u),o.writeInt32(e),o.writeInt32(a),o.offset()}}p.EdgeEnd=l})(s=n.fbs||(n.fbs={}))})(r=t.experimental||(t.experimental={}))})(H||(H={})),(t=>{let r;(n=>{let s;(p=>{class l{constructor(){this.bb=null,this.bb_pos=0}__init(o,a){return this.bb_pos=o,this.bb=a,this}static getRootAsNodeEdge(o,a){return(a||new l).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsNodeEdge(o,a){return o.setPosition(o.position()+T.SIZE_PREFIX_LENGTH),(a||new l).__init(o.readInt32(o.position())+o.position(),o)}nodeIndex(){let o=this.bb.__offset(this.bb_pos,4);return o?this.bb.readUint32(this.bb_pos+o):0}inputEdges(o,a){let e=this.bb.__offset(this.bb_pos,6);return e?(a||new t.experimental.fbs.EdgeEnd).__init(this.bb.__vector(this.bb_pos+e)+o*12,this.bb):null}inputEdgesLength(){let o=this.bb.__offset(this.bb_pos,6);return o?this.bb.__vector_len(this.bb_pos+o):0}outputEdges(o,a){let e=this.bb.__offset(this.bb_pos,8);return e?(a||new t.experimental.fbs.EdgeEnd).__init(this.bb.__vector(this.bb_pos+e)+o*12,this.bb):null}outputEdgesLength(){let o=this.bb.__offset(this.bb_pos,8);return o?this.bb.__vector_len(this.bb_pos+o):0}static startNodeEdge(o){o.startObject(3)}static addNodeIndex(o,a){o.addFieldInt32(0,a,0)}static addInputEdges(o,a){o.addFieldOffset(1,a,0)}static startInputEdgesVector(o,a){o.startVector(12,a,4)}static addOutputEdges(o,a){o.addFieldOffset(2,a,0)}static startOutputEdgesVector(o,a){o.startVector(12,a,4)}static endNodeEdge(o){return o.endObject()}static createNodeEdge(o,a,e,u){return l.startNodeEdge(o),l.addNodeIndex(o,a),l.addInputEdges(o,e),l.addOutputEdges(o,u),l.endNodeEdge(o)}}p.NodeEdge=l})(s=n.fbs||(n.fbs={}))})(r=t.experimental||(t.experimental={}))})(H||(H={})),(t=>{let r;(n=>{let s;(p=>{class l{constructor(){this.bb=null,this.bb_pos=0}__init(o,a){return this.bb_pos=o,this.bb=a,this}static getRootAsNode(o,a){return(a||new l).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsNode(o,a){return o.setPosition(o.position()+T.SIZE_PREFIX_LENGTH),(a||new l).__init(o.readInt32(o.position())+o.position(),o)}name(o){let a=this.bb.__offset(this.bb_pos,4);return a?this.bb.__string(this.bb_pos+a,o):null}docString(o){let a=this.bb.__offset(this.bb_pos,6);return a?this.bb.__string(this.bb_pos+a,o):null}domain(o){let a=this.bb.__offset(this.bb_pos,8);return a?this.bb.__string(this.bb_pos+a,o):null}sinceVersion(){let o=this.bb.__offset(this.bb_pos,10);return o?this.bb.readInt32(this.bb_pos+o):0}index(){let o=this.bb.__offset(this.bb_pos,12);return o?this.bb.readUint32(this.bb_pos+o):0}opType(o){let a=this.bb.__offset(this.bb_pos,14);return a?this.bb.__string(this.bb_pos+a,o):null}type(){let o=this.bb.__offset(this.bb_pos,16);return o?this.bb.readInt32(this.bb_pos+o):0}executionProviderType(o){let a=this.bb.__offset(this.bb_pos,18);return a?this.bb.__string(this.bb_pos+a,o):null}inputs(o,a){let e=this.bb.__offset(this.bb_pos,20);return e?this.bb.__string(this.bb.__vector(this.bb_pos+e)+o*4,a):null}inputsLength(){let o=this.bb.__offset(this.bb_pos,20);return o?this.bb.__vector_len(this.bb_pos+o):0}outputs(o,a){let e=this.bb.__offset(this.bb_pos,22);return e?this.bb.__string(this.bb.__vector(this.bb_pos+e)+o*4,a):null}outputsLength(){let o=this.bb.__offset(this.bb_pos,22);return o?this.bb.__vector_len(this.bb_pos+o):0}attributes(o,a){let e=this.bb.__offset(this.bb_pos,24);return e?(a||new t.experimental.fbs.Attribute).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+e)+o*4),this.bb):null}attributesLength(){let o=this.bb.__offset(this.bb_pos,24);return o?this.bb.__vector_len(this.bb_pos+o):0}inputArgCounts(o){let a=this.bb.__offset(this.bb_pos,26);return a?this.bb.readInt32(this.bb.__vector(this.bb_pos+a)+o*4):0}inputArgCountsLength(){let o=this.bb.__offset(this.bb_pos,26);return o?this.bb.__vector_len(this.bb_pos+o):0}inputArgCountsArray(){let o=this.bb.__offset(this.bb_pos,26);return o?new Int32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+o),this.bb.__vector_len(this.bb_pos+o)):null}implicitInputs(o,a){let e=this.bb.__offset(this.bb_pos,28);return e?this.bb.__string(this.bb.__vector(this.bb_pos+e)+o*4,a):null}implicitInputsLength(){let o=this.bb.__offset(this.bb_pos,28);return o?this.bb.__vector_len(this.bb_pos+o):0}static startNode(o){o.startObject(13)}static addName(o,a){o.addFieldOffset(0,a,0)}static addDocString(o,a){o.addFieldOffset(1,a,0)}static addDomain(o,a){o.addFieldOffset(2,a,0)}static addSinceVersion(o,a){o.addFieldInt32(3,a,0)}static addIndex(o,a){o.addFieldInt32(4,a,0)}static addOpType(o,a){o.addFieldOffset(5,a,0)}static addType(o,a){o.addFieldInt32(6,a,0)}static addExecutionProviderType(o,a){o.addFieldOffset(7,a,0)}static addInputs(o,a){o.addFieldOffset(8,a,0)}static createInputsVector(o,a){o.startVector(4,a.length,4);for(let e=a.length-1;e>=0;e--)o.addOffset(a[e]);return o.endVector()}static startInputsVector(o,a){o.startVector(4,a,4)}static addOutputs(o,a){o.addFieldOffset(9,a,0)}static createOutputsVector(o,a){o.startVector(4,a.length,4);for(let e=a.length-1;e>=0;e--)o.addOffset(a[e]);return o.endVector()}static startOutputsVector(o,a){o.startVector(4,a,4)}static addAttributes(o,a){o.addFieldOffset(10,a,0)}static createAttributesVector(o,a){o.startVector(4,a.length,4);for(let e=a.length-1;e>=0;e--)o.addOffset(a[e]);return o.endVector()}static startAttributesVector(o,a){o.startVector(4,a,4)}static addInputArgCounts(o,a){o.addFieldOffset(11,a,0)}static createInputArgCountsVector(o,a){o.startVector(4,a.length,4);for(let e=a.length-1;e>=0;e--)o.addInt32(a[e]);return o.endVector()}static startInputArgCountsVector(o,a){o.startVector(4,a,4)}static addImplicitInputs(o,a){o.addFieldOffset(12,a,0)}static createImplicitInputsVector(o,a){o.startVector(4,a.length,4);for(let e=a.length-1;e>=0;e--)o.addOffset(a[e]);return o.endVector()}static startImplicitInputsVector(o,a){o.startVector(4,a,4)}static endNode(o){return o.endObject()}static createNode(o,a,e,u,i,d,h,m,b,x,E,w,S,$){return l.startNode(o),l.addName(o,a),l.addDocString(o,e),l.addDomain(o,u),l.addSinceVersion(o,i),l.addIndex(o,d),l.addOpType(o,h),l.addType(o,m),l.addExecutionProviderType(o,b),l.addInputs(o,x),l.addOutputs(o,E),l.addAttributes(o,w),l.addInputArgCounts(o,S),l.addImplicitInputs(o,$),l.endNode(o)}}p.Node=l})(s=n.fbs||(n.fbs={}))})(r=t.experimental||(t.experimental={}))})(H||(H={})),(t=>{let r;(n=>{let s;(p=>{class l{constructor(){this.bb=null,this.bb_pos=0}__init(o,a){return this.bb_pos=o,this.bb=a,this}static getRootAsValueInfo(o,a){return(a||new l).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsValueInfo(o,a){return o.setPosition(o.position()+T.SIZE_PREFIX_LENGTH),(a||new l).__init(o.readInt32(o.position())+o.position(),o)}name(o){let a=this.bb.__offset(this.bb_pos,4);return a?this.bb.__string(this.bb_pos+a,o):null}docString(o){let a=this.bb.__offset(this.bb_pos,6);return a?this.bb.__string(this.bb_pos+a,o):null}type(o){let a=this.bb.__offset(this.bb_pos,8);return a?(o||new t.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+a),this.bb):null}static startValueInfo(o){o.startObject(3)}static addName(o,a){o.addFieldOffset(0,a,0)}static addDocString(o,a){o.addFieldOffset(1,a,0)}static addType(o,a){o.addFieldOffset(2,a,0)}static endValueInfo(o){return o.endObject()}static createValueInfo(o,a,e,u){return l.startValueInfo(o),l.addName(o,a),l.addDocString(o,e),l.addType(o,u),l.endValueInfo(o)}}p.ValueInfo=l})(s=n.fbs||(n.fbs={}))})(r=t.experimental||(t.experimental={}))})(H||(H={})),(t=>{let r;(n=>{let s;(p=>{class l{constructor(){this.bb=null,this.bb_pos=0}__init(o,a){return this.bb_pos=o,this.bb=a,this}static getRootAsTypeInfo(o,a){return(a||new l).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsTypeInfo(o,a){return o.setPosition(o.position()+T.SIZE_PREFIX_LENGTH),(a||new l).__init(o.readInt32(o.position())+o.position(),o)}denotation(o){let a=this.bb.__offset(this.bb_pos,4);return a?this.bb.__string(this.bb_pos+a,o):null}valueType(){let o=this.bb.__offset(this.bb_pos,6);return o?this.bb.readUint8(this.bb_pos+o):0}value(o){let a=this.bb.__offset(this.bb_pos,8);return a?this.bb.__union(o,this.bb_pos+a):null}static startTypeInfo(o){o.startObject(3)}static addDenotation(o,a){o.addFieldOffset(0,a,0)}static addValueType(o,a){o.addFieldInt8(1,a,0)}static addValue(o,a){o.addFieldOffset(2,a,0)}static endTypeInfo(o){return o.endObject()}static createTypeInfo(o,a,e,u){return l.startTypeInfo(o),l.addDenotation(o,a),l.addValueType(o,e),l.addValue(o,u),l.endTypeInfo(o)}}p.TypeInfo=l})(s=n.fbs||(n.fbs={}))})(r=t.experimental||(t.experimental={}))})(H||(H={})),(t=>{let r;(n=>{let s;(p=>{class l{constructor(){this.bb=null,this.bb_pos=0}__init(o,a){return this.bb_pos=o,this.bb=a,this}static getRootAsOperatorSetId(o,a){return(a||new l).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsOperatorSetId(o,a){return o.setPosition(o.position()+T.SIZE_PREFIX_LENGTH),(a||new l).__init(o.readInt32(o.position())+o.position(),o)}domain(o){let a=this.bb.__offset(this.bb_pos,4);return a?this.bb.__string(this.bb_pos+a,o):null}version(){let o=this.bb.__offset(this.bb_pos,6);return o?this.bb.readInt64(this.bb_pos+o):this.bb.createLong(0,0)}static startOperatorSetId(o){o.startObject(2)}static addDomain(o,a){o.addFieldOffset(0,a,0)}static addVersion(o,a){o.addFieldInt64(1,a,o.createLong(0,0))}static endOperatorSetId(o){return o.endObject()}static createOperatorSetId(o,a,e){return l.startOperatorSetId(o),l.addDomain(o,a),l.addVersion(o,e),l.endOperatorSetId(o)}}p.OperatorSetId=l})(s=n.fbs||(n.fbs={}))})(r=t.experimental||(t.experimental={}))})(H||(H={})),(t=>{let r;(n=>{let s;(p=>{class l{constructor(){this.bb=null,this.bb_pos=0}__init(o,a){return this.bb_pos=o,this.bb=a,this}static getRootAsTensor(o,a){return(a||new l).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsTensor(o,a){return o.setPosition(o.position()+T.SIZE_PREFIX_LENGTH),(a||new l).__init(o.readInt32(o.position())+o.position(),o)}name(o){let a=this.bb.__offset(this.bb_pos,4);return a?this.bb.__string(this.bb_pos+a,o):null}docString(o){let a=this.bb.__offset(this.bb_pos,6);return a?this.bb.__string(this.bb_pos+a,o):null}dims(o){let a=this.bb.__offset(this.bb_pos,8);return a?this.bb.readInt64(this.bb.__vector(this.bb_pos+a)+o*8):this.bb.createLong(0,0)}dimsLength(){let o=this.bb.__offset(this.bb_pos,8);return o?this.bb.__vector_len(this.bb_pos+o):0}dataType(){let o=this.bb.__offset(this.bb_pos,10);return o?this.bb.readInt32(this.bb_pos+o):0}rawData(o){let a=this.bb.__offset(this.bb_pos,12);return a?this.bb.readUint8(this.bb.__vector(this.bb_pos+a)+o):0}rawDataLength(){let o=this.bb.__offset(this.bb_pos,12);return o?this.bb.__vector_len(this.bb_pos+o):0}rawDataArray(){let o=this.bb.__offset(this.bb_pos,12);return o?new Uint8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+o),this.bb.__vector_len(this.bb_pos+o)):null}stringData(o,a){let e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__string(this.bb.__vector(this.bb_pos+e)+o*4,a):null}stringDataLength(){let o=this.bb.__offset(this.bb_pos,14);return o?this.bb.__vector_len(this.bb_pos+o):0}static startTensor(o){o.startObject(6)}static addName(o,a){o.addFieldOffset(0,a,0)}static addDocString(o,a){o.addFieldOffset(1,a,0)}static addDims(o,a){o.addFieldOffset(2,a,0)}static createDimsVector(o,a){o.startVector(8,a.length,8);for(let e=a.length-1;e>=0;e--)o.addInt64(a[e]);return o.endVector()}static startDimsVector(o,a){o.startVector(8,a,8)}static addDataType(o,a){o.addFieldInt32(3,a,0)}static addRawData(o,a){o.addFieldOffset(4,a,0)}static createRawDataVector(o,a){o.startVector(1,a.length,1);for(let e=a.length-1;e>=0;e--)o.addInt8(a[e]);return o.endVector()}static startRawDataVector(o,a){o.startVector(1,a,1)}static addStringData(o,a){o.addFieldOffset(5,a,0)}static createStringDataVector(o,a){o.startVector(4,a.length,4);for(let e=a.length-1;e>=0;e--)o.addOffset(a[e]);return o.endVector()}static startStringDataVector(o,a){o.startVector(4,a,4)}static endTensor(o){return o.endObject()}static createTensor(o,a,e,u,i,d,h){return l.startTensor(o),l.addName(o,a),l.addDocString(o,e),l.addDims(o,u),l.addDataType(o,i),l.addRawData(o,d),l.addStringData(o,h),l.endTensor(o)}}p.Tensor=l})(s=n.fbs||(n.fbs={}))})(r=t.experimental||(t.experimental={}))})(H||(H={})),(t=>{let r;(n=>{let s;(p=>{class l{constructor(){this.bb=null,this.bb_pos=0}__init(o,a){return this.bb_pos=o,this.bb=a,this}static getRootAsSparseTensor(o,a){return(a||new l).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsSparseTensor(o,a){return o.setPosition(o.position()+T.SIZE_PREFIX_LENGTH),(a||new l).__init(o.readInt32(o.position())+o.position(),o)}values(o){let a=this.bb.__offset(this.bb_pos,4);return a?(o||new t.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+a),this.bb):null}indices(o){let a=this.bb.__offset(this.bb_pos,6);return a?(o||new t.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+a),this.bb):null}dims(o){let a=this.bb.__offset(this.bb_pos,8);return a?this.bb.readInt64(this.bb.__vector(this.bb_pos+a)+o*8):this.bb.createLong(0,0)}dimsLength(){let o=this.bb.__offset(this.bb_pos,8);return o?this.bb.__vector_len(this.bb_pos+o):0}static startSparseTensor(o){o.startObject(3)}static addValues(o,a){o.addFieldOffset(0,a,0)}static addIndices(o,a){o.addFieldOffset(1,a,0)}static addDims(o,a){o.addFieldOffset(2,a,0)}static createDimsVector(o,a){o.startVector(8,a.length,8);for(let e=a.length-1;e>=0;e--)o.addInt64(a[e]);return o.endVector()}static startDimsVector(o,a){o.startVector(8,a,8)}static endSparseTensor(o){return o.endObject()}static createSparseTensor(o,a,e,u){return l.startSparseTensor(o),l.addValues(o,a),l.addIndices(o,e),l.addDims(o,u),l.endSparseTensor(o)}}p.SparseTensor=l})(s=n.fbs||(n.fbs={}))})(r=t.experimental||(t.experimental={}))})(H||(H={})),(t=>{let r;(n=>{let s;(p=>{class l{constructor(){this.bb=null,this.bb_pos=0}__init(o,a){return this.bb_pos=o,this.bb=a,this}static getRootAsAttribute(o,a){return(a||new l).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsAttribute(o,a){return o.setPosition(o.position()+T.SIZE_PREFIX_LENGTH),(a||new l).__init(o.readInt32(o.position())+o.position(),o)}name(o){let a=this.bb.__offset(this.bb_pos,4);return a?this.bb.__string(this.bb_pos+a,o):null}docString(o){let a=this.bb.__offset(this.bb_pos,6);return a?this.bb.__string(this.bb_pos+a,o):null}type(){let o=this.bb.__offset(this.bb_pos,8);return o?this.bb.readInt32(this.bb_pos+o):0}f(){let o=this.bb.__offset(this.bb_pos,10);return o?this.bb.readFloat32(this.bb_pos+o):0}i(){let o=this.bb.__offset(this.bb_pos,12);return o?this.bb.readInt64(this.bb_pos+o):this.bb.createLong(0,0)}s(o){let a=this.bb.__offset(this.bb_pos,14);return a?this.bb.__string(this.bb_pos+a,o):null}t(o){let a=this.bb.__offset(this.bb_pos,16);return a?(o||new t.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+a),this.bb):null}g(o){let a=this.bb.__offset(this.bb_pos,18);return a?(o||new t.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb_pos+a),this.bb):null}floats(o){let a=this.bb.__offset(this.bb_pos,20);return a?this.bb.readFloat32(this.bb.__vector(this.bb_pos+a)+o*4):0}floatsLength(){let o=this.bb.__offset(this.bb_pos,20);return o?this.bb.__vector_len(this.bb_pos+o):0}floatsArray(){let o=this.bb.__offset(this.bb_pos,20);return o?new Float32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+o),this.bb.__vector_len(this.bb_pos+o)):null}ints(o){let a=this.bb.__offset(this.bb_pos,22);return a?this.bb.readInt64(this.bb.__vector(this.bb_pos+a)+o*8):this.bb.createLong(0,0)}intsLength(){let o=this.bb.__offset(this.bb_pos,22);return o?this.bb.__vector_len(this.bb_pos+o):0}strings(o,a){let e=this.bb.__offset(this.bb_pos,24);return e?this.bb.__string(this.bb.__vector(this.bb_pos+e)+o*4,a):null}stringsLength(){let o=this.bb.__offset(this.bb_pos,24);return o?this.bb.__vector_len(this.bb_pos+o):0}tensors(o,a){let e=this.bb.__offset(this.bb_pos,26);return e?(a||new t.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+e)+o*4),this.bb):null}tensorsLength(){let o=this.bb.__offset(this.bb_pos,26);return o?this.bb.__vector_len(this.bb_pos+o):0}graphs(o,a){let e=this.bb.__offset(this.bb_pos,28);return e?(a||new t.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+e)+o*4),this.bb):null}graphsLength(){let o=this.bb.__offset(this.bb_pos,28);return o?this.bb.__vector_len(this.bb_pos+o):0}static startAttribute(o){o.startObject(13)}static addName(o,a){o.addFieldOffset(0,a,0)}static addDocString(o,a){o.addFieldOffset(1,a,0)}static addType(o,a){o.addFieldInt32(2,a,0)}static addF(o,a){o.addFieldFloat32(3,a,0)}static addI(o,a){o.addFieldInt64(4,a,o.createLong(0,0))}static addS(o,a){o.addFieldOffset(5,a,0)}static addT(o,a){o.addFieldOffset(6,a,0)}static addG(o,a){o.addFieldOffset(7,a,0)}static addFloats(o,a){o.addFieldOffset(8,a,0)}static createFloatsVector(o,a){o.startVector(4,a.length,4);for(let e=a.length-1;e>=0;e--)o.addFloat32(a[e]);return o.endVector()}static startFloatsVector(o,a){o.startVector(4,a,4)}static addInts(o,a){o.addFieldOffset(9,a,0)}static createIntsVector(o,a){o.startVector(8,a.length,8);for(let e=a.length-1;e>=0;e--)o.addInt64(a[e]);return o.endVector()}static startIntsVector(o,a){o.startVector(8,a,8)}static addStrings(o,a){o.addFieldOffset(10,a,0)}static createStringsVector(o,a){o.startVector(4,a.length,4);for(let e=a.length-1;e>=0;e--)o.addOffset(a[e]);return o.endVector()}static startStringsVector(o,a){o.startVector(4,a,4)}static addTensors(o,a){o.addFieldOffset(11,a,0)}static createTensorsVector(o,a){o.startVector(4,a.length,4);for(let e=a.length-1;e>=0;e--)o.addOffset(a[e]);return o.endVector()}static startTensorsVector(o,a){o.startVector(4,a,4)}static addGraphs(o,a){o.addFieldOffset(12,a,0)}static createGraphsVector(o,a){o.startVector(4,a.length,4);for(let e=a.length-1;e>=0;e--)o.addOffset(a[e]);return o.endVector()}static startGraphsVector(o,a){o.startVector(4,a,4)}static endAttribute(o){return o.endObject()}static createAttribute(o,a,e,u,i,d,h,m,b,x,E,w,S,$){return l.startAttribute(o),l.addName(o,a),l.addDocString(o,e),l.addType(o,u),l.addF(o,i),l.addI(o,d),l.addS(o,h),l.addT(o,m),l.addG(o,b),l.addFloats(o,x),l.addInts(o,E),l.addStrings(o,w),l.addTensors(o,S),l.addGraphs(o,$),l.endAttribute(o)}}p.Attribute=l})(s=n.fbs||(n.fbs={}))})(r=t.experimental||(t.experimental={}))})(H||(H={})),(t=>{let r;(n=>{let s;(p=>{class l{constructor(){this.bb=null,this.bb_pos=0}__init(o,a){return this.bb_pos=o,this.bb=a,this}static getRootAsGraph(o,a){return(a||new l).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsGraph(o,a){return o.setPosition(o.position()+T.SIZE_PREFIX_LENGTH),(a||new l).__init(o.readInt32(o.position())+o.position(),o)}initializers(o,a){let e=this.bb.__offset(this.bb_pos,4);return e?(a||new t.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+e)+o*4),this.bb):null}initializersLength(){let o=this.bb.__offset(this.bb_pos,4);return o?this.bb.__vector_len(this.bb_pos+o):0}nodeArgs(o,a){let e=this.bb.__offset(this.bb_pos,6);return e?(a||new t.experimental.fbs.ValueInfo).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+e)+o*4),this.bb):null}nodeArgsLength(){let o=this.bb.__offset(this.bb_pos,6);return o?this.bb.__vector_len(this.bb_pos+o):0}nodes(o,a){let e=this.bb.__offset(this.bb_pos,8);return e?(a||new t.experimental.fbs.Node).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+e)+o*4),this.bb):null}nodesLength(){let o=this.bb.__offset(this.bb_pos,8);return o?this.bb.__vector_len(this.bb_pos+o):0}maxNodeIndex(){let o=this.bb.__offset(this.bb_pos,10);return o?this.bb.readUint32(this.bb_pos+o):0}nodeEdges(o,a){let e=this.bb.__offset(this.bb_pos,12);return e?(a||new t.experimental.fbs.NodeEdge).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+e)+o*4),this.bb):null}nodeEdgesLength(){let o=this.bb.__offset(this.bb_pos,12);return o?this.bb.__vector_len(this.bb_pos+o):0}inputs(o,a){let e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__string(this.bb.__vector(this.bb_pos+e)+o*4,a):null}inputsLength(){let o=this.bb.__offset(this.bb_pos,14);return o?this.bb.__vector_len(this.bb_pos+o):0}outputs(o,a){let e=this.bb.__offset(this.bb_pos,16);return e?this.bb.__string(this.bb.__vector(this.bb_pos+e)+o*4,a):null}outputsLength(){let o=this.bb.__offset(this.bb_pos,16);return o?this.bb.__vector_len(this.bb_pos+o):0}sparseInitializers(o,a){let e=this.bb.__offset(this.bb_pos,18);return e?(a||new t.experimental.fbs.SparseTensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+e)+o*4),this.bb):null}sparseInitializersLength(){let o=this.bb.__offset(this.bb_pos,18);return o?this.bb.__vector_len(this.bb_pos+o):0}static startGraph(o){o.startObject(8)}static addInitializers(o,a){o.addFieldOffset(0,a,0)}static createInitializersVector(o,a){o.startVector(4,a.length,4);for(let e=a.length-1;e>=0;e--)o.addOffset(a[e]);return o.endVector()}static startInitializersVector(o,a){o.startVector(4,a,4)}static addNodeArgs(o,a){o.addFieldOffset(1,a,0)}static createNodeArgsVector(o,a){o.startVector(4,a.length,4);for(let e=a.length-1;e>=0;e--)o.addOffset(a[e]);return o.endVector()}static startNodeArgsVector(o,a){o.startVector(4,a,4)}static addNodes(o,a){o.addFieldOffset(2,a,0)}static createNodesVector(o,a){o.startVector(4,a.length,4);for(let e=a.length-1;e>=0;e--)o.addOffset(a[e]);return o.endVector()}static startNodesVector(o,a){o.startVector(4,a,4)}static addMaxNodeIndex(o,a){o.addFieldInt32(3,a,0)}static addNodeEdges(o,a){o.addFieldOffset(4,a,0)}static createNodeEdgesVector(o,a){o.startVector(4,a.length,4);for(let e=a.length-1;e>=0;e--)o.addOffset(a[e]);return o.endVector()}static startNodeEdgesVector(o,a){o.startVector(4,a,4)}static addInputs(o,a){o.addFieldOffset(5,a,0)}static createInputsVector(o,a){o.startVector(4,a.length,4);for(let e=a.length-1;e>=0;e--)o.addOffset(a[e]);return o.endVector()}static startInputsVector(o,a){o.startVector(4,a,4)}static addOutputs(o,a){o.addFieldOffset(6,a,0)}static createOutputsVector(o,a){o.startVector(4,a.length,4);for(let e=a.length-1;e>=0;e--)o.addOffset(a[e]);return o.endVector()}static startOutputsVector(o,a){o.startVector(4,a,4)}static addSparseInitializers(o,a){o.addFieldOffset(7,a,0)}static createSparseInitializersVector(o,a){o.startVector(4,a.length,4);for(let e=a.length-1;e>=0;e--)o.addOffset(a[e]);return o.endVector()}static startSparseInitializersVector(o,a){o.startVector(4,a,4)}static endGraph(o){return o.endObject()}static createGraph(o,a,e,u,i,d,h,m,b){return l.startGraph(o),l.addInitializers(o,a),l.addNodeArgs(o,e),l.addNodes(o,u),l.addMaxNodeIndex(o,i),l.addNodeEdges(o,d),l.addInputs(o,h),l.addOutputs(o,m),l.addSparseInitializers(o,b),l.endGraph(o)}}p.Graph=l})(s=n.fbs||(n.fbs={}))})(r=t.experimental||(t.experimental={}))})(H||(H={})),(t=>{let r;(n=>{let s;(p=>{class l{constructor(){this.bb=null,this.bb_pos=0}__init(o,a){return this.bb_pos=o,this.bb=a,this}static getRootAsModel(o,a){return(a||new l).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsModel(o,a){return o.setPosition(o.position()+T.SIZE_PREFIX_LENGTH),(a||new l).__init(o.readInt32(o.position())+o.position(),o)}irVersion(){let o=this.bb.__offset(this.bb_pos,4);return o?this.bb.readInt64(this.bb_pos+o):this.bb.createLong(0,0)}opsetImport(o,a){let e=this.bb.__offset(this.bb_pos,6);return e?(a||new t.experimental.fbs.OperatorSetId).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+e)+o*4),this.bb):null}opsetImportLength(){let o=this.bb.__offset(this.bb_pos,6);return o?this.bb.__vector_len(this.bb_pos+o):0}producerName(o){let a=this.bb.__offset(this.bb_pos,8);return a?this.bb.__string(this.bb_pos+a,o):null}producerVersion(o){let a=this.bb.__offset(this.bb_pos,10);return a?this.bb.__string(this.bb_pos+a,o):null}domain(o){let a=this.bb.__offset(this.bb_pos,12);return a?this.bb.__string(this.bb_pos+a,o):null}modelVersion(){let o=this.bb.__offset(this.bb_pos,14);return o?this.bb.readInt64(this.bb_pos+o):this.bb.createLong(0,0)}docString(o){let a=this.bb.__offset(this.bb_pos,16);return a?this.bb.__string(this.bb_pos+a,o):null}graph(o){let a=this.bb.__offset(this.bb_pos,18);return a?(o||new t.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb_pos+a),this.bb):null}graphDocString(o){let a=this.bb.__offset(this.bb_pos,20);return a?this.bb.__string(this.bb_pos+a,o):null}static startModel(o){o.startObject(9)}static addIrVersion(o,a){o.addFieldInt64(0,a,o.createLong(0,0))}static addOpsetImport(o,a){o.addFieldOffset(1,a,0)}static createOpsetImportVector(o,a){o.startVector(4,a.length,4);for(let e=a.length-1;e>=0;e--)o.addOffset(a[e]);return o.endVector()}static startOpsetImportVector(o,a){o.startVector(4,a,4)}static addProducerName(o,a){o.addFieldOffset(2,a,0)}static addProducerVersion(o,a){o.addFieldOffset(3,a,0)}static addDomain(o,a){o.addFieldOffset(4,a,0)}static addModelVersion(o,a){o.addFieldInt64(5,a,o.createLong(0,0))}static addDocString(o,a){o.addFieldOffset(6,a,0)}static addGraph(o,a){o.addFieldOffset(7,a,0)}static addGraphDocString(o,a){o.addFieldOffset(8,a,0)}static endModel(o){return o.endObject()}static createModel(o,a,e,u,i,d,h,m,b,x){return l.startModel(o),l.addIrVersion(o,a),l.addOpsetImport(o,e),l.addProducerName(o,u),l.addProducerVersion(o,i),l.addDomain(o,d),l.addModelVersion(o,h),l.addDocString(o,m),l.addGraph(o,b),l.addGraphDocString(o,x),l.endModel(o)}}p.Model=l})(s=n.fbs||(n.fbs={}))})(r=t.experimental||(t.experimental={}))})(H||(H={})),(t=>{let r;(n=>{let s;(p=>{class l{constructor(){this.bb=null,this.bb_pos=0}__init(o,a){return this.bb_pos=o,this.bb=a,this}static getRootAsKernelCreateInfos(o,a){return(a||new l).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsKernelCreateInfos(o,a){return o.setPosition(o.position()+T.SIZE_PREFIX_LENGTH),(a||new l).__init(o.readInt32(o.position())+o.position(),o)}nodeIndices(o){let a=this.bb.__offset(this.bb_pos,4);return a?this.bb.readUint32(this.bb.__vector(this.bb_pos+a)+o*4):0}nodeIndicesLength(){let o=this.bb.__offset(this.bb_pos,4);return o?this.bb.__vector_len(this.bb_pos+o):0}nodeIndicesArray(){let o=this.bb.__offset(this.bb_pos,4);return o?new Uint32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+o),this.bb.__vector_len(this.bb_pos+o)):null}kernelDefHashes(o){let a=this.bb.__offset(this.bb_pos,6);return a?this.bb.readUint64(this.bb.__vector(this.bb_pos+a)+o*8):this.bb.createLong(0,0)}kernelDefHashesLength(){let o=this.bb.__offset(this.bb_pos,6);return o?this.bb.__vector_len(this.bb_pos+o):0}static startKernelCreateInfos(o){o.startObject(2)}static addNodeIndices(o,a){o.addFieldOffset(0,a,0)}static createNodeIndicesVector(o,a){o.startVector(4,a.length,4);for(let e=a.length-1;e>=0;e--)o.addInt32(a[e]);return o.endVector()}static startNodeIndicesVector(o,a){o.startVector(4,a,4)}static addKernelDefHashes(o,a){o.addFieldOffset(1,a,0)}static createKernelDefHashesVector(o,a){o.startVector(8,a.length,8);for(let e=a.length-1;e>=0;e--)o.addInt64(a[e]);return o.endVector()}static startKernelDefHashesVector(o,a){o.startVector(8,a,8)}static endKernelCreateInfos(o){return o.endObject()}static createKernelCreateInfos(o,a,e){return l.startKernelCreateInfos(o),l.addNodeIndices(o,a),l.addKernelDefHashes(o,e),l.endKernelCreateInfos(o)}}p.KernelCreateInfos=l})(s=n.fbs||(n.fbs={}))})(r=t.experimental||(t.experimental={}))})(H||(H={})),(t=>{let r;(n=>{let s;(p=>{class l{constructor(){this.bb=null,this.bb_pos=0}__init(o,a){return this.bb_pos=o,this.bb=a,this}static getRootAsSubGraphSessionState(o,a){return(a||new l).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsSubGraphSessionState(o,a){return o.setPosition(o.position()+T.SIZE_PREFIX_LENGTH),(a||new l).__init(o.readInt32(o.position())+o.position(),o)}graphId(o){let a=this.bb.__offset(this.bb_pos,4);return a?this.bb.__string(this.bb_pos+a,o):null}sessionState(o){let a=this.bb.__offset(this.bb_pos,6);return a?(o||new t.experimental.fbs.SessionState).__init(this.bb.__indirect(this.bb_pos+a),this.bb):null}static startSubGraphSessionState(o){o.startObject(2)}static addGraphId(o,a){o.addFieldOffset(0,a,0)}static addSessionState(o,a){o.addFieldOffset(1,a,0)}static endSubGraphSessionState(o){let a=o.endObject();return o.requiredField(a,4),a}static createSubGraphSessionState(o,a,e){return l.startSubGraphSessionState(o),l.addGraphId(o,a),l.addSessionState(o,e),l.endSubGraphSessionState(o)}}p.SubGraphSessionState=l})(s=n.fbs||(n.fbs={}))})(r=t.experimental||(t.experimental={}))})(H||(H={})),(t=>{let r;(n=>{let s;(p=>{class l{constructor(){this.bb=null,this.bb_pos=0}__init(o,a){return this.bb_pos=o,this.bb=a,this}static getRootAsSessionState(o,a){return(a||new l).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsSessionState(o,a){return o.setPosition(o.position()+T.SIZE_PREFIX_LENGTH),(a||new l).__init(o.readInt32(o.position())+o.position(),o)}kernels(o){let a=this.bb.__offset(this.bb_pos,4);return a?(o||new t.experimental.fbs.KernelCreateInfos).__init(this.bb.__indirect(this.bb_pos+a),this.bb):null}subGraphSessionStates(o,a){let e=this.bb.__offset(this.bb_pos,6);return e?(a||new t.experimental.fbs.SubGraphSessionState).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+e)+o*4),this.bb):null}subGraphSessionStatesLength(){let o=this.bb.__offset(this.bb_pos,6);return o?this.bb.__vector_len(this.bb_pos+o):0}static startSessionState(o){o.startObject(2)}static addKernels(o,a){o.addFieldOffset(0,a,0)}static addSubGraphSessionStates(o,a){o.addFieldOffset(1,a,0)}static createSubGraphSessionStatesVector(o,a){o.startVector(4,a.length,4);for(let e=a.length-1;e>=0;e--)o.addOffset(a[e]);return o.endVector()}static startSubGraphSessionStatesVector(o,a){o.startVector(4,a,4)}static endSessionState(o){return o.endObject()}static createSessionState(o,a,e){return l.startSessionState(o),l.addKernels(o,a),l.addSubGraphSessionStates(o,e),l.endSessionState(o)}}p.SessionState=l})(s=n.fbs||(n.fbs={}))})(r=t.experimental||(t.experimental={}))})(H||(H={})),(t=>{let r;(n=>{let s;(p=>{class l{constructor(){this.bb=null,this.bb_pos=0}__init(o,a){return this.bb_pos=o,this.bb=a,this}static getRootAsInferenceSession(o,a){return(a||new l).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsInferenceSession(o,a){return o.setPosition(o.position()+T.SIZE_PREFIX_LENGTH),(a||new l).__init(o.readInt32(o.position())+o.position(),o)}static bufferHasIdentifier(o){return o.__has_identifier("ORTM")}ortVersion(o){let a=this.bb.__offset(this.bb_pos,4);return a?this.bb.__string(this.bb_pos+a,o):null}model(o){let a=this.bb.__offset(this.bb_pos,6);return a?(o||new t.experimental.fbs.Model).__init(this.bb.__indirect(this.bb_pos+a),this.bb):null}sessionState(o){let a=this.bb.__offset(this.bb_pos,8);return a?(o||new t.experimental.fbs.SessionState).__init(this.bb.__indirect(this.bb_pos+a),this.bb):null}static startInferenceSession(o){o.startObject(3)}static addOrtVersion(o,a){o.addFieldOffset(0,a,0)}static addModel(o,a){o.addFieldOffset(1,a,0)}static addSessionState(o,a){o.addFieldOffset(2,a,0)}static endInferenceSession(o){return o.endObject()}static finishInferenceSessionBuffer(o,a){o.finish(a,"ORTM")}static finishSizePrefixedInferenceSessionBuffer(o,a){o.finish(a,"ORTM",!0)}static createInferenceSession(o,a,e,u){return l.startInferenceSession(o),l.addOrtVersion(o,a),l.addModel(o,e),l.addSessionState(o,u),l.endInferenceSession(o)}}p.InferenceSession=l})(s=n.fbs||(n.fbs={}))})(r=t.experimental||(t.experimental={}))})(H||(H={}))}),Ch=nt((t,r)=>{"use strict";r.exports=n;function n(s,p){for(var l=new Array(arguments.length-1),c=0,o=2,a=!0;o<arguments.length;)l[c++]=arguments[o++];return new Promise(function(e,u){l[c]=function(i){if(a)if(a=!1,i)u(i);else{for(var d=new Array(arguments.length-1),h=0;h<d.length;)d[h++]=arguments[h];e.apply(null,d)}};try{s.apply(p||null,l)}catch(i){a&&(a=!1,u(i))}})}}),Lh=nt(t=>{"use strict";var r=t;r.length=function(c){var o=c.length;if(!o)return 0;for(var a=0;--o%4>1&&c.charAt(o)==="=";)++a;return Math.ceil(c.length*3)/4-a};var n=new Array(64),s=new Array(123);for(p=0;p<64;)s[n[p]=p<26?p+65:p<52?p+71:p<62?p-4:p-59|43]=p++;var p;r.encode=function(c,o,a){for(var e=null,u=[],i=0,d=0,h;o<a;){var m=c[o++];switch(d){case 0:u[i++]=n[m>>2],h=(m&3)<<4,d=1;break;case 1:u[i++]=n[h|m>>4],h=(m&15)<<2,d=2;break;case 2:u[i++]=n[h|m>>6],u[i++]=n[m&63],d=0;break}i>8191&&((e||(e=[])).push(String.fromCharCode.apply(String,u)),i=0)}return d&&(u[i++]=n[h],u[i++]=61,d===1&&(u[i++]=61)),e?(i&&e.push(String.fromCharCode.apply(String,u.slice(0,i))),e.join("")):String.fromCharCode.apply(String,u.slice(0,i))};var l="invalid encoding";r.decode=function(c,o,a){for(var e=a,u=0,i,d=0;d<c.length;){var h=c.charCodeAt(d++);if(h===61&&u>1)break;if((h=s[h])===void 0)throw Error(l);switch(u){case 0:i=h,u=1;break;case 1:o[a++]=i<<2|(h&48)>>4,i=h,u=2;break;case 2:o[a++]=(i&15)<<4|(h&60)>>2,i=h,u=3;break;case 3:o[a++]=(i&3)<<6|h,u=0;break}}if(u===1)throw Error(l);return a-e},r.test=function(c){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(c)}}),Rh=nt((t,r)=>{"use strict";r.exports=n;function n(){this._listeners={}}n.prototype.on=function(s,p,l){return(this._listeners[s]||(this._listeners[s]=[])).push({fn:p,ctx:l||this}),this},n.prototype.off=function(s,p){if(s===void 0)this._listeners={};else if(p===void 0)this._listeners[s]=[];else for(var l=this._listeners[s],c=0;c<l.length;)l[c].fn===p?l.splice(c,1):++c;return this},n.prototype.emit=function(s){var p=this._listeners[s];if(p){for(var l=[],c=1;c<arguments.length;)l.push(arguments[c++]);for(c=0;c<p.length;)p[c].fn.apply(p[c++].ctx,l)}return this}}),jh=nt((t,r)=>{"use strict";r.exports=n(n);function n(o){return typeof Float32Array<"u"?function(){var a=new Float32Array([-0]),e=new Uint8Array(a.buffer),u=e[3]===128;function i(b,x,E){a[0]=b,x[E]=e[0],x[E+1]=e[1],x[E+2]=e[2],x[E+3]=e[3]}function d(b,x,E){a[0]=b,x[E]=e[3],x[E+1]=e[2],x[E+2]=e[1],x[E+3]=e[0]}o.writeFloatLE=u?i:d,o.writeFloatBE=u?d:i;function h(b,x){return e[0]=b[x],e[1]=b[x+1],e[2]=b[x+2],e[3]=b[x+3],a[0]}function m(b,x){return e[3]=b[x],e[2]=b[x+1],e[1]=b[x+2],e[0]=b[x+3],a[0]}o.readFloatLE=u?h:m,o.readFloatBE=u?m:h}():function(){function a(u,i,d,h){var m=i<0?1:0;if(m&&(i=-i),i===0)u(1/i>0?0:2147483648,d,h);else if(isNaN(i))u(2143289344,d,h);else if(i>34028234663852886e22)u((m<<31|2139095040)>>>0,d,h);else if(i<11754943508222875e-54)u((m<<31|Math.round(i/1401298464324817e-60))>>>0,d,h);else{var b=Math.floor(Math.log(i)/Math.LN2),x=Math.round(i*Math.pow(2,-b)*8388608)&8388607;u((m<<31|b+127<<23|x)>>>0,d,h)}}o.writeFloatLE=a.bind(null,s),o.writeFloatBE=a.bind(null,p);function e(u,i,d){var h=u(i,d),m=(h>>31)*2+1,b=h>>>23&255,x=h&8388607;return b===255?x?NaN:m*(1/0):b===0?m*1401298464324817e-60*x:m*Math.pow(2,b-150)*(x+8388608)}o.readFloatLE=e.bind(null,l),o.readFloatBE=e.bind(null,c)}(),typeof Float64Array<"u"?function(){var a=new Float64Array([-0]),e=new Uint8Array(a.buffer),u=e[7]===128;function i(b,x,E){a[0]=b,x[E]=e[0],x[E+1]=e[1],x[E+2]=e[2],x[E+3]=e[3],x[E+4]=e[4],x[E+5]=e[5],x[E+6]=e[6],x[E+7]=e[7]}function d(b,x,E){a[0]=b,x[E]=e[7],x[E+1]=e[6],x[E+2]=e[5],x[E+3]=e[4],x[E+4]=e[3],x[E+5]=e[2],x[E+6]=e[1],x[E+7]=e[0]}o.writeDoubleLE=u?i:d,o.writeDoubleBE=u?d:i;function h(b,x){return e[0]=b[x],e[1]=b[x+1],e[2]=b[x+2],e[3]=b[x+3],e[4]=b[x+4],e[5]=b[x+5],e[6]=b[x+6],e[7]=b[x+7],a[0]}function m(b,x){return e[7]=b[x],e[6]=b[x+1],e[5]=b[x+2],e[4]=b[x+3],e[3]=b[x+4],e[2]=b[x+5],e[1]=b[x+6],e[0]=b[x+7],a[0]}o.readDoubleLE=u?h:m,o.readDoubleBE=u?m:h}():function(){function a(u,i,d,h,m,b){var x=h<0?1:0;if(x&&(h=-h),h===0)u(0,m,b+i),u(1/h>0?0:2147483648,m,b+d);else if(isNaN(h))u(0,m,b+i),u(2146959360,m,b+d);else if(h>17976931348623157e292)u(0,m,b+i),u((x<<31|2146435072)>>>0,m,b+d);else{var E;if(h<22250738585072014e-324)E=h/5e-324,u(E>>>0,m,b+i),u((x<<31|E/4294967296)>>>0,m,b+d);else{var w=Math.floor(Math.log(h)/Math.LN2);w===1024&&(w=1023),E=h*Math.pow(2,-w),u(E*4503599627370496>>>0,m,b+i),u((x<<31|w+1023<<20|E*1048576&1048575)>>>0,m,b+d)}}}o.writeDoubleLE=a.bind(null,s,0,4),o.writeDoubleBE=a.bind(null,p,4,0);function e(u,i,d,h,m){var b=u(h,m+i),x=u(h,m+d),E=(x>>31)*2+1,w=x>>>20&2047,S=4294967296*(x&1048575)+b;return w===2047?S?NaN:E*(1/0):w===0?E*5e-324*S:E*Math.pow(2,w-1075)*(S+4503599627370496)}o.readDoubleLE=e.bind(null,l,0,4),o.readDoubleBE=e.bind(null,c,4,0)}(),o}function s(o,a,e){a[e]=o&255,a[e+1]=o>>>8&255,a[e+2]=o>>>16&255,a[e+3]=o>>>24}function p(o,a,e){a[e]=o>>>24,a[e+1]=o>>>16&255,a[e+2]=o>>>8&255,a[e+3]=o&255}function l(o,a){return(o[a]|o[a+1]<<8|o[a+2]<<16|o[a+3]<<24)>>>0}function c(o,a){return(o[a]<<24|o[a+1]<<16|o[a+2]<<8|o[a+3])>>>0}}),Bh=nt((exports,module)=>{"use strict";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}}),Vh=nt(t=>{"use strict";var r=t;r.length=function(n){for(var s=0,p=0,l=0;l<n.length;++l)p=n.charCodeAt(l),p<128?s+=1:p<2048?s+=2:(p&64512)===55296&&(n.charCodeAt(l+1)&64512)===56320?(++l,s+=4):s+=3;return s},r.read=function(n,s,p){var l=p-s;if(l<1)return"";for(var c=null,o=[],a=0,e;s<p;)e=n[s++],e<128?o[a++]=e:e>191&&e<224?o[a++]=(e&31)<<6|n[s++]&63:e>239&&e<365?(e=((e&7)<<18|(n[s++]&63)<<12|(n[s++]&63)<<6|n[s++]&63)-65536,o[a++]=55296+(e>>10),o[a++]=56320+(e&1023)):o[a++]=(e&15)<<12|(n[s++]&63)<<6|n[s++]&63,a>8191&&((c||(c=[])).push(String.fromCharCode.apply(String,o)),a=0);return c?(a&&c.push(String.fromCharCode.apply(String,o.slice(0,a))),c.join("")):String.fromCharCode.apply(String,o.slice(0,a))},r.write=function(n,s,p){for(var l=p,c,o,a=0;a<n.length;++a)c=n.charCodeAt(a),c<128?s[p++]=c:c<2048?(s[p++]=c>>6|192,s[p++]=c&63|128):(c&64512)===55296&&((o=n.charCodeAt(a+1))&64512)===56320?(c=65536+((c&1023)<<10)+(o&1023),++a,s[p++]=c>>18|240,s[p++]=c>>12&63|128,s[p++]=c>>6&63|128,s[p++]=c&63|128):(s[p++]=c>>12|224,s[p++]=c>>6&63|128,s[p++]=c&63|128);return p-l}}),Mh=nt((t,r)=>{"use strict";r.exports=n;function n(s,p,l){var c=l||8192,o=c>>>1,a=null,e=c;return function(u){if(u<1||u>o)return s(u);e+u>c&&(a=s(c),e=0);var i=p.call(a,e,e+=u);return e&7&&(e=(e|7)+1),i}}}),zh=nt((t,r)=>{"use strict";r.exports=s;var n=we();function s(o,a){this.lo=o>>>0,this.hi=a>>>0}var p=s.zero=new s(0,0);p.toNumber=function(){return 0},p.zzEncode=p.zzDecode=function(){return this},p.length=function(){return 1};var l=s.zeroHash="\0\0\0\0\0\0\0\0";s.fromNumber=function(o){if(o===0)return p;var a=o<0;a&&(o=-o);var e=o>>>0,u=(o-e)/4294967296>>>0;return a&&(u=~u>>>0,e=~e>>>0,++e>4294967295&&(e=0,++u>4294967295&&(u=0))),new s(e,u)},s.from=function(o){if(typeof o=="number")return s.fromNumber(o);if(n.isString(o))if(n.Long)o=n.Long.fromString(o);else return s.fromNumber(parseInt(o,10));return o.low||o.high?new s(o.low>>>0,o.high>>>0):p},s.prototype.toNumber=function(o){if(!o&&this.hi>>>31){var a=~this.lo+1>>>0,e=~this.hi>>>0;return a||(e=e+1>>>0),-(a+e*4294967296)}return this.lo+this.hi*4294967296},s.prototype.toLong=function(o){return n.Long?new n.Long(this.lo|0,this.hi|0,!!o):{low:this.lo|0,high:this.hi|0,unsigned:!!o}};var c=String.prototype.charCodeAt;s.fromHash=function(o){return o===l?p:new s((c.call(o,0)|c.call(o,1)<<8|c.call(o,2)<<16|c.call(o,3)<<24)>>>0,(c.call(o,4)|c.call(o,5)<<8|c.call(o,6)<<16|c.call(o,7)<<24)>>>0)},s.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)},s.prototype.zzEncode=function(){var o=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^o)>>>0,this.lo=(this.lo<<1^o)>>>0,this},s.prototype.zzDecode=function(){var o=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^o)>>>0,this.hi=(this.hi>>>1^o)>>>0,this},s.prototype.length=function(){var o=this.lo,a=(this.lo>>>28|this.hi<<4)>>>0,e=this.hi>>>24;return e===0?a===0?o<16384?o<128?1:2:o<2097152?3:4:a<16384?a<128?5:6:a<2097152?7:8:e<128?9:10}}),we=nt(t=>{"use strict";var r=t;r.asPromise=Ch(),r.base64=Lh(),r.EventEmitter=Rh(),r.float=jh(),r.inquire=Bh(),r.utf8=Vh(),r.pool=Mh(),r.LongBits=zh(),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(p){return typeof p=="number"&&isFinite(p)&&Math.floor(p)===p},r.isString=function(p){return typeof p=="string"||p instanceof String},r.isObject=function(p){return p&&typeof p=="object"},r.isset=r.isSet=function(p,l){var c=p[l];return c!=null&&p.hasOwnProperty(l)?typeof c!="object"||(Array.isArray(c)?c.length:Object.keys(c).length)>0:!1},r.Buffer=function(){try{var p=r.inquire("buffer").Buffer;return p.prototype.utf8Write?p:null}catch{return null}}(),r._Buffer_from=null,r._Buffer_allocUnsafe=null,r.newBuffer=function(p){return typeof p=="number"?r.Buffer?r._Buffer_allocUnsafe(p):new r.Array(p):r.Buffer?r._Buffer_from(p):typeof Uint8Array>"u"?p:new Uint8Array(p)},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(p){return p?r.LongBits.from(p).toHash():r.LongBits.zeroHash},r.longFromHash=function(p,l){var c=r.LongBits.fromHash(p);return r.Long?r.Long.fromBits(c.lo,c.hi,l):c.toNumber(!!l)};function n(p,l,c){for(var o=Object.keys(l),a=0;a<o.length;++a)(p[o[a]]===void 0||!c)&&(p[o[a]]=l[o[a]]);return p}r.merge=n,r.lcFirst=function(p){return p.charAt(0).toLowerCase()+p.substring(1)};function s(p){function l(c,o){if(!(this instanceof l))return new l(c,o);Object.defineProperty(this,"message",{get:function(){return c}}),Error.captureStackTrace?Error.captureStackTrace(this,l):Object.defineProperty(this,"stack",{value:new Error().stack||""}),o&&n(this,o)}return l.prototype=Object.create(Error.prototype,{constructor:{value:l,writable:!0,enumerable:!1,configurable:!0},name:{get:function(){return p},set:void 0,enumerable:!1,configurable:!0},toString:{value:function(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),l}r.newError=s,r.ProtocolError=s("ProtocolError"),r.oneOfGetter=function(p){for(var l={},c=0;c<p.length;++c)l[p[c]]=1;return function(){for(var o=Object.keys(this),a=o.length-1;a>-1;--a)if(l[o[a]]===1&&this[o[a]]!==void 0&&this[o[a]]!==null)return o[a]}},r.oneOfSetter=function(p){return function(l){for(var c=0;c<p.length;++c)p[c]!==l&&delete this[p[c]]}},r.toJSONOptions={longs:String,enums:String,bytes:String,json:!0},r._configure=function(){var p=r.Buffer;if(!p){r._Buffer_from=r._Buffer_allocUnsafe=null;return}r._Buffer_from=p.from!==Uint8Array.from&&p.from||function(l,c){return new p(l,c)},r._Buffer_allocUnsafe=p.allocUnsafe||function(l){return new p(l)}}}),gl=nt((t,r)=>{"use strict";r.exports=u;var n=we(),s,p=n.LongBits,l=n.base64,c=n.utf8;function o(w,S,$){this.fn=w,this.len=S,this.next=void 0,this.val=$}function a(){}function e(w){this.head=w.head,this.tail=w.tail,this.len=w.len,this.next=w.states}function u(){this.len=0,this.head=new o(a,0,0),this.tail=this.head,this.states=null}var i=function(){return n.Buffer?function(){return(u.create=function(){return new s})()}:function(){return new u}};u.create=i(),u.alloc=function(w){return new n.Array(w)},n.Array!==Array&&(u.alloc=n.pool(u.alloc,n.Array.prototype.subarray)),u.prototype._push=function(w,S,$){return this.tail=this.tail.next=new o(w,S,$),this.len+=S,this};function d(w,S,$){S[$]=w&255}function h(w,S,$){for(;w>127;)S[$++]=w&127|128,w>>>=7;S[$]=w}function m(w,S){this.len=w,this.next=void 0,this.val=S}m.prototype=Object.create(o.prototype),m.prototype.fn=h,u.prototype.uint32=function(w){return this.len+=(this.tail=this.tail.next=new m((w=w>>>0)<128?1:w<16384?2:w<2097152?3:w<268435456?4:5,w)).len,this},u.prototype.int32=function(w){return w<0?this._push(b,10,p.fromNumber(w)):this.uint32(w)},u.prototype.sint32=function(w){return this.uint32((w<<1^w>>31)>>>0)};function b(w,S,$){for(;w.hi;)S[$++]=w.lo&127|128,w.lo=(w.lo>>>7|w.hi<<25)>>>0,w.hi>>>=7;for(;w.lo>127;)S[$++]=w.lo&127|128,w.lo=w.lo>>>7;S[$++]=w.lo}u.prototype.uint64=function(w){var S=p.from(w);return this._push(b,S.length(),S)},u.prototype.int64=u.prototype.uint64,u.prototype.sint64=function(w){var S=p.from(w).zzEncode();return this._push(b,S.length(),S)},u.prototype.bool=function(w){return this._push(d,1,w?1:0)};function x(w,S,$){S[$]=w&255,S[$+1]=w>>>8&255,S[$+2]=w>>>16&255,S[$+3]=w>>>24}u.prototype.fixed32=function(w){return this._push(x,4,w>>>0)},u.prototype.sfixed32=u.prototype.fixed32,u.prototype.fixed64=function(w){var S=p.from(w);return this._push(x,4,S.lo)._push(x,4,S.hi)},u.prototype.sfixed64=u.prototype.fixed64,u.prototype.float=function(w){return this._push(n.float.writeFloatLE,4,w)},u.prototype.double=function(w){return this._push(n.float.writeDoubleLE,8,w)};var E=n.Array.prototype.set?function(w,S,$){S.set(w,$)}:function(w,S,$){for(var F=0;F<w.length;++F)S[$+F]=w[F]};u.prototype.bytes=function(w){var S=w.length>>>0;if(!S)return this._push(d,1,0);if(n.isString(w)){var $=u.alloc(S=l.length(w));l.decode(w,$,0),w=$}return this.uint32(S)._push(E,S,w)},u.prototype.string=function(w){var S=c.length(w);return S?this.uint32(S)._push(c.write,S,w):this._push(d,1,0)},u.prototype.fork=function(){return this.states=new e(this),this.head=this.tail=new o(a,0,0),this.len=0,this},u.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new o(a,0,0),this.len=0),this},u.prototype.ldelim=function(){var w=this.head,S=this.tail,$=this.len;return this.reset().uint32($),$&&(this.tail.next=w.next,this.tail=S,this.len+=$),this},u.prototype.finish=function(){for(var w=this.head.next,S=this.constructor.alloc(this.len),$=0;w;)w.fn(w.val,S,$),$+=w.len,w=w.next;return S},u._configure=function(w){s=w,u.create=i(),s._configure()}}),Uh=nt((t,r)=>{"use strict";r.exports=p;var n=gl();(p.prototype=Object.create(n.prototype)).constructor=p;var s=we();function p(){n.call(this)}p._configure=function(){p.alloc=s._Buffer_allocUnsafe,p.writeBytesBuffer=s.Buffer&&s.Buffer.prototype instanceof Uint8Array&&s.Buffer.prototype.set.name==="set"?function(c,o,a){o.set(c,a)}:function(c,o,a){if(c.copy)c.copy(o,a,0,c.length);else for(var e=0;e<c.length;)o[a++]=c[e++]}},p.prototype.bytes=function(c){s.isString(c)&&(c=s._Buffer_from(c,"base64"));var o=c.length>>>0;return this.uint32(o),o&&this._push(p.writeBytesBuffer,o,c),this};function l(c,o,a){c.length<40?s.utf8.write(c,o,a):o.utf8Write?o.utf8Write(c,a):o.write(c,a)}p.prototype.string=function(c){var o=s.Buffer.byteLength(c);return this.uint32(o),o&&this._push(l,o,c),this},p._configure()}),ml=nt((t,r)=>{"use strict";r.exports=o;var n=we(),s,p=n.LongBits,l=n.utf8;function c(h,m){return RangeError("index out of range: "+h.pos+" + "+(m||1)+" > "+h.len)}function o(h){this.buf=h,this.pos=0,this.len=h.length}var a=typeof Uint8Array<"u"?function(h){if(h instanceof Uint8Array||Array.isArray(h))return new o(h);throw Error("illegal buffer")}:function(h){if(Array.isArray(h))return new o(h);throw Error("illegal buffer")},e=function(){return n.Buffer?function(h){return(o.create=function(m){return n.Buffer.isBuffer(m)?new s(m):a(m)})(h)}:a};o.create=e(),o.prototype._slice=n.Array.prototype.subarray||n.Array.prototype.slice,o.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,c(this,10);return h}}(),o.prototype.int32=function(){return this.uint32()|0},o.prototype.sint32=function(){var h=this.uint32();return h>>>1^-(h&1)|0};function u(){var h=new p(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 c(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 c(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")}o.prototype.bool=function(){return this.uint32()!==0};function i(h,m){return(h[m-4]|h[m-3]<<8|h[m-2]<<16|h[m-1]<<24)>>>0}o.prototype.fixed32=function(){if(this.pos+4>this.len)throw c(this,4);return i(this.buf,this.pos+=4)},o.prototype.sfixed32=function(){if(this.pos+4>this.len)throw c(this,4);return i(this.buf,this.pos+=4)|0};function d(){if(this.pos+8>this.len)throw c(this,8);return new p(i(this.buf,this.pos+=4),i(this.buf,this.pos+=4))}o.prototype.float=function(){if(this.pos+4>this.len)throw c(this,4);var h=n.float.readFloatLE(this.buf,this.pos);return this.pos+=4,h},o.prototype.double=function(){if(this.pos+8>this.len)throw c(this,4);var h=n.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,h},o.prototype.bytes=function(){var h=this.uint32(),m=this.pos,b=this.pos+h;if(b>this.len)throw c(this,h);if(this.pos+=h,Array.isArray(this.buf))return this.buf.slice(m,b);if(m===b){var x=n.Buffer;return x?x.alloc(0):new this.buf.constructor(0)}return this._slice.call(this.buf,m,b)},o.prototype.string=function(){var h=this.bytes();return l.read(h,0,h.length)},o.prototype.skip=function(h){if(typeof h=="number"){if(this.pos+h>this.len)throw c(this,h);this.pos+=h}else do if(this.pos>=this.len)throw c(this);while(this.buf[this.pos++]&128);return this},o.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},o._configure=function(h){s=h,o.create=e(),s._configure();var m=n.Long?"toLong":"toNumber";n.merge(o.prototype,{int64:function(){return u.call(this)[m](!1)},uint64:function(){return u.call(this)[m](!0)},sint64:function(){return u.call(this).zzDecode()[m](!1)},fixed64:function(){return d.call(this)[m](!0)},sfixed64:function(){return d.call(this)[m](!1)}})}}),Gh=nt((t,r)=>{"use strict";r.exports=p;var n=ml();(p.prototype=Object.create(n.prototype)).constructor=p;var s=we();function p(l){n.call(this,l)}p._configure=function(){s.Buffer&&(p.prototype._slice=s.Buffer.prototype.slice)},p.prototype.string=function(){var l=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+l,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+l,this.len))},p._configure()}),Hh=nt((t,r)=>{"use strict";r.exports=s;var n=we();(s.prototype=Object.create(n.EventEmitter.prototype)).constructor=s;function s(p,l,c){if(typeof p!="function")throw TypeError("rpcImpl must be a function");n.EventEmitter.call(this),this.rpcImpl=p,this.requestDelimited=!!l,this.responseDelimited=!!c}s.prototype.rpcCall=function p(l,c,o,a,e){if(!a)throw TypeError("request must be specified");var u=this;if(!e)return n.asPromise(p,u,l,c,o,a);if(!u.rpcImpl){setTimeout(function(){e(Error("already ended"))},0);return}try{return u.rpcImpl(l,c[u.requestDelimited?"encodeDelimited":"encode"](a).finish(),function(i,d){if(i)return u.emit("error",i,l),e(i);if(d===null){u.end(!0);return}if(!(d instanceof o))try{d=o[u.responseDelimited?"decodeDelimited":"decode"](d)}catch(h){return u.emit("error",h,l),e(h)}return u.emit("data",d,l),e(null,d)})}catch(i){u.emit("error",i,l),setTimeout(function(){e(i)},0);return}},s.prototype.end=function(p){return this.rpcImpl&&(p||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}}),qh=nt(t=>{"use strict";var r=t;r.Service=Hh()}),Wh=nt((t,r)=>{"use strict";r.exports={}}),Xh=nt(t=>{"use strict";var r=t;r.build="minimal",r.Writer=gl(),r.BufferWriter=Uh(),r.Reader=ml(),r.BufferReader=Gh(),r.util=we(),r.rpc=qh(),r.roots=Wh(),r.configure=n;function n(){r.util._configure(),r.Writer._configure(r.BufferWriter),r.Reader._configure(r.BufferReader)}n()}),Kh=nt((t,r)=>{"use strict";r.exports=Xh()}),mr=nt((t,r)=>{"use strict";var n=Kh(),s=n.Reader,p=n.Writer,l=n.util,c=n.roots.default||(n.roots.default={});c.onnx=function(){var o={};return o.Version=function(){var a={},e=Object.create(a);return e[a[0]="_START_VERSION"]=0,e[a[1]="IR_VERSION_2017_10_10"]=1,e[a[2]="IR_VERSION_2017_10_30"]=2,e[a[3]="IR_VERSION_2017_11_3"]=3,e[a[4]="IR_VERSION_2019_1_22"]=4,e[a[5]="IR_VERSION_2019_3_18"]=5,e[a[6]="IR_VERSION_2019_9_19"]=6,e[a[7]="IR_VERSION_2020_5_8"]=7,e[a[8]="IR_VERSION_2021_7_30"]=8,e[a[9]="IR_VERSION"]=9,e}(),o.AttributeProto=function(){function a(e){if(this.floats=[],this.ints=[],this.strings=[],this.tensors=[],this.graphs=[],this.sparseTensors=[],this.typeProtos=[],e)for(var u=Object.keys(e),i=0;i<u.length;++i)e[u[i]]!=null&&(this[u[i]]=e[u[i]])}return a.prototype.name="",a.prototype.refAttrName="",a.prototype.docString="",a.prototype.type=0,a.prototype.f=0,a.prototype.i=l.Long?l.Long.fromBits(0,0,!1):0,a.prototype.s=l.newBuffer([]),a.prototype.t=null,a.prototype.g=null,a.prototype.sparseTensor=null,a.prototype.tp=null,a.prototype.floats=l.emptyArray,a.prototype.ints=l.emptyArray,a.prototype.strings=l.emptyArray,a.prototype.tensors=l.emptyArray,a.prototype.graphs=l.emptyArray,a.prototype.sparseTensors=l.emptyArray,a.prototype.typeProtos=l.emptyArray,a.create=function(e){return new a(e)},a.encode=function(e,u){if(u||(u=p.create()),e.name!=null&&Object.hasOwnProperty.call(e,"name")&&u.uint32(10).string(e.name),e.f!=null&&Object.hasOwnProperty.call(e,"f")&&u.uint32(21).float(e.f),e.i!=null&&Object.hasOwnProperty.call(e,"i")&&u.uint32(24).int64(e.i),e.s!=null&&Object.hasOwnProperty.call(e,"s")&&u.uint32(34).bytes(e.s),e.t!=null&&Object.hasOwnProperty.call(e,"t")&&c.onnx.TensorProto.encode(e.t,u.uint32(42).fork()).ldelim(),e.g!=null&&Object.hasOwnProperty.call(e,"g")&&c.onnx.GraphProto.encode(e.g,u.uint32(50).fork()).ldelim(),e.floats!=null&&e.floats.length){u.uint32(58).fork();for(var i=0;i<e.floats.length;++i)u.float(e.floats[i]);u.ldelim()}if(e.ints!=null&&e.ints.length){u.uint32(66).fork();for(var i=0;i<e.ints.length;++i)u.int64(e.ints[i]);u.ldelim()}if(e.strings!=null&&e.strings.length)for(var i=0;i<e.strings.length;++i)u.uint32(74).bytes(e.strings[i]);if(e.tensors!=null&&e.tensors.length)for(var i=0;i<e.tensors.length;++i)c.onnx.TensorProto.encode(e.tensors[i],u.uint32(82).fork()).ldelim();if(e.graphs!=null&&e.graphs.length)for(var i=0;i<e.graphs.length;++i)c.onnx.GraphProto.encode(e.graphs[i],u.uint32(90).fork()).ldelim();if(e.docString!=null&&Object.hasOwnProperty.call(e,"docString")&&u.uint32(106).string(e.docString),e.tp!=null&&Object.hasOwnProperty.call(e,"tp")&&c.onnx.TypeProto.encode(e.tp,u.uint32(114).fork()).ldelim(),e.typeProtos!=null&&e.typeProtos.length)for(var i=0;i<e.typeProtos.length;++i)c.onnx.TypeProto.encode(e.typeProtos[i],u.uint32(122).fork()).ldelim();if(e.type!=null&&Object.hasOwnProperty.call(e,"type")&&u.uint32(160).int32(e.type),e.refAttrName!=null&&Object.hasOwnProperty.call(e,"refAttrName")&&u.uint32(170).string(e.refAttrName),e.sparseTensor!=null&&Object.hasOwnProperty.call(e,"sparseTensor")&&c.onnx.SparseTensorProto.encode(e.sparseTensor,u.uint32(178).fork()).ldelim(),e.sparseTensors!=null&&e.sparseTensors.length)for(var i=0;i<e.sparseTensors.length;++i)c.onnx.SparseTensorProto.encode(e.sparseTensors[i],u.uint32(186).fork()).ldelim();return u},a.encodeDelimited=function(e,u){return this.encode(e,u).ldelim()},a.decode=function(e,u){e instanceof s||(e=s.create(e));for(var i=u===void 0?e.len:e.pos+u,d=new c.onnx.AttributeProto;e.pos<i;){var h=e.uint32();switch(h>>>3){case 1:{d.name=e.string();break}case 21:{d.refAttrName=e.string();break}case 13:{d.docString=e.string();break}case 20:{d.type=e.int32();break}case 2:{d.f=e.float();break}case 3:{d.i=e.int64();break}case 4:{d.s=e.bytes();break}case 5:{d.t=c.onnx.TensorProto.decode(e,e.uint32());break}case 6:{d.g=c.onnx.GraphProto.decode(e,e.uint32());break}case 22:{d.sparseTensor=c.onnx.SparseTensorProto.decode(e,e.uint32());break}case 14:{d.tp=c.onnx.TypeProto.decode(e,e.uint32());break}case 7:{if(d.floats&&d.floats.length||(d.floats=[]),(h&7)===2)for(var m=e.uint32()+e.pos;e.pos<m;)d.floats.push(e.float());else d.floats.push(e.float());break}case 8:{if(d.ints&&d.ints.length||(d.ints=[]),(h&7)===2)for(var m=e.uint32()+e.pos;e.pos<m;)d.ints.push(e.int64());else d.ints.push(e.int64());break}case 9:{d.strings&&d.strings.length||(d.strings=[]),d.strings.push(e.bytes());break}case 10:{d.tensors&&d.tensors.length||(d.tensors=[]),d.tensors.push(c.onnx.TensorProto.decode(e,e.uint32()));break}case 11:{d.graphs&&d.graphs.length||(d.graphs=[]),d.graphs.push(c.onnx.GraphProto.decode(e,e.uint32()));break}case 23:{d.sparseTensors&&d.sparseTensors.length||(d.sparseTensors=[]),d.sparseTensors.push(c.onnx.SparseTensorProto.decode(e,e.uint32()));break}case 15:{d.typeProtos&&d.typeProtos.length||(d.typeProtos=[]),d.typeProtos.push(c.onnx.TypeProto.decode(e,e.uint32()));break}default:e.skipType(h&7);break}}return d},a.decodeDelimited=function(e){return e instanceof s||(e=new s(e)),this.decode(e,e.uint32())},a.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.name!=null&&e.hasOwnProperty("name")&&!l.isString(e.name))return"name: string expected";if(e.refAttrName!=null&&e.hasOwnProperty("refAttrName")&&!l.isString(e.refAttrName))return"refAttrName: string expected";if(e.docString!=null&&e.hasOwnProperty("docString")&&!l.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")&&!l.isInteger(e.i)&&!(e.i&&l.isInteger(e.i.low)&&l.isInteger(e.i.high)))return"i: integer|Long expected";if(e.s!=null&&e.hasOwnProperty("s")&&!(e.s&&typeof e.s.length=="number"||l.isString(e.s)))return"s: buffer expected";if(e.t!=null&&e.hasOwnProperty("t")){var u=c.onnx.TensorProto.verify(e.t);if(u)return"t."+u}if(e.g!=null&&e.hasOwnProperty("g")){var u=c.onnx.GraphProto.verify(e.g);if(u)return"g."+u}if(e.sparseTensor!=null&&e.hasOwnProperty("sparseTensor")){var u=c.onnx.SparseTensorProto.verify(e.sparseTensor);if(u)return"sparseTensor."+u}if(e.tp!=null&&e.hasOwnProperty("tp")){var u=c.onnx.TypeProto.verify(e.tp);if(u)return"tp."+u}if(e.floats!=null&&e.hasOwnProperty("floats")){if(!Array.isArray(e.floats))return"floats: array expected";for(var i=0;i<e.floats.length;++i)if(typeof e.floats[i]!="number")return"floats: number[] expected"}if(e.ints!=null&&e.hasOwnProperty("ints")){if(!Array.isArray(e.ints))return"ints: array expected";for(var i=0;i<e.ints.length;++i)if(!l.isInteger(e.ints[i])&&!(e.ints[i]&&l.isInteger(e.ints[i].low)&&l.isInteger(e.ints[i].high)))return"ints: integer|Long[] expected"}if(e.strings!=null&&e.hasOwnProperty("strings")){if(!Array.isArray(e.strings))return"strings: array expected";for(var i=0;i<e.strings.length;++i)if(!(e.strings[i]&&typeof e.strings[i].length=="number"||l.isString(e.strings[i])))return"strings: buffer[] expected"}if(e.tensors!=null&&e.hasOwnProperty("tensors")){if(!Array.isArray(e.tensors))return"tensors: array expected";for(var i=0;i<e.tensors.length;++i){var u=c.onnx.TensorProto.verify(e.tensors[i]);if(u)return"tensors."+u}}if(e.graphs!=null&&e.hasOwnProperty("graphs")){if(!Array.isArray(e.graphs))return"graphs: array expected";for(var i=0;i<e.graphs.length;++i){var u=c.onnx.GraphProto.verify(e.graphs[i]);if(u)return"graphs."+u}}if(e.sparseTensors!=null&&e.hasOwnProperty("sparseTensors")){if(!Array.isArray(e.sparseTensors))return"sparseTensors: array expected";for(var i=0;i<e.sparseTensors.length;++i){var u=c.onnx.SparseTensorProto.verify(e.sparseTensors[i]);if(u)return"sparseTensors."+u}}if(e.typeProtos!=null&&e.hasOwnProperty("typeProtos")){if(!Array.isArray(e.typeProtos))return"typeProtos: array expected";for(var i=0;i<e.typeProtos.length;++i){var u=c.onnx.TypeProto.verify(e.typeProtos[i]);if(u)return"typeProtos."+u}}return null},a.fromObject=function(e){if(e instanceof c.onnx.AttributeProto)return e;var u=new c.onnx.AttributeProto;switch(e.name!=null&&(u.name=String(e.name)),e.refAttrName!=null&&(u.refAttrName=String(e.refAttrName)),e.docString!=null&&(u.docString=String(e.docString)),e.type){default:if(typeof e.type=="number"){u.type=e.type;break}break;case"UNDEFINED":case 0:u.type=0;break;case"FLOAT":case 1:u.type=1;break;case"INT":case 2:u.type=2;break;case"STRING":case 3:u.type=3;break;case"TENSOR":case 4:u.type=4;break;case"GRAPH":case 5:u.type=5;break;case"SPARSE_TENSOR":case 11:u.type=11;break;case"TYPE_PROTO":case 13:u.type=13;break;case"FLOATS":case 6:u.type=6;break;case"INTS":case 7:u.type=7;break;case"STRINGS":case 8:u.type=8;break;case"TENSORS":case 9:u.type=9;break;case"GRAPHS":case 10:u.type=10;break;case"SPARSE_TENSORS":case 12:u.type=12;break;case"TYPE_PROTOS":case 14:u.type=14;break}if(e.f!=null&&(u.f=Number(e.f)),e.i!=null&&(l.Long?(u.i=l.Long.fromValue(e.i)).unsigned=!1:typeof e.i=="string"?u.i=parseInt(e.i,10):typeof e.i=="number"?u.i=e.i:typeof e.i=="object"&&(u.i=new l.LongBits(e.i.low>>>0,e.i.high>>>0).toNumber())),e.s!=null&&(typeof e.s=="string"?l.base64.decode(e.s,u.s=l.newBuffer(l.base64.length(e.s)),0):e.s.length>=0&&(u.s=e.s)),e.t!=null){if(typeof e.t!="object")throw TypeError(".onnx.AttributeProto.t: object expected");u.t=c.onnx.TensorProto.fromObject(e.t)}if(e.g!=null){if(typeof e.g!="object")throw TypeError(".onnx.AttributeProto.g: object expected");u.g=c.onnx.GraphProto.fromObject(e.g)}if(e.sparseTensor!=null){if(typeof e.sparseTensor!="object")throw TypeError(".onnx.AttributeProto.sparseTensor: object expected");u.sparseTensor=c.onnx.SparseTensorProto.fromObject(e.sparseTensor)}if(e.tp!=null){if(typeof e.tp!="object")throw TypeError(".onnx.AttributeProto.tp: object expected");u.tp=c.onnx.TypeProto.fromObject(e.tp)}if(e.floats){if(!Array.isArray(e.floats))throw TypeError(".onnx.AttributeProto.floats: array expected");u.floats=[];for(var i=0;i<e.floats.length;++i)u.floats[i]=Number(e.floats[i])}if(e.ints){if(!Array.isArray(e.ints))throw TypeError(".onnx.AttributeProto.ints: array expected");u.ints=[];for(var i=0;i<e.ints.length;++i)l.Long?(u.ints[i]=l.Long.fromValue(e.ints[i])).unsigned=!1:typeof e.ints[i]=="string"?u.ints[i]=parseInt(e.ints[i],10):typeof e.ints[i]=="number"?u.ints[i]=e.ints[i]:typeof e.ints[i]=="object"&&(u.ints[i]=new l.LongBits(e.ints[i].low>>>0,e.ints[i].high>>>0).toNumber())}if(e.strings){if(!Array.isArray(e.strings))throw TypeError(".onnx.AttributeProto.strings: array expected");u.strings=[];for(var i=0;i<e.strings.length;++i)typeof e.strings[i]=="string"?l.base64.decode(e.strings[i],u.strings[i]=l.newBuffer(l.base64.length(e.strings[i])),0):e.strings[i].length>=0&&(u.strings[i]=e.strings[i])}if(e.tensors){if(!Array.isArray(e.tensors))throw TypeError(".onnx.AttributeProto.tensors: array expected");u.tensors=[];for(var i=0;i<e.tensors.length;++i){if(typeof e.tensors[i]!="object")throw TypeError(".onnx.AttributeProto.tensors: object expected");u.tensors[i]=c.onnx.TensorProto.fromObject(e.tensors[i])}}if(e.graphs){if(!Array.isArray(e.graphs))throw TypeError(".onnx.AttributeProto.graphs: array expected");u.graphs=[];for(var i=0;i<e.graphs.length;++i){if(typeof e.graphs[i]!="object")throw TypeError(".onnx.AttributeProto.graphs: object expected");u.graphs[i]=c.onnx.GraphProto.fromObject(e.graphs[i])}}if(e.sparseTensors){if(!Array.isArray(e.sparseTensors))throw TypeError(".onnx.AttributeProto.sparseTensors: array expected");u.sparseTensors=[];for(var i=0;i<e.sparseTensors.length;++i){if(typeof e.sparseTensors[i]!="object")throw TypeError(".onnx.AttributeProto.sparseTensors: object expected");u.sparseTensors[i]=c.onnx.SparseTensorProto.fromObject(e.sparseTensors[i])}}if(e.typeProtos){if(!Array.isArray(e.typeProtos))throw TypeError(".onnx.AttributeProto.typeProtos: array expected");u.typeProtos=[];for(var i=0;i<e.typeProtos.length;++i){if(typeof e.typeProtos[i]!="object")throw TypeError(".onnx.AttributeProto.typeProtos: object expected");u.typeProtos[i]=c.onnx.TypeProto.fromObject(e.typeProtos[i])}}return u},a.toObject=function(e,u){u||(u={});var i={};if((u.arrays||u.defaults)&&(i.floats=[],i.ints=[],i.strings=[],i.tensors=[],i.graphs=[],i.typeProtos=[],i.sparseTensors=[]),u.defaults){if(i.name="",i.f=0,l.Long){var d=new l.Long(0,0,!1);i.i=u.longs===String?d.toString():u.longs===Number?d.toNumber():d}else i.i=u.longs===String?"0":0;u.bytes===String?i.s="":(i.s=[],u.bytes!==Array&&(i.s=l.newBuffer(i.s))),i.t=null,i.g=null,i.docString="",i.tp=null,i.type=u.enums===String?"UNDEFINED":0,i.refAttrName="",i.sparseTensor=null}if(e.name!=null&&e.hasOwnProperty("name")&&(i.name=e.name),e.f!=null&&e.hasOwnProperty("f")&&(i.f=u.json&&!isFinite(e.f)?String(e.f):e.f),e.i!=null&&e.hasOwnProperty("i")&&(typeof e.i=="number"?i.i=u.longs===String?String(e.i):e.i:i.i=u.longs===String?l.Long.prototype.toString.call(e.i):u.longs===Number?new l.LongBits(e.i.low>>>0,e.i.high>>>0).toNumber():e.i),e.s!=null&&e.hasOwnProperty("s")&&(i.s=u.bytes===String?l.base64.encode(e.s,0,e.s.length):u.bytes===Array?Array.prototype.slice.call(e.s):e.s),e.t!=null&&e.hasOwnProperty("t")&&(i.t=c.onnx.TensorProto.toObject(e.t,u)),e.g!=null&&e.hasOwnProperty("g")&&(i.g=c.onnx.GraphProto.toObject(e.g,u)),e.floats&&e.floats.length){i.floats=[];for(var h=0;h<e.floats.length;++h)i.floats[h]=u.json&&!isFinite(e.floats[h])?String(e.floats[h]):e.floats[h]}if(e.ints&&e.ints.length){i.ints=[];for(var h=0;h<e.ints.length;++h)typeof e.ints[h]=="number"?i.ints[h]=u.longs===String?String(e.ints[h]):e.ints[h]:i.ints[h]=u.longs===String?l.Long.prototype.toString.call(e.ints[h]):u.longs===Number?new l.LongBits(e.ints[h].low>>>0,e.ints[h].high>>>0).toNumber():e.ints[h]}if(e.strings&&e.strings.length){i.strings=[];for(var h=0;h<e.strings.length;++h)i.strings[h]=u.bytes===String?l.base64.encode(e.strings[h],0,e.strings[h].length):u.bytes===Array?Array.prototype.slice.call(e.strings[h]):e.strings[h]}if(e.tensors&&e.tensors.length){i.tensors=[];for(var h=0;h<e.tensors.length;++h)i.tensors[h]=c.onnx.TensorProto.toObject(e.tensors[h],u)}if(e.graphs&&e.graphs.length){i.graphs=[];for(var h=0;h<e.graphs.length;++h)i.graphs[h]=c.onnx.GraphProto.toObject(e.graphs[h],u)}if(e.docString!=null&&e.hasOwnProperty("docString")&&(i.docString=e.docString),e.tp!=null&&e.hasOwnProperty("tp")&&(i.tp=c.onnx.TypeProto.toObject(e.tp,u)),e.typeProtos&&e.typeProtos.length){i.typeProtos=[];for(var h=0;h<e.typeProtos.length;++h)i.typeProtos[h]=c.onnx.TypeProto.toObject(e.typeProtos[h],u)}if(e.type!=null&&e.hasOwnProperty("type")&&(i.type=u.enums===String?c.onnx.AttributeProto.AttributeType[e.type]===void 0?e.type:c.onnx.AttributeProto.AttributeType[e.type]:e.type),e.refAttrName!=null&&e.hasOwnProperty("refAttrName")&&(i.refAttrName=e.refAttrName),e.sparseTensor!=null&&e.hasOwnProperty("sparseTensor")&&(i.sparseTensor=c.onnx.SparseTensorProto.toObject(e.sparseTensor,u)),e.sparseTensors&&e.sparseTensors.length){i.sparseTensors=[];for(var h=0;h<e.sparseTensors.length;++h)i.sparseTensors[h]=c.onnx.SparseTensorProto.toObject(e.sparseTensors[h],u)}return i},a.prototype.toJSON=function(){return this.constructor.toObject(this,n.util.toJSONOptions)},a.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/onnx.AttributeProto"},a.AttributeType=function(){var e={},u=Object.create(e);return u[e[0]="UNDEFINED"]=0,u[e[1]="FLOAT"]=1,u[e[2]="INT"]=2,u[e[3]="STRING"]=3,u[e[4]="TENSOR"]=4,u[e[5]="GRAPH"]=5,u[e[11]="SPARSE_TENSOR"]=11,u[e[13]="TYPE_PROTO"]=13,u[e[6]="FLOATS"]=6,u[e[7]="INTS"]=7,u[e[8]="STRINGS"]=8,u[e[9]="TENSORS"]=9,u[e[10]="GRAPHS"]=10,u[e[12]="SPARSE_TENSORS"]=12,u[e[14]="TYPE_PROTOS"]=14,u}(),a}(),o.ValueInfoProto=function(){function a(e){if(e)for(var u=Object.keys(e),i=0;i<u.length;++i)e[u[i]]!=null&&(this[u[i]]=e[u[i]])}return a.prototype.name="",a.prototype.type=null,a.prototype.docString="",a.create=function(e){return new a(e)},a.encode=function(e,u){return u||(u=p.create()),e.name!=null&&Object.hasOwnProperty.call(e,"name")&&u.uint32(10).string(e.name),e.type!=null&&Object.hasOwnProperty.call(e,"type")&&c.onnx.TypeProto.encode(e.type,u.uint32(18).fork()).ldelim(),e.docString!=null&&Object.hasOwnProperty.call(e,"docString")&&u.uint32(26).string(e.docString),u},a.encodeDelimited=function(e,u){return this.encode(e,u).ldelim()},a.decode=function(e,u){e instanceof s||(e=s.create(e));for(var i=u===void 0?e.len:e.pos+u,d=new c.onnx.ValueInfoProto;e.pos<i;){var h=e.uint32();switch(h>>>3){case 1:{d.name=e.string();break}case 2:{d.type=c.onnx.TypeProto.decode(e,e.uint32());break}case 3:{d.docString=e.string();break}default:e.skipType(h&7);break}}return d},a.decodeDelimited=function(e){return e instanceof s||(e=new s(e)),this.decode(e,e.uint32())},a.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.name!=null&&e.hasOwnProperty("name")&&!l.isString(e.name))return"name: string expected";if(e.type!=null&&e.hasOwnProperty("type")){var u=c.onnx.TypeProto.verify(e.type);if(u)return"type."+u}return e.docString!=null&&e.hasOwnProperty("docString")&&!l.isString(e.docString)?"docString: string expected":null},a.fromObject=function(e){if(e instanceof c.onnx.ValueInfoProto)return e;var u=new c.onnx.ValueInfoProto;if(e.name!=null&&(u.name=String(e.name)),e.type!=null){if(typeof e.type!="object")throw TypeError(".onnx.ValueInfoProto.type: object expected");u.type=c.onnx.TypeProto.fromObject(e.type)}return e.docString!=null&&(u.docString=String(e.docString)),u},a.toObject=function(e,u){u||(u={});var i={};return u.defaults&&(i.name="",i.type=null,i.docString=""),e.name!=null&&e.hasOwnProperty("name")&&(i.name=e.name),e.type!=null&&e.hasOwnProperty("type")&&(i.type=c.onnx.TypeProto.toObject(e.type,u)),e.docString!=null&&e.hasOwnProperty("docString")&&(i.docString=e.docString),i},a.prototype.toJSON=function(){return this.constructor.toObject(this,n.util.toJSONOptions)},a.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/onnx.ValueInfoProto"},a}(),o.NodeProto=function(){function a(e){if(this.input=[],this.output=[],this.attribute=[],e)for(var u=Object.keys(e),i=0;i<u.length;++i)e[u[i]]!=null&&(this[u[i]]=e[u[i]])}return a.prototype.input=l.emptyArray,a.prototype.output=l.emptyArray,a.prototype.name="",a.prototype.opType="",a.prototype.domain="",a.prototype.attribute=l.emptyArray,a.prototype.docString="",a.create=function(e){return new a(e)},a.encode=function(e,u){if(u||(u=p.create()),e.input!=null&&e.input.length)for(var i=0;i<e.input.length;++i)u.uint32(10).string(e.input[i]);if(e.output!=null&&e.output.length)for(var i=0;i<e.output.length;++i)u.uint32(18).string(e.output[i]);if(e.name!=null&&Object.hasOwnProperty.call(e,"name")&&u.uint32(26).string(e.name),e.opType!=null&&Object.hasOwnProperty.call(e,"opType")&&u.uint32(34).string(e.opType),e.attribute!=null&&e.attribute.length)for(var i=0;i<e.attribute.length;++i)c.onnx.AttributeProto.encode(e.attribute[i],u.uint32(42).fork()).ldelim();return e.docString!=null&&Object.hasOwnProperty.call(e,"docString")&&u.uint32(50).string(e.docString),e.domain!=null&&Object.hasOwnProperty.call(e,"domain")&&u.uint32(58).string(e.domain),u},a.encodeDelimited=function(e,u){return this.encode(e,u).ldelim()},a.decode=function(e,u){e instanceof s||(e=s.create(e));for(var i=u===void 0?e.len:e.pos+u,d=new c.onnx.NodeProto;e.pos<i;){var h=e.uint32();switch(h>>>3){case 1:{d.input&&d.input.length||(d.input=[]),d.input.push(e.string());break}case 2:{d.output&&d.output.length||(d.output=[]),d.output.push(e.string());break}case 3:{d.name=e.string();break}case 4:{d.opType=e.string();break}case 7:{d.domain=e.string();break}case 5:{d.attribute&&d.attribute.length||(d.attribute=[]),d.attribute.push(c.onnx.AttributeProto.decode(e,e.uint32()));break}case 6:{d.docString=e.string();break}default:e.skipType(h&7);break}}return d},a.decodeDelimited=function(e){return e instanceof s||(e=new s(e)),this.decode(e,e.uint32())},a.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 u=0;u<e.input.length;++u)if(!l.isString(e.input[u]))return"input: string[] expected"}if(e.output!=null&&e.hasOwnProperty("output")){if(!Array.isArray(e.output))return"output: array expected";for(var u=0;u<e.output.length;++u)if(!l.isString(e.output[u]))return"output: string[] expected"}if(e.name!=null&&e.hasOwnProperty("name")&&!l.isString(e.name))return"name: string expected";if(e.opType!=null&&e.hasOwnProperty("opType")&&!l.isString(e.opType))return"opType: string expected";if(e.domain!=null&&e.hasOwnProperty("domain")&&!l.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 u=0;u<e.attribute.length;++u){var i=c.onnx.AttributeProto.verify(e.attribute[u]);if(i)return"attribute."+i}}return e.docString!=null&&e.hasOwnProperty("docString")&&!l.isString(e.docString)?"docString: string expected":null},a.fromObject=function(e){if(e instanceof c.onnx.NodeProto)return e;var u=new c.onnx.NodeProto;if(e.input){if(!Array.isArray(e.input))throw TypeError(".onnx.NodeProto.input: array expected");u.input=[];for(var i=0;i<e.input.length;++i)u.input[i]=String(e.input[i])}if(e.output){if(!Array.isArray(e.output))throw TypeError(".onnx.NodeProto.output: array expected");u.output=[];for(var i=0;i<e.output.length;++i)u.output[i]=String(e.output[i])}if(e.name!=null&&(u.name=String(e.name)),e.opType!=null&&(u.opType=String(e.opType)),e.domain!=null&&(u.domain=String(e.domain)),e.attribute){if(!Array.isArray(e.attribute))throw TypeError(".onnx.NodeProto.attribute: array expected");u.attribute=[];for(var i=0;i<e.attribute.length;++i){if(typeof e.attribute[i]!="object")throw TypeError(".onnx.NodeProto.attribute: object expected");u.attribute[i]=c.onnx.AttributeProto.fromObject(e.attribute[i])}}return e.docString!=null&&(u.docString=String(e.docString)),u},a.toObject=function(e,u){u||(u={});var i={};if((u.arrays||u.defaults)&&(i.input=[],i.output=[],i.attribute=[]),u.defaults&&(i.name="",i.opType="",i.docString="",i.domain=""),e.input&&e.input.length){i.input=[];for(var d=0;d<e.input.length;++d)i.input[d]=e.input[d]}if(e.output&&e.output.length){i.output=[];for(var d=0;d<e.output.length;++d)i.output[d]=e.output[d]}if(e.name!=null&&e.hasOwnProperty("name")&&(i.name=e.name),e.opType!=null&&e.hasOwnProperty("opType")&&(i.opType=e.opType),e.attribute&&e.attribute.length){i.attribute=[];for(var d=0;d<e.attribute.length;++d)i.attribute[d]=c.onnx.AttributeProto.toObject(e.attribute[d],u)}return e.docString!=null&&e.hasOwnProperty("docString")&&(i.docString=e.docString),e.domain!=null&&e.hasOwnProperty("domain")&&(i.domain=e.domain),i},a.prototype.toJSON=function(){return this.constructor.toObject(this,n.util.toJSONOptions)},a.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/onnx.NodeProto"},a}(),o.TrainingInfoProto=function(){function a(e){if(this.initializationBinding=[],this.updateBinding=[],e)for(var u=Object.keys(e),i=0;i<u.length;++i)e[u[i]]!=null&&(this[u[i]]=e[u[i]])}return a.prototype.initialization=null,a.prototype.algorithm=null,a.prototype.initializationBinding=l.emptyArray,a.prototype.updateBinding=l.emptyArray,a.create=function(e){return new a(e)},a.encode=function(e,u){if(u||(u=p.create()),e.initialization!=null&&Object.hasOwnProperty.call(e,"initialization")&&c.onnx.GraphProto.encode(e.initialization,u.uint32(10).fork()).ldelim(),e.algorithm!=null&&Object.hasOwnProperty.call(e,"algorithm")&&c.onnx.GraphProto.encode(e.algorithm,u.uint32(18).fork()).ldelim(),e.initializationBinding!=null&&e.initializationBinding.length)for(var i=0;i<e.initializationBinding.length;++i)c.onnx.StringStringEntryProto.encode(e.initializationBinding[i],u.uint32(26).fork()).ldelim();if(e.updateBinding!=null&&e.updateBinding.length)for(var i=0;i<e.updateBinding.length;++i)c.onnx.StringStringEntryProto.encode(e.updateBinding[i],u.uint32(34).fork()).ldelim();return u},a.encodeDelimited=function(e,u){return this.encode(e,u).ldelim()},a.decode=function(e,u){e instanceof s||(e=s.create(e));for(var i=u===void 0?e.len:e.pos+u,d=new c.onnx.TrainingInfoProto;e.pos<i;){var h=e.uint32();switch(h>>>3){case 1:{d.initialization=c.onnx.GraphProto.decode(e,e.uint32());break}case 2:{d.algorithm=c.onnx.GraphProto.decode(e,e.uint32());break}case 3:{d.initializationBinding&&d.initializationBinding.length||(d.initializationBinding=[]),d.initializationBinding.push(c.onnx.StringStringEntryProto.decode(e,e.uint32()));break}case 4:{d.updateBinding&&d.updateBinding.length||(d.updateBinding=[]),d.updateBinding.push(c.onnx.StringStringEntryProto.decode(e,e.uint32()));break}default:e.skipType(h&7);break}}return d},a.decodeDelimited=function(e){return e instanceof s||(e=new s(e)),this.decode(e,e.uint32())},a.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.initialization!=null&&e.hasOwnProperty("initialization")){var u=c.onnx.GraphProto.verify(e.initialization);if(u)return"initialization."+u}if(e.algorithm!=null&&e.hasOwnProperty("algorithm")){var u=c.onnx.GraphProto.verify(e.algorithm);if(u)return"algorithm."+u}if(e.initializationBinding!=null&&e.hasOwnProperty("initializationBinding")){if(!Array.isArray(e.initializationBinding))return"initializationBinding: array expected";for(var i=0;i<e.initializationBinding.length;++i){var u=c.onnx.StringStringEntryProto.verify(e.initializationBinding[i]);if(u)return"initializationBinding."+u}}if(e.updateBinding!=null&&e.hasOwnProperty("updateBinding")){if(!Array.isArray(e.updateBinding))return"updateBinding: array expected";for(var i=0;i<e.updateBinding.length;++i){var u=c.onnx.StringStringEntryProto.verify(e.updateBinding[i]);if(u)return"updateBinding."+u}}return null},a.fromObject=function(e){if(e instanceof c.onnx.TrainingInfoProto)return e;var u=new c.onnx.TrainingInfoProto;if(e.initialization!=null){if(typeof e.initialization!="object")throw TypeError(".onnx.TrainingInfoProto.initialization: object expected");u.initialization=c.onnx.GraphProto.fromObject(e.initialization)}if(e.algorithm!=null){if(typeof e.algorithm!="object")throw TypeError(".onnx.TrainingInfoProto.algorithm: object expected");u.algorithm=c.onnx.GraphProto.fromObject(e.algorithm)}if(e.initializationBinding){if(!Array.isArray(e.initializationBinding))throw TypeError(".onnx.TrainingInfoProto.initializationBinding: array expected");u.initializationBinding=[];for(var i=0;i<e.initializationBinding.length;++i){if(typeof e.initializationBinding[i]!="object")throw TypeError(".onnx.TrainingInfoProto.initializationBinding: object expected");u.initializationBinding[i]=c.onnx.StringStringEntryProto.fromObject(e.initializationBinding[i])}}if(e.updateBinding){if(!Array.isArray(e.updateBinding))throw TypeError(".onnx.TrainingInfoProto.updateBinding: array expected");u.updateBinding=[];for(var i=0;i<e.updateBinding.length;++i){if(typeof e.updateBinding[i]!="object")throw TypeError(".onnx.TrainingInfoProto.updateBinding: object expected");u.updateBinding[i]=c.onnx.StringStringEntryProto.fromObject(e.updateBinding[i])}}return u},a.toObject=function(e,u){u||(u={});var i={};if((u.arrays||u.defaults)&&(i.initializationBinding=[],i.updateBinding=[]),u.defaults&&(i.initialization=null,i.algorithm=null),e.initialization!=null&&e.hasOwnProperty("initialization")&&(i.initialization=c.onnx.GraphProto.toObject(e.initialization,u)),e.algorithm!=null&&e.hasOwnProperty("algorithm")&&(i.algorithm=c.onnx.GraphProto.toObject(e.algorithm,u)),e.initializationBinding&&e.initializationBinding.length){i.initializationBinding=[];for(var d=0;d<e.initializationBinding.length;++d)i.initializationBinding[d]=c.onnx.StringStringEntryProto.toObject(e.initializationBinding[d],u)}if(e.updateBinding&&e.updateBinding.length){i.updateBinding=[];for(var d=0;d<e.updateBinding.length;++d)i.updateBinding[d]=c.onnx.StringStringEntryProto.toObject(e.updateBinding[d],u)}return i},a.prototype.toJSON=function(){return this.constructor.toObject(this,n.util.toJSONOptions)},a.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/onnx.TrainingInfoProto"},a}(),o.ModelProto=function(){function a(e){if(this.opsetImport=[],this.metadataProps=[],this.trainingInfo=[],this.functions=[],e)for(var u=Object.keys(e),i=0;i<u.length;++i)e[u[i]]!=null&&(this[u[i]]=e[u[i]])}return a.prototype.irVersion=l.Long?l.Long.fromBits(0,0,!1):0,a.prototype.opsetImport=l.emptyArray,a.prototype.producerName="",a.prototype.producerVersion="",a.prototype.domain="",a.prototype.modelVersion=l.Long?l.Long.fromBits(0,0,!1):0,a.prototype.docString="",a.prototype.graph=null,a.prototype.metadataProps=l.emptyArray,a.prototype.trainingInfo=l.emptyArray,a.prototype.functions=l.emptyArray,a.create=function(e){return new a(e)},a.encode=function(e,u){if(u||(u=p.create()),e.irVersion!=null&&Object.hasOwnProperty.call(e,"irVersion")&&u.uint32(8).int64(e.irVersion),e.producerName!=null&&Object.hasOwnProperty.call(e,"producerName")&&u.uint32(18).string(e.producerName),e.producerVersion!=null&&Object.hasOwnProperty.call(e,"producerVersion")&&u.uint32(26).string(e.producerVersion),e.domain!=null&&Object.hasOwnProperty.call(e,"domain")&&u.uint32(34).string(e.domain),e.modelVersion!=null&&Object.hasOwnProperty.call(e,"modelVersion")&&u.uint32(40).int64(e.modelVersion),e.docString!=null&&Object.hasOwnProperty.call(e,"docString")&&u.uint32(50).string(e.docString),e.graph!=null&&Object.hasOwnProperty.call(e,"graph")&&c.onnx.GraphProto.encode(e.graph,u.uint32(58).fork()).ldelim(),e.opsetImport!=null&&e.opsetImport.length)for(var i=0;i<e.opsetImport.length;++i)c.onnx.OperatorSetIdProto.encode(e.opsetImport[i],u.uint32(66).fork()).ldelim();if(e.metadataProps!=null&&e.metadataProps.length)for(var i=0;i<e.metadataProps.length;++i)c.onnx.StringStringEntryProto.encode(e.metadataProps[i],u.uint32(114).fork()).ldelim();if(e.trainingInfo!=null&&e.trainingInfo.length)for(var i=0;i<e.trainingInfo.length;++i)c.onnx.TrainingInfoProto.encode(e.trainingInfo[i],u.uint32(162).fork()).ldelim();if(e.functions!=null&&e.functions.length)for(var i=0;i<e.functions.length;++i)c.onnx.FunctionProto.encode(e.functions[i],u.uint32(202).fork()).ldelim();return u},a.encodeDelimited=function(e,u){return this.encode(e,u).ldelim()},a.decode=function(e,u){e instanceof s||(e=s.create(e));for(var i=u===void 0?e.len:e.pos+u,d=new c.onnx.ModelProto;e.pos<i;){var h=e.uint32();switch(h>>>3){case 1:{d.irVersion=e.int64();break}case 8:{d.opsetImport&&d.opsetImport.length||(d.opsetImport=[]),d.opsetImport.push(c.onnx.OperatorSetIdProto.decode(e,e.uint32()));break}case 2:{d.producerName=e.string();break}case 3:{d.producerVersion=e.string();break}case 4:{d.domain=e.string();break}case 5:{d.modelVersion=e.int64();break}case 6:{d.docString=e.string();break}case 7:{d.graph=c.onnx.GraphProto.decode(e,e.uint32());break}case 14:{d.metadataProps&&d.metadataProps.length||(d.metadataProps=[]),d.metadataProps.push(c.onnx.StringStringEntryProto.decode(e,e.uint32()));break}case 20:{d.trainingInfo&&d.trainingInfo.length||(d.trainingInfo=[]),d.trainingInfo.push(c.onnx.TrainingInfoProto.decode(e,e.uint32()));break}case 25:{d.functions&&d.functions.length||(d.functions=[]),d.functions.push(c.onnx.FunctionProto.decode(e,e.uint32()));break}default:e.skipType(h&7);break}}return d},a.decodeDelimited=function(e){return e instanceof s||(e=new s(e)),this.decode(e,e.uint32())},a.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.irVersion!=null&&e.hasOwnProperty("irVersion")&&!l.isInteger(e.irVersion)&&!(e.irVersion&&l.isInteger(e.irVersion.low)&&l.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 u=0;u<e.opsetImport.length;++u){var i=c.onnx.OperatorSetIdProto.verify(e.opsetImport[u]);if(i)return"opsetImport."+i}}if(e.producerName!=null&&e.hasOwnProperty("producerName")&&!l.isString(e.producerName))return"producerName: string expected";if(e.producerVersion!=null&&e.hasOwnProperty("producerVersion")&&!l.isString(e.producerVersion))return"producerVersion: string expected";if(e.domain!=null&&e.hasOwnProperty("domain")&&!l.isString(e.domain))return"domain: string expected";if(e.modelVersion!=null&&e.hasOwnProperty("modelVersion")&&!l.isInteger(e.modelVersion)&&!(e.modelVersion&&l.isInteger(e.modelVersion.low)&&l.isInteger(e.modelVersion.high)))return"modelVersion: integer|Long expected";if(e.docString!=null&&e.hasOwnProperty("docString")&&!l.isString(e.docString))return"docString: string expected";if(e.graph!=null&&e.hasOwnProperty("graph")){var i=c.onnx.GraphProto.verify(e.graph);if(i)return"graph."+i}if(e.metadataProps!=null&&e.hasOwnProperty("metadataProps")){if(!Array.isArray(e.metadataProps))return"metadataProps: array expected";for(var u=0;u<e.metadataProps.length;++u){var i=c.onnx.StringStringEntryProto.verify(e.metadataProps[u]);if(i)return"metadataProps."+i}}if(e.trainingInfo!=null&&e.hasOwnProperty("trainingInfo")){if(!Array.isArray(e.trainingInfo))return"trainingInfo: array expected";for(var u=0;u<e.trainingInfo.length;++u){var i=c.onnx.TrainingInfoProto.verify(e.trainingInfo[u]);if(i)return"trainingInfo."+i}}if(e.functions!=null&&e.hasOwnProperty("functions")){if(!Array.isArray(e.functions))return"functions: array expected";for(var u=0;u<e.functions.length;++u){var i=c.onnx.FunctionProto.verify(e.functions[u]);if(i)return"functions."+i}}return null},a.fromObject=function(e){if(e instanceof c.onnx.ModelProto)return e;var u=new c.onnx.ModelProto;if(e.irVersion!=null&&(l.Long?(u.irVersion=l.Long.fromValue(e.irVersion)).unsigned=!1:typeof e.irVersion=="string"?u.irVersion=parseInt(e.irVersion,10):typeof e.irVersion=="number"?u.irVersion=e.irVersion:typeof e.irVersion=="object"&&(u.irVersion=new l.LongBits(e.irVersion.low>>>0,e.irVersion.high>>>0).toNumber())),e.opsetImport){if(!Array.isArray(e.opsetImport))throw TypeError(".onnx.ModelProto.opsetImport: array expected");u.opsetImport=[];for(var i=0;i<e.opsetImport.length;++i){if(typeof e.opsetImport[i]!="object")throw TypeError(".onnx.ModelProto.opsetImport: object expected");u.opsetImport[i]=c.onnx.OperatorSetIdProto.fromObject(e.opsetImport[i])}}if(e.producerName!=null&&(u.producerName=String(e.producerName)),e.producerVersion!=null&&(u.producerVersion=String(e.producerVersion)),e.domain!=null&&(u.domain=String(e.domain)),e.modelVersion!=null&&(l.Long?(u.modelVersion=l.Long.fromValue(e.modelVersion)).unsigned=!1:typeof e.modelVersion=="string"?u.modelVersion=parseInt(e.modelVersion,10):typeof e.modelVersion=="number"?u.modelVersion=e.modelVersion:typeof e.modelVersion=="object"&&(u.modelVersion=new l.LongBits(e.modelVersion.low>>>0,e.modelVersion.high>>>0).toNumber())),e.docString!=null&&(u.docString=String(e.docString)),e.graph!=null){if(typeof e.graph!="object")throw TypeError(".onnx.ModelProto.graph: object expected");u.graph=c.onnx.GraphProto.fromObject(e.graph)}if(e.metadataProps){if(!Array.isArray(e.metadataProps))throw TypeError(".onnx.ModelProto.metadataProps: array expected");u.metadataProps=[];for(var i=0;i<e.metadataProps.length;++i){if(typeof e.metadataProps[i]!="object")throw TypeError(".onnx.ModelProto.metadataProps: object expected");u.metadataProps[i]=c.onnx.StringStringEntryProto.fromObject(e.metadataProps[i])}}if(e.trainingInfo){if(!Array.isArray(e.trainingInfo))throw TypeError(".onnx.ModelProto.trainingInfo: array expected");u.trainingInfo=[];for(var i=0;i<e.trainingInfo.length;++i){if(typeof e.trainingInfo[i]!="object")throw TypeError(".onnx.ModelProto.trainingInfo: object expected");u.trainingInfo[i]=c.onnx.TrainingInfoProto.fromObject(e.trainingInfo[i])}}if(e.functions){if(!Array.isArray(e.functions))throw TypeError(".onnx.ModelProto.functions: array expected");u.functions=[];for(var i=0;i<e.functions.length;++i){if(typeof e.functions[i]!="object")throw TypeError(".onnx.ModelProto.functions: object expected");u.functions[i]=c.onnx.FunctionProto.fromObject(e.functions[i])}}return u},a.toObject=function(e,u){u||(u={});var i={};if((u.arrays||u.defaults)&&(i.opsetImport=[],i.metadataProps=[],i.trainingInfo=[],i.functions=[]),u.defaults){if(l.Long){var d=new l.Long(0,0,!1);i.irVersion=u.longs===String?d.toString():u.longs===Number?d.toNumber():d}else i.irVersion=u.longs===String?"0":0;if(i.producerName="",i.producerVersion="",i.domain="",l.Long){var d=new l.Long(0,0,!1);i.modelVersion=u.longs===String?d.toString():u.longs===Number?d.toNumber():d}else i.modelVersion=u.longs===String?"0":0;i.docString="",i.graph=null}if(e.irVersion!=null&&e.hasOwnProperty("irVersion")&&(typeof e.irVersion=="number"?i.irVersion=u.longs===String?String(e.irVersion):e.irVersion:i.irVersion=u.longs===String?l.Long.prototype.toString.call(e.irVersion):u.longs===Number?new l.LongBits(e.irVersion.low>>>0,e.irVersion.high>>>0).toNumber():e.irVersion),e.producerName!=null&&e.hasOwnProperty("producerName")&&(i.producerName=e.producerName),e.producerVersion!=null&&e.hasOwnProperty("producerVersion")&&(i.producerVersion=e.producerVersion),e.domain!=null&&e.hasOwnProperty("domain")&&(i.domain=e.domain),e.modelVersion!=null&&e.hasOwnProperty("modelVersion")&&(typeof e.modelVersion=="number"?i.modelVersion=u.longs===String?String(e.modelVersion):e.modelVersion:i.modelVersion=u.longs===String?l.Long.prototype.toString.call(e.modelVersion):u.longs===Number?new l.LongBits(e.modelVersion.low>>>0,e.modelVersion.high>>>0).toNumber():e.modelVersion),e.docString!=null&&e.hasOwnProperty("docString")&&(i.docString=e.docString),e.graph!=null&&e.hasOwnProperty("graph")&&(i.graph=c.onnx.GraphProto.toObject(e.graph,u)),e.opsetImport&&e.opsetImport.length){i.opsetImport=[];for(var h=0;h<e.opsetImport.length;++h)i.opsetImport[h]=c.onnx.OperatorSetIdProto.toObject(e.opsetImport[h],u)}if(e.metadataProps&&e.metadataProps.length){i.metadataProps=[];for(var h=0;h<e.metadataProps.length;++h)i.metadataProps[h]=c.onnx.StringStringEntryProto.toObject(e.metadataProps[h],u)}if(e.trainingInfo&&e.trainingInfo.length){i.trainingInfo=[];for(var h=0;h<e.trainingInfo.length;++h)i.trainingInfo[h]=c.onnx.TrainingInfoProto.toObject(e.trainingInfo[h],u)}if(e.functions&&e.functions.length){i.functions=[];for(var h=0;h<e.functions.length;++h)i.functions[h]=c.onnx.FunctionProto.toObject(e.functions[h],u)}return i},a.prototype.toJSON=function(){return this.constructor.toObject(this,n.util.toJSONOptions)},a.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/onnx.ModelProto"},a}(),o.StringStringEntryProto=function(){function a(e){if(e)for(var u=Object.keys(e),i=0;i<u.length;++i)e[u[i]]!=null&&(this[u[i]]=e[u[i]])}return a.prototype.key="",a.prototype.value="",a.create=function(e){return new a(e)},a.encode=function(e,u){return u||(u=p.create()),e.key!=null&&Object.hasOwnProperty.call(e,"key")&&u.uint32(10).string(e.key),e.value!=null&&Object.hasOwnProperty.call(e,"value")&&u.uint32(18).string(e.value),u},a.encodeDelimited=function(e,u){return this.encode(e,u).ldelim()},a.decode=function(e,u){e instanceof s||(e=s.create(e));for(var i=u===void 0?e.len:e.pos+u,d=new c.onnx.StringStringEntryProto;e.pos<i;){var h=e.uint32();switch(h>>>3){case 1:{d.key=e.string();break}case 2:{d.value=e.string();break}default:e.skipType(h&7);break}}return d},a.decodeDelimited=function(e){return e instanceof s||(e=new s(e)),this.decode(e,e.uint32())},a.verify=function(e){return typeof e!="object"||e===null?"object expected":e.key!=null&&e.hasOwnProperty("key")&&!l.isString(e.key)?"key: string expected":e.value!=null&&e.hasOwnProperty("value")&&!l.isString(e.value)?"value: string expected":null},a.fromObject=function(e){if(e instanceof c.onnx.StringStringEntryProto)return e;var u=new c.onnx.StringStringEntryProto;return e.key!=null&&(u.key=String(e.key)),e.value!=null&&(u.value=String(e.value)),u},a.toObject=function(e,u){u||(u={});var i={};return u.defaults&&(i.key="",i.value=""),e.key!=null&&e.hasOwnProperty("key")&&(i.key=e.key),e.value!=null&&e.hasOwnProperty("value")&&(i.value=e.value),i},a.prototype.toJSON=function(){return this.constructor.toObject(this,n.util.toJSONOptions)},a.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/onnx.StringStringEntryProto"},a}(),o.TensorAnnotation=function(){function a(e){if(this.quantParameterTensorNames=[],e)for(var u=Object.keys(e),i=0;i<u.length;++i)e[u[i]]!=null&&(this[u[i]]=e[u[i]])}return a.prototype.tensorName="",a.prototype.quantParameterTensorNames=l.emptyArray,a.create=function(e){return new a(e)},a.encode=function(e,u){if(u||(u=p.create()),e.tensorName!=null&&Object.hasOwnProperty.call(e,"tensorName")&&u.uint32(10).string(e.tensorName),e.quantParameterTensorNames!=null&&e.quantParameterTensorNames.length)for(var i=0;i<e.quantParameterTensorNames.length;++i)c.onnx.StringStringEntryProto.encode(e.quantParameterTensorNames[i],u.uint32(18).fork()).ldelim();return u},a.encodeDelimited=function(e,u){return this.encode(e,u).ldelim()},a.decode=function(e,u){e instanceof s||(e=s.create(e));for(var i=u===void 0?e.len:e.pos+u,d=new c.onnx.TensorAnnotation;e.pos<i;){var h=e.uint32();switch(h>>>3){case 1:{d.tensorName=e.string();break}case 2:{d.quantParameterTensorNames&&d.quantParameterTensorNames.length||(d.quantParameterTensorNames=[]),d.quantParameterTensorNames.push(c.onnx.StringStringEntryProto.decode(e,e.uint32()));break}default:e.skipType(h&7);break}}return d},a.decodeDelimited=function(e){return e instanceof s||(e=new s(e)),this.decode(e,e.uint32())},a.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.tensorName!=null&&e.hasOwnProperty("tensorName")&&!l.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 u=0;u<e.quantParameterTensorNames.length;++u){var i=c.onnx.StringStringEntryProto.verify(e.quantParameterTensorNames[u]);if(i)return"quantParameterTensorNames."+i}}return null},a.fromObject=function(e){if(e instanceof c.onnx.TensorAnnotation)return e;var u=new c.onnx.TensorAnnotation;if(e.tensorName!=null&&(u.tensorName=String(e.tensorName)),e.quantParameterTensorNames){if(!Array.isArray(e.quantParameterTensorNames))throw TypeError(".onnx.TensorAnnotation.quantParameterTensorNames: array expected");u.quantParameterTensorNames=[];for(var i=0;i<e.quantParameterTensorNames.length;++i){if(typeof e.quantParameterTensorNames[i]!="object")throw TypeError(".onnx.TensorAnnotation.quantParameterTensorNames: object expected");u.quantParameterTensorNames[i]=c.onnx.StringStringEntryProto.fromObject(e.quantParameterTensorNames[i])}}return u},a.toObject=function(e,u){u||(u={});var i={};if((u.arrays||u.defaults)&&(i.quantParameterTensorNames=[]),u.defaults&&(i.tensorName=""),e.tensorName!=null&&e.hasOwnProperty("tensorName")&&(i.tensorName=e.tensorName),e.quantParameterTensorNames&&e.quantParameterTensorNames.length){i.quantParameterTensorNames=[];for(var d=0;d<e.quantParameterTensorNames.length;++d)i.quantParameterTensorNames[d]=c.onnx.StringStringEntryProto.toObject(e.quantParameterTensorNames[d],u)}return i},a.prototype.toJSON=function(){return this.constructor.toObject(this,n.util.toJSONOptions)},a.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/onnx.TensorAnnotation"},a}(),o.GraphProto=function(){function a(e){if(this.node=[],this.initializer=[],this.sparseInitializer=[],this.input=[],this.output=[],this.valueInfo=[],this.quantizationAnnotation=[],e)for(var u=Object.keys(e),i=0;i<u.length;++i)e[u[i]]!=null&&(this[u[i]]=e[u[i]])}return a.prototype.node=l.emptyArray,a.prototype.name="",a.prototype.initializer=l.emptyArray,a.prototype.sparseInitializer=l.emptyArray,a.prototype.docString="",a.prototype.input=l.emptyArray,a.prototype.output=l.emptyArray,a.prototype.valueInfo=l.emptyArray,a.prototype.quantizationAnnotation=l.emptyArray,a.create=function(e){return new a(e)},a.encode=function(e,u){if(u||(u=p.create()),e.node!=null&&e.node.length)for(var i=0;i<e.node.length;++i)c.onnx.NodeProto.encode(e.node[i],u.uint32(10).fork()).ldelim();if(e.name!=null&&Object.hasOwnProperty.call(e,"name")&&u.uint32(18).string(e.name),e.initializer!=null&&e.initializer.length)for(var i=0;i<e.initializer.length;++i)c.onnx.TensorProto.encode(e.initializer[i],u.uint32(42).fork()).ldelim();if(e.docString!=null&&Object.hasOwnProperty.call(e,"docString")&&u.uint32(82).string(e.docString),e.input!=null&&e.input.length)for(var i=0;i<e.input.length;++i)c.onnx.ValueInfoProto.encode(e.input[i],u.uint32(90).fork()).ldelim();if(e.output!=null&&e.output.length)for(var i=0;i<e.output.length;++i)c.onnx.ValueInfoProto.encode(e.output[i],u.uint32(98).fork()).ldelim();if(e.valueInfo!=null&&e.valueInfo.length)for(var i=0;i<e.valueInfo.length;++i)c.onnx.ValueInfoProto.encode(e.valueInfo[i],u.uint32(106).fork()).ldelim();if(e.quantizationAnnotation!=null&&e.quantizationAnnotation.length)for(var i=0;i<e.quantizationAnnotation.length;++i)c.onnx.TensorAnnotation.encode(e.quantizationAnnotation[i],u.uint32(114).fork()).ldelim();if(e.sparseInitializer!=null&&e.sparseInitializer.length)for(var i=0;i<e.sparseInitializer.length;++i)c.onnx.SparseTensorProto.encode(e.sparseInitializer[i],u.uint32(122).fork()).ldelim();return u},a.encodeDelimited=function(e,u){return this.encode(e,u).ldelim()},a.decode=function(e,u){e instanceof s||(e=s.create(e));for(var i=u===void 0?e.len:e.pos+u,d=new c.onnx.GraphProto;e.pos<i;){var h=e.uint32();switch(h>>>3){case 1:{d.node&&d.node.length||(d.node=[]),d.node.push(c.onnx.NodeProto.decode(e,e.uint32()));break}case 2:{d.name=e.string();break}case 5:{d.initializer&&d.initializer.length||(d.initializer=[]),d.initializer.push(c.onnx.TensorProto.decode(e,e.uint32()));break}case 15:{d.sparseInitializer&&d.sparseInitializer.length||(d.sparseInitializer=[]),d.sparseInitializer.push(c.onnx.SparseTensorProto.decode(e,e.uint32()));break}case 10:{d.docString=e.string();break}case 11:{d.input&&d.input.length||(d.input=[]),d.input.push(c.onnx.ValueInfoProto.decode(e,e.uint32()));break}case 12:{d.output&&d.output.length||(d.output=[]),d.output.push(c.onnx.ValueInfoProto.decode(e,e.uint32()));break}case 13:{d.valueInfo&&d.valueInfo.length||(d.valueInfo=[]),d.valueInfo.push(c.onnx.ValueInfoProto.decode(e,e.uint32()));break}case 14:{d.quantizationAnnotation&&d.quantizationAnnotation.length||(d.quantizationAnnotation=[]),d.quantizationAnnotation.push(c.onnx.TensorAnnotation.decode(e,e.uint32()));break}default:e.skipType(h&7);break}}return d},a.decodeDelimited=function(e){return e instanceof s||(e=new s(e)),this.decode(e,e.uint32())},a.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 u=0;u<e.node.length;++u){var i=c.onnx.NodeProto.verify(e.node[u]);if(i)return"node."+i}}if(e.name!=null&&e.hasOwnProperty("name")&&!l.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 u=0;u<e.initializer.length;++u){var i=c.onnx.TensorProto.verify(e.initializer[u]);if(i)return"initializer."+i}}if(e.sparseInitializer!=null&&e.hasOwnProperty("sparseInitializer")){if(!Array.isArray(e.sparseInitializer))return"sparseInitializer: array expected";for(var u=0;u<e.sparseInitializer.length;++u){var i=c.onnx.SparseTensorProto.verify(e.sparseInitializer[u]);if(i)return"sparseInitializer."+i}}if(e.docString!=null&&e.hasOwnProperty("docString")&&!l.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 u=0;u<e.input.length;++u){var i=c.onnx.ValueInfoProto.verify(e.input[u]);if(i)return"input."+i}}if(e.output!=null&&e.hasOwnProperty("output")){if(!Array.isArray(e.output))return"output: array expected";for(var u=0;u<e.output.length;++u){var i=c.onnx.ValueInfoProto.verify(e.output[u]);if(i)return"output."+i}}if(e.valueInfo!=null&&e.hasOwnProperty("valueInfo")){if(!Array.isArray(e.valueInfo))return"valueInfo: array expected";for(var u=0;u<e.valueInfo.length;++u){var i=c.onnx.ValueInfoProto.verify(e.valueInfo[u]);if(i)return"valueInfo."+i}}if(e.quantizationAnnotation!=null&&e.hasOwnProperty("quantizationAnnotation")){if(!Array.isArray(e.quantizationAnnotation))return"quantizationAnnotation: array expected";for(var u=0;u<e.quantizationAnnotation.length;++u){var i=c.onnx.TensorAnnotation.verify(e.quantizationAnnotation[u]);if(i)return"quantizationAnnotation."+i}}return null},a.fromObject=function(e){if(e instanceof c.onnx.GraphProto)return e;var u=new c.onnx.GraphProto;if(e.node){if(!Array.isArray(e.node))throw TypeError(".onnx.GraphProto.node: array expected");u.node=[];for(var i=0;i<e.node.length;++i){if(typeof e.node[i]!="object")throw TypeError(".onnx.GraphProto.node: object expected");u.node[i]=c.onnx.NodeProto.fromObject(e.node[i])}}if(e.name!=null&&(u.name=String(e.name)),e.initializer){if(!Array.isArray(e.initializer))throw TypeError(".onnx.GraphProto.initializer: array expected");u.initializer=[];for(var i=0;i<e.initializer.length;++i){if(typeof e.initializer[i]!="object")throw TypeError(".onnx.GraphProto.initializer: object expected");u.initializer[i]=c.onnx.TensorProto.fromObject(e.initializer[i])}}if(e.sparseInitializer){if(!Array.isArray(e.sparseInitializer))throw TypeError(".onnx.GraphProto.sparseInitializer: array expected");u.sparseInitializer=[];for(var i=0;i<e.sparseInitializer.length;++i){if(typeof e.sparseInitializer[i]!="object")throw TypeError(".onnx.GraphProto.sparseInitializer: object expected");u.sparseInitializer[i]=c.onnx.SparseTensorProto.fromObject(e.sparseInitializer[i])}}if(e.docString!=null&&(u.docString=String(e.docString)),e.input){if(!Array.isArray(e.input))throw TypeError(".onnx.GraphProto.input: array expected");u.input=[];for(var i=0;i<e.input.length;++i){if(typeof e.input[i]!="object")throw TypeError(".onnx.GraphProto.input: object expected");u.input[i]=c.onnx.ValueInfoProto.fromObject(e.input[i])}}if(e.output){if(!Array.isArray(e.output))throw TypeError(".onnx.GraphProto.output: array expected");u.output=[];for(var i=0;i<e.output.length;++i){if(typeof e.output[i]!="object")throw TypeError(".onnx.GraphProto.output: object expected");u.output[i]=c.onnx.ValueInfoProto.fromObject(e.output[i])}}if(e.valueInfo){if(!Array.isArray(e.valueInfo))throw TypeError(".onnx.GraphProto.valueInfo: array expected");u.valueInfo=[];for(var i=0;i<e.valueInfo.length;++i){if(typeof e.valueInfo[i]!="object")throw TypeError(".onnx.GraphProto.valueInfo: object expected");u.valueInfo[i]=c.onnx.ValueInfoProto.fromObject(e.valueInfo[i])}}if(e.quantizationAnnotation){if(!Array.isArray(e.quantizationAnnotation))throw TypeError(".onnx.GraphProto.quantizationAnnotation: array expected");u.quantizationAnnotation=[];for(var i=0;i<e.quantizationAnnotation.length;++i){if(typeof e.quantizationAnnotation[i]!="object")throw TypeError(".onnx.GraphProto.quantizationAnnotation: object expected");u.quantizationAnnotation[i]=c.onnx.TensorAnnotation.fromObject(e.quantizationAnnotation[i])}}return u},a.toObject=function(e,u){u||(u={});var i={};if((u.arrays||u.defaults)&&(i.node=[],i.initializer=[],i.input=[],i.output=[],i.valueInfo=[],i.quantizationAnnotation=[],i.sparseInitializer=[]),u.defaults&&(i.name="",i.docString=""),e.node&&e.node.length){i.node=[];for(var d=0;d<e.node.length;++d)i.node[d]=c.onnx.NodeProto.toObject(e.node[d],u)}if(e.name!=null&&e.hasOwnProperty("name")&&(i.name=e.name),e.initializer&&e.initializer.length){i.initializer=[];for(var d=0;d<e.initializer.length;++d)i.initializer[d]=c.onnx.TensorProto.toObject(e.initializer[d],u)}if(e.docString!=null&&e.hasOwnProperty("docString")&&(i.docString=e.docString),e.input&&e.input.length){i.input=[];for(var d=0;d<e.input.length;++d)i.input[d]=c.onnx.ValueInfoProto.toObject(e.input[d],u)}if(e.output&&e.output.length){i.output=[];for(var d=0;d<e.output.length;++d)i.output[d]=c.onnx.ValueInfoProto.toObject(e.output[d],u)}if(e.valueInfo&&e.valueInfo.length){i.valueInfo=[];for(var d=0;d<e.valueInfo.length;++d)i.valueInfo[d]=c.onnx.ValueInfoProto.toObject(e.valueInfo[d],u)}if(e.quantizationAnnotation&&e.quantizationAnnotation.length){i.quantizationAnnotation=[];for(var d=0;d<e.quantizationAnnotation.length;++d)i.quantizationAnnotation[d]=c.onnx.TensorAnnotation.toObject(e.quantizationAnnotation[d],u)}if(e.sparseInitializer&&e.sparseInitializer.length){i.sparseInitializer=[];for(var d=0;d<e.sparseInitializer.length;++d)i.sparseInitializer[d]=c.onnx.SparseTensorProto.toObject(e.sparseInitializer[d],u)}return i},a.prototype.toJSON=function(){return this.constructor.toObject(this,n.util.toJSONOptions)},a.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/onnx.GraphProto"},a}(),o.TensorProto=function(){function a(e){if(this.dims=[],this.floatData=[],this.int32Data=[],this.stringData=[],this.int64Data=[],this.externalData=[],this.doubleData=[],this.uint64Data=[],e)for(var u=Object.keys(e),i=0;i<u.length;++i)e[u[i]]!=null&&(this[u[i]]=e[u[i]])}return a.prototype.dims=l.emptyArray,a.prototype.dataType=0,a.prototype.segment=null,a.prototype.floatData=l.emptyArray,a.prototype.int32Data=l.emptyArray,a.prototype.stringData=l.emptyArray,a.prototype.int64Data=l.emptyArray,a.prototype.name="",a.prototype.docString="",a.prototype.rawData=l.newBuffer([]),a.prototype.externalData=l.emptyArray,a.prototype.dataLocation=0,a.prototype.doubleData=l.emptyArray,a.prototype.uint64Data=l.emptyArray,a.create=function(e){return new a(e)},a.encode=function(e,u){if(u||(u=p.create()),e.dims!=null&&e.dims.length){u.uint32(10).fork();for(var i=0;i<e.dims.length;++i)u.int64(e.dims[i]);u.ldelim()}if(e.dataType!=null&&Object.hasOwnProperty.call(e,"dataType")&&u.uint32(16).int32(e.dataType),e.segment!=null&&Object.hasOwnProperty.call(e,"segment")&&c.onnx.TensorProto.Segment.encode(e.segment,u.uint32(26).fork()).ldelim(),e.floatData!=null&&e.floatData.length){u.uint32(34).fork();for(var i=0;i<e.floatData.length;++i)u.float(e.floatData[i]);u.ldelim()}if(e.int32Data!=null&&e.int32Data.length){u.uint32(42).fork();for(var i=0;i<e.int32Data.length;++i)u.int32(e.int32Data[i]);u.ldelim()}if(e.stringData!=null&&e.stringData.length)for(var i=0;i<e.stringData.length;++i)u.uint32(50).bytes(e.stringData[i]);if(e.int64Data!=null&&e.int64Data.length){u.uint32(58).fork();for(var i=0;i<e.int64Data.length;++i)u.int64(e.int64Data[i]);u.ldelim()}if(e.name!=null&&Object.hasOwnProperty.call(e,"name")&&u.uint32(66).string(e.name),e.rawData!=null&&Object.hasOwnProperty.call(e,"rawData")&&u.uint32(74).bytes(e.rawData),e.doubleData!=null&&e.doubleData.length){u.uint32(82).fork();for(var i=0;i<e.doubleData.length;++i)u.double(e.doubleData[i]);u.ldelim()}if(e.uint64Data!=null&&e.uint64Data.length){u.uint32(90).fork();for(var i=0;i<e.uint64Data.length;++i)u.uint64(e.uint64Data[i]);u.ldelim()}if(e.docString!=null&&Object.hasOwnProperty.call(e,"docString")&&u.uint32(98).string(e.docString),e.externalData!=null&&e.externalData.length)for(var i=0;i<e.externalData.length;++i)c.onnx.StringStringEntryProto.encode(e.externalData[i],u.uint32(106).fork()).ldelim();return e.dataLocation!=null&&Object.hasOwnProperty.call(e,"dataLocation")&&u.uint32(112).int32(e.dataLocation),u},a.encodeDelimited=function(e,u){return this.encode(e,u).ldelim()},a.decode=function(e,u){e instanceof s||(e=s.create(e));for(var i=u===void 0?e.len:e.pos+u,d=new c.onnx.TensorProto;e.pos<i;){var h=e.uint32();switch(h>>>3){case 1:{if(d.dims&&d.dims.length||(d.dims=[]),(h&7)===2)for(var m=e.uint32()+e.pos;e.pos<m;)d.dims.push(e.int64());else d.dims.push(e.int64());break}case 2:{d.dataType=e.int32();break}case 3:{d.segment=c.onnx.TensorProto.Segment.decode(e,e.uint32());break}case 4:{if(d.floatData&&d.floatData.length||(d.floatData=[]),(h&7)===2)for(var m=e.uint32()+e.pos;e.pos<m;)d.floatData.push(e.float());else d.floatData.push(e.float());break}case 5:{if(d.int32Data&&d.int32Data.length||(d.int32Data=[]),(h&7)===2)for(var m=e.uint32()+e.pos;e.pos<m;)d.int32Data.push(e.int32());else d.int32Data.push(e.int32());break}case 6:{d.stringData&&d.stringData.length||(d.stringData=[]),d.stringData.push(e.bytes());break}case 7:{if(d.int64Data&&d.int64Data.length||(d.int64Data=[]),(h&7)===2)for(var m=e.uint32()+e.pos;e.pos<m;)d.int64Data.push(e.int64());else d.int64Data.push(e.int64());break}case 8:{d.name=e.string();break}case 12:{d.docString=e.string();break}case 9:{d.rawData=e.bytes();break}case 13:{d.externalData&&d.externalData.length||(d.externalData=[]),d.externalData.push(c.onnx.StringStringEntryProto.decode(e,e.uint32()));break}case 14:{d.dataLocation=e.int32();break}case 10:{if(d.doubleData&&d.doubleData.length||(d.doubleData=[]),(h&7)===2)for(var m=e.uint32()+e.pos;e.pos<m;)d.doubleData.push(e.double());else d.doubleData.push(e.double());break}case 11:{if(d.uint64Data&&d.uint64Data.length||(d.uint64Data=[]),(h&7)===2)for(var m=e.uint32()+e.pos;e.pos<m;)d.uint64Data.push(e.uint64());else d.uint64Data.push(e.uint64());break}default:e.skipType(h&7);break}}return d},a.decodeDelimited=function(e){return e instanceof s||(e=new s(e)),this.decode(e,e.uint32())},a.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 u=0;u<e.dims.length;++u)if(!l.isInteger(e.dims[u])&&!(e.dims[u]&&l.isInteger(e.dims[u].low)&&l.isInteger(e.dims[u].high)))return"dims: integer|Long[] expected"}if(e.dataType!=null&&e.hasOwnProperty("dataType")&&!l.isInteger(e.dataType))return"dataType: integer expected";if(e.segment!=null&&e.hasOwnProperty("segment")){var i=c.onnx.TensorProto.Segment.verify(e.segment);if(i)return"segment."+i}if(e.floatData!=null&&e.hasOwnProperty("floatData")){if(!Array.isArray(e.floatData))return"floatData: array expected";for(var u=0;u<e.floatData.length;++u)if(typeof e.floatData[u]!="number")return"floatData: number[] expected"}if(e.int32Data!=null&&e.hasOwnProperty("int32Data")){if(!Array.isArray(e.int32Data))return"int32Data: array expected";for(var u=0;u<e.int32Data.length;++u)if(!l.isInteger(e.int32Data[u]))return"int32Data: integer[] expected"}if(e.stringData!=null&&e.hasOwnProperty("stringData")){if(!Array.isArray(e.stringData))return"stringData: array expected";for(var u=0;u<e.stringData.length;++u)if(!(e.stringData[u]&&typeof e.stringData[u].length=="number"||l.isString(e.stringData[u])))return"stringData: buffer[] expected"}if(e.int64Data!=null&&e.hasOwnProperty("int64Data")){if(!Array.isArray(e.int64Data))return"int64Data: array expected";for(var u=0;u<e.int64Data.length;++u)if(!l.isInteger(e.int64Data[u])&&!(e.int64Data[u]&&l.isInteger(e.int64Data[u].low)&&l.isInteger(e.int64Data[u].high)))return"int64Data: integer|Long[] expected"}if(e.name!=null&&e.hasOwnProperty("name")&&!l.isString(e.name))return"name: string expected";if(e.docString!=null&&e.hasOwnProperty("docString")&&!l.isString(e.docString))return"docString: string expected";if(e.rawData!=null&&e.hasOwnProperty("rawData")&&!(e.rawData&&typeof e.rawData.length=="number"||l.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 u=0;u<e.externalData.length;++u){var i=c.onnx.StringStringEntryProto.verify(e.externalData[u]);if(i)return"externalData."+i}}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 u=0;u<e.doubleData.length;++u)if(typeof e.doubleData[u]!="number")return"doubleData: number[] expected"}if(e.uint64Data!=null&&e.hasOwnProperty("uint64Data")){if(!Array.isArray(e.uint64Data))return"uint64Data: array expected";for(var u=0;u<e.uint64Data.length;++u)if(!l.isInteger(e.uint64Data[u])&&!(e.uint64Data[u]&&l.isInteger(e.uint64Data[u].low)&&l.isInteger(e.uint64Data[u].high)))return"uint64Data: integer|Long[] expected"}return null},a.fromObject=function(e){if(e instanceof c.onnx.TensorProto)return e;var u=new c.onnx.TensorProto;if(e.dims){if(!Array.isArray(e.dims))throw TypeError(".onnx.TensorProto.dims: array expected");u.dims=[];for(var i=0;i<e.dims.length;++i)l.Long?(u.dims[i]=l.Long.fromValue(e.dims[i])).unsigned=!1:typeof e.dims[i]=="string"?u.dims[i]=parseInt(e.dims[i],10):typeof e.dims[i]=="number"?u.dims[i]=e.dims[i]:typeof e.dims[i]=="object"&&(u.dims[i]=new l.LongBits(e.dims[i].low>>>0,e.dims[i].high>>>0).toNumber())}if(e.dataType!=null&&(u.dataType=e.dataType|0),e.segment!=null){if(typeof e.segment!="object")throw TypeError(".onnx.TensorProto.segment: object expected");u.segment=c.onnx.TensorProto.Segment.fromObject(e.segment)}if(e.floatData){if(!Array.isArray(e.floatData))throw TypeError(".onnx.TensorProto.floatData: array expected");u.floatData=[];for(var i=0;i<e.floatData.length;++i)u.floatData[i]=Number(e.floatData[i])}if(e.int32Data){if(!Array.isArray(e.int32Data))throw TypeError(".onnx.TensorProto.int32Data: array expected");u.int32Data=[];for(var i=0;i<e.int32Data.length;++i)u.int32Data[i]=e.int32Data[i]|0}if(e.stringData){if(!Array.isArray(e.stringData))throw TypeError(".onnx.TensorProto.stringData: array expected");u.stringData=[];for(var i=0;i<e.stringData.length;++i)typeof e.stringData[i]=="string"?l.base64.decode(e.stringData[i],u.stringData[i]=l.newBuffer(l.base64.length(e.stringData[i])),0):e.stringData[i].length>=0&&(u.stringData[i]=e.stringData[i])}if(e.int64Data){if(!Array.isArray(e.int64Data))throw TypeError(".onnx.TensorProto.int64Data: array expected");u.int64Data=[];for(var i=0;i<e.int64Data.length;++i)l.Long?(u.int64Data[i]=l.Long.fromValue(e.int64Data[i])).unsigned=!1:typeof e.int64Data[i]=="string"?u.int64Data[i]=parseInt(e.int64Data[i],10):typeof e.int64Data[i]=="number"?u.int64Data[i]=e.int64Data[i]:typeof e.int64Data[i]=="object"&&(u.int64Data[i]=new l.LongBits(e.int64Data[i].low>>>0,e.int64Data[i].high>>>0).toNumber())}if(e.name!=null&&(u.name=String(e.name)),e.docString!=null&&(u.docString=String(e.docString)),e.rawData!=null&&(typeof e.rawData=="string"?l.base64.decode(e.rawData,u.rawData=l.newBuffer(l.base64.length(e.rawData)),0):e.rawData.length>=0&&(u.rawData=e.rawData)),e.externalData){if(!Array.isArray(e.externalData))throw TypeError(".onnx.TensorProto.externalData: array expected");u.externalData=[];for(var i=0;i<e.externalData.length;++i){if(typeof e.externalData[i]!="object")throw TypeError(".onnx.TensorProto.externalData: object expected");u.externalData[i]=c.onnx.StringStringEntryProto.fromObject(e.externalData[i])}}switch(e.dataLocation){default:if(typeof e.dataLocation=="number"){u.dataLocation=e.dataLocation;break}break;case"DEFAULT":case 0:u.dataLocation=0;break;case"EXTERNAL":case 1:u.dataLocation=1;break}if(e.doubleData){if(!Array.isArray(e.doubleData))throw TypeError(".onnx.TensorProto.doubleData: array expected");u.doubleData=[];for(var i=0;i<e.doubleData.length;++i)u.doubleData[i]=Number(e.doubleData[i])}if(e.uint64Data){if(!Array.isArray(e.uint64Data))throw TypeError(".onnx.TensorProto.uint64Data: array expected");u.uint64Data=[];for(var i=0;i<e.uint64Data.length;++i)l.Long?(u.uint64Data[i]=l.Long.fromValue(e.uint64Data[i])).unsigned=!0:typeof e.uint64Data[i]=="string"?u.uint64Data[i]=parseInt(e.uint64Data[i],10):typeof e.uint64Data[i]=="number"?u.uint64Data[i]=e.uint64Data[i]:typeof e.uint64Data[i]=="object"&&(u.uint64Data[i]=new l.LongBits(e.uint64Data[i].low>>>0,e.uint64Data[i].high>>>0).toNumber(!0))}return u},a.toObject=function(e,u){u||(u={});var i={};if((u.arrays||u.defaults)&&(i.dims=[],i.floatData=[],i.int32Data=[],i.stringData=[],i.int64Data=[],i.doubleData=[],i.uint64Data=[],i.externalData=[]),u.defaults&&(i.dataType=0,i.segment=null,i.name="",u.bytes===String?i.rawData="":(i.rawData=[],u.bytes!==Array&&(i.rawData=l.newBuffer(i.rawData))),i.docString="",i.dataLocation=u.enums===String?"DEFAULT":0),e.dims&&e.dims.length){i.dims=[];for(var d=0;d<e.dims.length;++d)typeof e.dims[d]=="number"?i.dims[d]=u.longs===String?String(e.dims[d]):e.dims[d]:i.dims[d]=u.longs===String?l.Long.prototype.toString.call(e.dims[d]):u.longs===Number?new l.LongBits(e.dims[d].low>>>0,e.dims[d].high>>>0).toNumber():e.dims[d]}if(e.dataType!=null&&e.hasOwnProperty("dataType")&&(i.dataType=e.dataType),e.segment!=null&&e.hasOwnProperty("segment")&&(i.segment=c.onnx.TensorProto.Segment.toObject(e.segment,u)),e.floatData&&e.floatData.length){i.floatData=[];for(var d=0;d<e.floatData.length;++d)i.floatData[d]=u.json&&!isFinite(e.floatData[d])?String(e.floatData[d]):e.floatData[d]}if(e.int32Data&&e.int32Data.length){i.int32Data=[];for(var d=0;d<e.int32Data.length;++d)i.int32Data[d]=e.int32Data[d]}if(e.stringData&&e.stringData.length){i.stringData=[];for(var d=0;d<e.stringData.length;++d)i.stringData[d]=u.bytes===String?l.base64.encode(e.stringData[d],0,e.stringData[d].length):u.bytes===Array?Array.prototype.slice.call(e.stringData[d]):e.stringData[d]}if(e.int64Data&&e.int64Data.length){i.int64Data=[];for(var d=0;d<e.int64Data.length;++d)typeof e.int64Data[d]=="number"?i.int64Data[d]=u.longs===String?String(e.int64Data[d]):e.int64Data[d]:i.int64Data[d]=u.longs===String?l.Long.prototype.toString.call(e.int64Data[d]):u.longs===Number?new l.LongBits(e.int64Data[d].low>>>0,e.int64Data[d].high>>>0).toNumber():e.int64Data[d]}if(e.name!=null&&e.hasOwnProperty("name")&&(i.name=e.name),e.rawData!=null&&e.hasOwnProperty("rawData")&&(i.rawData=u.bytes===String?l.base64.encode(e.rawData,0,e.rawData.length):u.bytes===Array?Array.prototype.slice.call(e.rawData):e.rawData),e.doubleData&&e.doubleData.length){i.doubleData=[];for(var d=0;d<e.doubleData.length;++d)i.doubleData[d]=u.json&&!isFinite(e.doubleData[d])?String(e.doubleData[d]):e.doubleData[d]}if(e.uint64Data&&e.uint64Data.length){i.uint64Data=[];for(var d=0;d<e.uint64Data.length;++d)typeof e.uint64Data[d]=="number"?i.uint64Data[d]=u.longs===String?String(e.uint64Data[d]):e.uint64Data[d]:i.uint64Data[d]=u.longs===String?l.Long.prototype.toString.call(e.uint64Data[d]):u.longs===Number?new l.LongBits(e.uint64Data[d].low>>>0,e.uint64Data[d].high>>>0).toNumber(!0):e.uint64Data[d]}if(e.docString!=null&&e.hasOwnProperty("docString")&&(i.docString=e.docString),e.externalData&&e.externalData.length){i.externalData=[];for(var d=0;d<e.externalData.length;++d)i.externalData[d]=c.onnx.StringStringEntryProto.toObject(e.externalData[d],u)}return e.dataLocation!=null&&e.hasOwnProperty("dataLocation")&&(i.dataLocation=u.enums===String?c.onnx.TensorProto.DataLocation[e.dataLocation]===void 0?e.dataLocation:c.onnx.TensorProto.DataLocation[e.dataLocation]:e.dataLocation),i},a.prototype.toJSON=function(){return this.constructor.toObject(this,n.util.toJSONOptions)},a.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/onnx.TensorProto"},a.DataType=function(){var e={},u=Object.create(e);return u[e[0]="UNDEFINED"]=0,u[e[1]="FLOAT"]=1,u[e[2]="UINT8"]=2,u[e[3]="INT8"]=3,u[e[4]="UINT16"]=4,u[e[5]="INT16"]=5,u[e[6]="INT32"]=6,u[e[7]="INT64"]=7,u[e[8]="STRING"]=8,u[e[9]="BOOL"]=9,u[e[10]="FLOAT16"]=10,u[e[11]="DOUBLE"]=11,u[e[12]="UINT32"]=12,u[e[13]="UINT64"]=13,u[e[14]="COMPLEX64"]=14,u[e[15]="COMPLEX128"]=15,u[e[16]="BFLOAT16"]=16,u[e[17]="FLOAT8E4M3FN"]=17,u[e[18]="FLOAT8E4M3FNUZ"]=18,u[e[19]="FLOAT8E5M2"]=19,u[e[20]="FLOAT8E5M2FNUZ"]=20,u}(),a.Segment=function(){function e(u){if(u)for(var i=Object.keys(u),d=0;d<i.length;++d)u[i[d]]!=null&&(this[i[d]]=u[i[d]])}return e.prototype.begin=l.Long?l.Long.fromBits(0,0,!1):0,e.prototype.end=l.Long?l.Long.fromBits(0,0,!1):0,e.create=function(u){return new e(u)},e.encode=function(u,i){return i||(i=p.create()),u.begin!=null&&Object.hasOwnProperty.call(u,"begin")&&i.uint32(8).int64(u.begin),u.end!=null&&Object.hasOwnProperty.call(u,"end")&&i.uint32(16).int64(u.end),i},e.encodeDelimited=function(u,i){return this.encode(u,i).ldelim()},e.decode=function(u,i){u instanceof s||(u=s.create(u));for(var d=i===void 0?u.len:u.pos+i,h=new c.onnx.TensorProto.Segment;u.pos<d;){var m=u.uint32();switch(m>>>3){case 1:{h.begin=u.int64();break}case 2:{h.end=u.int64();break}default:u.skipType(m&7);break}}return h},e.decodeDelimited=function(u){return u instanceof s||(u=new s(u)),this.decode(u,u.uint32())},e.verify=function(u){return typeof u!="object"||u===null?"object expected":u.begin!=null&&u.hasOwnProperty("begin")&&!l.isInteger(u.begin)&&!(u.begin&&l.isInteger(u.begin.low)&&l.isInteger(u.begin.high))?"begin: integer|Long expected":u.end!=null&&u.hasOwnProperty("end")&&!l.isInteger(u.end)&&!(u.end&&l.isInteger(u.end.low)&&l.isInteger(u.end.high))?"end: integer|Long expected":null},e.fromObject=function(u){if(u instanceof c.onnx.TensorProto.Segment)return u;var i=new c.onnx.TensorProto.Segment;return u.begin!=null&&(l.Long?(i.begin=l.Long.fromValue(u.begin)).unsigned=!1:typeof u.begin=="string"?i.begin=parseInt(u.begin,10):typeof u.begin=="number"?i.begin=u.begin:typeof u.begin=="object"&&(i.begin=new l.LongBits(u.begin.low>>>0,u.begin.high>>>0).toNumber())),u.end!=null&&(l.Long?(i.end=l.Long.fromValue(u.end)).unsigned=!1:typeof u.end=="string"?i.end=parseInt(u.end,10):typeof u.end=="number"?i.end=u.end:typeof u.end=="object"&&(i.end=new l.LongBits(u.end.low>>>0,u.end.high>>>0).toNumber())),i},e.toObject=function(u,i){i||(i={});var d={};if(i.defaults){if(l.Long){var h=new l.Long(0,0,!1);d.begin=i.longs===String?h.toString():i.longs===Number?h.toNumber():h}else d.begin=i.longs===String?"0":0;if(l.Long){var h=new l.Long(0,0,!1);d.end=i.longs===String?h.toString():i.longs===Number?h.toNumber():h}else d.end=i.longs===String?"0":0}return u.begin!=null&&u.hasOwnProperty("begin")&&(typeof u.begin=="number"?d.begin=i.longs===String?String(u.begin):u.begin:d.begin=i.longs===String?l.Long.prototype.toString.call(u.begin):i.longs===Number?new l.LongBits(u.begin.low>>>0,u.begin.high>>>0).toNumber():u.begin),u.end!=null&&u.hasOwnProperty("end")&&(typeof u.end=="number"?d.end=i.longs===String?String(u.end):u.end:d.end=i.longs===String?l.Long.prototype.toString.call(u.end):i.longs===Number?new l.LongBits(u.end.low>>>0,u.end.high>>>0).toNumber():u.end),d},e.prototype.toJSON=function(){return this.constructor.toObject(this,n.util.toJSONOptions)},e.getTypeUrl=function(u){return u===void 0&&(u="type.googleapis.com"),u+"/onnx.TensorProto.Segment"},e}(),a.DataLocation=function(){var e={},u=Object.create(e);return u[e[0]="DEFAULT"]=0,u[e[1]="EXTERNAL"]=1,u}(),a}(),o.SparseTensorProto=function(){function a(e){if(this.dims=[],e)for(var u=Object.keys(e),i=0;i<u.length;++i)e[u[i]]!=null&&(this[u[i]]=e[u[i]])}return a.prototype.values=null,a.prototype.indices=null,a.prototype.dims=l.emptyArray,a.create=function(e){return new a(e)},a.encode=function(e,u){if(u||(u=p.create()),e.values!=null&&Object.hasOwnProperty.call(e,"values")&&c.onnx.TensorProto.encode(e.values,u.uint32(10).fork()).ldelim(),e.indices!=null&&Object.hasOwnProperty.call(e,"indices")&&c.onnx.TensorProto.encode(e.indices,u.uint32(18).fork()).ldelim(),e.dims!=null&&e.dims.length){u.uint32(26).fork();for(var i=0;i<e.dims.length;++i)u.int64(e.dims[i]);u.ldelim()}return u},a.encodeDelimited=function(e,u){return this.encode(e,u).ldelim()},a.decode=function(e,u){e instanceof s||(e=s.create(e));for(var i=u===void 0?e.len:e.pos+u,d=new c.onnx.SparseTensorProto;e.pos<i;){var h=e.uint32();switch(h>>>3){case 1:{d.values=c.onnx.TensorProto.decode(e,e.uint32());break}case 2:{d.indices=c.onnx.TensorProto.decode(e,e.uint32());break}case 3:{if(d.dims&&d.dims.length||(d.dims=[]),(h&7)===2)for(var m=e.uint32()+e.pos;e.pos<m;)d.dims.push(e.int64());else d.dims.push(e.int64());break}default:e.skipType(h&7);break}}return d},a.decodeDelimited=function(e){return e instanceof s||(e=new s(e)),this.decode(e,e.uint32())},a.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.values!=null&&e.hasOwnProperty("values")){var u=c.onnx.TensorProto.verify(e.values);if(u)return"values."+u}if(e.indices!=null&&e.hasOwnProperty("indices")){var u=c.onnx.TensorProto.verify(e.indices);if(u)return"indices."+u}if(e.dims!=null&&e.hasOwnProperty("dims")){if(!Array.isArray(e.dims))return"dims: array expected";for(var i=0;i<e.dims.length;++i)if(!l.isInteger(e.dims[i])&&!(e.dims[i]&&l.isInteger(e.dims[i].low)&&l.isInteger(e.dims[i].high)))return"dims: integer|Long[] expected"}return null},a.fromObject=function(e){if(e instanceof c.onnx.SparseTensorProto)return e;var u=new c.onnx.SparseTensorProto;if(e.values!=null){if(typeof e.values!="object")throw TypeError(".onnx.SparseTensorProto.values: object expected");u.values=c.onnx.TensorProto.fromObject(e.values)}if(e.indices!=null){if(typeof e.indices!="object")throw TypeError(".onnx.SparseTensorProto.indices: object expected");u.indices=c.onnx.TensorProto.fromObject(e.indices)}if(e.dims){if(!Array.isArray(e.dims))throw TypeError(".onnx.SparseTensorProto.dims: array expected");u.dims=[];for(var i=0;i<e.dims.length;++i)l.Long?(u.dims[i]=l.Long.fromValue(e.dims[i])).unsigned=!1:typeof e.dims[i]=="string"?u.dims[i]=parseInt(e.dims[i],10):typeof e.dims[i]=="number"?u.dims[i]=e.dims[i]:typeof e.dims[i]=="object"&&(u.dims[i]=new l.LongBits(e.dims[i].low>>>0,e.dims[i].high>>>0).toNumber())}return u},a.toObject=function(e,u){u||(u={});var i={};if((u.arrays||u.defaults)&&(i.dims=[]),u.defaults&&(i.values=null,i.indices=null),e.values!=null&&e.hasOwnProperty("values")&&(i.values=c.onnx.TensorProto.toObject(e.values,u)),e.indices!=null&&e.hasOwnProperty("indices")&&(i.indices=c.onnx.TensorProto.toObject(e.indices,u)),e.dims&&e.dims.length){i.dims=[];for(var d=0;d<e.dims.length;++d)typeof e.dims[d]=="number"?i.dims[d]=u.longs===String?String(e.dims[d]):e.dims[d]:i.dims[d]=u.longs===String?l.Long.prototype.toString.call(e.dims[d]):u.longs===Number?new l.LongBits(e.dims[d].low>>>0,e.dims[d].high>>>0).toNumber():e.dims[d]}return i},a.prototype.toJSON=function(){return this.constructor.toObject(this,n.util.toJSONOptions)},a.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/onnx.SparseTensorProto"},a}(),o.TensorShapeProto=function(){function a(e){if(this.dim=[],e)for(var u=Object.keys(e),i=0;i<u.length;++i)e[u[i]]!=null&&(this[u[i]]=e[u[i]])}return a.prototype.dim=l.emptyArray,a.create=function(e){return new a(e)},a.encode=function(e,u){if(u||(u=p.create()),e.dim!=null&&e.dim.length)for(var i=0;i<e.dim.length;++i)c.onnx.TensorShapeProto.Dimension.encode(e.dim[i],u.uint32(10).fork()).ldelim();return u},a.encodeDelimited=function(e,u){return this.encode(e,u).ldelim()},a.decode=function(e,u){e instanceof s||(e=s.create(e));for(var i=u===void 0?e.len:e.pos+u,d=new c.onnx.TensorShapeProto;e.pos<i;){var h=e.uint32();switch(h>>>3){case 1:{d.dim&&d.dim.length||(d.dim=[]),d.dim.push(c.onnx.TensorShapeProto.Dimension.decode(e,e.uint32()));break}default:e.skipType(h&7);break}}return d},a.decodeDelimited=function(e){return e instanceof s||(e=new s(e)),this.decode(e,e.uint32())},a.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 u=0;u<e.dim.length;++u){var i=c.onnx.TensorShapeProto.Dimension.verify(e.dim[u]);if(i)return"dim."+i}}return null},a.fromObject=function(e){if(e instanceof c.onnx.TensorShapeProto)return e;var u=new c.onnx.TensorShapeProto;if(e.dim){if(!Array.isArray(e.dim))throw TypeError(".onnx.TensorShapeProto.dim: array expected");u.dim=[];for(var i=0;i<e.dim.length;++i){if(typeof e.dim[i]!="object")throw TypeError(".onnx.TensorShapeProto.dim: object expected");u.dim[i]=c.onnx.TensorShapeProto.Dimension.fromObject(e.dim[i])}}return u},a.toObject=function(e,u){u||(u={});var i={};if((u.arrays||u.defaults)&&(i.dim=[]),e.dim&&e.dim.length){i.dim=[];for(var d=0;d<e.dim.length;++d)i.dim[d]=c.onnx.TensorShapeProto.Dimension.toObject(e.dim[d],u)}return i},a.prototype.toJSON=function(){return this.constructor.toObject(this,n.util.toJSONOptions)},a.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/onnx.TensorShapeProto"},a.Dimension=function(){function e(i){if(i)for(var d=Object.keys(i),h=0;h<d.length;++h)i[d[h]]!=null&&(this[d[h]]=i[d[h]])}e.prototype.dimValue=null,e.prototype.dimParam=null,e.prototype.denotation="";var u;return Object.defineProperty(e.prototype,"value",{get:l.oneOfGetter(u=["dimValue","dimParam"]),set:l.oneOfSetter(u)}),e.create=function(i){return new e(i)},e.encode=function(i,d){return d||(d=p.create()),i.dimValue!=null&&Object.hasOwnProperty.call(i,"dimValue")&&d.uint32(8).int64(i.dimValue),i.dimParam!=null&&Object.hasOwnProperty.call(i,"dimParam")&&d.uint32(18).string(i.dimParam),i.denotation!=null&&Object.hasOwnProperty.call(i,"denotation")&&d.uint32(26).string(i.denotation),d},e.encodeDelimited=function(i,d){return this.encode(i,d).ldelim()},e.decode=function(i,d){i instanceof s||(i=s.create(i));for(var h=d===void 0?i.len:i.pos+d,m=new c.onnx.TensorShapeProto.Dimension;i.pos<h;){var b=i.uint32();switch(b>>>3){case 1:{m.dimValue=i.int64();break}case 2:{m.dimParam=i.string();break}case 3:{m.denotation=i.string();break}default:i.skipType(b&7);break}}return m},e.decodeDelimited=function(i){return i instanceof s||(i=new s(i)),this.decode(i,i.uint32())},e.verify=function(i){if(typeof i!="object"||i===null)return"object expected";var d={};if(i.dimValue!=null&&i.hasOwnProperty("dimValue")&&(d.value=1,!l.isInteger(i.dimValue)&&!(i.dimValue&&l.isInteger(i.dimValue.low)&&l.isInteger(i.dimValue.high))))return"dimValue: integer|Long expected";if(i.dimParam!=null&&i.hasOwnProperty("dimParam")){if(d.value===1)return"value: multiple values";if(d.value=1,!l.isString(i.dimParam))return"dimParam: string expected"}return i.denotation!=null&&i.hasOwnProperty("denotation")&&!l.isString(i.denotation)?"denotation: string expected":null},e.fromObject=function(i){if(i instanceof c.onnx.TensorShapeProto.Dimension)return i;var d=new c.onnx.TensorShapeProto.Dimension;return i.dimValue!=null&&(l.Long?(d.dimValue=l.Long.fromValue(i.dimValue)).unsigned=!1:typeof i.dimValue=="string"?d.dimValue=parseInt(i.dimValue,10):typeof i.dimValue=="number"?d.dimValue=i.dimValue:typeof i.dimValue=="object"&&(d.dimValue=new l.LongBits(i.dimValue.low>>>0,i.dimValue.high>>>0).toNumber())),i.dimParam!=null&&(d.dimParam=String(i.dimParam)),i.denotation!=null&&(d.denotation=String(i.denotation)),d},e.toObject=function(i,d){d||(d={});var h={};return d.defaults&&(h.denotation=""),i.dimValue!=null&&i.hasOwnProperty("dimValue")&&(typeof i.dimValue=="number"?h.dimValue=d.longs===String?String(i.dimValue):i.dimValue:h.dimValue=d.longs===String?l.Long.prototype.toString.call(i.dimValue):d.longs===Number?new l.LongBits(i.dimValue.low>>>0,i.dimValue.high>>>0).toNumber():i.dimValue,d.oneofs&&(h.value="dimValue")),i.dimParam!=null&&i.hasOwnProperty("dimParam")&&(h.dimParam=i.dimParam,d.oneofs&&(h.value="dimParam")),i.denotation!=null&&i.hasOwnProperty("denotation")&&(h.denotation=i.denotation),h},e.prototype.toJSON=function(){return this.constructor.toObject(this,n.util.toJSONOptions)},e.getTypeUrl=function(i){return i===void 0&&(i="type.googleapis.com"),i+"/onnx.TensorShapeProto.Dimension"},e}(),a}(),o.TypeProto=function(){function a(u){if(u)for(var i=Object.keys(u),d=0;d<i.length;++d)u[i[d]]!=null&&(this[i[d]]=u[i[d]])}a.prototype.tensorType=null,a.prototype.sequenceType=null,a.prototype.mapType=null,a.prototype.optionalType=null,a.prototype.sparseTensorType=null,a.prototype.denotation="";var e;return Object.defineProperty(a.prototype,"value",{get:l.oneOfGetter(e=["tensorType","sequenceType","mapType","optionalType","sparseTensorType"]),set:l.oneOfSetter(e)}),a.create=function(u){return new a(u)},a.encode=function(u,i){return i||(i=p.create()),u.tensorType!=null&&Object.hasOwnProperty.call(u,"tensorType")&&c.onnx.TypeProto.Tensor.encode(u.tensorType,i.uint32(10).fork()).ldelim(),u.sequenceType!=null&&Object.hasOwnProperty.call(u,"sequenceType")&&c.onnx.TypeProto.Sequence.encode(u.sequenceType,i.uint32(34).fork()).ldelim(),u.mapType!=null&&Object.hasOwnProperty.call(u,"mapType")&&c.onnx.TypeProto.Map.encode(u.mapType,i.uint32(42).fork()).ldelim(),u.denotation!=null&&Object.hasOwnProperty.call(u,"denotation")&&i.uint32(50).string(u.denotation),u.sparseTensorType!=null&&Object.hasOwnProperty.call(u,"sparseTensorType")&&c.onnx.TypeProto.SparseTensor.encode(u.sparseTensorType,i.uint32(66).fork()).ldelim(),u.optionalType!=null&&Object.hasOwnProperty.call(u,"optionalType")&&c.onnx.TypeProto.Optional.encode(u.optionalType,i.uint32(74).fork()).ldelim(),i},a.encodeDelimited=function(u,i){return this.encode(u,i).ldelim()},a.decode=function(u,i){u instanceof s||(u=s.create(u));for(var d=i===void 0?u.len:u.pos+i,h=new c.onnx.TypeProto;u.pos<d;){var m=u.uint32();switch(m>>>3){case 1:{h.tensorType=c.onnx.TypeProto.Tensor.decode(u,u.uint32());break}case 4:{h.sequenceType=c.onnx.TypeProto.Sequence.decode(u,u.uint32());break}case 5:{h.mapType=c.onnx.TypeProto.Map.decode(u,u.uint32());break}case 9:{h.optionalType=c.onnx.TypeProto.Optional.decode(u,u.uint32());break}case 8:{h.sparseTensorType=c.onnx.TypeProto.SparseTensor.decode(u,u.uint32());break}case 6:{h.denotation=u.string();break}default:u.skipType(m&7);break}}return h},a.decodeDelimited=function(u){return u instanceof s||(u=new s(u)),this.decode(u,u.uint32())},a.verify=function(u){if(typeof u!="object"||u===null)return"object expected";var i={};if(u.tensorType!=null&&u.hasOwnProperty("tensorType")){i.value=1;{var d=c.onnx.TypeProto.Tensor.verify(u.tensorType);if(d)return"tensorType."+d}}if(u.sequenceType!=null&&u.hasOwnProperty("sequenceType")){if(i.value===1)return"value: multiple values";i.value=1;{var d=c.onnx.TypeProto.Sequence.verify(u.sequenceType);if(d)return"sequenceType."+d}}if(u.mapType!=null&&u.hasOwnProperty("mapType")){if(i.value===1)return"value: multiple values";i.value=1;{var d=c.onnx.TypeProto.Map.verify(u.mapType);if(d)return"mapType."+d}}if(u.optionalType!=null&&u.hasOwnProperty("optionalType")){if(i.value===1)return"value: multiple values";i.value=1;{var d=c.onnx.TypeProto.Optional.verify(u.optionalType);if(d)return"optionalType."+d}}if(u.sparseTensorType!=null&&u.hasOwnProperty("sparseTensorType")){if(i.value===1)return"value: multiple values";i.value=1;{var d=c.onnx.TypeProto.SparseTensor.verify(u.sparseTensorType);if(d)return"sparseTensorType."+d}}return u.denotation!=null&&u.hasOwnProperty("denotation")&&!l.isString(u.denotation)?"denotation: string expected":null},a.fromObject=function(u){if(u instanceof c.onnx.TypeProto)return u;var i=new c.onnx.TypeProto;if(u.tensorType!=null){if(typeof u.tensorType!="object")throw TypeError(".onnx.TypeProto.tensorType: object expected");i.tensorType=c.onnx.TypeProto.Tensor.fromObject(u.tensorType)}if(u.sequenceType!=null){if(typeof u.sequenceType!="object")throw TypeError(".onnx.TypeProto.sequenceType: object expected");i.sequenceType=c.onnx.TypeProto.Sequence.fromObject(u.sequenceType)}if(u.mapType!=null){if(typeof u.mapType!="object")throw TypeError(".onnx.TypeProto.mapType: object expected");i.mapType=c.onnx.TypeProto.Map.fromObject(u.mapType)}if(u.optionalType!=null){if(typeof u.optionalType!="object")throw TypeError(".onnx.TypeProto.optionalType: object expected");i.optionalType=c.onnx.TypeProto.Optional.fromObject(u.optionalType)}if(u.sparseTensorType!=null){if(typeof u.sparseTensorType!="object")throw TypeError(".onnx.TypeProto.sparseTensorType: object expected");i.sparseTensorType=c.onnx.TypeProto.SparseTensor.fromObject(u.sparseTensorType)}return u.denotation!=null&&(i.denotation=String(u.denotation)),i},a.toObject=function(u,i){i||(i={});var d={};return i.defaults&&(d.denotation=""),u.tensorType!=null&&u.hasOwnProperty("tensorType")&&(d.tensorType=c.onnx.TypeProto.Tensor.toObject(u.tensorType,i),i.oneofs&&(d.value="tensorType")),u.sequenceType!=null&&u.hasOwnProperty("sequenceType")&&(d.sequenceType=c.onnx.TypeProto.Sequence.toObject(u.sequenceType,i),i.oneofs&&(d.value="sequenceType")),u.mapType!=null&&u.hasOwnProperty("mapType")&&(d.mapType=c.onnx.TypeProto.Map.toObject(u.mapType,i),i.oneofs&&(d.value="mapType")),u.denotation!=null&&u.hasOwnProperty("denotation")&&(d.denotation=u.denotation),u.sparseTensorType!=null&&u.hasOwnProperty("sparseTensorType")&&(d.sparseTensorType=c.onnx.TypeProto.SparseTensor.toObject(u.sparseTensorType,i),i.oneofs&&(d.value="sparseTensorType")),u.optionalType!=null&&u.hasOwnProperty("optionalType")&&(d.optionalType=c.onnx.TypeProto.Optional.toObject(u.optionalType,i),i.oneofs&&(d.value="optionalType")),d},a.prototype.toJSON=function(){return this.constructor.toObject(this,n.util.toJSONOptions)},a.getTypeUrl=function(u){return u===void 0&&(u="type.googleapis.com"),u+"/onnx.TypeProto"},a.Tensor=function(){function u(i){if(i)for(var d=Object.keys(i),h=0;h<d.length;++h)i[d[h]]!=null&&(this[d[h]]=i[d[h]])}return u.prototype.elemType=0,u.prototype.shape=null,u.create=function(i){return new u(i)},u.encode=function(i,d){return d||(d=p.create()),i.elemType!=null&&Object.hasOwnProperty.call(i,"elemType")&&d.uint32(8).int32(i.elemType),i.shape!=null&&Object.hasOwnProperty.call(i,"shape")&&c.onnx.TensorShapeProto.encode(i.shape,d.uint32(18).fork()).ldelim(),d},u.encodeDelimited=function(i,d){return this.encode(i,d).ldelim()},u.decode=function(i,d){i instanceof s||(i=s.create(i));for(var h=d===void 0?i.len:i.pos+d,m=new c.onnx.TypeProto.Tensor;i.pos<h;){var b=i.uint32();switch(b>>>3){case 1:{m.elemType=i.int32();break}case 2:{m.shape=c.onnx.TensorShapeProto.decode(i,i.uint32());break}default:i.skipType(b&7);break}}return m},u.decodeDelimited=function(i){return i instanceof s||(i=new s(i)),this.decode(i,i.uint32())},u.verify=function(i){if(typeof i!="object"||i===null)return"object expected";if(i.elemType!=null&&i.hasOwnProperty("elemType")&&!l.isInteger(i.elemType))return"elemType: integer expected";if(i.shape!=null&&i.hasOwnProperty("shape")){var d=c.onnx.TensorShapeProto.verify(i.shape);if(d)return"shape."+d}return null},u.fromObject=function(i){if(i instanceof c.onnx.TypeProto.Tensor)return i;var d=new c.onnx.TypeProto.Tensor;if(i.elemType!=null&&(d.elemType=i.elemType|0),i.shape!=null){if(typeof i.shape!="object")throw TypeError(".onnx.TypeProto.Tensor.shape: object expected");d.shape=c.onnx.TensorShapeProto.fromObject(i.shape)}return d},u.toObject=function(i,d){d||(d={});var h={};return d.defaults&&(h.elemType=0,h.shape=null),i.elemType!=null&&i.hasOwnProperty("elemType")&&(h.elemType=i.elemType),i.shape!=null&&i.hasOwnProperty("shape")&&(h.shape=c.onnx.TensorShapeProto.toObject(i.shape,d)),h},u.prototype.toJSON=function(){return this.constructor.toObject(this,n.util.toJSONOptions)},u.getTypeUrl=function(i){return i===void 0&&(i="type.googleapis.com"),i+"/onnx.TypeProto.Tensor"},u}(),a.Sequence=function(){function u(i){if(i)for(var d=Object.keys(i),h=0;h<d.length;++h)i[d[h]]!=null&&(this[d[h]]=i[d[h]])}return u.prototype.elemType=null,u.create=function(i){return new u(i)},u.encode=function(i,d){return d||(d=p.create()),i.elemType!=null&&Object.hasOwnProperty.call(i,"elemType")&&c.onnx.TypeProto.encode(i.elemType,d.uint32(10).fork()).ldelim(),d},u.encodeDelimited=function(i,d){return this.encode(i,d).ldelim()},u.decode=function(i,d){i instanceof s||(i=s.create(i));for(var h=d===void 0?i.len:i.pos+d,m=new c.onnx.TypeProto.Sequence;i.pos<h;){var b=i.uint32();switch(b>>>3){case 1:{m.elemType=c.onnx.TypeProto.decode(i,i.uint32());break}default:i.skipType(b&7);break}}return m},u.decodeDelimited=function(i){return i instanceof s||(i=new s(i)),this.decode(i,i.uint32())},u.verify=function(i){if(typeof i!="object"||i===null)return"object expected";if(i.elemType!=null&&i.hasOwnProperty("elemType")){var d=c.onnx.TypeProto.verify(i.elemType);if(d)return"elemType."+d}return null},u.fromObject=function(i){if(i instanceof c.onnx.TypeProto.Sequence)return i;var d=new c.onnx.TypeProto.Sequence;if(i.elemType!=null){if(typeof i.elemType!="object")throw TypeError(".onnx.TypeProto.Sequence.elemType: object expected");d.elemType=c.onnx.TypeProto.fromObject(i.elemType)}return d},u.toObject=function(i,d){d||(d={});var h={};return d.defaults&&(h.elemType=null),i.elemType!=null&&i.hasOwnProperty("elemType")&&(h.elemType=c.onnx.TypeProto.toObject(i.elemType,d)),h},u.prototype.toJSON=function(){return this.constructor.toObject(this,n.util.toJSONOptions)},u.getTypeUrl=function(i){return i===void 0&&(i="type.googleapis.com"),i+"/onnx.TypeProto.Sequence"},u}(),a.Map=function(){function u(i){if(i)for(var d=Object.keys(i),h=0;h<d.length;++h)i[d[h]]!=null&&(this[d[h]]=i[d[h]])}return u.prototype.keyType=0,u.prototype.valueType=null,u.create=function(i){return new u(i)},u.encode=function(i,d){return d||(d=p.create()),i.keyType!=null&&Object.hasOwnProperty.call(i,"keyType")&&d.uint32(8).int32(i.keyType),i.valueType!=null&&Object.hasOwnProperty.call(i,"valueType")&&c.onnx.TypeProto.encode(i.valueType,d.uint32(18).fork()).ldelim(),d},u.encodeDelimited=function(i,d){return this.encode(i,d).ldelim()},u.decode=function(i,d){i instanceof s||(i=s.create(i));for(var h=d===void 0?i.len:i.pos+d,m=new c.onnx.TypeProto.Map;i.pos<h;){var b=i.uint32();switch(b>>>3){case 1:{m.keyType=i.int32();break}case 2:{m.valueType=c.onnx.TypeProto.decode(i,i.uint32());break}default:i.skipType(b&7);break}}return m},u.decodeDelimited=function(i){return i instanceof s||(i=new s(i)),this.decode(i,i.uint32())},u.verify=function(i){if(typeof i!="object"||i===null)return"object expected";if(i.keyType!=null&&i.hasOwnProperty("keyType")&&!l.isInteger(i.keyType))return"keyType: integer expected";if(i.valueType!=null&&i.hasOwnProperty("valueType")){var d=c.onnx.TypeProto.verify(i.valueType);if(d)return"valueType."+d}return null},u.fromObject=function(i){if(i instanceof c.onnx.TypeProto.Map)return i;var d=new c.onnx.TypeProto.Map;if(i.keyType!=null&&(d.keyType=i.keyType|0),i.valueType!=null){if(typeof i.valueType!="object")throw TypeError(".onnx.TypeProto.Map.valueType: object expected");d.valueType=c.onnx.TypeProto.fromObject(i.valueType)}return d},u.toObject=function(i,d){d||(d={});var h={};return d.defaults&&(h.keyType=0,h.valueType=null),i.keyType!=null&&i.hasOwnProperty("keyType")&&(h.keyType=i.keyType),i.valueType!=null&&i.hasOwnProperty("valueType")&&(h.valueType=c.onnx.TypeProto.toObject(i.valueType,d)),h},u.prototype.toJSON=function(){return this.constructor.toObject(this,n.util.toJSONOptions)},u.getTypeUrl=function(i){return i===void 0&&(i="type.googleapis.com"),i+"/onnx.TypeProto.Map"},u}(),a.Optional=function(){function u(i){if(i)for(var d=Object.keys(i),h=0;h<d.length;++h)i[d[h]]!=null&&(this[d[h]]=i[d[h]])}return u.prototype.elemType=null,u.create=function(i){return new u(i)},u.encode=function(i,d){return d||(d=p.create()),i.elemType!=null&&Object.hasOwnProperty.call(i,"elemType")&&c.onnx.TypeProto.encode(i.elemType,d.uint32(10).fork()).ldelim(),d},u.encodeDelimited=function(i,d){return this.encode(i,d).ldelim()},u.decode=function(i,d){i instanceof s||(i=s.create(i));for(var h=d===void 0?i.len:i.pos+d,m=new c.onnx.TypeProto.Optional;i.pos<h;){var b=i.uint32();switch(b>>>3){case 1:{m.elemType=c.onnx.TypeProto.decode(i,i.uint32());break}default:i.skipType(b&7);break}}return m},u.decodeDelimited=function(i){return i instanceof s||(i=new s(i)),this.decode(i,i.uint32())},u.verify=function(i){if(typeof i!="object"||i===null)return"object expected";if(i.elemType!=null&&i.hasOwnProperty("elemType")){var d=c.onnx.TypeProto.verify(i.elemType);if(d)return"elemType."+d}return null},u.fromObject=function(i){if(i instanceof c.onnx.TypeProto.Optional)return i;var d=new c.onnx.TypeProto.Optional;if(i.elemType!=null){if(typeof i.elemType!="object")throw TypeError(".onnx.TypeProto.Optional.elemType: object expected");d.elemType=c.onnx.TypeProto.fromObject(i.elemType)}return d},u.toObject=function(i,d){d||(d={});var h={};return d.defaults&&(h.elemType=null),i.elemType!=null&&i.hasOwnProperty("elemType")&&(h.elemType=c.onnx.TypeProto.toObject(i.elemType,d)),h},u.prototype.toJSON=function(){return this.constructor.toObject(this,n.util.toJSONOptions)},u.getTypeUrl=function(i){return i===void 0&&(i="type.googleapis.com"),i+"/onnx.TypeProto.Optional"},u}(),a.SparseTensor=function(){function u(i){if(i)for(var d=Object.keys(i),h=0;h<d.length;++h)i[d[h]]!=null&&(this[d[h]]=i[d[h]])}return u.prototype.elemType=0,u.prototype.shape=null,u.create=function(i){return new u(i)},u.encode=function(i,d){return d||(d=p.create()),i.elemType!=null&&Object.hasOwnProperty.call(i,"elemType")&&d.uint32(8).int32(i.elemType),i.shape!=null&&Object.hasOwnProperty.call(i,"shape")&&c.onnx.TensorShapeProto.encode(i.shape,d.uint32(18).fork()).ldelim(),d},u.encodeDelimited=function(i,d){return this.encode(i,d).ldelim()},u.decode=function(i,d){i instanceof s||(i=s.create(i));for(var h=d===void 0?i.len:i.pos+d,m=new c.onnx.TypeProto.SparseTensor;i.pos<h;){var b=i.uint32();switch(b>>>3){case 1:{m.elemType=i.int32();break}case 2:{m.shape=c.onnx.TensorShapeProto.decode(i,i.uint32());break}default:i.skipType(b&7);break}}return m},u.decodeDelimited=function(i){return i instanceof s||(i=new s(i)),this.decode(i,i.uint32())},u.verify=function(i){if(typeof i!="object"||i===null)return"object expected";if(i.elemType!=null&&i.hasOwnProperty("elemType")&&!l.isInteger(i.elemType))return"elemType: integer expected";if(i.shape!=null&&i.hasOwnProperty("shape")){var d=c.onnx.TensorShapeProto.verify(i.shape);if(d)return"shape."+d}return null},u.fromObject=function(i){if(i instanceof c.onnx.TypeProto.SparseTensor)return i;var d=new c.onnx.TypeProto.SparseTensor;if(i.elemType!=null&&(d.elemType=i.elemType|0),i.shape!=null){if(typeof i.shape!="object")throw TypeError(".onnx.TypeProto.SparseTensor.shape: object expected");d.shape=c.onnx.TensorShapeProto.fromObject(i.shape)}return d},u.toObject=function(i,d){d||(d={});var h={};return d.defaults&&(h.elemType=0,h.shape=null),i.elemType!=null&&i.hasOwnProperty("elemType")&&(h.elemType=i.elemType),i.shape!=null&&i.hasOwnProperty("shape")&&(h.shape=c.onnx.TensorShapeProto.toObject(i.shape,d)),h},u.prototype.toJSON=function(){return this.constructor.toObject(this,n.util.toJSONOptions)},u.getTypeUrl=function(i){return i===void 0&&(i="type.googleapis.com"),i+"/onnx.TypeProto.SparseTensor"},u}(),a}(),o.OperatorSetIdProto=function(){function a(e){if(e)for(var u=Object.keys(e),i=0;i<u.length;++i)e[u[i]]!=null&&(this[u[i]]=e[u[i]])}return a.prototype.domain="",a.prototype.version=l.Long?l.Long.fromBits(0,0,!1):0,a.create=function(e){return new a(e)},a.encode=function(e,u){return u||(u=p.create()),e.domain!=null&&Object.hasOwnProperty.call(e,"domain")&&u.uint32(10).string(e.domain),e.version!=null&&Object.hasOwnProperty.call(e,"version")&&u.uint32(16).int64(e.version),u},a.encodeDelimited=function(e,u){return this.encode(e,u).ldelim()},a.decode=function(e,u){e instanceof s||(e=s.create(e));for(var i=u===void 0?e.len:e.pos+u,d=new c.onnx.OperatorSetIdProto;e.pos<i;){var h=e.uint32();switch(h>>>3){case 1:{d.domain=e.string();break}case 2:{d.version=e.int64();break}default:e.skipType(h&7);break}}return d},a.decodeDelimited=function(e){return e instanceof s||(e=new s(e)),this.decode(e,e.uint32())},a.verify=function(e){return typeof e!="object"||e===null?"object expected":e.domain!=null&&e.hasOwnProperty("domain")&&!l.isString(e.domain)?"domain: string expected":e.version!=null&&e.hasOwnProperty("version")&&!l.isInteger(e.version)&&!(e.version&&l.isInteger(e.version.low)&&l.isInteger(e.version.high))?"version: integer|Long expected":null},a.fromObject=function(e){if(e instanceof c.onnx.OperatorSetIdProto)return e;var u=new c.onnx.OperatorSetIdProto;return e.domain!=null&&(u.domain=String(e.domain)),e.version!=null&&(l.Long?(u.version=l.Long.fromValue(e.version)).unsigned=!1:typeof e.version=="string"?u.version=parseInt(e.version,10):typeof e.version=="number"?u.version=e.version:typeof e.version=="object"&&(u.version=new l.LongBits(e.version.low>>>0,e.version.high>>>0).toNumber())),u},a.toObject=function(e,u){u||(u={});var i={};if(u.defaults)if(i.domain="",l.Long){var d=new l.Long(0,0,!1);i.version=u.longs===String?d.toString():u.longs===Number?d.toNumber():d}else i.version=u.longs===String?"0":0;return e.domain!=null&&e.hasOwnProperty("domain")&&(i.domain=e.domain),e.version!=null&&e.hasOwnProperty("version")&&(typeof e.version=="number"?i.version=u.longs===String?String(e.version):e.version:i.version=u.longs===String?l.Long.prototype.toString.call(e.version):u.longs===Number?new l.LongBits(e.version.low>>>0,e.version.high>>>0).toNumber():e.version),i},a.prototype.toJSON=function(){return this.constructor.toObject(this,n.util.toJSONOptions)},a.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/onnx.OperatorSetIdProto"},a}(),o.OperatorStatus=function(){var a={},e=Object.create(a);return e[a[0]="EXPERIMENTAL"]=0,e[a[1]="STABLE"]=1,e}(),o.FunctionProto=function(){function a(e){if(this.input=[],this.output=[],this.attribute=[],this.attributeProto=[],this.node=[],this.opsetImport=[],e)for(var u=Object.keys(e),i=0;i<u.length;++i)e[u[i]]!=null&&(this[u[i]]=e[u[i]])}return a.prototype.name="",a.prototype.input=l.emptyArray,a.prototype.output=l.emptyArray,a.prototype.attribute=l.emptyArray,a.prototype.attributeProto=l.emptyArray,a.prototype.node=l.emptyArray,a.prototype.docString="",a.prototype.opsetImport=l.emptyArray,a.prototype.domain="",a.create=function(e){return new a(e)},a.encode=function(e,u){if(u||(u=p.create()),e.name!=null&&Object.hasOwnProperty.call(e,"name")&&u.uint32(10).string(e.name),e.input!=null&&e.input.length)for(var i=0;i<e.input.length;++i)u.uint32(34).string(e.input[i]);if(e.output!=null&&e.output.length)for(var i=0;i<e.output.length;++i)u.uint32(42).string(e.output[i]);if(e.attribute!=null&&e.attribute.length)for(var i=0;i<e.attribute.length;++i)u.uint32(50).string(e.attribute[i]);if(e.node!=null&&e.node.length)for(var i=0;i<e.node.length;++i)c.onnx.NodeProto.encode(e.node[i],u.uint32(58).fork()).ldelim();if(e.docString!=null&&Object.hasOwnProperty.call(e,"docString")&&u.uint32(66).string(e.docString),e.opsetImport!=null&&e.opsetImport.length)for(var i=0;i<e.opsetImport.length;++i)c.onnx.OperatorSetIdProto.encode(e.opsetImport[i],u.uint32(74).fork()).ldelim();if(e.domain!=null&&Object.hasOwnProperty.call(e,"domain")&&u.uint32(82).string(e.domain),e.attributeProto!=null&&e.attributeProto.length)for(var i=0;i<e.attributeProto.length;++i)c.onnx.AttributeProto.encode(e.attributeProto[i],u.uint32(90).fork()).ldelim();return u},a.encodeDelimited=function(e,u){return this.encode(e,u).ldelim()},a.decode=function(e,u){e instanceof s||(e=s.create(e));for(var i=u===void 0?e.len:e.pos+u,d=new c.onnx.FunctionProto;e.pos<i;){var h=e.uint32();switch(h>>>3){case 1:{d.name=e.string();break}case 4:{d.input&&d.input.length||(d.input=[]),d.input.push(e.string());break}case 5:{d.output&&d.output.length||(d.output=[]),d.output.push(e.string());break}case 6:{d.attribute&&d.attribute.length||(d.attribute=[]),d.attribute.push(e.string());break}case 11:{d.attributeProto&&d.attributeProto.length||(d.attributeProto=[]),d.attributeProto.push(c.onnx.AttributeProto.decode(e,e.uint32()));break}case 7:{d.node&&d.node.length||(d.node=[]),d.node.push(c.onnx.NodeProto.decode(e,e.uint32()));break}case 8:{d.docString=e.string();break}case 9:{d.opsetImport&&d.opsetImport.length||(d.opsetImport=[]),d.opsetImport.push(c.onnx.OperatorSetIdProto.decode(e,e.uint32()));break}case 10:{d.domain=e.string();break}default:e.skipType(h&7);break}}return d},a.decodeDelimited=function(e){return e instanceof s||(e=new s(e)),this.decode(e,e.uint32())},a.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.name!=null&&e.hasOwnProperty("name")&&!l.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 u=0;u<e.input.length;++u)if(!l.isString(e.input[u]))return"input: string[] expected"}if(e.output!=null&&e.hasOwnProperty("output")){if(!Array.isArray(e.output))return"output: array expected";for(var u=0;u<e.output.length;++u)if(!l.isString(e.output[u]))return"output: string[] expected"}if(e.attribute!=null&&e.hasOwnProperty("attribute")){if(!Array.isArray(e.attribute))return"attribute: array expected";for(var u=0;u<e.attribute.length;++u)if(!l.isString(e.attribute[u]))return"attribute: string[] expected"}if(e.attributeProto!=null&&e.hasOwnProperty("attributeProto")){if(!Array.isArray(e.attributeProto))return"attributeProto: array expected";for(var u=0;u<e.attributeProto.length;++u){var i=c.onnx.AttributeProto.verify(e.attributeProto[u]);if(i)return"attributeProto."+i}}if(e.node!=null&&e.hasOwnProperty("node")){if(!Array.isArray(e.node))return"node: array expected";for(var u=0;u<e.node.length;++u){var i=c.onnx.NodeProto.verify(e.node[u]);if(i)return"node."+i}}if(e.docString!=null&&e.hasOwnProperty("docString")&&!l.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 u=0;u<e.opsetImport.length;++u){var i=c.onnx.OperatorSetIdProto.verify(e.opsetImport[u]);if(i)return"opsetImport."+i}}return e.domain!=null&&e.hasOwnProperty("domain")&&!l.isString(e.domain)?"domain: string expected":null},a.fromObject=function(e){if(e instanceof c.onnx.FunctionProto)return e;var u=new c.onnx.FunctionProto;if(e.name!=null&&(u.name=String(e.name)),e.input){if(!Array.isArray(e.input))throw TypeError(".onnx.FunctionProto.input: array expected");u.input=[];for(var i=0;i<e.input.length;++i)u.input[i]=String(e.input[i])}if(e.output){if(!Array.isArray(e.output))throw TypeError(".onnx.FunctionProto.output: array expected");u.output=[];for(var i=0;i<e.output.length;++i)u.output[i]=String(e.output[i])}if(e.attribute){if(!Array.isArray(e.attribute))throw TypeError(".onnx.FunctionProto.attribute: array expected");u.attribute=[];for(var i=0;i<e.attribute.length;++i)u.attribute[i]=String(e.attribute[i])}if(e.attributeProto){if(!Array.isArray(e.attributeProto))throw TypeError(".onnx.FunctionProto.attributeProto: array expected");u.attributeProto=[];for(var i=0;i<e.attributeProto.length;++i){if(typeof e.attributeProto[i]!="object")throw TypeError(".onnx.FunctionProto.attributeProto: object expected");u.attributeProto[i]=c.onnx.AttributeProto.fromObject(e.attributeProto[i])}}if(e.node){if(!Array.isArray(e.node))throw TypeError(".onnx.FunctionProto.node: array expected");u.node=[];for(var i=0;i<e.node.length;++i){if(typeof e.node[i]!="object")throw TypeError(".onnx.FunctionProto.node: object expected");u.node[i]=c.onnx.NodeProto.fromObject(e.node[i])}}if(e.docString!=null&&(u.docString=String(e.docString)),e.opsetImport){if(!Array.isArray(e.opsetImport))throw TypeError(".onnx.FunctionProto.opsetImport: array expected");u.opsetImport=[];for(var i=0;i<e.opsetImport.length;++i){if(typeof e.opsetImport[i]!="object")throw TypeError(".onnx.FunctionProto.opsetImport: object expected");u.opsetImport[i]=c.onnx.OperatorSetIdProto.fromObject(e.opsetImport[i])}}return e.domain!=null&&(u.domain=String(e.domain)),u},a.toObject=function(e,u){u||(u={});var i={};if((u.arrays||u.defaults)&&(i.input=[],i.output=[],i.attribute=[],i.node=[],i.opsetImport=[],i.attributeProto=[]),u.defaults&&(i.name="",i.docString="",i.domain=""),e.name!=null&&e.hasOwnProperty("name")&&(i.name=e.name),e.input&&e.input.length){i.input=[];for(var d=0;d<e.input.length;++d)i.input[d]=e.input[d]}if(e.output&&e.output.length){i.output=[];for(var d=0;d<e.output.length;++d)i.output[d]=e.output[d]}if(e.attribute&&e.attribute.length){i.attribute=[];for(var d=0;d<e.attribute.length;++d)i.attribute[d]=e.attribute[d]}if(e.node&&e.node.length){i.node=[];for(var d=0;d<e.node.length;++d)i.node[d]=c.onnx.NodeProto.toObject(e.node[d],u)}if(e.docString!=null&&e.hasOwnProperty("docString")&&(i.docString=e.docString),e.opsetImport&&e.opsetImport.length){i.opsetImport=[];for(var d=0;d<e.opsetImport.length;++d)i.opsetImport[d]=c.onnx.OperatorSetIdProto.toObject(e.opsetImport[d],u)}if(e.domain!=null&&e.hasOwnProperty("domain")&&(i.domain=e.domain),e.attributeProto&&e.attributeProto.length){i.attributeProto=[];for(var d=0;d<e.attributeProto.length;++d)i.attributeProto[d]=c.onnx.AttributeProto.toObject(e.attributeProto[d],u)}return i},a.prototype.toJSON=function(){return this.constructor.toObject(this,n.util.toJSONOptions)},a.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/onnx.FunctionProto"},a}(),o}(),r.exports=c});function Ur(t,r){if(!t)throw new Error(typeof r=="string"?r:r())}function co(t){return new TextDecoder().decode(t)}var q,Qe,ya,Mt,bl,Et,Vt,C,ho,Gr,dr,hr,U=I(()=>{"use strict";Ho(),fl(),q=Ie(mr()),De(),Qe=class{static arraysEqual(t,r){if(t.length!==r.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==r[n])return!1;return!0}},ya=class{static preprocessInputShapes(t,r){let n=t.length===1?[1,t[0]]:t,s=r.length===1?[r[0],1]:r;return[n,s]}static postprocessOutputShape(t,r,n){r===1&&t.splice(t.length-2,1),n===1&&t.pop()}static calcMatMulShape(t,r){return t[1]!==r[0]?void 0:[t[0],r[1]]}},Mt=class tr{static calcShape(r,n,s=!1){let p=r.length,l=n.length;if(p===0)return n;if(l===0)return r;let c=Math.max(r.length,n.length),o=new Array(c);if(s){if(p<2||l<2)return;let a=ya.calcMatMulShape([r[p-2],r[p-1]],[n[l-2],n[l-1]]);if(a===void 0)return;[o[c-2],o[c-1]]=a}for(let a=s?3:1;a<=c;a++){let e=p-a<0?1:r[p-a],u=l-a<0?1:n[l-a];if(e!==u&&e>1&&u>1)return;o[c-a]=Math.max(e,u)}return o}static index(r,n){let s=new Array(n.length);return tr.fillIndex(r,n,s),s}static fillIndex(r,n,s){let p=r.length-n.length;for(let l=0;l<n.length;l++)s[l]=r[p+l]%n[l]}static calc(r,n,s,p,l){let c=tr.calcShape(r.dims,n.dims);if(c){if(p&&!C.areEqual(c,r.dims))return;let o=C.size(c),a=p?r:new Pt(c,l||r.type);if(c.length===0)a.set([],s(r.get([]),n.get([])));else{let e=new Array(c.length),u=new Array(r.dims.length),i=new Array(n.dims.length),d=0,h=0,m=!1,b=!1;r.dims.length===0&&(d=r.get([]),m=!0),n.dims.length===0&&(h=n.get([]),b=!0);let x;for(let E=0;E<o;E++){x=E;for(let w=c.length-1;w>=0;w--)e[w]=x%c[w],x=Math.floor(x/c[w]);m||(tr.fillIndex(e,r.dims,u),d=r.get(u)),b||(tr.fillIndex(e,n.dims,i),h=n.get(i)),a.set(e,s(d,h))}}return a}}static isValidBroadcast(r,n){let s=r.length,p=n.length;if(s>p)return!1;for(let l=1;l<=s;l++)if(r[s-l]!==1&&r[s-l]!==n[p-l])return!1;return!0}static getBroadcastDims(r,n){let s=r.length,p=[];for(let l=0;l<s;l++){let c=s-1-l,o=r[c]||1;(n[n.length-1-l]||1)>1&&o===1&&p.unshift(c)}return p}},bl=class{static getShapeOfGemmResult(t,r,n,s,p){if(t.length!==2||n.length!==2)throw new Error("shape need to be of size 2");let l,c,o;r?(l=t[1],c=t[0]):(l=t[0],c=t[1]);let a=-1;if(s?(o=n[0],a=1):(o=n[1],a=0),n[a]!==c)throw new Error("dimension mismatch");if(l<=0||o<=0||c<=0)throw new Error("invalid shape specified");if(p&&!Mt.isValidBroadcast(p,[l,o]))throw new Error("gemm: invalid bias shape for broadcast");return[l,o,c]}},Et=class fo{static tensorDataTypeFromProto(r){switch(r){case q.onnx.TensorProto.DataType.INT8:return"int8";case q.onnx.TensorProto.DataType.UINT8:return"uint8";case q.onnx.TensorProto.DataType.BOOL:return"bool";case q.onnx.TensorProto.DataType.INT16:return"int16";case q.onnx.TensorProto.DataType.UINT16:return"uint16";case q.onnx.TensorProto.DataType.INT32:return"int32";case q.onnx.TensorProto.DataType.UINT32:return"uint32";case q.onnx.TensorProto.DataType.FLOAT:return"float32";case q.onnx.TensorProto.DataType.DOUBLE:return"float64";case q.onnx.TensorProto.DataType.STRING:return"string";case q.onnx.TensorProto.DataType.INT64:return"int32";case q.onnx.TensorProto.DataType.UINT64:return"uint32";default:throw new Error(`unsupported data type: ${q.onnx.TensorProto.DataType[r]}`)}}static tensorDataTypeStringToEnum(r){switch(r){case"int8":return q.onnx.TensorProto.DataType.INT8;case"uint8":return q.onnx.TensorProto.DataType.UINT8;case"bool":return q.onnx.TensorProto.DataType.BOOL;case"int16":return q.onnx.TensorProto.DataType.INT16;case"uint16":return q.onnx.TensorProto.DataType.UINT16;case"int32":return q.onnx.TensorProto.DataType.INT32;case"uint32":return q.onnx.TensorProto.DataType.UINT32;case"float32":return q.onnx.TensorProto.DataType.FLOAT;case"float64":return q.onnx.TensorProto.DataType.DOUBLE;case"string":return q.onnx.TensorProto.DataType.STRING;case"int64":return q.onnx.TensorProto.DataType.INT64;case"uint64":return q.onnx.TensorProto.DataType.UINT64;default:throw new Error(`unsupported data type: ${r}`)}}static tensorDimsFromProto(r){return r.map(n=>ee.isLong(n)?n.toNumber():n)}static tensorValueTypeFromProto(r){return{tensorType:fo.tensorDataTypeFromProto(r.elemType),shape:{dims:fo.tensorDimsFromProto(r.shape.dim.map(n=>n.dimValue))}}}static tensorDimsFromORTFormat(r){let n=[];for(let s=0;s<r.dimsLength();s++)n.push(Vt.longToNumber(r.dims(s)));return n}static tensorAttributesFromORTFormat(r){let n=[];for(let s=0;s<r.attributesLength();s++)n.push(r.attributes(s));return n}},Vt=class{static longToNumber(t,r){return ee.isLong(t)?t.toNumber():t instanceof T.Long?ee.fromValue({low:t.low,high:t.high,unsigned:r??!1}).toNumber():t}static isLong(t){return ee.isLong(t)||t instanceof T.Long}},C=class Qt{static size(r){return Qt.getSizeFromDimensionRange(r,0,r.length)}static sizeFromDimension(r,n){if(n<0||n>r.length)throw new Error(`invalid dimension of ${n} for sizeFromDimension as Tensor has ${r.length} dimensions.`);return Qt.getSizeFromDimensionRange(r,n,r.length)}static sizeToDimension(r,n){if(n<0||n>r.length)throw new Error(`invalid dimension of ${n} for sizeToDimension as Tensor has ${r.length} dimensions.`);return Qt.getSizeFromDimensionRange(r,0,n)}static getSizeFromDimensionRange(r,n,s){let p=1;for(let l=n;l<s;l++){if(r[l]<=0)throw new Error("cannot get valid size from specified dimension range. Most likely the range contains 0 or negative values in them.");p*=r[l]}return p}static computeStrides(r){let n=r.length;if(n===0)return[];if(n===1)return[1];let s=new Array(n);s[n-1]=1,s[n-2]=r[n-1];for(let p=n-3;p>=0;--p)s[p]=s[p+1]*r[p+1];return s}static transpose(r){return r.slice().reverse()}static indicesToOffset(r,n,s){s===void 0&&(s=r.length);let p=0;for(let l=0;l<s;++l)p+=n[l]*r[l];return p}static offsetToIndices(r,n){let s=n.length;if(s===0)return[];if(s===1)return[r*n[0]];let p=new Array(n.length);for(let l=0;l<p.length-1;++l)p[l]=Math.floor(r/n[l]),r-=p[l]*n[l];return p[p.length-1]=r,p}static normalizeAxis(r,n){if(r<-n&&r>=n)throw new Error("unsupported axis for this operation.");return r<0?r+n:r}static normalizeAxes(r,n){return r.map(s=>this.normalizeAxis(s,n))}static incrementIndex(r,n,s){if(n.length===0||r.length===0)throw new Error("Index incrementing unsupported for scalar Tensor");if(s===void 0)s=n.length;else if(s<=0||s>n.length)throw new Error("Incorrect axis to increment on");for(let p=s-1;p>=0&&(r[p]++,!(r[p]<n[p]));--p)r[p]=0}static calculateReshapedDims(r,n){if(n.length===0){if(r.length===0||Qt.size(r)===1)return[];throw new Error("cannot reshape to a scalar Tensor")}let s=n.length,p=new Array(s),l=-1,c=1;for(let a=0;a<s;a++){if(n[a]<-1)throw new Error("a dimension in shape hints cannot be less than -1");if(n[a]===-1){if(l!==-1)throw new Error("at most one dimension in shape hints can be -1");l=a}else{if(n[a]===0){if(a>=r.length)throw new Error("the dimension with value zero exceeds the dimension size of the input tensor");p[a]=r[a]}else p[a]=n[a];c*=p[a]}}let o=Qt.size(r);if(l!==-1){if(o%c!==0)throw new Error(`the input tensor cannot be reshaped to the requested shape. Input shape: [${r}] Output shape: [${n}]`);p[l]=o/c}else if(c!==o)throw new Error("reshapedDims and originalDims don't have matching sizes");return p}static sortBasedOnPerm(r,n){return n?n.map(s=>r[s]):r.slice().reverse()}static padShape(r,n){let s=r.length;return r.map((p,l)=>p+n[l]+n[l+s])}static areEqual(r,n){return r.length!==n.length?!1:r.every((s,p)=>s===n[p])}static validateDimsAndCalcSize(r){if(r.length>6)throw new TypeError("Only rank 0 to 6 is supported for tensor shape.");let n=1;for(let s of r){if(!Number.isInteger(s))throw new TypeError(`Invalid shape: ${s} is not an integer`);if(s<0||s>2147483647)throw new TypeError(`Invalid shape: length ${s} is not allowed`);n*=s}return n}static flattenShape(r,n){n<0&&(n+=r.length);let s=r.reduce((l,c)=>l*c,1),p=r.slice(n).reduce((l,c)=>l*c,1);return[s/p,p]}static squeezeShape(r,n){let s=new Array;n=Qt.normalizeAxes(n,r.length);for(let p=0;p<r.length;p++){let l=n.indexOf(p)>=0;if(l&&r[p]!==1)throw new Error("squeeze an axis of size different than 1");(n.length===0&&r[p]>1||n.length>0&&!l)&&s.push(r[p])}return s}static unsqueezeShape(r,n){let s=new Array(r.length+n.length);s.fill(0);for(let l=0;l<n.length;l++){let c=Qt.normalizeAxis(n[l],s.length);if(c>=s.length)throw new Error("'axes' has an out of range axis");if(s[c]!==0)throw new Error("'axes' has a duplicate axis");s[c]=1}let p=0;for(let l=0;l<s.length;l++)s[l]===0&&(s[l]=r[p++]);if(p!==r.length)throw new Error("the unsqueezed dimension could not be established");return s}},ho=class yl{static splitShape(r,n,s,p){if(s.length===0){if(!p)throw new Error("need to know number of outputs when the 'split' attribute is not specified");yl.determineSplit(r[n],p,s)}let l=[],c=[0];for(let o=0;o<s.length;++o){o!==0&&c.push(c[o-1]+s[o-1]);let a=r.slice();a[n]=s[o],l.push(a)}return[l,c]}static determineSplit(r,n,s){if(r%n!==0)throw new Error("cannot split tensor to equal sized parts");for(let p=0;p<n;++p)s.push(r/n)}},Gr=class er{static adjustPoolAttributes(r,n,s,p,l,c){if(!r&&s.length!==n.length-2)throw new Error("length of specified kernel shapes should be 2 less than length of input dimensions");if(r)for(let o=0;o<n.length-2;o++)o>=s.length?s.push(n[o+2]):s[o]=n[o+2];for(let o=0;o<s.length;o++)if(o<p.length){if(p[o]<0)throw new Error("strides should be greater than or equal to 1")}else p.push(1);for(let o=0;o<s.length;o++)if(o<l.length){if(l[o]<0)throw new Error("dilations should be greater than or equal to 1")}else l.push(1);for(let o=0;o<s.length*2;o++)if(o<c.length){if(c[o]<0)throw new Error("pad should be greater than or equal to 1")}else c.push(0);for(let o=0;o<s.length;o++){if(s[o]<=0)throw new Error("kernel shapes need to be greater than 0");if(c[o]>=s[o]||c[o+s.length]>=s[o])throw new Error("pads should be smaller than kernel")}}static adjustPadsBasedOnAutoPad(r,n,s,p,l,c){if(c){if(l.length!==2*(r.length-2))throw new Error("length of pads should be twice the length of data dimensions");if(n.length!==r.length-2)throw new Error("length of strides should be the length of data dimensions");if(p.length!==r.length-2)throw new Error("length of kernel shapes should be the length of data dimensions");for(let o=0;o<r.length-2;o++)er.adjustPadAndReturnShape(r[o+2],n[o],s[o],p[o],l,o,o+r.length-2,c)}}static computePoolOutputShape(r,n,s,p,l,c,o){if(n.length<=0)throw new Error("input shape must be of size greater than 0");let a=[n[0],n[1]];return er.computeShapeHelper(r,n,a,s,p,l,c,o),a}static computeConvOutputShape(r,n,s,p,l,c,o){if(r.length<=0||n.length<=0)throw new Error("invalid input tensor dims or invalid filter tensor dims");let a=[r[0],n[0]];return er.computeShapeHelper(!1,r,a,s,p,l,c,o),a}static computeShapeHelper(r,n,s,p,l,c,o,a){if(r)for(let e=0;e<n.length-2;e++)s.push(1);else for(let e=0;e<n.length-2;e++)s.push(er.adjustPadAndReturnShape(n[e+2],p[e],l[e],c[e],o,e,e+n.length-2,a))}static adjustPadAndReturnShape(r,n,s,p,l,c,o,a){let e=s*(p-1)+1;if(a&&a!=="NOTSET")switch(a){case"VALID":return l[c]=0,l[o]=0,Math.floor((r-e)/n+1);case"SAME_LOWER":case"SAME_UPPER":if(s!==1)throw new Error("Dilation not supported for SAME_UPPER or SAME_LOWER");{let u=((r+n-1)/n-1)*n+p-r;return l[c]=Math.floor(a==="SAME_LOWER"?(u+1)/2:u/2),l[o]=u-l[c],Math.floor((r+u-p)/n+1)}default:throw new Error("Unsupported AutoPad type")}else return Math.floor((r+l[c]+l[o]-e)/n+1)}},dr=-34028234663852886e22,hr=34028234663852886e22});function Zh(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 wa(t){switch(t){case L.onnx.TensorProto.DataType.UINT8:case L.onnx.TensorProto.DataType.INT8:case L.onnx.TensorProto.DataType.BOOL:return 1;case L.onnx.TensorProto.DataType.UINT16:case L.onnx.TensorProto.DataType.INT16:return 2;case L.onnx.TensorProto.DataType.FLOAT:case L.onnx.TensorProto.DataType.INT32:case L.onnx.TensorProto.DataType.UINT32:return 4;case L.onnx.TensorProto.DataType.INT64:case L.onnx.TensorProto.DataType.DOUBLE:case L.onnx.TensorProto.DataType.UINT64:return 8;default:throw new Error(`cannot calculate sizeof() on type ${L.onnx.TensorProto.DataType[t]}`)}}function Jh(t,r){return new(wl(r))(t)}function wl(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 go(t,r){if(r===L.onnx.TensorProto.DataType.INT64||r===Vr.TensorDataType.INT64){if(t.greaterThanOrEqual(2147483648)||t.lessThan(-2147483648))throw new TypeError("int64 is not supported")}else if(r===L.onnx.TensorProto.DataType.UINT32||r===Vr.TensorDataType.UINT32||r===L.onnx.TensorProto.DataType.UINT64||r===Vr.TensorDataType.UINT64){if(t.greaterThanOrEqual(4294967296)||t.lessThan(0))throw new TypeError("uint64 is not supported")}else throw new TypeError(`not a LONG type: ${L.onnx.TensorProto.DataType[r]}`);return t.toNumber()}function va(t,r,n){switch(r){case L.onnx.TensorProto.DataType.BOOL:case L.onnx.TensorProto.DataType.UINT8:return t.getUint8(n);case L.onnx.TensorProto.DataType.INT8:return t.getInt8(n);case L.onnx.TensorProto.DataType.UINT16:return t.getUint16(n,!0);case L.onnx.TensorProto.DataType.INT16:return t.getInt16(n,!0);case L.onnx.TensorProto.DataType.FLOAT:return t.getFloat32(n,!0);case L.onnx.TensorProto.DataType.INT32:return t.getInt32(n,!0);case L.onnx.TensorProto.DataType.UINT32:return t.getUint32(n,!0);case L.onnx.TensorProto.DataType.INT64:return go(ee.fromBits(t.getUint32(n,!0),t.getUint32(n+4,!0),!1),r);case L.onnx.TensorProto.DataType.DOUBLE:return t.getFloat64(n,!0);case L.onnx.TensorProto.DataType.UINT64:return go(ee.fromBits(t.getUint32(n,!0),t.getUint32(n+4,!0),!0),r);default:throw new Error(`cannot read from DataView for type ${L.onnx.TensorProto.DataType[r]}`)}}var xa,L,Vr,Pt,De=I(()=>{"use strict";xa=Ie(Fh()),fl(),Zr(),L=Ie(mr()),U(),Vr=H.experimental.fbs,Pt=class Mr{constructor(r,n,s,p,l,c=xa.Guid.create()){this.dims=r,this.type=n,this.dataProvider=s,this.asyncDataProvider=p,this.cache=l,this.dataId=c,this.size=C.validateDimsAndCalcSize(r);let o=this.size,a=s===void 0&&p===void 0&&l===void 0;if(l!==void 0&&l.length!==o)throw new RangeError("Input dims doesn't match data length.");if(n==="string"){if(l!==void 0&&(!Array.isArray(l)||!l.every(e=>typeof e=="string")))throw new TypeError("cache should be a string array");a&&(this.cache=new Array(o))}else{if(l!==void 0){let e=wl(n);if(!(l instanceof e))throw new TypeError(`cache should be type ${e.name}`)}if(a){let e=new ArrayBuffer(o*Zh(n));this.cache=Jh(e,n)}}}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[C.indicesToOffset(r,this.strides)]}set(r,n){this.data[C.indicesToOffset(r,this.strides)]=n}async getData(){return this.cache===void 0&&(this.cache=await this.asyncDataProvider(this.dataId)),this.cache}get strides(){return this._strides||(this._strides=C.computeStrides(this.dims)),this._strides}static fromProto(r){if(!r)throw new Error("cannot construct Value from an empty tensor");let n=Et.tensorDataTypeFromProto(r.dataType),s=Et.tensorDimsFromProto(r.dims),p=new Mr(s,n);if(n==="string")r.stringData.forEach((l,c)=>{p.data[c]=co(l)});else if(r.rawData&&typeof r.rawData.byteLength=="number"&&r.rawData.byteLength>0){let l=p.data,c=new DataView(r.rawData.buffer,r.rawData.byteOffset,r.rawData.byteLength),o=wa(r.dataType),a=r.rawData.byteLength/o;if(r.rawData.byteLength%o!==0)throw new Error("invalid buffer length");if(l.length!==a)throw new Error("buffer length mismatch");for(let e=0;e<a;e++){let u=va(c,r.dataType,e*o);l[e]=u}}else{let l;switch(r.dataType){case L.onnx.TensorProto.DataType.FLOAT:l=r.floatData;break;case L.onnx.TensorProto.DataType.INT32:case L.onnx.TensorProto.DataType.INT16:case L.onnx.TensorProto.DataType.UINT16:case L.onnx.TensorProto.DataType.INT8:case L.onnx.TensorProto.DataType.UINT8:case L.onnx.TensorProto.DataType.BOOL:l=r.int32Data;break;case L.onnx.TensorProto.DataType.INT64:l=r.int64Data;break;case L.onnx.TensorProto.DataType.DOUBLE:l=r.doubleData;break;case L.onnx.TensorProto.DataType.UINT32:case L.onnx.TensorProto.DataType.UINT64:l=r.uint64Data;break;default:throw new Error("unspecific error")}if(l==null)throw new Error("failed to populate data from a tensorproto value");let c=p.data;if(c.length!==l.length)throw new Error("array length mismatch");for(let o=0;o<l.length;o++){let a=l[o];ee.isLong(a)?c[o]=go(a,r.dataType):c[o]=a}}return p}static fromData(r,n,s){return new Mr(n,s,void 0,void 0,r)}static fromOrtTensor(r){if(!r)throw new Error("cannot construct Value from an empty tensor");let n=Et.tensorDimsFromORTFormat(r),s=Et.tensorDataTypeFromProto(r.dataType()),p=new Mr(n,s);if(s==="string")for(let l=0;l<r.stringDataLength();l++)p.data[l]=r.stringData(l);else if(r.rawDataArray()&&typeof r.rawDataLength()=="number"&&r.rawDataLength()>0){let l=p.data,c=new DataView(r.rawDataArray().buffer,r.rawDataArray().byteOffset,r.rawDataLength()),o=wa(r.dataType()),a=r.rawDataLength()/o;if(r.rawDataLength()%o!==0)throw new Error("invalid buffer length");if(l.length!==a)throw new Error("buffer length mismatch");for(let e=0;e<a;e++){let u=va(c,r.dataType(),e*o);l[e]=u}}return p}}});function B(t){return t===1?vl:xl}function Yh(t){let r=B(t);return`${r.version}
|
|
2
|
+
precision highp float;
|
|
3
|
+
${r.attribute} vec3 position;
|
|
4
|
+
${r.attribute} vec2 textureCoord;
|
|
5
|
+
|
|
6
|
+
${r.varyingVertex} vec2 TexCoords;
|
|
7
|
+
|
|
8
|
+
void main()
|
|
9
|
+
{
|
|
10
|
+
gl_Position = vec4(position, 1.0);
|
|
11
|
+
TexCoords = textureCoord;
|
|
12
|
+
}`}function Qh(t){let r=B(t);return`${r.version}
|
|
13
|
+
precision highp float;
|
|
14
|
+
precision highp int;
|
|
15
|
+
precision highp sampler2D;
|
|
16
|
+
${r.varyingFrag} vec2 TexCoords;
|
|
17
|
+
${r.outputDeclaration}
|
|
18
|
+
const vec2 halfCR = vec2(0.5, 0.5);
|
|
19
|
+
|
|
20
|
+
// Custom vector types to handle higher dimenalities.
|
|
21
|
+
struct ivec5
|
|
22
|
+
{
|
|
23
|
+
int x;
|
|
24
|
+
int y;
|
|
25
|
+
int z;
|
|
26
|
+
int w;
|
|
27
|
+
int u;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
struct ivec6
|
|
31
|
+
{
|
|
32
|
+
int x;
|
|
33
|
+
int y;
|
|
34
|
+
int z;
|
|
35
|
+
int w;
|
|
36
|
+
int u;
|
|
37
|
+
int v;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
int imod(int x, int y) {
|
|
41
|
+
return x - y * (x / y);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
`}function tf(t,r){let n=B(t);return`
|
|
45
|
+
void main() {
|
|
46
|
+
int indices[${r}];
|
|
47
|
+
toVec(TexCoords, indices);
|
|
48
|
+
vec4 result = vec4(process(indices));
|
|
49
|
+
${n.output} = result;
|
|
50
|
+
}
|
|
51
|
+
`}var vl,xl,Y=I(()=>{"use strict";vl={version:"",attribute:"attribute",varyingVertex:"varying",varyingFrag:"varying",texture2D:"texture2D",output:"gl_FragColor",outputDeclaration:""},xl={version:"#version 300 es",attribute:"in",varyingVertex:"out",varyingFrag:"in",texture2D:"texture",output:"outputColor",outputDeclaration:"out vec4 outputColor;"}}),V=I(()=>{"use strict"});async function Ta(t,r=s=>0,n){return new Promise((s,p)=>{let l=0,c=()=>{if(t()){s();return}l++;let o=r(l);if(n!=null&&l>=n){p();return}setTimeout(c,o)};c()})}function _n(t){return Ur(typeof t<"u"&&t.length!==0,()=>"empty string found for sampler name"),"get"+t.charAt(0).toUpperCase()+t.slice(1)}function ef(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 Ue(t,r){let n=JSON.parse(JSON.stringify(t));return n=r,n}function Ge(t,r){return r.map(n=>t[n]).join(", ")}function re(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 $e(t=6){return["x","y","z","w","u","v"].slice(0,t)}var qt=I(()=>{"use strict";U()});function rf(t,r){return $e(r).map(n=>`${t}.${n}`)}function qo(t,r){return r===1?[t]:rf(t,r)}function br(){return`
|
|
52
|
+
float getChannel(vec4 frag, int dim) {
|
|
53
|
+
int modCoord = imod(dim, 2);
|
|
54
|
+
return modCoord == 0 ? frag.r : frag.g;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
float getChannel(vec4 frag, vec2 innerDims) {
|
|
58
|
+
vec2 modCoord = mod(innerDims, 2.);
|
|
59
|
+
return modCoord.x == 0. ?
|
|
60
|
+
(modCoord.y == 0. ? frag.r : frag.g) :
|
|
61
|
+
(modCoord.y == 0. ? frag.b : frag.a);
|
|
62
|
+
}
|
|
63
|
+
`}var Ne=I(()=>{"use strict";qt()});function nf(t,r,n){if(t===0)return"false";if(t===1)return`rc > ${r[0]}`;let s="";for(let p=t-2;p<t;p++)s+=`${n[p]} >= ${r[p-t+2]}`,p<t-1&&(s+="||");return s}function of(t,r){let n=t.length;if(n===0)return"getA(), 0, 0, 0";if(n===1)return`getA(rc),
|
|
64
|
+
rc + 1 >= ${t[0]} ? 0. : getA(rc + 1),
|
|
65
|
+
0, 0`;let s="r, c",p="r, cp1",l="rp1, c",c="rp1, cp1",o="";if(n>2)for(let a=0;a<n-2;++a)o=o+`${r[a]},`;return`getA(${o}${s}),
|
|
66
|
+
rEdge ? 0. : getA(${o}${l}),
|
|
67
|
+
cEdge ? 0. : getA(${o}${p}),
|
|
68
|
+
rEdge || cEdge ? 0. : getA(${o}${c})`}function af(t,r,n,s){return t===0||t===1?"":`
|
|
69
|
+
int r = ${r[t-2]};
|
|
70
|
+
int c = ${r[t-1]};
|
|
71
|
+
int rp1 = ${r[t-2]} + 1;
|
|
72
|
+
int cp1 = ${r[t-1]} + 1;
|
|
73
|
+
bool rEdge = rp1 >= ${s};
|
|
74
|
+
bool cEdge = cp1 >= ${n};
|
|
75
|
+
`}var Sn,_a,Tl,sf=I(()=>{"use strict";Y(),V(),qt(),Ne(),Sn={name:"pack",inputNames:["A"],inputTypes:[1]},_a=(t,r)=>{let n=B(t.session.backend.glContext.version),s=r.dims,p=s.length,l=r.dims.length,c=re(l),o=qo("rc",l),a=af(l,o,s[s.length-2],s[s.length-1]),e;p===0?e=[1,1]:p===1?e=[s[0],1]:e=[s[l-1],s[l-2]];let u=nf(l,e,o),i=of(s,o),d=`
|
|
76
|
+
void main() {
|
|
77
|
+
${c} rc = getOutputCoords();
|
|
78
|
+
|
|
79
|
+
if(${u}) {
|
|
80
|
+
${n.output} = vec4(0);
|
|
81
|
+
} else {
|
|
82
|
+
${a}
|
|
83
|
+
|
|
84
|
+
${n.output} = vec4(${i});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
`;return{...Sn,hasMain:!0,output:{dims:r.dims,type:r.type,textureType:2},shaderSource:d}},Tl=(t,r)=>({...Sn,get:()=>_a(t,r)})});function Sa(t){if(t.length===0)return[1,1,1];let r=1;for(let n=0;n<t.length-2;++n)r*=t[n];return[r,t.length>1?t[t.length-2]:1,t[t.length-1]]}function uf(t,r){let n=!1;return t.length===0||r.length===0?n=!0:t.length<2||r.length<2?n=t[t.length-1]===r[r.length-1]:n=t[t.length-1]===r[r.length-1]&&t[t.length-2]===r[r.length-2],n}function lf(t){let r=C.computeStrides(t),n=["b","r","c"],s="index";return`
|
|
88
|
+
ivec3 inputCoordsFromReshapedOutCoords(int index) {
|
|
89
|
+
${r.map((p,l)=>{let c=`int ${n[l]} = ${s} / ${p}`,o=l===r.length-1?`int ${n[l+1]} = ${s} - ${n[l]} * ${p}`:`index -= ${n[l]} * ${p}`;return`${c}; ${o};`}).join("")}
|
|
90
|
+
return ivec3(b, r, c);
|
|
91
|
+
}
|
|
92
|
+
`}function pf(t){let r=C.computeStrides(t);return`
|
|
93
|
+
int getFlattenedIndex(ivec3 coords) {
|
|
94
|
+
// reverse y, z order
|
|
95
|
+
return coords.x * ${r[0]} + coords.z * ${r[1]} + coords.y;
|
|
96
|
+
}
|
|
97
|
+
`}var Oa,Ea,_l,cf=I(()=>{"use strict";U(),Y(),V(),Ne(),Oa=t=>({name:"Reshape (packed)",inputTypes:[2],inputNames:["A"],cacheHint:`${t}`}),Ea=(t,r,n,s)=>{let p=r.dims,l=s,c="";for(let e=0;e<4;e++){let u="";switch(e){case 0:u="outputCoords = rc;";break;case 1:u="outputCoords = ivec3(rc.x, rc.y+1, rc.z);";break;case 2:u="outputCoords = ivec3(rc.x, rc.y, rc.z+1);";break;case 3:u="outputCoords = ivec3(rc.x, rc.y+1, rc.z+1);";break;default:throw new Error}c+=`
|
|
98
|
+
${u}
|
|
99
|
+
${e>0?"if(outputCoords.y < rows && outputCoords.z < cols){":""}
|
|
100
|
+
int flattenedIndex = getFlattenedIndex(outputCoords);
|
|
101
|
+
|
|
102
|
+
ivec3 inputRC = inputCoordsFromReshapedOutCoords(flattenedIndex);
|
|
103
|
+
vec2 innerDims = vec2(float(inputRC.y),float(inputRC.z));
|
|
104
|
+
|
|
105
|
+
result[${e}] = getChannel(getA(inputRC.x, inputRC.y, inputRC.z), innerDims);
|
|
106
|
+
|
|
107
|
+
${e>0?"}":""}
|
|
108
|
+
`}let o=B(t.session.backend.glContext.version),a=`
|
|
109
|
+
${lf(p)}
|
|
110
|
+
${pf(l)}
|
|
111
|
+
${br()}
|
|
112
|
+
|
|
113
|
+
void main() {
|
|
114
|
+
ivec3 rc = getOutputCoords();
|
|
115
|
+
|
|
116
|
+
vec4 result = vec4(0.0);
|
|
117
|
+
|
|
118
|
+
ivec3 outputCoords;
|
|
119
|
+
int rows = ${l[2]};
|
|
120
|
+
int cols = ${l[1]};
|
|
121
|
+
|
|
122
|
+
${c}
|
|
123
|
+
${o.output} = result;
|
|
124
|
+
}
|
|
125
|
+
`;return{...n,output:{dims:l,type:r.type,textureType:2},shaderSource:a,hasMain:!0}},_l=(t,r,n)=>{let s=Oa(n);return{...s,get:()=>Ea(t,r,s,n)}}}),mo,df=I(()=>{"use strict";Y(),V(),mo=(t,r)=>{let n=r.shape,s=B(t.session.backend.glContext.version),p=`
|
|
126
|
+
const float FLOAT_MAX = 1.70141184e38;
|
|
127
|
+
const float FLOAT_MIN = 1.17549435e-38;
|
|
128
|
+
|
|
129
|
+
bool isNaN(float val) {
|
|
130
|
+
return (val < 1.0 || 0.0 < val || val == 0.0) ? false : true;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
highp vec4 encodeAsUint8(highp float v) {
|
|
134
|
+
if (isNaN(v)) {
|
|
135
|
+
return vec4(255, 255, 255, 255);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
highp float av = abs(v);
|
|
139
|
+
|
|
140
|
+
if(av < FLOAT_MIN) {
|
|
141
|
+
return vec4(0.0, 0.0, 0.0, 0.0);
|
|
142
|
+
} else if(v > FLOAT_MAX) {
|
|
143
|
+
return vec4(0.0, 0.0, 128.0, 127.0) / 255.0;
|
|
144
|
+
} else if(v < -FLOAT_MAX) {
|
|
145
|
+
return vec4(0.0, 0.0, 128.0, 255.0) / 255.0;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
highp vec4 c = vec4(0,0,0,0);
|
|
149
|
+
|
|
150
|
+
highp float e = floor(log2(av));
|
|
151
|
+
highp float m = exp2(fract(log2(av))) - 1.0;
|
|
152
|
+
|
|
153
|
+
c[2] = floor(128.0 * m);
|
|
154
|
+
m -= c[2] / 128.0;
|
|
155
|
+
c[1] = floor(32768.0 * m);
|
|
156
|
+
m -= c[1] / 32768.0;
|
|
157
|
+
c[0] = floor(8388608.0 * m);
|
|
158
|
+
|
|
159
|
+
highp float ebias = e + 127.0;
|
|
160
|
+
c[3] = floor(ebias / 2.0);
|
|
161
|
+
ebias -= c[3] * 2.0;
|
|
162
|
+
c[2] += floor(ebias) * 128.0;
|
|
163
|
+
|
|
164
|
+
c[3] += 128.0 * step(0.0, -v);
|
|
165
|
+
|
|
166
|
+
return c / 255.0;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
void main() {
|
|
170
|
+
float value = ${s.texture2D}(X,TexCoords).r;
|
|
171
|
+
${s.output} = encodeAsUint8(value);
|
|
172
|
+
}`,l={name:"Uint8Encode",inputTypes:[0],inputNames:["X"],output:{dims:n,type:r.tensor.type,textureType:3},shaderSource:p,hasMain:!0};return t.executeProgram(l,[r.tensor])}});function hf(t,r){if(t===1)return"rc";let n="";for(let s=0;s<t;s++)n+=r[s],s<t-1&&(n+=",");return n}var On,Ia,Sl,ff=I(()=>{"use strict";Y(),V(),qt(),Ne(),On={name:"unpack",inputNames:["A"],inputTypes:[2]},Ia=(t,r)=>{let n=r.dims.length,s=qo("rc",n),p=s.slice(-2),l=re(n),c=br(),o=r.dims.length===0?"":hf(n,s),a=n<=1?"rc":`vec2(${p.join(",")})`,e=B(t.session.backend.glContext.version),u=`
|
|
173
|
+
${c}
|
|
174
|
+
void main() {
|
|
175
|
+
${l} rc = getOutputCoords();
|
|
176
|
+
|
|
177
|
+
// Sample the texture with the coords to get the rgba channel value.
|
|
178
|
+
vec4 packedInput = getA(${o});
|
|
179
|
+
|
|
180
|
+
${e.output} = vec4(getChannel(packedInput, ${a}), 0, 0, 0);
|
|
181
|
+
}
|
|
182
|
+
`;return{...On,hasMain:!0,output:{dims:r.dims,type:r.type,textureType:0},shaderSource:u}},Sl=(t,r)=>({...On,get:()=>Ia(t,r)})}),Ol,bo,El,Hr=I(()=>{"use strict";Rt(),Ol=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 n,s;return t.constructor!==Float32Array&&(tt.warning("Encoder","data was not of type Float32; creating new Float32Array"),s=new Float32Array(t)),r*this.channelSize>t.length?(tt.warning("Encoder","Source data too small. Allocating larger array"),s=t,n=this.allocate(r*this.channelSize),s.forEach((p,l)=>n[l]=p)):(s=t,n=s),n}allocate(t){return new Float32Array(t*4)}decode(t,r){return this.channelSize===1?t.filter((n,s)=>s%4===0).subarray(0,r):t.subarray(0,r)}},bo=class{constructor(t,r=1,n){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=n||t.FLOAT}encode(t,r){let n=t;return this.channelSize===1&&(tt.verbose("Encoder","Exploding into a larger array"),n=this.allocate(r),t.forEach((s,p)=>n[p*4]=s)),n}allocate(t){return new Float32Array(t*4)}decode(t,r){return this.channelSize===1?t.filter((n,s)=>s%4===0).subarray(0,r):t.subarray(0,r)}},El=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}`)}}}),ur,Il,yo,gf=I(()=>{"use strict";U(),V(),ur=(t,r,n)=>{let s=n===0||n===1?1:4,p=n===2,l=n===1||n===2,c=n===4?r.length-1:void 0,o=n===4?r.map((a,e)=>e===r.length-1?a*4:a):void 0;return yo(t,r,s,o,{isPacked:p,reverseWH:l,breakAxis:c})},Il=(t,r,n)=>{let s=ur(t,r,n);return[s.width,s.height]},yo=(t,r,n=1,s,p)=>{let l=!!(p&&p.isPacked),[c,o]=t.computeTextureWH(l&&s||r,p),a=r.length,e=r.slice(0);if(a===0&&(e=[1]),n===1)s=r;else if(l){if(n!==4)throw new Error("a packed texture must be 4-channel");s=r,a>0&&(e[a-1]=Math.ceil(e[a-1]/2)),a>1&&(e[a-2]=Math.ceil(e[a-2]/2))}else if(!s)throw new Error("Unpacked shape is needed when using channels > 1");return{width:c,height:o,channels:n,isPacked:l,shape:e,strides:C.computeStrides(e),unpackedShape:s,reversedWH:p&&p.reverseWH}}}),Pa,Pl,mf=I(()=>{"use strict";Rt(),De(),U(),sf(),cf(),df(),ff(),Hr(),gf(),V(),Pa=(t,r)=>{let n=r.map(p=>`${p.unpackedShape.join(",")};${p.width}x${p.height}`).join("_"),s=t.name;return t.cacheHint&&(s+="["+t.cacheHint+"]"),s+=":"+n,s},Pl=class{constructor(t){this.session=t,this.packedTextureDataCache=new Map,this.unpackedTextureDataCache=new Map}calculateTextureWidthAndHeight(t,r){return Il(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 n=[];for(let a=0;a<t.inputNames.length;++a)n[a]=this.getOrCreateTextureData(r[a],t.inputTypes[a]);let s=Pa(t,n),p=this.session.programManager.getArtifact(s),l=p?p.programInfo:typeof t.get=="function"?t.get():t,c=ur(this.session.layoutStrategy,l.output.dims,l.output.textureType),o=this.createTextureData(c,l.output.type);return p||(p=this.session.programManager.build(l,n,o),this.session.programManager.setArtifact(s,p)),this.runProgram(p,n,o),o}run(t,r){return this.executeProgram(t,r).tensor}runProgram(t,r,n){for(let s=0;s<r.length;++s)if(!!r[s].isPacked!=(t.programInfo.inputTypes[s]===2))throw new Error(`input[${s}] property packed inconsistent`);if(!!n.isPacked!=(t.programInfo.output.textureType===2))throw new Error("output property packed inconsistent");this.session.programManager.run(t,r,n)}getOrCreateTextureData(t,r){let n=this.getTextureData(t.dataId,r===2);if(!n&&(n=this.getTextureData(t.dataId,r!==2),n))return r===2?this.pack(n):this.unpack(n);if(!n){let s=ur(this.session.layoutStrategy,t.dims,r);if(r===4){let p=t.dims;if(p.length===4){let l=[p[0],Math.ceil(p[1]*p[2]*p[3]/4)],c=ur(this.session.layoutStrategy,l,r),o=t.numberData;if(p[1]*p[2]*p[3]%4!==0){let a=p[0],e=p[1]*p[2]*p[3],u=Math.ceil(e*1/4)*4,i=a*u;o=new Float32Array(i);for(let d=0;d<a;++d){let h=d*e,m=d*u+d%1*e;o.set(t.numberData.subarray(h,h+e),m)}}return this.createTextureData(c,t.type,o,t,1)}}if(r===2){let p=yo(this.session.layoutStrategy,t.dims,1,[],{reverseWH:!0}),l=this.createTextureData(p,t.type,t.numberData,t,1);n=this.pack(l)}else n=this.createTextureData(s,t.type,t.numberData,t,1)}return n}createTextureDataFromLayoutBindTensor(t,r,n,s){return this.createTextureData(t,r,n,s,1)}createTextureData(t,r,n,s,p){tt.verbose("InferenceHandler",`Creating TextureData: layout:[${JSON.stringify(t)}]`);let l=this.session.textureManager.createTextureFromLayout(r,t,n,p);return this.createTextureDataFromTexture(t,r,l,s)}reshapeUnpacked(t,r){let n=this.getOrCreateTextureData(t,0),s={channels:n.channels,height:n.height,width:n.width,shape:r.length!==0?r:[1],strides:C.computeStrides(r),unpackedShape:r};return this.createTextureDataFromTexture(s,t.type,n.texture).tensor}reshapePacked(t,r){let n=this.getOrCreateTextureData(t,2);if(uf(t.dims,r)){let o={channels:n.channels,height:n.height,width:n.width,shape:r.length!==0?r:[1],strides:C.computeStrides(r),unpackedShape:r,isPacked:!0};return this.createTextureDataFromTexture(o,t.type,n.texture).tensor}let s=Sa(t.dims),p=Sa(r),l=this.reshapePacked(t,s),c=this.run(_l(this,l,p),[l]);return this.reshapePacked(c,r)}cast(t,r){let n=this.getOrCreateTextureData(t,0);return this.createTextureDataFromTexture(n,r,n.texture).tensor}createTextureDataFromTexture(t,r,n,s,p){let l={...t,tensor:s||new Pt(t.unpackedShape,r,c=>this.readTexture(l),async c=>this.readTextureAsync(l),void 0,p),texture:n};return this.setTextureData(l.tensor.dataId,l,t.isPacked),l}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,n=!1){this.session.isInitializer(t)?this.session.setTextureData(t,r,n):(n?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(mo(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(mo(this,t))}pack(t){return this.executeProgram(Tl(this,t.tensor),[t.tensor])}unpack(t){return this.executeProgram(Sl(this,t.tensor),[t.tensor])}}}),Aa,X,lt=I(()=>{"use strict";Aa=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}},X=t=>new Aa(t)}),En,Al,$l,$a,Da,bf=I(()=>{"use strict";lt(),Y(),V(),En={name:"BatchNormalization",inputNames:["A","Scale","B","Mean","Variance"],inputTypes:[0,0,0,0,0]},Al=(t,r,n)=>(Da(r),[t.run({...En,cacheHint:n.cacheKey,get:()=>$a(t,r,n)},r)]),$l=t=>{let r=t.attributes.getFloat("epsilon",1e-5),n=t.attributes.getFloat("momentum",.9),s=t.attributes.getInt("spatial",1);return X({epsilon:r,momentum:n,spatial:s})},$a=(t,r,n)=>{let s=B(t.session.backend.glContext.version),p=r[0].dims.length,[l,c]=t.calculateTextureWidthAndHeight(r[1].dims,0),o=`
|
|
183
|
+
float process(int[${p}] indices) {
|
|
184
|
+
vec2 position = offsetToCoords(indices[1], ${l}, ${c});
|
|
185
|
+
float scale = getColorAsFloat(${s.texture2D}(Scale, position));
|
|
186
|
+
float mean = getColorAsFloat(${s.texture2D}(Mean, position));
|
|
187
|
+
float variance = getColorAsFloat(${s.texture2D}(Variance, position));
|
|
188
|
+
float b = getColorAsFloat(${s.texture2D}(B, position));
|
|
189
|
+
|
|
190
|
+
return scale * ( (_A(indices) - mean) / sqrt(variance + float(${n.epsilon})) ) + b;
|
|
191
|
+
}`;return{...En,output:{dims:r[0].dims,type:r[0].type,textureType:0},shaderSource:o}},Da=t=>{if(!t||t.length!==5)throw new Error("BatchNormalization requires 5 inputs.");let r=t[0],n=t[1],s=t[2],p=t[3],l=t[4];if(r.dims.length<3||n.dims.length!==1||s.dims.length!==1||p.dims.length!==1||l.dims.length!==1)throw new Error("invalid input shape.");if(n.dims[0]!==r.dims[1]||s.dims[0]!==r.dims[1]||p.dims[0]!==r.dims[1]||l.dims[0]!==r.dims[1])throw new Error("invalid input shape.");if(r.type!=="float32"&&r.type!=="float64"||n.type!=="float32"&&n.type!=="float64"||s.type!=="float32"&&s.type!=="float64"||p.type!=="float32"&&p.type!=="float64"||l.type!=="float32"&&l.type!=="float64")throw new Error("invalid input tensor types.")}}),Dl,ke,D,wo,Nl,ne=I(()=>{"use strict";Dl=class{constructor(t,r,n,s){this.glContext=t,this.programInfo=r,this.inputTextureLayouts=n,this.outputTextureLayout=s}},ke=class{constructor(t){this.context=t}},D=class{constructor(t,r){this.routineBody=t,this.dependencies=r}},wo=class{constructor(t,r,n){this.name=t,n?this.dependencies=n:this.dependencies=[],r&&(this.routineBody=r)}addDependency(t){t&&this.dependencies.push(t)}},Nl=class{static returnOrderedNodes(t){if(!t||t.length===0)return[];if(t.length===1)return t;let r=new Set,n=new Set,s=new Array;return this.createOrderedNodes(t,r,n,s),s}static createOrderedNodes(t,r,n,s){for(let p=0;p<t.length;++p)this.dfsTraverse(t[p],r,n,s)}static dfsTraverse(t,r,n,s){if(!t||n.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 p=t.dependencies;if(p&&p.length>0)for(let l=0;l<p.length;++l)this.dfsTraverse(p[l],r,n,s);s.push(t),n.add(t.name),r.delete(t.name)}}});function yf(){let t="add_";return{body:`
|
|
192
|
+
float ${t}(float a, float b) {
|
|
193
|
+
return a + b;
|
|
194
|
+
}
|
|
195
|
+
vec4 ${t}(vec4 v1, vec4 v2) {
|
|
196
|
+
return v1 + v2;
|
|
197
|
+
}
|
|
198
|
+
`,name:t,type:0}}function wf(){let t="div_";return{body:`
|
|
199
|
+
float ${t}(float a, float b) {
|
|
200
|
+
return a / b;
|
|
201
|
+
}
|
|
202
|
+
vec4 ${t}(vec4 v1, vec4 v2) {
|
|
203
|
+
return v1 / v2;
|
|
204
|
+
}
|
|
205
|
+
`,name:t,type:0}}function vf(){let t="mul_";return{body:`
|
|
206
|
+
float ${t}(float a, float b) {
|
|
207
|
+
return a * b;
|
|
208
|
+
}
|
|
209
|
+
vec4 ${t}(vec4 v1, vec4 v2) {
|
|
210
|
+
return v1 * v2;
|
|
211
|
+
}
|
|
212
|
+
`,name:t,type:0}}function xf(){let t="sub_";return{body:`
|
|
213
|
+
float ${t}(float a, float b) {
|
|
214
|
+
return a - b;
|
|
215
|
+
}
|
|
216
|
+
vec4 ${t}(vec4 v1, vec4 v2) {
|
|
217
|
+
return v1 - v2;
|
|
218
|
+
}
|
|
219
|
+
`,name:t,type:0}}function Tf(){let t="equal_";return{body:`
|
|
220
|
+
float ${t}(float a, float b) {
|
|
221
|
+
return float(a == b);
|
|
222
|
+
}
|
|
223
|
+
vec4 ${t}(vec4 v1, vec4 v2) {
|
|
224
|
+
return vec4(equal(v1, v2));
|
|
225
|
+
}
|
|
226
|
+
`,name:t,type:0}}function _f(){let t="greater_";return{body:`
|
|
227
|
+
float ${t}(float a, float b) {
|
|
228
|
+
return float(a > b);
|
|
229
|
+
}
|
|
230
|
+
vec4 ${t}(vec4 v1, vec4 v2) {
|
|
231
|
+
return vec4( v1.r > v2.r ,
|
|
232
|
+
v1.g > v2.g,
|
|
233
|
+
v1.b > v2.b,
|
|
234
|
+
v1.a > v2.a );
|
|
235
|
+
}
|
|
236
|
+
`,name:t,type:0}}function Sf(){let t="less_";return{body:`
|
|
237
|
+
float ${t}(float a, float b) {
|
|
238
|
+
return float(a < b);
|
|
239
|
+
}
|
|
240
|
+
vec4 ${t}(vec4 v1, vec4 v2) {
|
|
241
|
+
return vec4( v1.r < v2.r ,
|
|
242
|
+
v1.g < v2.g,
|
|
243
|
+
v1.b < v2.b,
|
|
244
|
+
v1.a < v2.a );
|
|
245
|
+
}
|
|
246
|
+
`,name:t,type:0}}function Of(){let t="and_";return{body:`
|
|
247
|
+
float ${t}(float a, float b) {
|
|
248
|
+
return float( bool(a) && bool(b) );
|
|
249
|
+
}
|
|
250
|
+
vec4 ${t}(vec4 v1, vec4 v2) {
|
|
251
|
+
bvec4 b1 = bvec4(v1);
|
|
252
|
+
bvec4 b2 = bvec4(v2);
|
|
253
|
+
return vec4( b1.r && b2.r ,
|
|
254
|
+
b1.g && b2.g,
|
|
255
|
+
b1.b && b2.b,
|
|
256
|
+
b1.a && b2.a );
|
|
257
|
+
}
|
|
258
|
+
`,name:t,type:0}}function Ef(){let t="or_";return{body:`
|
|
259
|
+
float ${t}(float a, float b) {
|
|
260
|
+
return float( bool(a) || bool(b) );
|
|
261
|
+
}
|
|
262
|
+
vec4 ${t}(vec4 v1, vec4 v2) {
|
|
263
|
+
bvec4 b1 = bvec4(v1);
|
|
264
|
+
bvec4 b2 = bvec4(v2);
|
|
265
|
+
return vec4( b1.r || b2.r ,
|
|
266
|
+
b1.g || b2.g,
|
|
267
|
+
b1.b || b2.b,
|
|
268
|
+
b1.a || b2.a );
|
|
269
|
+
}
|
|
270
|
+
`,name:t,type:0}}function If(){let t="xor_";return{body:`
|
|
271
|
+
float ${t}(float a, float b) {
|
|
272
|
+
return float( bool(a) ^^ bool(b) );
|
|
273
|
+
}
|
|
274
|
+
vec4 ${t}(vec4 v1, vec4 v2) {
|
|
275
|
+
bvec4 b1 = bvec4(v1);
|
|
276
|
+
bvec4 b2 = bvec4(v2);
|
|
277
|
+
return vec4( b1.r ^^ b2.r ,
|
|
278
|
+
b1.g ^^ b2.g,
|
|
279
|
+
b1.b ^^ b2.b,
|
|
280
|
+
b1.a ^^ b2.a );
|
|
281
|
+
}
|
|
282
|
+
`,name:t,type:0}}function Pf(){return $f("pow")}function Af(){let t="prelu_";return{body:`
|
|
283
|
+
float ${t}(float a, float b) {
|
|
284
|
+
return a < 0.0 ? a * b: a;
|
|
285
|
+
}
|
|
286
|
+
vec4 ${t}(vec4 v1, vec4 v2) {
|
|
287
|
+
return vec4(
|
|
288
|
+
v1.r < 0.0 ? v1.r * v2.r: v1.r,
|
|
289
|
+
v1.g < 0.0 ? v1.g * v2.g: v1.g,
|
|
290
|
+
v1.b < 0.0 ? v1.b * v2.b: v1.b,
|
|
291
|
+
v1.a < 0.0 ? v1.a * v2.a: v1.a
|
|
292
|
+
);
|
|
293
|
+
}
|
|
294
|
+
`,name:t,type:0}}function $f(t){let r=`${t}_`;return{body:`
|
|
295
|
+
float ${r}(float a, float b) {
|
|
296
|
+
return ${t}(a, b);
|
|
297
|
+
}
|
|
298
|
+
vec4 ${r}(vec4 v1, vec4 v2) {
|
|
299
|
+
return ${t}(v1, v2);
|
|
300
|
+
}
|
|
301
|
+
`,name:r,type:0}}var St,Na,kl,Fl,Cl,Ll,Rl,jl,Bl,Vl,Ml,zl,Ul,Gl,Df=I(()=>{"use strict";U(),ne(),Y(),V(),St=(t,r,n,s=r[0].type,p)=>{let l=t.session.pack?2:0;return{name:n.name,inputNames:["A","B"],inputTypes:[l,l],cacheHint:p,get:()=>Na(t,r,n,s)}},Na=(t,r,n,s=r[0].type)=>{let p=t.session.pack?2:0,l=!C.areEqual(r[0].dims,r[1].dims),c=r[0].dims,o=t.session.pack;if(l){let u=Mt.calcShape(r[0].dims,r[1].dims,!1);if(!u)throw new Error("Can't perform binary op on the given tensors");c=u;let i=c.length,d=r[0].dims.length!==0?r[0].dims.length:1,h=r[1].dims.length!==0?r[1].dims.length:1,m=r[0].dims.length!==0?"bcastIndices_A(indices, aindices);":"aindices[0] = 0;",b=r[1].dims.length!==0?"bcastIndices_B(indices, bindices);":"bindices[0] = 0;",x=B(t.session.backend.glContext.version),E=o?`
|
|
302
|
+
${n.body}
|
|
303
|
+
void main() {
|
|
304
|
+
vec4 a = getAAtOutCoords();
|
|
305
|
+
vec4 b = getBAtOutCoords();
|
|
306
|
+
vec4 result = ${n.name}(a, b);
|
|
307
|
+
${x.output} = result;
|
|
308
|
+
}`:`
|
|
309
|
+
${n.body}
|
|
310
|
+
float process(int indices[${i}]) {
|
|
311
|
+
int aindices[${d}];
|
|
312
|
+
int bindices[${h}];
|
|
313
|
+
${m}
|
|
314
|
+
${b}
|
|
315
|
+
return ${n.name}(_A(aindices), _B(bindices));
|
|
316
|
+
}`;return{name:n.name,inputNames:["A","B"],inputTypes:[p,p],output:{dims:c,type:s,textureType:p},shaderSource:E,hasMain:o}}let a=B(t.session.backend.glContext.version),e=`
|
|
317
|
+
${n.body}
|
|
318
|
+
void main() {
|
|
319
|
+
vec4 v1 = ${a.texture2D}(A, TexCoords);
|
|
320
|
+
vec4 v2 = ${a.texture2D}(B, TexCoords);
|
|
321
|
+
vec4 result = ${n.name}(v1, v2);
|
|
322
|
+
${a.output} = result;
|
|
323
|
+
}
|
|
324
|
+
`;return{name:n.name,inputNames:["A","B"],inputTypes:[p,p],output:{dims:r[0].dims,type:s,textureType:p},shaderSource:e,hasMain:!0}},kl=(t,r)=>[t.run(St(t,r,yf()),r)],Fl=(t,r)=>[t.run(St(t,r,Of(),"bool"),r)],Cl=(t,r)=>[t.run(St(t,r,wf()),r)],Ll=(t,r)=>[t.run(St(t,r,Tf(),"bool"),r)],Rl=(t,r)=>[t.run(St(t,r,_f(),"bool"),r)],jl=(t,r)=>[t.run(St(t,r,Sf(),"bool"),r)],Bl=(t,r)=>[t.run(St(t,r,vf()),r)],Vl=(t,r)=>[t.run(St(t,r,Ef(),"bool"),r)],Ml=(t,r)=>[t.run(St(t,r,Pf()),r)],zl=(t,r)=>[t.run(St(t,r,Af()),r)],Ul=(t,r)=>[t.run(St(t,r,xf()),r)],Gl=(t,r)=>[t.run(St(t,r,If(),"bool"),r)]}),Hl,ql,ka,Nf=I(()=>{"use strict";U(),Hl=(t,r,n)=>(ka(r),[t.cast(r[0],n)]),ql=t=>Et.tensorDataTypeFromProto(t.attributes.getInt("to")),ka=t=>{if(!t||t.length!==1)throw new Error("Cast requires 1 input.");if(t[0].type==="string")throw new Error("Invalid input type.")}}),Fa,Ca,Wl,He,kf=I(()=>{"use strict";Y(),V(),qt(),Ne(),Fa=(t,r)=>({name:"Concat (packed)",inputNames:Array.from({length:t},(n,s)=>`X${s}`),inputTypes:Array(t).fill(2),cacheHint:r}),Ca=(t,r,n,s)=>{let p=n[0].dims.slice();if(s>=p.length||s<-1*p.length)throw new Error("axis specified for concat doesn't match input dimensionality");s<0&&(s=p.length+s);let l=p.slice(0);for(let F=1;F<n.length;F++){let bt=n[F].dims.slice();for(let pt=0;pt<p.length;pt++)if(pt===s)l[s]+=bt[pt];else if(p[pt]!==bt[pt])throw new Error("non concat dimensions must match")}let c=l.length,o=qo("coords",c),a=re(c),e=br(),u=n.map(F=>F.dims),i=$e(c),d=new Array(u.length-1);d[0]=u[0][s];for(let F=1;F<d.length;F++)d[F]=d[F-1]+u[F][s];let h=i[s],m=i.slice(-2),b=i.join(),x=`if (${h} < ${d[0]}) {
|
|
325
|
+
return getChannel(
|
|
326
|
+
getX0(${b}), vec2(${m.join()}));
|
|
327
|
+
}`;for(let F=1;F<d.length;F++){let bt=d[F-1];x+=`
|
|
328
|
+
if (${h} < ${d[F]} && ${h} >= ${d[F-1]}) {
|
|
329
|
+
return getChannel(
|
|
330
|
+
getX${F}(${He(i,h,bt)}),
|
|
331
|
+
vec2(${He(m,h,bt)}));
|
|
332
|
+
}`}let E=d.length,w=d[d.length-1];x+=`
|
|
333
|
+
return getChannel(
|
|
334
|
+
getX${E}(${He(i,h,w)}),
|
|
335
|
+
vec2(${He(m,h,w)}));`;let S=B(t.session.backend.glContext.version),$=`
|
|
336
|
+
${e}
|
|
337
|
+
float getValue(${i.map(F=>"int "+F)}) {
|
|
338
|
+
${x}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
void main() {
|
|
342
|
+
${a} coords = getOutputCoords();
|
|
343
|
+
int lastDim = coords.${i[c-1]};
|
|
344
|
+
coords.${i[c-1]} = coords.${i[c-2]};
|
|
345
|
+
coords.${i[c-2]} = lastDim;
|
|
346
|
+
|
|
347
|
+
vec4 result = vec4(getValue(${o}), 0., 0., 0.);
|
|
348
|
+
|
|
349
|
+
${o[c-1]} = ${o[c-1]} + 1;
|
|
350
|
+
if (${o[c-1]} < ${l[c-1]}) {
|
|
351
|
+
result.g = getValue(${o});
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
${o[c-2]} = ${o[c-2]} + 1;
|
|
355
|
+
if (${o[c-2]} < ${l[c-2]}) {
|
|
356
|
+
result.a = getValue(${o});
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
${o[c-1]} = ${o[c-1]} - 1;
|
|
360
|
+
if (${o[c-2]} < ${l[c-2]} &&
|
|
361
|
+
${o[c-1]} < ${l[c-1]}) {
|
|
362
|
+
result.b = getValue(${o});
|
|
363
|
+
}
|
|
364
|
+
${S.output} = result;
|
|
365
|
+
}
|
|
366
|
+
`;return{...r,output:{dims:l,type:n[0].type,textureType:2},shaderSource:$,hasMain:!0}},Wl=(t,r,n)=>{let s=Fa(r.length,n.cacheKey);return{...s,get:()=>Ca(t,s,r,n.axis)}},He=(t,r,n)=>{let s=t.indexOf(r);return t.map((p,l)=>l===s?`${p} - ${n}`:p).join()}}),Xl,La,Ra,ja,In,Ba,Va,Ma,Kl,za,Ff=I(()=>{"use strict";lt(),V(),kf(),Xl=(t,r,n)=>(za(r),t.session.pack&&r[0].dims.length>1?[t.run(Wl(t,r,n),r)]:[t.run(ja(t,r,n),r)]),La=(t,r)=>({name:"Concat",inputNames:Array.from({length:t},(n,s)=>`X${s}`),inputTypes:Array(t).fill(0),cacheHint:r}),Ra=(t,r,n,s)=>{let p=n[0].dims.slice();if(s>=p.length||s<-1*p.length)throw new Error("axis specified for concat doesn't match input dimensionality");s<0&&(s=p.length+s);let l=p.slice(0);for(let h=1;h<n.length;h++){let m=n[h].dims.slice();for(let b=0;b<p.length;b++)if(b===s)l[s]+=m[b];else if(p[b]!==m[b])throw new Error("non concat dimensions must match")}let c=l.length,o=new Array(n.length),a=0;for(let h=0;h<o.length;++h)a+=n[h].dims[s],o[h]=a;let e="";n.length<5?e=In(o):e=Ba(o);let u=Va(n.length,c),i=Ma(o),d=`
|
|
367
|
+
${u}
|
|
368
|
+
${i}
|
|
369
|
+
${e}
|
|
370
|
+
float process(int indices[${c}]) {
|
|
371
|
+
int textureIndex = getTextureWhereDataResides (indices[${s}]);
|
|
372
|
+
|
|
373
|
+
if(textureIndex != 0) {
|
|
374
|
+
indices[${s}] = indices[${s}] - int(getSizeInConcatAxisValueFromIndex(textureIndex-int(1)));
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
return fetchDataFromCorrectTexture(textureIndex, indices);
|
|
378
|
+
}`;return{...r,output:{dims:l,type:n[0].type,textureType:0},shaderSource:d}},ja=(t,r,n)=>{let s=La(r.length,n.cacheKey);return{...s,get:()=>Ra(t,s,r,n.axis)}},In=t=>`int getTextureWhereDataResides(int index) {
|
|
379
|
+
${t.map((r,n)=>`if(index<${r}) {return ${n};}
|
|
380
|
+
`).join("")}
|
|
381
|
+
}`,Ba=t=>In(t),Va=(t,r)=>{let n=[`float fetchDataFromCorrectTexture(int textureIndex, int indices[${r}]) {`];for(let s=0;s<t;++s)s===0?n.push(` if (textureIndex == ${s}) { return _X${s}(indices); }`):s===t-1?n.push(` else { return _X${s}(indices); }`):n.push(` else if (textureIndex == ${s}) { return _X${s}(indices); }`);return n.push(" }"),n.join(`
|
|
382
|
+
`)},Ma=t=>{let r=["int getSizeInConcatAxisValueFromIndex(int index) {"];for(let n=0;n<t.length;++n)n===0?r.push(` if (index == ${n}) { return ${t[n]}; }`):n===t.length-1?r.push(` else { return ${t[n]}; }`):r.push(` else if (index == ${n}) { return ${t[n]}; }`);return r.push(" }"),r.join(`
|
|
383
|
+
`)},Kl=t=>X({axis:t.attributes.getInt("axis")}),za=t=>{if(!t||t.length<1)throw new Error("too few inputs");let r=t[0].type,n=t[0].dims.length;if(r==="string")throw new Error("string tensor is not supported yet");for(let s of t){if(s.type!==r)throw new Error("input tensors should be one type");if(s.dims.length!==n)throw new Error("input tensors should have the same shape")}}});function Cf(){return Ft("abs")}function Lf(){return Ft("acos")}function Rf(){return Ft("asin")}function jf(){return Ft("atan")}function Bf(){return Ft("ceil")}function Vf(){return Ft("cos")}function Mf(t){let r="elu";return{body:`
|
|
384
|
+
const float alpha = float(${t});
|
|
385
|
+
|
|
386
|
+
float ${r}_(float a) {
|
|
387
|
+
return a >= 0.0 ? a: (exp(a) - 1.0) * alpha;
|
|
388
|
+
}
|
|
389
|
+
vec4 ${r}_(vec4 v) {
|
|
390
|
+
return vec4(${r}_(v.x), ${r}_(v.y), ${r}_(v.z), ${r}_(v.w));
|
|
391
|
+
}
|
|
392
|
+
`,name:r,type:0}}function zf(){return Ft("exp")}function Uf(){return Ft("floor")}function Zl(t,r){let n="clip";return{body:`
|
|
393
|
+
const float min = float(${t});
|
|
394
|
+
const float max = float(${r});
|
|
395
|
+
|
|
396
|
+
float ${n}_(float a) {
|
|
397
|
+
return clamp(a, min, max);
|
|
398
|
+
}
|
|
399
|
+
vec4 ${n}_(vec4 v) {
|
|
400
|
+
return clamp(v, min, max);
|
|
401
|
+
}
|
|
402
|
+
`,name:n,type:0}}function Gf(){let t="indentity";return{body:`
|
|
403
|
+
float ${t}_(float a) {
|
|
404
|
+
return a;
|
|
405
|
+
}
|
|
406
|
+
vec4 ${t}_(vec4 v) {
|
|
407
|
+
return v;
|
|
408
|
+
}
|
|
409
|
+
`,name:t,type:0}}function Hf(t){let r="leakyRelu";return{body:`
|
|
410
|
+
const float alpha = float(${t});
|
|
411
|
+
|
|
412
|
+
float ${r}_(float a) {
|
|
413
|
+
return a < 0.0 ? a * alpha : a;
|
|
414
|
+
}
|
|
415
|
+
vec4 ${r}_(vec4 v) {
|
|
416
|
+
return vec4(${r}_(v.x), ${r}_(v.y), ${r}_(v.z), ${r}_(v.w));
|
|
417
|
+
}
|
|
418
|
+
`,name:r,type:0}}function qf(){return Ft("log")}function Wf(){let t="neg";return{body:`
|
|
419
|
+
float ${t}_(float a) {
|
|
420
|
+
return -a;
|
|
421
|
+
}
|
|
422
|
+
vec4 ${t}_(vec4 v) {
|
|
423
|
+
return -v;
|
|
424
|
+
}
|
|
425
|
+
`,name:t,type:0}}function Xf(){let t="not";return{body:`
|
|
426
|
+
float ${t}_(float a) {
|
|
427
|
+
return float( ! bool(a) );
|
|
428
|
+
}
|
|
429
|
+
bool ${t}_(bool a) {
|
|
430
|
+
return !a;
|
|
431
|
+
}
|
|
432
|
+
vec4 ${t}_(vec4 v) {
|
|
433
|
+
return vec4(!bool(v.x), !bool(v.y), !bool(v.z), !bool(v.w));
|
|
434
|
+
}
|
|
435
|
+
bvec4 ${t}_(bvec4 v) {
|
|
436
|
+
return bvec4(!v.x, !v.y, !v.z, !v.w);
|
|
437
|
+
}
|
|
438
|
+
`,name:t,type:0}}function Kf(){return Ft("sin")}function Jl(){let t="relu";return{body:`
|
|
439
|
+
float ${t}_(float a) {
|
|
440
|
+
return max( a, 0.0 );
|
|
441
|
+
}
|
|
442
|
+
vec4 ${t}_(vec4 v) {
|
|
443
|
+
return max( v, 0.0 );
|
|
444
|
+
}
|
|
445
|
+
`,name:t,type:0}}function Yl(){let t="sigmoid";return{body:`
|
|
446
|
+
float ${t}_(float a) {
|
|
447
|
+
return 1.0 / (1.0 + exp(-a));
|
|
448
|
+
}
|
|
449
|
+
vec4 ${t}_(vec4 v) {
|
|
450
|
+
return 1.0 / (1.0 + exp(-v));
|
|
451
|
+
}
|
|
452
|
+
`,name:t,type:0}}function Zf(){return Ft("sqrt")}function Jf(){return Ft("tan")}function Yf(){let t="tanh";return{body:`
|
|
453
|
+
float ${t}_(float a) {
|
|
454
|
+
a = clamp(a, -10., 10.);
|
|
455
|
+
a = exp(2.*a);
|
|
456
|
+
return (a - 1.) / (a + 1.);
|
|
457
|
+
}
|
|
458
|
+
vec4 ${t}_(vec4 v) {
|
|
459
|
+
v = clamp(v, -10., 10.);
|
|
460
|
+
v = exp(2.*v);
|
|
461
|
+
return (v - 1.) / (v + 1.);
|
|
462
|
+
}
|
|
463
|
+
`,name:t,type:0}}function Ft(t){return{body:`
|
|
464
|
+
float ${t}_(float a) {
|
|
465
|
+
return ${t}(a);
|
|
466
|
+
}
|
|
467
|
+
vec4 ${t}_(vec4 v) {
|
|
468
|
+
return ${t}(v);
|
|
469
|
+
}
|
|
470
|
+
`,name:t,type:0}}var Ua,Q,Ql,tp,ep,rp,vo,np,op,Ga,ip,ap,sp,up,lp,pp,xo,cp,dp,hp,fp,gp,mp,bp,yp,wp,vp,xp,Tp=I(()=>{"use strict";lt(),U(),ne(),Y(),V(),Ua=(t,r,n,s)=>{let p=t.session.pack?2:0,l=B(t.session.backend.glContext.version);return{...r,output:{dims:n.dims,type:n.type,textureType:p},shaderSource:`
|
|
471
|
+
${s.body}
|
|
472
|
+
void main() {
|
|
473
|
+
vec4 v = ${l.texture2D}(A, TexCoords);
|
|
474
|
+
v = ${s.name}_(v);
|
|
475
|
+
${l.output} = v;
|
|
476
|
+
}
|
|
477
|
+
`,hasMain:!0}},Q=(t,r,n,s)=>{let p=t.session.pack?2:0,l={name:n.name,inputTypes:[p],inputNames:["A"],cacheHint:s};return{...l,get:()=>Ua(t,l,r,n)}},Ql=(t,r)=>[t.run(Q(t,r[0],Cf()),r)],tp=(t,r)=>[t.run(Q(t,r[0],Lf()),r)],ep=(t,r)=>[t.run(Q(t,r[0],Rf()),r)],rp=(t,r)=>[t.run(Q(t,r[0],jf()),r)],vo=(t,r,n)=>[t.run(Q(t,r[0],Zl(n.min,n.max),n.cacheKey),r)],np=t=>X({min:t.attributes.getFloat("min",dr),max:t.attributes.getFloat("max",hr)}),op=(t,r)=>{let n=Ga(t,r);return vo(t,[r[0]],n)},Ga=(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 n=r.length>=3?r[1].numberData[0]:dr,s=r.length>=3?r[2].numberData[0]:hr;return X({min:n,max:s})},ip=(t,r)=>[t.run(Q(t,r[0],Bf()),r)],ap=(t,r)=>[t.run(Q(t,r[0],Vf()),r)],sp=(t,r,n)=>[t.run(Q(t,r[0],Mf(n.alpha),n.cacheKey),r)],up=t=>X({alpha:t.attributes.getFloat("alpha",1)}),lp=(t,r)=>[t.run(Q(t,r[0],zf()),r)],pp=(t,r)=>[t.run(Q(t,r[0],Uf()),r)],xo=(t,r)=>[t.run(Q(t,r[0],Gf()),r)],cp=(t,r,n)=>[t.run(Q(t,r[0],Hf(n.alpha),n.cacheKey),r)],dp=t=>X({alpha:t.attributes.getFloat("alpha",.01)}),hp=(t,r)=>[t.run(Q(t,r[0],qf()),r)],fp=(t,r)=>[t.run(Q(t,r[0],Wf()),r)],gp=(t,r)=>[t.run(Q(t,r[0],Xf()),r)],mp=(t,r)=>[t.run(Q(t,r[0],Jl()),r)],bp=(t,r)=>[t.run(Q(t,r[0],Yl()),r)],yp=(t,r)=>[t.run(Q(t,r[0],Kf()),r)],wp=(t,r)=>[t.run(Q(t,r[0],Zf()),r)],vp=(t,r)=>[t.run(Q(t,r[0],Jf()),r)],xp=(t,r)=>[t.run(Q(t,r[0],Yf()),r)]});function yr(t){let r;switch(t.activation){case"Relu":r=Jl();break;case"Sigmoid":r=Yl();break;case"Clip":r=Zl(t.clipMin,t.clipMax);break;default:return{activationFunction:"",applyActivation:""}}let n=r.name,s=r.body,p=`value = ${n}_(value);`;return{activationFunction:s,applyActivation:p}}var Jr,Fe=I(()=>{"use strict";U(),Tp(),Jr=t=>{let r=t.getString("activation","");if(r==="Clip"){let[n,s]=t.getFloats("activation_params",[dr,hr]);return{activation:r,clipMax:s,clipMin:n,activationCacheKey:`${r}:${n},${s}`}}return{activation:r,activationCacheKey:r}}}),Ha,qa,_p,Qf=I(()=>{"use strict";Rt(),Y(),V(),Ko(),Fe(),Ha=(t,r)=>({name:"GroupedConv",inputNames:t?["X","W","Bias"]:["X","W"],inputTypes:t?[0,0,0]:[0,0],cacheHint:r}),qa=(t,r,n,s)=>{let p=r.length>2?"value += getBias(output_channel);":"",l=r[0].dims.slice(),c=r[1].dims.slice(),o=c[0]/s.group;tt.verbose("GroupedConv",`autpPad:${s.autoPad}, dilations:${s.dilations}, group:${s.group}, kernelShape:${s.kernelShape}, pads:${s.pads}, strides:${s.strides}`);let a=lr(l,c,s.dilations,s.pads,s.strides),e=B(t.session.backend.glContext.version),{activationFunction:u,applyActivation:i}=yr(s),d=`
|
|
478
|
+
const ivec2 strides = ivec2(${s.strides[0]}, ${s.strides[1]});
|
|
479
|
+
const ivec2 pads = ivec2(${s.pads[0]}, ${s.pads[1]});
|
|
480
|
+
${u}
|
|
481
|
+
void main() {
|
|
482
|
+
ivec4 coords = getOutputCoords();
|
|
483
|
+
int batch = coords.x;
|
|
484
|
+
int output_channel = coords.y;
|
|
485
|
+
ivec2 xRCCorner = coords.zw * strides - pads;
|
|
486
|
+
int group_id = output_channel / ${o};
|
|
487
|
+
|
|
488
|
+
float value = 0.0;
|
|
489
|
+
for (int wInChannel = 0; wInChannel < ${c[1]}; wInChannel++) {
|
|
490
|
+
int input_channel = group_id * ${c[1]} + wInChannel;
|
|
491
|
+
for (int wHeight = 0; wHeight < ${c[2]}; wHeight++) {
|
|
492
|
+
int xHeight = xRCCorner.x + wHeight * ${s.dilations[0]};
|
|
493
|
+
|
|
494
|
+
if (xHeight < 0 || xHeight >= ${l[2]}) {
|
|
495
|
+
continue;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
for (int wWidth = 0; wWidth < ${c[3]}; wWidth++) {
|
|
499
|
+
int xWidth = xRCCorner.y + wWidth * ${s.dilations[1]};
|
|
500
|
+
if (xWidth < 0 || xWidth >= ${l[3]}) {
|
|
501
|
+
continue;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
float xVal = getX(batch, input_channel, xWidth, xHeight);
|
|
505
|
+
float wVal = getW(output_channel, wInChannel, wWidth, wHeight);
|
|
506
|
+
value += xVal*wVal;
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
${p}
|
|
511
|
+
${i}
|
|
512
|
+
${e.output} = vec4(value, .0, .0, .0);
|
|
513
|
+
}
|
|
514
|
+
`;return{...n,output:{dims:a,type:r[0].type,textureType:0},shaderSource:d,hasMain:!0}},_p=(t,r,n)=>{let s=Ha(r.length>2,n.cacheKey);return{...s,get:()=>qa(t,r,s,n)}}}),Wa,Xa,Sp,tg=I(()=>{"use strict";Y(),V(),Ne(),Wa=t=>({name:"Im2Col (packed)",inputNames:["A"],inputTypes:[2],cacheHint:t}),Xa=(t,r,n,s,p,l)=>{let c=n.dims,o=s.dims,a=2,e=3,u=p.length,i=[o[1]*o[2]*o[3],p[2]*p[3]],d=o[2]*o[3],h=br(),m=B(t.session.backend.glContext.version),b="";for(let E=0;E<=1;E++)for(let w=0;w<=1;w++)b+=`
|
|
515
|
+
blockIndex = rc.x + ${w};
|
|
516
|
+
pos = rc.y + ${E};
|
|
517
|
+
|
|
518
|
+
if(blockIndex < ${i[1]} && pos < ${i[0]}) {
|
|
519
|
+
offsetY = int(blockIndex / (${p[u-1]})) * ${l.strides[0]} -
|
|
520
|
+
${l.pads[0]};
|
|
521
|
+
d0 = offsetY + ${l.dilations[0]} * (imod(pos, ${d}) / ${o[2]});
|
|
522
|
+
|
|
523
|
+
if(d0 < ${c[a]} && d0 >= 0) {
|
|
524
|
+
offsetX = imod(blockIndex, ${p[u-1]}) * ${l.strides[1]} -
|
|
525
|
+
${l.pads[1]};
|
|
526
|
+
d1 = offsetX + ${l.dilations[1]} * imod(imod(pos, ${d}), ${o[2]});
|
|
527
|
+
|
|
528
|
+
if(d1 < ${c[e]} && d1 >= 0) {
|
|
529
|
+
|
|
530
|
+
ch = int(float(pos)/ ${d}.);
|
|
531
|
+
innerDims = vec2(d0, d1);
|
|
532
|
+
result[${E*2+w}] = getChannel(
|
|
533
|
+
getA(0, ch, int(innerDims.x),
|
|
534
|
+
int(innerDims.y)), innerDims);
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
`;let x=`
|
|
540
|
+
${h}
|
|
541
|
+
|
|
542
|
+
void main() {
|
|
543
|
+
ivec2 rc = getOutputCoords();
|
|
544
|
+
vec4 result = vec4(0.0);
|
|
545
|
+
int blockIndex, pos, offsetY, d0, offsetX, d1, ch;
|
|
546
|
+
vec2 innerDims;
|
|
547
|
+
${b}
|
|
548
|
+
${m.output} = result;
|
|
549
|
+
}
|
|
550
|
+
`;return{...r,output:{dims:i,type:n.type,textureType:2},shaderSource:x,hasMain:!0}},Sp=(t,r,n,s,p)=>{let l=Wa(p.cacheKey);return{...l,get:()=>Xa(t,l,r,n,s,p)}}});function eg(t,r,n){let s=r[0].dims,p=r[1].dims,l=Mt.calcShape(s,p,!0);if(!l)throw new Error("Can't use matmul on the given tensors");let c=re(l.length),o=$e(),{activationFunction:a,applyActivation:e}=yr(n),u=r.length>2,i=u?"value += getBiasForMatmul();":"",d=u?`${Ep(c,o,r[2].dims,l,!1)}`:"",h=l.length,m=s.length,b=p.length,x=s[s.length-1],E=`
|
|
551
|
+
${a}
|
|
552
|
+
${d}
|
|
553
|
+
float process(int indices[${h}]) {
|
|
554
|
+
int a[${m}];
|
|
555
|
+
int b[${b}];
|
|
556
|
+
bcastMatmulIndices_A(indices, a);
|
|
557
|
+
bcastMatmulIndices_B(indices, b);
|
|
558
|
+
|
|
559
|
+
float value;
|
|
560
|
+
for (int k=0; k<${x}; ++k) {
|
|
561
|
+
a[${m-1}] = k;
|
|
562
|
+
b[${b-2}] = k;
|
|
563
|
+
value += _A(a) * _B(b);
|
|
564
|
+
}
|
|
565
|
+
${i}
|
|
566
|
+
${e}
|
|
567
|
+
return value;
|
|
568
|
+
}`;return{...t,output:{dims:l,type:r[0].type,textureType:0},shaderSource:E}}function Op(t,r){let n=Ap(t.length>2,r.activationCacheKey);return{...n,get:()=>eg(n,t,r)}}function Ep(t,r,n,s,p){let l="",c=n.length,o=s.length,a=o-c;o<2&&c>0?l="coords":l=n.map((d,h)=>`coords.${r[h+a]}`).join(", ");let e=Mt.getBroadcastDims(n,s).map(d=>`coords.${r[d+a]} = 0;`).join(`
|
|
569
|
+
`),u=C.size(n)===1,i="vec4(outputValue.xx, outputValue.yy)";return u&&(i="vec4(outputValue.x)"),p?`
|
|
570
|
+
vec4 getBiasForMatmul() {
|
|
571
|
+
${t} coords = getOutputCoords();
|
|
572
|
+
${e}
|
|
573
|
+
vec4 outputValue = getBias(${l});
|
|
574
|
+
return ${i};
|
|
575
|
+
}`:`
|
|
576
|
+
float getBiasForMatmul() {
|
|
577
|
+
${t} coords = getOutputCoords();
|
|
578
|
+
${e}
|
|
579
|
+
return getBias(coords.x);
|
|
580
|
+
}`}var Ip,Pp,Ap,Ka,Wo=I(()=>{"use strict";U(),V(),qt(),Fe(),$p(),Ip=(t,r,n)=>(Ka(r),t.session.pack?[t.run(Xo(t,r,n),r)]:[t.run(Op(r,n),r)]),Pp=t=>Jr(t.attributes),Ap=(t,r)=>({name:"MatMul",inputNames:t?["A","B","Bias"]:["A","B"],inputTypes:t?[0,0,0]:[0,0],cacheHint:r}),Ka=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 rg(t,r,n,s){let p=[],l=[],c=n[0].dims,o=n[1].dims,a=c.length,e=o.length,u=s.length,i=u-a,d=u-e;p=c.map((w,S)=>`coords.${r[S+i]}`),p[a-1]="i*2",p.join(", "),l=o.map((w,S)=>`coords.${r[S+d]}`),l[e-2]="i*2",l.join(", ");let h=Mt.getBroadcastDims(c,s),m=Mt.getBroadcastDims(o,s),b=h.map(w=>`coords.${r[w+i]} = 0;`).join(`
|
|
581
|
+
`),x=m.map(w=>`coords.${r[w+d]} = 0;`).join(`
|
|
582
|
+
`),E=`int lastDim = coords.${r[u-1]};
|
|
583
|
+
coords.${r[u-1]} = coords.${r[u-2]};
|
|
584
|
+
coords.${r[u-2]} = lastDim;`;return`
|
|
585
|
+
vec4 getAAtOutCoordsMatmul(int i) {
|
|
586
|
+
${t} coords = getOutputCoords();
|
|
587
|
+
${E}
|
|
588
|
+
${b}
|
|
589
|
+
vec4 outputValue = getA(${p});
|
|
590
|
+
return outputValue;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
vec4 getBAtOutCoordsMatmul(int i) {
|
|
594
|
+
${t} coords = getOutputCoords();
|
|
595
|
+
${E}
|
|
596
|
+
${x}
|
|
597
|
+
vec4 outputValue = getB(${l});
|
|
598
|
+
return outputValue;
|
|
599
|
+
}`}function ng(t,r){let n="";for(let s=0;s<r-2;s++)n+=`rc.${t[s]}, `;return n+=`rc.${t[r-2]}, i*2`,n}function og(t,r){let n="";for(let s=0;s<r-2;s++)n+=`rc.${t[s]}, `;return n+=`i*2, rc.${t[r-1]}`,n}var Za,Ja,Xo,$p=I(()=>{"use strict";U(),Y(),V(),qt(),Fe(),Wo(),Za=(t,r)=>({name:"MatMul (packed)",inputNames:t?["A","B","Bias"]:["A","B"],inputTypes:t?[2,2,2]:[2,2],cacheHint:r}),Ja=(t,r,n,s)=>{let p=n.length>2,l=p?"value += getBiasForMatmul();":"",c=n[0].dims,o=n[1].dims,a=Mt.calcShape(c,o,!0),e=!C.areEqual(n[0].dims,n[1].dims);if(!a)throw new Error("Can't use matmul on the given tensors");let u=c[c.length-1],i=Math.ceil(u/2),d=c.length,h=o.length,m=B(t.session.backend.glContext.version),b=re(a.length),x=a.length,E=$e(),{activationFunction:w,applyActivation:S}=yr(s),$=p?`${Ep(b,E,n[2].dims,a,!0)}`:"",F=e?`${rg(b,E,n,a)}`:"",bt=e?"getAAtOutCoordsMatmul(i)":`getA(${ng(E,d)})`,pt=e?"getBAtOutCoordsMatmul(i)":`getB(${og(E,h)})`,Z=e?"":`${b} rc =
|
|
600
|
+
getOutputCoords(); int lastDim = rc.${E[x-1]}; rc.${E[x-1]} =
|
|
601
|
+
rc.${E[x-2]}; rc.${E[x-2]} = lastDim;
|
|
602
|
+
`,Le=`
|
|
603
|
+
${F}
|
|
604
|
+
${$}
|
|
605
|
+
${w}
|
|
606
|
+
void main() {
|
|
607
|
+
${Z}
|
|
608
|
+
|
|
609
|
+
vec4 value = vec4(0);
|
|
610
|
+
for (int i = 0; i < ${i}; i++) {
|
|
611
|
+
vec4 a = ${bt};
|
|
612
|
+
vec4 b = ${pt};
|
|
613
|
+
|
|
614
|
+
value += (a.rrbb * b.rgrg);
|
|
615
|
+
value += (a.ggaa * b.baba);
|
|
616
|
+
}
|
|
617
|
+
${l}
|
|
618
|
+
${S}
|
|
619
|
+
${m.output} = value;
|
|
620
|
+
}`;return{...r,output:{dims:a,type:n[0].type,textureType:2},shaderSource:Le,hasMain:!0}},Xo=(t,r,n)=>{let s=Za(r.length>2,n.activationCacheKey);return{...s,get:()=>Ja(t,s,r,n)}}}),Dp,ig=I(()=>{"use strict";Ko(),tg(),$p(),Dp=(t,r,n)=>{let s=r[0].dims,p=r[1].dims,l=lr(s,p,n.dilations,n.pads,n.strides),c=t.run(Sp(t,r[0],r[1],l,n),[r[0]]),o=t.reshapePacked(r[1],[p[0],p[1]*p[2]*p[3]]),a=r.length===3?[o,c,r[2]]:[o,c],e=t.run(Xo(t,a,n),a);return t.reshapePacked(e,l)}}),Ya,Qa,Np,To,kp=I(()=>{"use strict";V(),Ya=t=>({name:"Im2Col",inputNames:["X"],inputTypes:[0],cacheHint:t}),Qa=(t,r,n,s,p,l)=>{let c=n.dims,o=s.dims,a=p.length,e=To(c,o,p,4),u=`
|
|
621
|
+
const int XC = ${c[1]};
|
|
622
|
+
const int XH = ${c[2]};
|
|
623
|
+
const int XW = ${c[3]};
|
|
624
|
+
const int KH = ${l.kernelShape[0]};
|
|
625
|
+
const int KW = ${l.kernelShape[1]};
|
|
626
|
+
const int dilationH = ${l.dilations[0]};
|
|
627
|
+
const int dilationW = ${l.dilations[1]};
|
|
628
|
+
const int strideH = ${l.strides[0]};
|
|
629
|
+
const int strideW = ${l.strides[1]};
|
|
630
|
+
const int padH = ${l.pads[0]};
|
|
631
|
+
const int padW = ${l.pads[1]};
|
|
632
|
+
const int KHKW = KH*KW;
|
|
633
|
+
const int XCKHKW = XC * KHKW;
|
|
634
|
+
const int outputChannels = 4;
|
|
635
|
+
vec4 process(int indices[${a}]) {
|
|
636
|
+
int b = indices[0]; // batch size
|
|
637
|
+
int oh = indices[1] * strideH - padH; //output height
|
|
638
|
+
int ow = indices[2] * strideW - padW; //output width
|
|
639
|
+
int p = indices[3] * outputChannels; //patch
|
|
640
|
+
vec4 value = vec4(0.0);
|
|
641
|
+
for(int i=0; i < outputChannels; ++i) {
|
|
642
|
+
if(p < XCKHKW) {
|
|
643
|
+
int patchC = p / KHKW;
|
|
644
|
+
int patchH = (p - patchC*KHKW) / KW;
|
|
645
|
+
int patchW = (p - patchC*KHKW) - patchH * KW;
|
|
646
|
+
int xh2 = oh + patchH * dilationH;
|
|
647
|
+
int xw2 = ow + patchW * dilationW;
|
|
648
|
+
int x[${c.length}];
|
|
649
|
+
x[0] = b;
|
|
650
|
+
x[1] = patchC;
|
|
651
|
+
x[2] = xh2;
|
|
652
|
+
x[3] = xw2;
|
|
653
|
+
if(xh2 >= 0 &&
|
|
654
|
+
xh2 < XH &&
|
|
655
|
+
xw2 >= 0 &&
|
|
656
|
+
xw2 < XW) {
|
|
657
|
+
value[i] = _X(x);
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
++p;
|
|
661
|
+
}
|
|
662
|
+
return value;
|
|
663
|
+
}
|
|
664
|
+
`;return{...r,output:{dims:e,type:n.type,textureType:4},shaderSource:u}},Np=(t,r,n,s,p)=>{let l=Ya(p.cacheKey);return{...l,get:()=>Qa(t,l,r,n,s,p)}},To=(t,r,n,s=4)=>[n[0],n[2],n[3],Math.ceil(t[1]*r[2]*r[3]/s)]}),ts,es,Fp,ag=I(()=>{"use strict";U(),Y(),V(),Fe(),kp(),ts=(t,r)=>({name:"ConvDotProduct",inputNames:t?["Im2Col","K","B"]:["Im2Col","K"],inputTypes:t?[0,4,0]:[0,4],cacheKey:r.activationCacheKey}),es=(t,r,n,s,p)=>{let l=n[0].dims,c=n[1].dims,o=[c[0],Math.ceil(l[1]*c[2]*c[3]/4)],a=To(l,c,s),[e,u]=t.calculateTextureWidthAndHeight(o,4),i=C.computeStrides(a),[d,h]=t.calculateTextureWidthAndHeight(a,4),m=s.length,b=n.length<3?"0.0":"_B(b)",x=Math.ceil(l[1]*c[2]*c[3]/4),{activationFunction:E,applyActivation:w}=yr(p),S=B(t.session.backend.glContext.version),$=`
|
|
665
|
+
${E}
|
|
666
|
+
float process(int indices[${m}]) {
|
|
667
|
+
int b[1];
|
|
668
|
+
b[0] = indices[1];
|
|
669
|
+
int im2col[4];
|
|
670
|
+
im2col[0] = indices[0];
|
|
671
|
+
im2col[1] = indices[2];
|
|
672
|
+
im2col[2] = indices[3];
|
|
673
|
+
int im2colOffset = im2col[0] * ${i[0]} + im2col[1] * ${i[1]} + im2col[2] * ${i[2]};
|
|
674
|
+
int kernelOffset = indices[1] * ${o[1]};
|
|
675
|
+
float value = ${b};
|
|
676
|
+
for (int i = 0; i < ${x}; ++i) {
|
|
677
|
+
vec2 im2colCoords = offsetToCoords(im2colOffset, ${d}, ${h});
|
|
678
|
+
vec2 kernelCoords = offsetToCoords(kernelOffset, ${e}, ${u});
|
|
679
|
+
value += dot(${S.texture2D}(Im2Col, im2colCoords), ${S.texture2D}(K, kernelCoords));
|
|
680
|
+
++im2colOffset;
|
|
681
|
+
++kernelOffset;
|
|
682
|
+
}
|
|
683
|
+
${w}
|
|
684
|
+
return value;
|
|
685
|
+
}`;return{...r,output:{dims:s,type:n[0].type,textureType:0},shaderSource:$}},Fp=(t,r,n,s)=>{let p=ts(r.length>2,s);return{...p,get:()=>es(t,p,r,n,s)}}}),lr,_o,rs,ns,os,is,So,as,Ko=I(()=>{"use strict";lt(),U(),Qf(),ig(),ag(),Fe(),kp(),Wo(),lr=(t,r,n,s,p)=>{let l=t[0],c=t.slice(2),o=c.length,a=r[0],e=r.slice(2).map((i,d)=>i+(i-1)*(n[d]-1)),u=c.map((i,d)=>i+s[d]+s[d+o]).map((i,d)=>Math.floor((i-e[d]+p[d])/p[d]));return[l,a].concat(...u)},_o=(t,r,n)=>(as(r,n),rs(t,r,n)),rs=(t,r,n)=>{let s=is(n,r),p=t.session.pack,l=s.kernelShape[0]===1&&s.kernelShape[1]===1;return s.group>1?[t.run(_p(t,r,s),r)]:l&&p?[ns(t,r,s)]:p&&r[0].dims.length===4&&r[0].dims[0]===1&&!l?[Dp(t,r,s)]:[os(t,r,s)]},ns=(t,r,n)=>{let s=r[0].dims,p=r[1].dims,l=lr(s,p,n.dilations,n.pads,n.strides),c=t.reshapeUnpacked(r[0],[s[1],s[2]*s[3]]),o=t.reshapeUnpacked(r[1],[p[0],p[1]]),a=r.length>2?[o,c,r[2]]:[o,c],e=t.run(Op(a,n),a);return t.reshapeUnpacked(e,l)},os=(t,r,n)=>{let s=r[0].dims,p=r[1].dims,l=lr(s,p,n.dilations,n.pads,n.strides),c=t.run(Np(t,r[0],r[1],l,n),[r[0]]),o=r.length===3?[c,r[1],r[2]]:[c,r[1]];return t.run(Fp(t,r,l,n),o)},is=(t,r)=>{let n=t.kernelShape.slice();if(t.kernelShape.length===0)for(let l=2;l<r[1].dims.length;++l)n.push(r[1].dims[l]);let s=t.pads.slice();Gr.adjustPadsBasedOnAutoPad(r[0].dims,t.strides,t.dilations,n,s,t.autoPad);let p=Object.assign({},t);return Object.assign(p,{kernelShape:n,pads:s,cacheKey:t.cacheKey}),p},So=t=>{let r=t.attributes,n=Jr(r),s=r.getString("auto_pad","NOTSET"),p=r.getInts("dilations",[1,1]),l=r.getInt("group",1),c=r.getInts("kernel_shape",[]),o=r.getInts("pads",[0,0,0,0]),a=r.getInts("strides",[1,1]);return X({autoPad:s,dilations:p,group:l,kernelShape:c,pads:o,strides:a,...n})},as=(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 n=t[0].dims[1],s=t[1].dims[1]*r.group;if(n!==s)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 p=t[0].dims.length-2;if(r.dilations.length!==p)throw new Error(`dilations should be ${p}D`);if(r.strides.length!==p)throw new Error(`strides should be ${p}D`);if(r.pads.length!==p*2)throw new Error(`pads should be ${p*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")}}),ss,us,ls,Cp,ps,cs,ds,hs,fs,gs,Lp,ms,sg=I(()=>{"use strict";lt(),Y(),V(),Fe(),ss=(t,r,n,s,p,l)=>(t-1)*r+n+(s-1)*p+1-l,us=(t,r,n,s,p)=>{let l=Math.floor(t/2);r==="SAME_UPPER"?(n[s]=l,n[p]=t-l):r==="SAME_LOWER"&&(n[s]=t-l,n[p]=l)},ls=(t,r,n,s,p,l,c,o)=>{let a=t.length-2,e=o.length===0;for(let u=0;u<a;++u){let i=e?t[u+2]*l[u]:o[u],d=ss(t[u+2],l[u],p[u],r[u],n[u],i);us(d,s,p,u,u+a),e&&o.push(l[u]*(t[u+2]-1)+c[u]+(r[u]-1)*n[u]+1-p[u]-p[u+a])}},Cp=(t,r,n)=>(ms(r,n),ps(t,r,n)),ps=(t,r,n)=>{let s=gs(n,r);return[fs(t,r,s)]},cs=(t,r)=>({name:"ConvTranspose",inputNames:t?["X","W","B"]:["X","W"],inputTypes:t?[0,0,0]:[0,0],cacheHint:r}),ds=(t,r,n,s)=>{let p=r.length>2?"getB(output_channel)":"0.0",l=r[0].dims,c=r[1].dims,o=c[1],a=c[0]/s.group,e=[r[0].dims[0],r[1].dims[1]*s.group,...s.outputShape],u=B(t.session.backend.glContext.version),{activationFunction:i,applyActivation:d}=yr(s),h=`
|
|
686
|
+
const ivec2 strides = ivec2(${s.strides[0]}, ${s.strides[1]});
|
|
687
|
+
const ivec2 pads = ivec2(${s.pads[0]}, ${s.pads[1]});
|
|
688
|
+
${i}
|
|
689
|
+
void main() {
|
|
690
|
+
ivec4 coords = getOutputCoords();
|
|
691
|
+
int batch = coords.x;
|
|
692
|
+
int output_channel = coords.y;
|
|
693
|
+
|
|
694
|
+
ivec2 loc = coords.zw + pads;
|
|
695
|
+
|
|
696
|
+
int group_id = output_channel / ${o};
|
|
697
|
+
int wOutChannel = output_channel - group_id * ${o};
|
|
698
|
+
|
|
699
|
+
float value = ${p};
|
|
700
|
+
for (int inChannelOffset = 0; inChannelOffset < ${a}; inChannelOffset++) {
|
|
701
|
+
int input_channel = group_id * ${a} + inChannelOffset;
|
|
702
|
+
for (int wWOff = 0; wWOff < ${c[2]}; wWOff++) {
|
|
703
|
+
for (int wHOff = 0; wHOff < ${c[3]}; wHOff++) {
|
|
704
|
+
ivec2 wOff = ivec2(wWOff * ${s.dilations[0]}, wHOff * ${s.dilations[1]});
|
|
705
|
+
ivec2 wLoc = loc - wOff;
|
|
706
|
+
ivec2 wLocIn = wLoc / strides;
|
|
707
|
+
if (
|
|
708
|
+
wLocIn * strides == wLoc &&
|
|
709
|
+
wLocIn.x >= 0 && wLocIn.x < ${l[2]} &&
|
|
710
|
+
wLocIn.y >= 0 && wLocIn.y < ${l[3]}
|
|
711
|
+
) {
|
|
712
|
+
float xVal = getX(batch, input_channel, wLocIn.y, wLocIn.x);
|
|
713
|
+
float wVal = getW(input_channel, wOutChannel, wHOff, wWOff);
|
|
714
|
+
value += xVal * wVal;
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
${d}
|
|
720
|
+
${u.output} = vec4(value, .0, .0, .0);
|
|
721
|
+
}
|
|
722
|
+
`;return{...n,output:{dims:e,type:r[0].type,textureType:0},shaderSource:h,hasMain:!0}},hs=(t,r,n)=>{let s=cs(r.length>2,n.cacheKey);return{...s,get:()=>ds(t,r,s,n)}},fs=(t,r,n)=>t.run(hs(t,r,n),r),gs=(t,r)=>{let n=t.kernelShape.slice();if(t.kernelShape.length===0)for(let o=2;o<r[1].dims.length;++o)n.push(r[1].dims[o]);let s=t.pads.slice(),p=t.outputShape.slice(),l=r[0].dims;ls(l,n,t.dilations,t.autoPad,s,t.strides,t.outputPadding,p);let c=Object.assign({},t);return Object.assign(c,{kernelShape:n,pads:s,outputShape:p,cacheKey:t.cacheKey}),c},Lp=t=>{let r=t.attributes,n=Jr(r),s=r.getString("auto_pad","NOTSET"),p=r.getInts("dilations",[1,1]),l=r.getInt("group",1),c=r.getInts("kernel_shape",[]),o=r.getInts("output_padding",[0,0]),a=r.getInts("output_shape",[]),e=r.getInts("pads",[0,0,0,0]),u=r.getInts("strides",[1,1]);return X({autoPad:s,dilations:p,group:l,kernelShape:c,outputPadding:o,outputShape:a,pads:e,strides:u,...n})},ms=(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 n=t[0].dims[1],s=t[1].dims[0];if(n!==s)throw new Error("FILTER_IN_CHANNEL should be equal to DATA_CHANNEL");let p=t[1].dims[1]*r.group;if(t.length===3&&(t[2].dims.length!==1||t[2].dims[0]!==p))throw new Error("invalid bias");let l=t[0].dims.length-2;if(r.dilations.length!==l)throw new Error(`dilations should be ${l}D`);if(r.strides.length!==l)throw new Error(`strides should be ${l}D`);if(r.pads.length!==l*2)throw new Error(`pads should be ${l*2}D`);if(r.outputPadding.length!==l)throw new Error(`output_padding should be ${l}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")}}),Pn,fr,Rp,bs,An,ys,ws,vs,Zo=I(()=>{"use strict";lt(),U(),V(),Pn={name:"Transpose",inputNames:["A"],inputTypes:[0]},fr=(t,r,n)=>(vs(r),[t.run({...Pn,cacheHint:n.cacheKey,get:()=>bs(t,r[0],n.perm)},r)]),Rp=t=>X({perm:t.attributes.getInts("perm",[])}),bs=(t,r,n)=>{let s=r.dims;n=An(s,n);let p=ys(s,n),l=s.length,c=`
|
|
723
|
+
${ws("perm",n,l)}
|
|
724
|
+
float process(int indices[${l}]) {
|
|
725
|
+
int a[${l}];
|
|
726
|
+
perm(a, indices);
|
|
727
|
+
return _A(a);
|
|
728
|
+
}`;return{...Pn,output:{dims:p,type:r.type,textureType:0},shaderSource:c}},An=(t,r)=>(r&&r.length!==t.length&&(r=[...t.keys()].reverse()),r),ys=(t,r)=>(r=An(t,r),C.sortBasedOnPerm(t,r)),ws=(t,r,n)=>{let s=[];s.push(`void ${t}(out int a[${n}], int src[${n}]) {`);for(let p=0;p<n;++p)s.push(` a[${r[p]}]=src[${p}];`);return s.push(" }"),s.join(`
|
|
729
|
+
`)},vs=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")}}),jp,Bp,xs,ug=I(()=>{"use strict";Zo(),jp=(t,r,n)=>{xs(r);let s=n.blocksize,p=s*s,l=n.mode==="DCR"?[0,3,4,1,5,2]:[0,1,4,2,5,3],c=n.mode==="DCR"?[r[0].dims[0],s,s,r[0].dims[1]/p,r[0].dims[2],r[0].dims[3]]:[r[0].dims[0],r[0].dims[1]/p,s,s,r[0].dims[2],r[0].dims[3]],o=t.reshapeUnpacked(r[0],c),a={perm:l,cacheKey:`${l}`},[e]=fr(t,[o],a),u=[r[0].dims[0],r[0].dims[1]/p,r[0].dims[2]*s,r[0].dims[3]*s];return[t.reshapeUnpacked(e,u)]},Bp=t=>{let r=t.attributes.getInt("blocksize");if(r<1)throw new Error(`blocksize must be >= 1, but got : ${r} for DepthToSpace`);let n=t.attributes.getString("mode","DCR");if(n!=="DCR"&&n!=="CRD")throw new Error(`unrecognized mode: ${n} for DepthToSpace`);return{mode:n,blocksize:r}},xs=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")}}),Vp,Mp,Ts,lg=I(()=>{"use strict";U(),Vp=(t,r,n)=>{Ts(r,n);let s=C.flattenShape(r[0].dims,n);return[t.reshapeUnpacked(r[0],s)]},Mp=t=>t.attributes.getInt("axis",1),Ts=(t,r)=>{if(!t||t.length!==1)throw new Error("Flatten requires 1 input.");let n=t[0].dims.length;if(n===0)throw new Error("scalar tensor is not supported.");if(r<-n||r>n)throw new Error("Invalid axis");if(t[0].type==="string")throw new Error("string tensor is not supported.")}}),wr,Yr=I(()=>{"use strict";wr=["float32","float64","int32","int16","int8","uint16","uint32","uint8"]}),zp,Up,_s,Ss,Os,Es,pg=I(()=>{"use strict";lt(),Yr(),U(),V(),zp=(t,r,n)=>(Es(r,n.axis),[t.run(Os(t,r,n),r)]),Up=t=>X({axis:t.attributes.getInt("axis",0)}),_s={name:"Gather",inputNames:["A","B"],inputTypes:[0,0]},Ss=(t,r,n,s)=>{let p=n[0].dims.slice(),l=n[1].dims.slice(),c=new Array(p.length+l.length-1);s=C.normalizeAxis(s,p.length);let o=[];for(let d=0;d<c.length;d++)d<s?(c[d]=p[d],o.push(`inputIdx[${d}] = outputIdx[${d}];`)):d<s+l.length?(c[d]=l[d-s],o.push(`indexDataIdx[${d-s}] = outputIdx[${d}];`)):(c[d]=p[d-l.length+1],o.push(`inputIdx[${d-l.length+1}] = outputIdx[${d}];`));let a=c.length||1,e=p.length,u=l.length||1,i=`
|
|
730
|
+
float process(int outputIdx[${a}]) {
|
|
731
|
+
int inputIdx[${e}];
|
|
732
|
+
int indexDataIdx[${u}];
|
|
733
|
+
indexDataIdx[0] = 0;
|
|
734
|
+
${o.join(`
|
|
735
|
+
`)}
|
|
736
|
+
int idx = int(_B(indexDataIdx));
|
|
737
|
+
inputIdx[${s}] = idx < 0 ? idx + ${p[s]} : idx;
|
|
738
|
+
return _A(inputIdx);
|
|
739
|
+
}`;return{...r,output:{dims:c,type:n[0].type,textureType:0},shaderSource:i}},Os=(t,r,n)=>{let s={..._s,cacheHint:n.cacheKey};return{...s,get:()=>Ss(t,s,r,n.axis)}},Es=(t,r)=>{if(!t||t.length!==2)throw new Error("Gather requires 2 inputs.");let n=t[0].dims.length;if(n<1)throw new Error("Invalid input shape.");if(r<-n||r>n-1)throw new Error("Invalid axis.");if(wr.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.")}}),Oo,$n,Gp,Hp,Is,Ps,As,cg=I(()=>{"use strict";lt(),U(),V(),Oo=(t,r,n)=>(As(r,n),[t.run(Is(r,n),r)]),$n=(t,r)=>{let n=t.attributes.getInt("transA",0)!==0,s=t.attributes.getInt("transB",0)!==0,p=t.attributes.getFloat("alpha",1),l=t.attributes.getFloat("beta",1);return X({transA:n,transB:s,alpha:p,beta:l,isOptionalC:r})},Gp=t=>$n(t,!1),Hp=t=>$n(t,!0),Is=(t,r)=>{let n={name:"Gemm",inputNames:t.length===3?["A","B","C"]:["A","B"],inputTypes:t.length===3?[0,0,0]:[0,0],key:r.cacheKey};return{...n,get:()=>Ps(n,t,r)}},Ps=(t,r,n)=>{let s=r[0].dims.slice(),p=r[1].dims.slice(),[l,c]=bl.getShapeOfGemmResult(s,n.transA,p,n.transB,r.length===3?r[2].dims:void 0),o=[l,c];if(!o)throw new Error("Can't use gemm on the given tensors");let a=s[s.length-1],e="";n.transA&&(a=s[0]),n.transA&&n.transB?e="value += _A_T(a) * _B_T(b);":n.transA&&!n.transB?e="value += _A_T(a) * _B(b);":!n.transA&&n.transB?e="value += _A(a) * _B_T(b);":!n.transA&&!n.transB&&(e="value += _A(a) * _B(b);");let u=o.length,i=r.length===3?`int c[${r[2].dims.length}];`:"",d=r.length===3?"bcastIndices_C(indices, c);":"",h=r.length===3?"value += beta * _C(c);":"",m=`
|
|
740
|
+
float process(int indices[${u}]) {
|
|
741
|
+
int a[${u}];
|
|
742
|
+
int b[${u}];
|
|
743
|
+
${i}
|
|
744
|
+
|
|
745
|
+
copyVec(indices, a);
|
|
746
|
+
copyVec(indices, b);
|
|
747
|
+
${d}
|
|
748
|
+
|
|
749
|
+
float value = 0.0;
|
|
750
|
+
for (int k=0; k<${a}; ++k) {
|
|
751
|
+
a[${u-1}] = k;
|
|
752
|
+
b[${u-2}] = k;
|
|
753
|
+
${e}
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
value = value * alpha;
|
|
757
|
+
${h}
|
|
758
|
+
return value;
|
|
759
|
+
}`;return{...t,output:{dims:o,type:r[0].type,textureType:0},variables:[{name:"alpha",type:"float",data:n.alpha},{name:"beta",type:"float",data:n.beta}],shaderSource:m}},As=(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")}}),qp,Wp,$s,Ds,Ns,ks,Fs,dg=I(()=>{"use strict";lt(),V(),qp=(t,r,n)=>(Fs(r),[t.run(Ns(t,r,n),r)]),Wp=t=>{let r=t.attributes.getFloat("scale"),n=t.attributes.getFloats("bias");return X({scale:r,bias:n})},$s={name:"ImageScaler",inputNames:["X"],inputTypes:[0]},Ds=(t,r,n,s)=>{let p=n[0].dims.slice(),l=p.length,c=`
|
|
760
|
+
${ks(s.bias.length)}
|
|
761
|
+
float process(int indices[${l}]) {
|
|
762
|
+
return _X(indices) * scale + getBias(bias, indices[1]);
|
|
763
|
+
}`;return{...r,output:{dims:p,type:n[0].type,textureType:0},variables:[{name:"bias",type:"float",arrayLength:s.bias.length,data:s.bias},{name:"scale",type:"float",data:s.scale}],shaderSource:c}},Ns=(t,r,n)=>{let s={...$s,cacheHint:n.cacheKey};return{...s,get:()=>Ds(t,s,r,n)}},ks=t=>{let r=[`float getBias(float bias[${t}], int channel) {`];for(let n=0;n<t;++n)n===0?r.push(` if (channel == ${n}) { return bias[${n}]; }`):n===t-1?r.push(` else { return bias[${n}]; }`):r.push(` else if (channel == ${n}) { return bias[${n}]; }`);return r.push(" }"),r.join(`
|
|
764
|
+
`)},Fs=t=>{if(!t||t.length!==1)throw new Error("ImageScaler requires 1 input.");if(t[0].dims.length!==4)throw new Error("Invalid input shape.");if(t[0].type!=="float32"&&t[0].type!=="float64")throw new Error("Invalid input type.")}}),Xp,Kp,Dn,Cs,Ls,Rs,js,Bs,Vs,hg=I(()=>{"use strict";Y(),V(),Xp=(t,r,n)=>{Vs(r);let s=t.run(Ls(r[0]),r);return[t.run(Bs(t,r[0],n,s.dims),[r[0],s,r[1],r[2]])]},Kp=t=>t.attributes.getFloat("epsilon",1e-5),Dn={name:"InstanceNormalization_MeanAndVariance",inputNames:["X"],inputTypes:[0]},Cs=(t,r)=>{let n=r.dims.slice(),s=n[1],p=n[2]*n[3],l=[n[0],s],c=`
|
|
765
|
+
vec4 process(int[2] indices) {
|
|
766
|
+
vec4 v = vec4(0.0);
|
|
767
|
+
int a[4];
|
|
768
|
+
a[0] = indices[0];
|
|
769
|
+
a[1] = indices[1];
|
|
770
|
+
float temp = 0.0;
|
|
771
|
+
for(int a2=0; a2<${n[2]}; a2++) {
|
|
772
|
+
a[2] = a2;
|
|
773
|
+
for(int a3=0; a3<${n[3]}; a3++) {
|
|
774
|
+
a[3] = a3;
|
|
775
|
+
float x = _X(a);
|
|
776
|
+
temp += x;
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
float mean = temp / float(${p});
|
|
780
|
+
temp = 0.0;
|
|
781
|
+
for(int a2=0; a2<${n[2]}; a2++) {
|
|
782
|
+
a[2] = a2;
|
|
783
|
+
for(int a3=0; a3<${n[3]}; a3++) {
|
|
784
|
+
a[3] = a3;
|
|
785
|
+
float x = _X(a);
|
|
786
|
+
temp += (x - mean) * (x - mean);
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
v.r = mean;
|
|
790
|
+
v.g = temp / float(${p});
|
|
791
|
+
|
|
792
|
+
return v;
|
|
793
|
+
}`;return{...t,output:{dims:l,type:r.type,textureType:4},shaderSource:c}},Ls=t=>({...Dn,get:()=>Cs(Dn,t)}),Rs={name:"InstanceNormalization_ComputeOutput",inputNames:["X","MeanAndVariance","Scale","B"],inputTypes:[0,4,0,0]},js=(t,r,n,s,p)=>{let l=B(t.session.backend.glContext.version),[c,o]=t.calculateTextureWidthAndHeight(p,4),[a,e]=[c/4,o],u=`
|
|
794
|
+
vec4 get_MeanAndVariance(int[2] mv) {
|
|
795
|
+
int offset = indicesToOffset_MeanAndVariance(mv);
|
|
796
|
+
vec2 coords = offsetToCoords(offset, ${a}, ${e});
|
|
797
|
+
return ${l.texture2D}(MeanAndVariance, coords);
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
float process(int[4] indices) {
|
|
801
|
+
int mv[2];
|
|
802
|
+
mv[0] = indices[0];
|
|
803
|
+
mv[1] = indices[1];
|
|
804
|
+
vec4 mean_and_variance = get_MeanAndVariance(mv);
|
|
805
|
+
float mean = mean_and_variance.r;
|
|
806
|
+
float variance = mean_and_variance.g;
|
|
807
|
+
|
|
808
|
+
int sb[1];
|
|
809
|
+
sb[0] = indices[1];
|
|
810
|
+
float scale = _Scale(sb);
|
|
811
|
+
float b = _B(sb);
|
|
812
|
+
|
|
813
|
+
return scale * (_X(indices) - mean) / sqrt(variance + epsilon) + b;
|
|
814
|
+
}`;return{...r,output:{dims:n.dims,type:n.type,textureType:0},variables:[{name:"epsilon",type:"float",data:s}],shaderSource:u}},Bs=(t,r,n,s)=>{let p={...Rs,cacheHint:`${n}`};return{...p,get:()=>js(t,p,r,n,s)}},Vs=t=>{if(!t||t.length!==3)throw new Error("InstanceNormalization requires 3 inputs.");let r=t[0],n=t[1],s=t[2];if(r.dims.length<3||n.dims.length!==1||s.dims.length!==1)throw new Error("Invalid input shape.");if(n.dims[0]!==r.dims[1]||s.dims[0]!==r.dims[1])throw new Error("Input shapes are mismatched.");if(r.type!=="float32"&&r.type!=="float64"||n.type!=="float32"&&n.type!=="float64"||s.type!=="float32"&&s.type!=="float64")throw new Error("Invalid input type.");if(t[0].dims.length!==4)throw new Error("Only support 4-D input shape.")}});function fg(t,r){let n=t[0].dims[1],s=t[0].dims.length,p=-Math.floor((r.size-1)/2),l=Math.ceil((r.size-1)/2),c=`float(${r.alpha}) / float(${r.size})`,o=`float(${r.bias})`,a=`float(${r.beta})`,e=`
|
|
815
|
+
float process(int indices[${s}]) {
|
|
816
|
+
int c = indices[1];
|
|
817
|
+
float x = _X(indices);
|
|
818
|
+
float square_sum = 0.0;
|
|
819
|
+
|
|
820
|
+
for (int i = ${p}; i <= ${l}; i++) {
|
|
821
|
+
int idx = c + i;
|
|
822
|
+
if (c >= 0 && c < ${n}) {
|
|
823
|
+
indices[1] = idx;
|
|
824
|
+
float j = _X(indices);
|
|
825
|
+
square_sum += j * j;
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
return x / pow(${o} + ${c} * square_sum, ${a});
|
|
829
|
+
}`;return{...Jo,cacheHint:r.cacheKey,output:{dims:t[0].dims,type:t[0].type,textureType:0},shaderSource:e}}function gg(t,r){return{...Jo,cacheHint:r.cacheKey,get:()=>fg(t,r)}}var Zp,Jp,Jo,Ms,mg=I(()=>{"use strict";lt(),V(),Zp=(t,r,n)=>(Ms(r),[t.run(gg(r,n),r)]),Jp=t=>{let r=t.attributes.getFloat("alpha",1e-4),n=t.attributes.getFloat("beta",.75),s=t.attributes.getFloat("bias",1),p=t.attributes.getInt("size");return X({alpha:r,beta:n,bias:s,size:p})},Jo={name:"LRN",inputNames:["X"],inputTypes:[0]},Ms=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")}}),zs,Eo,Yp,Qp,tc,Us,Gs,Hs,qs,Ws,Xs,Ks,Zs,bg=I(()=>{"use strict";lt(),U(),Y(),V(),zs={name:"Pad",inputNames:["A"],inputTypes:[0]},Eo=(t,r,n)=>(Hs(r),[t.run({...zs,cacheHint:n.cacheKey,get:()=>Gs(t,r[0],n)},r)]),Yp=t=>{let r=t.attributes.getString("mode","constant"),n=t.attributes.getFloat("value",0),s=t.attributes.getInts("pads");return X({mode:r,value:n,pads:s})},Qp=(t,r,n)=>{qs(r);let s=Us(t,r,n);return Eo(t,[r[0]],s)},tc=t=>t.attributes.getString("mode","constant"),Us=(t,r,n)=>{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 s=Array.from(r[1].integerData),p=r.length>=3?r[2].floatData[0]:0;return X({mode:n,pads:s,value:p})},Gs=(t,r,n)=>{let s=C.padShape(r.dims.slice(),n.pads),p=s.length,l=`
|
|
830
|
+
${Ws(t,r,n)}
|
|
831
|
+
float process(int[${p}] indices) {
|
|
832
|
+
return padA(indices);
|
|
833
|
+
}`;return{name:"Pad",inputNames:["A"],inputTypes:[0],output:{dims:s,type:r.type,textureType:0},shaderSource:l}},Hs=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.")},qs=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.")},Ws=(t,r,n)=>{let s=B(t.session.backend.glContext.version),[p,l]=t.calculateTextureWidthAndHeight(r.dims,0),c=C.computeStrides(r.dims);switch(n.mode){case"constant":return Xs(s,r.dims,c,p,l,n.pads,n.value);case"reflect":return Ks(s,r.dims,c,p,l,n.pads);case"edge":return Zs(s,r.dims,c,p,l,n.pads);default:throw new Error("Invalid mode")}},Xs=(t,r,n,s,p,l,c)=>{let o=r.length,a="";for(let e=o-1;e>=0;--e)a+=`
|
|
834
|
+
k = m[${e}] - ${l[e]};
|
|
835
|
+
if (k < 0) return constant;
|
|
836
|
+
if (k >= ${r[e]}) return constant;
|
|
837
|
+
offset += k * ${n[e]};
|
|
838
|
+
`;return`
|
|
839
|
+
float padA(int m[${o}]) {
|
|
840
|
+
const float constant = float(${c});
|
|
841
|
+
int offset = 0;
|
|
842
|
+
int k = 0;
|
|
843
|
+
${a}
|
|
844
|
+
vec2 coords = offsetToCoords(offset, ${s}, ${p});
|
|
845
|
+
float value = getColorAsFloat(${t.texture2D}(A, coords));
|
|
846
|
+
return value;
|
|
847
|
+
}
|
|
848
|
+
`},Ks=(t,r,n,s,p,l)=>{let c=r.length,o="";for(let a=c-1;a>=0;--a)o+=`
|
|
849
|
+
k = m[${a}] - ${l[a]};
|
|
850
|
+
if (k < 0) { k = -k; }
|
|
851
|
+
{
|
|
852
|
+
const int _2n_1 = ${2*(r[a]-1)};
|
|
853
|
+
k = int( mod( float(k), float(_2n_1) ) ) ;
|
|
854
|
+
if(k >= ${r[a]}) { k = _2n_1 - k; }
|
|
855
|
+
}
|
|
856
|
+
offset += k * ${n[a]};
|
|
857
|
+
`;return`
|
|
858
|
+
float padA(int m[${c}]) {
|
|
859
|
+
int offset = 0;
|
|
860
|
+
int k = 0;
|
|
861
|
+
${o}
|
|
862
|
+
vec2 coords = offsetToCoords(offset, ${s}, ${p});
|
|
863
|
+
float value = getColorAsFloat(${t.texture2D}(A, coords));
|
|
864
|
+
return value;
|
|
865
|
+
}
|
|
866
|
+
`},Zs=(t,r,n,s,p,l)=>{let c=r.length,o="";for(let a=c-1;a>=0;--a)o+=`
|
|
867
|
+
k = m[${a}] - ${l[a]};
|
|
868
|
+
if (k < 0) k = 0;
|
|
869
|
+
if (k >= ${r[a]}) k = ${r[a]-1};
|
|
870
|
+
offset += k * ${n[a]};
|
|
871
|
+
`;return`
|
|
872
|
+
float padA(int m[${c}]) {
|
|
873
|
+
int offset = 0;
|
|
874
|
+
int k = 0;
|
|
875
|
+
${o}
|
|
876
|
+
vec2 coords = offsetToCoords(offset, ${s}, ${p});
|
|
877
|
+
float value = getColorAsFloat(${t.texture2D}(A, coords));
|
|
878
|
+
return value;
|
|
879
|
+
}
|
|
880
|
+
`}}),ec,rc,Nn,nc,oc,ic,ac,kn,Fn,Js,Cn,sc,qe,Ln,We,Ys,yg=I(()=>{"use strict";lt(),U(),V(),ec=(t,r,n)=>{qe(r);let s={name:"AveragePool",inputNames:["X"],inputTypes:[0],cacheHint:n.cacheKey};return[t.run({...s,get:()=>Nn(r,s,!1,n)},r)]},rc=t=>{let r=t.attributes.getString("auto_pad","NOTSET"),n=t.attributes.getInt("ceil_mode",0),s=t.attributes.getInt("count_include_pad",0)!==0,p=t.attributes.getInts("kernel_shape"),l=t.attributes.getInts("strides",[]),c=t.attributes.getInts("pads",[]);if(n!==0)throw new Error("using ceil() in shape computation is not yet supported for AveragePool");return X({autoPad:r,ceilMode:n,countIncludePad:s,kernelShape:p,strides:l,pads:c})},Nn=(t,r,n,s)=>{let[p,l]=Fn(t,s,n),c=C.size(p.kernelShape),o="value += _X(x);",a="";p.countIncludePad?a+=`value /= float(${c});`:a+=`value /= float(${c} - pad);`;let e=`
|
|
881
|
+
${Ln(t[0].dims,p,o,a,"0.0")}
|
|
882
|
+
`;return{...r,output:{dims:l,type:t[0].type,textureType:0},shaderSource:e}},nc=(t,r,n)=>{qe(r);let s={name:"GlobalAveragePool",inputNames:["X"],inputTypes:[0],cacheHint:`${n.countIncludePad}`};return[t.run({...s,get:()=>Nn(r,s,!0,n)},r)]},oc=t=>{let r=t.attributes.getInt("count_include_pad",0)!==0;return X({autoPad:"",ceilMode:0,countIncludePad:r,kernelShape:[],strides:[],pads:[]})},ic=(t,r,n)=>{qe(r);let s={name:"MaxPool",inputNames:["X"],inputTypes:[0],cacheHint:n.cacheKey};return[t.run({...s,get:()=>kn(r,s,!1,n)},r)]},ac=t=>{let r=t.attributes.getString("auto_pad","NOTSET"),n=t.attributes.getInt("ceil_mode",0),s=t.attributes.getInts("kernel_shape"),p=t.attributes.getInts("strides",[]),l=t.attributes.getInts("pads",[]),c=t.attributes.getInt("storage_order",0),o=t.attributes.getInts("dilations",[]);if(c!==0)throw new Error("column major storage order is not yet supported for MaxPool");if(n!==0)throw new Error("using ceil() in shape computation is not yet supported for MaxPool");return X({autoPad:r,ceilMode:n,countIncludePad:!1,kernelShape:s,strides:p,pads:l,storageOrder:c,dilations:o})},kn=(t,r,n,s)=>{let[p,l]=Fn(t,s,n),c=`
|
|
883
|
+
value = max(_X(x), value);
|
|
884
|
+
`,o="",a=`
|
|
885
|
+
${Ln(t[0].dims,p,c,o,"-1e5")}
|
|
886
|
+
`;return{...r,output:{dims:l,type:t[0].type,textureType:0},shaderSource:a}},Fn=(t,r,n)=>{let s=t[0].dims.slice(),p=Object.hasOwnProperty.call(r,"dilations"),l=r.kernelShape.slice(),c=r.strides.slice(),o=p?r.dilations.slice():[],a=r.pads.slice();Gr.adjustPoolAttributes(n,s,l,c,o,a);let e=Gr.computePoolOutputShape(n,s,c,o,l,a,r.autoPad),u=Object.assign({},r);return p?Object.assign(u,{kernelShape:l,strides:c,pads:a,dilations:o,cacheKey:r.cacheKey}):Object.assign(u,{kernelShape:l,strides:c,pads:a,cacheKey:r.cacheKey}),[u,e]},Js={autoPad:"",ceilMode:0,countIncludePad:!1,kernelShape:[],strides:[],pads:[],storageOrder:0,dilations:[],cacheKey:""},Cn={name:"GlobalMaxPool",inputNames:["X"],inputTypes:[0]},sc=(t,r)=>(qe(r),[t.run({...Cn,get:()=>kn(r,Cn,!0,Js)},r)]),qe=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.")},Ln=(t,r,n,s,p)=>{let l=t.length;if(r.kernelShape.length<=2){let c=r.kernelShape[r.kernelShape.length-1],o=r.strides[r.strides.length-1],a=r.pads[r.pads.length/2-1],e=r.pads[r.pads.length-1],u=t[l-1],i="",d="",h="";if(a+e!==0?i=`
|
|
887
|
+
for (int i = 0; i < ${c}; i++) {
|
|
888
|
+
x[${l} - 1] = indices[${l} - 1] * ${o} - ${a} + i;
|
|
889
|
+
if (x[${l} - 1] < 0 || x[${l} - 1] >= ${u}) {
|
|
890
|
+
pad++;
|
|
891
|
+
continue;
|
|
892
|
+
}
|
|
893
|
+
${n}
|
|
894
|
+
}`:i=`
|
|
895
|
+
for (int i = 0; i < ${c}; i++) {
|
|
896
|
+
x[${l} - 1] = indices[${l} - 1] * ${o} - ${a} + i;
|
|
897
|
+
${n}
|
|
898
|
+
}`,r.kernelShape.length===2){let m=r.kernelShape[r.kernelShape.length-2],b=r.strides[r.strides.length-2],x=r.pads[r.pads.length/2-2],E=r.pads[r.pads.length-2],w=t[l-2];x+E!==0?d=`
|
|
899
|
+
for (int j = 0; j < ${m}; j++) {
|
|
900
|
+
x[${l} - 2] = indices[${l} - 2] * ${b} - ${x} + j;
|
|
901
|
+
if (x[${l} - 2] < 0 || x[${l} - 2] >= ${w}) {
|
|
902
|
+
pad+= ${c};
|
|
903
|
+
continue;
|
|
904
|
+
}
|
|
905
|
+
`:d=`
|
|
906
|
+
for (int j = 0; j < ${m}; j++) {
|
|
907
|
+
x[${l} - 2] = indices[${l} - 2] * ${b} - ${x} + j;
|
|
908
|
+
`,h=`
|
|
909
|
+
}
|
|
910
|
+
`}return`
|
|
911
|
+
float process(int indices[${l}]) {
|
|
912
|
+
int x[${l}];
|
|
913
|
+
copyVec(indices, x);
|
|
914
|
+
|
|
915
|
+
float value = ${p};
|
|
916
|
+
int pad = 0;
|
|
917
|
+
${d}
|
|
918
|
+
${i}
|
|
919
|
+
${h}
|
|
920
|
+
${s}
|
|
921
|
+
return value;
|
|
922
|
+
}
|
|
923
|
+
`}else{let c=C.size(r.kernelShape),o=C.computeStrides(r.kernelShape),a=o.length,e=r.pads.length,u=Ys(a),i=We(t,"inputDims"),d=We(r.pads,"pads"),h=We(o,"kernelStrides"),m=We(r.strides,"strides"),b=r.pads.reduce((E,w)=>E+w),x="";return b?x=`
|
|
924
|
+
if (x[j] >= inputDims[j] || x[j] < 0) {
|
|
925
|
+
pad++;
|
|
926
|
+
isPad = true;
|
|
927
|
+
break;
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
if (!isPad) {
|
|
931
|
+
${n}
|
|
932
|
+
}`:x=`
|
|
933
|
+
}
|
|
934
|
+
${n}
|
|
935
|
+
`,`
|
|
936
|
+
${u}
|
|
937
|
+
float process(int indices[${l}]) {
|
|
938
|
+
int x[${l}];
|
|
939
|
+
copyVec(indices, x);
|
|
940
|
+
int offset[${a}];
|
|
941
|
+
int pads[${e}];
|
|
942
|
+
int inputDims[${l}];
|
|
943
|
+
int kernelStrides[${a}];
|
|
944
|
+
int strides[${a}];
|
|
945
|
+
${d}
|
|
946
|
+
${i}
|
|
947
|
+
${m}
|
|
948
|
+
${h}
|
|
949
|
+
|
|
950
|
+
float value = ${p};
|
|
951
|
+
int pad = 0;
|
|
952
|
+
bool isPad = false;
|
|
953
|
+
for (int i = 0; i < ${c}; i++) {
|
|
954
|
+
offsetToIndices(i, kernelStrides, offset);
|
|
955
|
+
isPad = false;
|
|
956
|
+
for (int j = ${l} - ${a}; j < ${l}; j++) {
|
|
957
|
+
x[j] = indices[j] * strides[j - ${l} + ${a}]
|
|
958
|
+
+ offset[j - ${l} + ${a}] - pads[j - 2];
|
|
959
|
+
${x}
|
|
960
|
+
}
|
|
961
|
+
${s}
|
|
962
|
+
|
|
963
|
+
return value;
|
|
964
|
+
}
|
|
965
|
+
`}},We=(t,r)=>{let n="";for(let s=0;s<t.length;s++)n+=`
|
|
966
|
+
${r}[${s}] = ${t[s]};
|
|
967
|
+
`;return n},Ys=t=>`
|
|
968
|
+
void offsetToIndices(int offset, int[${t}] strides, out int[${t}] indices) {
|
|
969
|
+
if (${t} == 0) {
|
|
970
|
+
return;
|
|
971
|
+
}
|
|
972
|
+
for (int i = 0; i < ${t} - 1; ++i) {
|
|
973
|
+
indices[i] = offset / strides[i];
|
|
974
|
+
offset -= indices[i] * strides[i];
|
|
975
|
+
}
|
|
976
|
+
indices[${t} - 1] = offset;
|
|
977
|
+
}`}),Jt,te,Qs,tu,uc,lc,pc,cc,dc,hc,fc,wg=I(()=>{"use strict";lt(),Yr(),U(),V(),Jt=(t,r,n,s,p)=>{tu(r);let l={name:s,inputNames:["A"],inputTypes:[0]};return[t.run({...l,cacheHint:n.cacheKey,get:()=>Qs(t,r,n,s,p,l)},r)]},te=t=>{let r=t.attributes.getInts("axes",[]),n=t.attributes.getInt("keepdims",1)===1;return X({axes:r,keepDims:n})},Qs=(t,r,n,s,p,l)=>{let c=[],o=r[0].dims.length||1,a=[],e=C.normalizeAxes(n.axes,r[0].dims.length),u=p(r,e),i=u[1];for(let h=0;h<r[0].dims.length;h++)e.indexOf(h)>=0||e.length===0?(n.keepDims&&c.push(1),i=`
|
|
978
|
+
for(int j${h} = 0; j${h} < ${r[0].dims[h]}; j${h}++) {
|
|
979
|
+
inputIdx[${h}] = j${h};
|
|
980
|
+
${i}
|
|
981
|
+
}`):(a.push(`inputIdx[${h}] = outputIdx[${c.length}];`),c.push(r[0].dims[h]));let d=`
|
|
982
|
+
float process(int outputIdx[${c.length||1}]) {
|
|
983
|
+
float value; // final result
|
|
984
|
+
int inputIdx[${o}]; // addressing input data
|
|
985
|
+
${a.join(`
|
|
986
|
+
`)}
|
|
987
|
+
${u[0]} // init ops for reduce max/min
|
|
988
|
+
${i}
|
|
989
|
+
${u[2]} // final computation for reduce mean
|
|
990
|
+
return value;
|
|
991
|
+
}`;return{...l,output:{dims:c,type:r[0].type,textureType:0},shaderSource:d}},tu=t=>{if(!t||t.length!==1)throw new Error("Reduce op requires 1 input.");if(wr.indexOf(t[0].type)===-1)throw new Error("Invalid input type.")},uc=(t,r,n)=>Jt(t,r,n,"ReduceSum",()=>["value = 0.0;","value += _A(inputIdx);",""]),lc=(t,r,n)=>Jt(t,r,n,"ReduceMean",(s,p)=>{let l=1;for(let c=0;c<s[0].dims.length;c++)(p.indexOf(c)>=0||p.length===0)&&(l*=s[0].dims[c]);return["value = 0.0;","value += _A(inputIdx);",`value /= ${l}.;`]}),pc=(t,r,n)=>Jt(t,r,n,"ReduceMax",(s,p)=>{let l=[];for(let c=0;c<s[0].dims.length;c++)(p.indexOf(c)>=0||p.length===0)&&l.push(`inputIdx[${c}] = 0;`);return[`${l.join(`
|
|
992
|
+
`)}
|
|
993
|
+
value = _A(inputIdx);`,"value = max(value, _A(inputIdx));",""]}),cc=(t,r,n)=>Jt(t,r,n,"ReduceMin",(s,p)=>{let l=[];for(let c=0;c<s[0].dims.length;c++)(p.indexOf(c)>=0||p.length===0)&&l.push(`inputIdx[${c}] = 0;`);return[`${l.join(`
|
|
994
|
+
`)}
|
|
995
|
+
value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),dc=(t,r,n)=>Jt(t,r,n,"ReduceProd",()=>["value = 1.0;","value *= _A(inputIdx);",""]),hc=(t,r,n)=>Jt(t,r,n,"ReduceLogSum",()=>["value = 0.0;","value += _A(inputIdx);","value = log(value);"]),fc=(t,r,n)=>Jt(t,r,n,"ReduceLogSumSquare",()=>["float t; value = 0.0;","t = _A(inputIdx); value += t * t;",""])}),gc,vg=I(()=>{"use strict";U(),gc=(t,r)=>{let n=C.calculateReshapedDims(r[0].dims,r[1].integerData);return t.session.pack?[t.reshapePacked(r[0],n)]:[t.reshapeUnpacked(r[0],n)]}}),Rn,Io,mc,bc,pr,eu,Po,qr,yc=I(()=>{"use strict";lt(),Y(),V(),Rn={name:"Upsample",inputNames:["X"],inputTypes:[0]},Io=(t,r,n)=>(Po(r,n),[t.run({...Rn,cacheHint:n.cacheKey,get:()=>eu(t,r,n)},r)]),mc=t=>pr(t,7),bc=t=>pr(t,9),pr=(t,r)=>{let n=r>=10,s=t.attributes.getString("mode","nearest");if(s!=="nearest"&&s!=="linear"&&(r<11||s!=="cubic"))throw new Error(`unrecognized mode: ${s}`);let p=[];r<9&&(p=t.attributes.getFloats("scales"),qr(p,s,n));let l=t.attributes.getFloat("extrapolation_value",0),c=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(c)===-1)throw new Error(`coordinate_transform_mode '${c}' is not supported`);let o=c==="tf_crop_and_resize",a=o,e=s==="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 u=t.attributes.getFloat("cubic_coeff_a",-.75),i=t.attributes.getInt("exclude_outside",0)!==0;if(i&&s!=="cubic")throw new Error("exclude_outside can be set to 1 only when mode is CUBIC.");let d=r<11?!0:s==="nearest"&&c==="asymmetric"&&e==="floor",h=0,m=0,b=0;return r>10?t.inputs.length>2?(h=1,m=2,b=3):(m=1,b=2):r===9&&(m=1),X({opset:r,isResize:n,mode:s,scales:p,extrapolationValue:l,coordinateTransformMode:c,useExtrapolation:a,needRoiInput:o,nearestMode:e,cubicCoefficientA:u,excludeOutside:i,useNearest2xOptimization:d,roiInputIdx:h,scalesInputIdx:m,sizesInputIdx:b})},eu=(t,r,n)=>{let s=B(t.session.backend.glContext.version),[p,l]=t.calculateTextureWidthAndHeight(r[0].dims,0),c=r[0].dims.map((b,x)=>Math.floor(b*n.scales[x])),[o,a]=t.calculateTextureWidthAndHeight(c,0),e=c.length,u=new Array(e),i=new Array(e),d=`
|
|
996
|
+
int output_pitches[${e}];
|
|
997
|
+
int input_pitches[${e}];
|
|
998
|
+
`;for(let b=e-1;b>=0;b--)u[b]=b===e-1?1:u[b+1]*c[b+1],i[b]=b===e-1?1:i[b+1]*r[0].dims[b+1],d+=`
|
|
999
|
+
output_pitches[${b}] = ${u[b]};
|
|
1000
|
+
input_pitches[${b}] = ${i[b]};
|
|
1001
|
+
`;let h=`
|
|
1002
|
+
float getInputFloat(int index) {
|
|
1003
|
+
vec2 coords = offsetToCoords(index, ${p}, ${l});
|
|
1004
|
+
float value = getColorAsFloat(${s.texture2D}(X, coords));
|
|
1005
|
+
return value;
|
|
1006
|
+
}
|
|
1007
|
+
`,m=n.mode==="nearest"?`
|
|
1008
|
+
${h}
|
|
1009
|
+
float process(int indices[${e}]) {
|
|
1010
|
+
int input_index = 0;
|
|
1011
|
+
int output_index = coordsToOffset(TexCoords, ${o}, ${a});
|
|
1012
|
+
|
|
1013
|
+
${d}
|
|
1014
|
+
|
|
1015
|
+
int d, m;
|
|
1016
|
+
for (int dim = 0; dim < ${e}; ++dim) {
|
|
1017
|
+
d = output_index / output_pitches[dim];
|
|
1018
|
+
m = output_index - d * output_pitches[dim];
|
|
1019
|
+
output_index = m;
|
|
1020
|
+
|
|
1021
|
+
if (scales[dim] != 1 && d > 0) {
|
|
1022
|
+
int d2 = d / scales[dim];
|
|
1023
|
+
m = d - d2 * scales[dim];
|
|
1024
|
+
d = d2;
|
|
1025
|
+
}
|
|
1026
|
+
input_index += input_pitches[dim] * d;
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
return getInputFloat(input_index);
|
|
1030
|
+
}`:e===4?`
|
|
1031
|
+
${h}
|
|
1032
|
+
float process(int indices[4]) {
|
|
1033
|
+
int input_index = 0;
|
|
1034
|
+
int output_index = coordsToOffset(TexCoords, ${o}, ${a});
|
|
1035
|
+
|
|
1036
|
+
${d}
|
|
1037
|
+
|
|
1038
|
+
int m;
|
|
1039
|
+
int index_of_dim0, index_of_dim1, index_of_dim2, index_of_dim3;
|
|
1040
|
+
index_of_dim0 = output_index / output_pitches[0];
|
|
1041
|
+
m = output_index - index_of_dim0 * output_pitches[0];
|
|
1042
|
+
index_of_dim1 = m / output_pitches[1];
|
|
1043
|
+
m = m - index_of_dim1 * output_pitches[1];
|
|
1044
|
+
index_of_dim2 = m / output_pitches[2];
|
|
1045
|
+
m = m - index_of_dim2 * output_pitches[2];
|
|
1046
|
+
index_of_dim3 = m;
|
|
1047
|
+
|
|
1048
|
+
int index_of_input_dim2, index_of_input_dim3, x_offset, y_offset;
|
|
1049
|
+
index_of_input_dim2 = index_of_dim2 / scales[2];
|
|
1050
|
+
y_offset = index_of_dim2 - index_of_input_dim2 * scales[2];
|
|
1051
|
+
index_of_input_dim3 = index_of_dim3 / scales[3];
|
|
1052
|
+
x_offset = index_of_dim3 - index_of_input_dim3 * scales[3];
|
|
1053
|
+
|
|
1054
|
+
input_index = index_of_dim0 * input_pitches[0] +
|
|
1055
|
+
index_of_dim1 * input_pitches[1] +
|
|
1056
|
+
index_of_input_dim2 * input_pitches[2] +
|
|
1057
|
+
index_of_input_dim3;
|
|
1058
|
+
|
|
1059
|
+
float x00 = getInputFloat(input_index);
|
|
1060
|
+
float x10, x01, x11;
|
|
1061
|
+
|
|
1062
|
+
bool end_of_dim2 = false;
|
|
1063
|
+
if (index_of_input_dim2 == (${r[0].dims[2]} - 1)) {
|
|
1064
|
+
// It's the end in dimension 2
|
|
1065
|
+
x01 = x00;
|
|
1066
|
+
end_of_dim2 = true;
|
|
1067
|
+
} else {
|
|
1068
|
+
x01 = getInputFloat(input_index + input_pitches[2]);
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
if (index_of_input_dim3 == (input_pitches[2] - 1)) {
|
|
1072
|
+
// It's the end in dimension 3
|
|
1073
|
+
x10 = x00;
|
|
1074
|
+
x11 = x01;
|
|
1075
|
+
}
|
|
1076
|
+
else {
|
|
1077
|
+
x10 = getInputFloat(input_index + 1);
|
|
1078
|
+
x11 = end_of_dim2 ? x10 : getInputFloat(input_index + input_pitches[2] + 1);
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
float y0 = x00 + float(y_offset) * (x01 - x00) / float(scales[2]);
|
|
1082
|
+
float y1 = x10 + float(y_offset) * (x11 - x10) / float(scales[2]);
|
|
1083
|
+
return y0 + float(x_offset) * (y1 - y0) / float(scales[3]);
|
|
1084
|
+
}`:`
|
|
1085
|
+
${h}
|
|
1086
|
+
float process(int indices[2]) {
|
|
1087
|
+
int input_index = 0;
|
|
1088
|
+
int output_index = coordsToOffset(TexCoords, ${o}, ${a});
|
|
1089
|
+
|
|
1090
|
+
${d}
|
|
1091
|
+
|
|
1092
|
+
int m;
|
|
1093
|
+
int index_of_dim0, index_of_dim1;
|
|
1094
|
+
index_of_dim0 = output_index / output_pitches[0];
|
|
1095
|
+
m = output_index - index_of_dim0 * output_pitches[0];
|
|
1096
|
+
index_of_dim1 = m;
|
|
1097
|
+
|
|
1098
|
+
int index_of_input_dim0, index_of_input_dim1, x_offset, y_offset;
|
|
1099
|
+
index_of_input_dim0 = index_of_dim0 / scales[0];
|
|
1100
|
+
y_offset = index_of_dim0 - index_of_input_dim0 * scales[0];
|
|
1101
|
+
index_of_input_dim1 = index_of_dim1 / scales[1];
|
|
1102
|
+
x_offset = index_of_dim1 - index_of_input_dim1 * scales[1];
|
|
1103
|
+
|
|
1104
|
+
input_index = index_of_input_dim0 * input_pitches[0] + index_of_input_dim1;
|
|
1105
|
+
|
|
1106
|
+
float x00 = getInputFloat(input_index);
|
|
1107
|
+
float x10, x01, x11;
|
|
1108
|
+
|
|
1109
|
+
bool end_of_dim0 = false;
|
|
1110
|
+
if (index_of_input_dim0 == (${r[0].dims[0]} - 1)) {
|
|
1111
|
+
// It's the end in dimension 0
|
|
1112
|
+
x01 = x00;
|
|
1113
|
+
end_of_dim0 = true;
|
|
1114
|
+
} else {
|
|
1115
|
+
x01 = getInputFloat(input_index + input_pitches[0]);
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
if (index_of_input_dim1 == (input_pitches[0] - 1)) {
|
|
1119
|
+
// It's the end in dimension 1
|
|
1120
|
+
x10 = x00;
|
|
1121
|
+
x11 = x01;
|
|
1122
|
+
}
|
|
1123
|
+
else {
|
|
1124
|
+
x10 = getInputFloat(input_index + 1);
|
|
1125
|
+
x11 = end_of_dim0 ? x10 : getInputFloat(input_index + input_pitches[0] + 1);
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
float y0 = x00 + float(y_offset) * (x01 - x00) / float(scales[0]);
|
|
1129
|
+
float y1 = x10 + float(y_offset) * (x11 - x10) / float(scales[0]);
|
|
1130
|
+
return y0 + float(x_offset) * (y1 - y0) / float(scales[1]);
|
|
1131
|
+
}`;return{...Rn,output:{dims:c,type:r[0].type,textureType:0},shaderSource:m,variables:[{name:"scales",type:"int",arrayLength:n.scales.length,data:n.scales.map(b=>Math.ceil(b))}]}},Po=(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.")},qr=(t,r,n)=>{if(n){for(let s of t)if(s<=0)throw new Error("Scale value should be greater than 0.")}else for(let s of t)if(s<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 ${n?"Resize":"Upsample"} opeartor.`)}}),Cr,Ao,wc,vc,ru,nu,ou,iu,xg=I(()=>{"use strict";Y(),V(),qt(),Ne(),yc(),Cr={name:"Resize",inputNames:["A"],inputTypes:[2]},Ao=(t,r,n)=>(Po(r,n),[t.run({...Cr,cacheHint:n.cacheKey,get:()=>ru(t,r,n)},r)]),wc=t=>pr(t,10),vc=t=>pr(t,11),ru=(t,r,n)=>{let s=B(t.session.backend.glContext.version),[p,l]=nu(r,n);if(p.every(w=>w===1)&&n.coordinateTransformMode!=="tf_crop_and_resize")return{...Cr,output:{dims:l,type:r[0].type,textureType:2},hasMain:!0,shaderSource:`void main() {
|
|
1132
|
+
vec4 v = ${s.texture2D}(X, TexCoords);
|
|
1133
|
+
${s.output} = v;
|
|
1134
|
+
}`};let c=l.length;if(c<2)throw new Error(`output dimension should be at least 2, but got ${c}`);let o=l[c-2],a=l[c-1],e=r[0].dims;if(c!==e.length)throw new Error(`output dimension should match input ${e.length}, but got ${c}`);let u=e[c-2],i=e[c-1],d=p[c-2],h=p[c-1],m="";if(n.mode!=="linear")throw new Error(`resize (packed) does not support mode: '${n.mode}'`);switch(n.coordinateTransformMode){case"asymmetric":m=`
|
|
1135
|
+
vec4 getSourceFracIndex(ivec4 coords) {
|
|
1136
|
+
return vec4(coords) / scaleWHWH;
|
|
1137
|
+
}
|
|
1138
|
+
`;break;case"half_pixel":m=`
|
|
1139
|
+
vec4 getSourceFracIndex(ivec4 coords) {
|
|
1140
|
+
return (vec4(coords) + 0.5) / scaleWHWH - 0.5;
|
|
1141
|
+
}
|
|
1142
|
+
`;break;case"pytorch_half_pixel":m=`
|
|
1143
|
+
vec4 getSourceFracIndex(ivec4 coords) {
|
|
1144
|
+
vec4 fcoords = vec4(coords);
|
|
1145
|
+
return vec4(
|
|
1146
|
+
${a}.0 > 1.0 ? (fcoords.x + 0.5) / scaleWHWH.x - 0.5 : 0.0,
|
|
1147
|
+
${o}.0 > 1.0 ? (fcoords.y + 0.5) / scaleWHWH.y - 0.5 : 0.0,
|
|
1148
|
+
${a}.0 > 1.0 ? (fcoords.z + 0.5) / scaleWHWH.z - 0.5 : 0.0,
|
|
1149
|
+
${o}.0 > 1.0 ? (fcoords.w + 0.5) / scaleWHWH.w - 0.5 : 0.0
|
|
1150
|
+
);
|
|
1151
|
+
}
|
|
1152
|
+
`;break;case"align_corners":m=`
|
|
1153
|
+
vec4 getSourceFracIndex(ivec4 coords) {
|
|
1154
|
+
vec4 resized = vec4(${a}.0 - 1.0, ${o}.0 - 1.0, ${a}.0 - 1.0,
|
|
1155
|
+
${o}.0 - 1.0);
|
|
1156
|
+
vec4 original = vec4(${i}.0 - 1.0, ${u}.0 - 1.0, ${i}.0 - 1.0,
|
|
1157
|
+
${u}.0 - 1.0);
|
|
1158
|
+
vec4 new_scale = original / resized;
|
|
1159
|
+
return vec4(coords) * new_scale;
|
|
1160
|
+
}
|
|
1161
|
+
`;break;default:throw new Error(`resize (packed) does not support coordinateTransformMode: '${n.coordinateTransformMode}'`)}let b=re(c),x=br(),E=`
|
|
1162
|
+
const vec2 inputWH = vec2(${u}.0, ${i}.0);
|
|
1163
|
+
const vec4 scaleWHWH = vec4(float(${d}), float(${h}), float(${d}), float(${h}));
|
|
1164
|
+
${x}
|
|
1165
|
+
${m}
|
|
1166
|
+
float getAValue(int x10, int r, int c, int d) {
|
|
1167
|
+
return getChannel(getA(x10, r, c, d), vec2(c, d));
|
|
1168
|
+
}
|
|
1169
|
+
void main() {
|
|
1170
|
+
${b} rc = getOutputCoords();
|
|
1171
|
+
|
|
1172
|
+
int batch = rc[0];
|
|
1173
|
+
int depth = rc[1];
|
|
1174
|
+
|
|
1175
|
+
// retrieve the 4 coordinates that is used in the 4 packed output values.
|
|
1176
|
+
ivec4 coords = ivec4(rc.wz, rc.w + 1, rc.z + 1);
|
|
1177
|
+
|
|
1178
|
+
// calculate the source index in fraction
|
|
1179
|
+
vec4 sourceFrac = getSourceFracIndex(coords);
|
|
1180
|
+
|
|
1181
|
+
// get the lower and upper bound of the 4 values that will be packed into one texel.
|
|
1182
|
+
ivec4 x00 = ivec4(max(sourceFrac.xy, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.xy)));
|
|
1183
|
+
ivec4 x01 = ivec4(max(sourceFrac.xw, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.xw)));
|
|
1184
|
+
ivec4 x10 = ivec4(max(sourceFrac.zy, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.zy)));
|
|
1185
|
+
ivec4 x11 = ivec4(max(sourceFrac.zw, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.zw)));
|
|
1186
|
+
|
|
1187
|
+
bool hasNextRow = rc.w < ${o-1};
|
|
1188
|
+
bool hasNextCol = rc.z < ${a-1};
|
|
1189
|
+
|
|
1190
|
+
// pack x00, x01, x10, x11's top-left corner into one vec4 structure
|
|
1191
|
+
vec4 topLeft = vec4(
|
|
1192
|
+
getAValue(batch, depth, x00.x, x00.y),
|
|
1193
|
+
hasNextCol ? getAValue(batch, depth, x01.x, x01.y) : 0.0,
|
|
1194
|
+
hasNextRow ? getAValue(batch, depth, x10.x, x10.y) : 0.0,
|
|
1195
|
+
(hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.x, x11.y) : 0.0);
|
|
1196
|
+
|
|
1197
|
+
// pack x00, x01, x10, x11's top-right corner into one vec4 structure
|
|
1198
|
+
vec4 topRight = vec4(
|
|
1199
|
+
getAValue(batch, depth, x00.x, x00.w),
|
|
1200
|
+
hasNextCol ? getAValue(batch, depth, x01.x, x01.w) : 0.0,
|
|
1201
|
+
hasNextRow ? getAValue(batch, depth, x10.x, x10.w) : 0.0,
|
|
1202
|
+
(hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.x, x11.w) : 0.0);
|
|
1203
|
+
|
|
1204
|
+
// pack x00, x01, x10, x11's bottom-left corner into one vec4 structure
|
|
1205
|
+
vec4 bottomLeft = vec4(
|
|
1206
|
+
getAValue(batch, depth, x00.z, x00.y),
|
|
1207
|
+
hasNextCol ? getAValue(batch, depth, x01.z, x01.y) : 0.0,
|
|
1208
|
+
hasNextRow ? getAValue(batch, depth, x10.z, x10.y) : 0.0,
|
|
1209
|
+
(hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.z, x11.y) : 0.0);
|
|
1210
|
+
|
|
1211
|
+
// pack x00, x01, x10, x11's bottom-right corner into one vec4 structure
|
|
1212
|
+
vec4 bottomRight = vec4(
|
|
1213
|
+
getAValue(batch, depth, x00.z, x00.w),
|
|
1214
|
+
hasNextCol ? getAValue(batch, depth, x01.z, x01.w) : 0.0,
|
|
1215
|
+
hasNextRow ? getAValue(batch, depth, x10.z, x10.w) : 0.0,
|
|
1216
|
+
(hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.z, x11.w) : 0.0);
|
|
1217
|
+
|
|
1218
|
+
// calculate the interpolation fraction on u and v direction
|
|
1219
|
+
vec4 frac = vec4(sourceFrac) - floor(sourceFrac);
|
|
1220
|
+
vec4 clampFrac = clamp(frac, vec4(0.0), vec4(1.0));
|
|
1221
|
+
|
|
1222
|
+
vec4 top = mix(topLeft, topRight, clampFrac.ywyw);
|
|
1223
|
+
vec4 bottom = mix(bottomLeft, bottomRight, clampFrac.ywyw);
|
|
1224
|
+
vec4 newValue = mix(top, bottom, clampFrac.xxzz);
|
|
1225
|
+
|
|
1226
|
+
${s.output} = vec4(newValue);
|
|
1227
|
+
}
|
|
1228
|
+
`;return{...Cr,output:{dims:l,type:r[0].type,textureType:2},hasMain:!0,shaderSource:E}},nu=(t,r)=>{let n=t[0].dims,s=r.scales,p;if(s.length===0){let c=t[r.scalesInputIdx];if(c&&c.size!==0){if(t[r.sizesInputIdx])throw new Error("Only one of scales or sizes must be provided as input.");s=ou(c,r.mode,r.isResize)}else{let o=t[r.sizesInputIdx];if(!o||o.size===0)throw new Error("Either scales or sizes MUST be provided as input.");p=Array.from(o.integerData),s=iu(p,n,r.mode,r.isResize)}}else if(t[r.sizesInputIdx])throw new Error("Only one of scales or sizes must be provided as input.");let l=p||n.map((c,o)=>Math.floor(c*s[o]));return[s,l]},ou=(t,r,n)=>{let s=Array.from(t.floatData);return qr(s,r,n),s},iu=(t,r,n,s)=>{let p=r.length,l=new Array(p);for(let c=0,o=p;c<o;c++)if(r[c]===0){if(t[c]!==0)throw new Error("Input dim is zero but required output dim is non-zero.");l[c]=1}else l[c]=t[c]/r[c];return qr(l,n,s),l}}),xc,au,Tg=I(()=>{"use strict";De(),xc=(t,r)=>(au(r),[new Pt([r[0].dims.length],"int32",void 0,void 0,new Int32Array(r[0].dims))]),au=t=>{if(!t||t.length!==1)throw new Error("Shape requires 1 input.")}}),Lr,Tc,_c,jn,su,Sc,uu,lu,_g=I(()=>{"use strict";lt(),Yr(),U(),V(),Lr={name:"Slice",inputNames:["A"],inputTypes:[0]},Tc=(t,r,n)=>(su(r),[t.run({...Lr,cacheHint:n.cacheKey,get:()=>jn(t,r[0],n)},r)]),_c=t=>{let r=t.attributes.getInts("starts"),n=t.attributes.getInts("ends"),s=t.attributes.getInts("axes",[]);return X({starts:r,ends:n,axes:s})},jn=(t,r,n)=>{let s=n.axes.length===0?r.dims.slice(0).map((u,i)=>i):n.axes,p=C.normalizeAxes(s,r.dims.length),l=n.starts.map((u,i)=>u>r.dims[p[i]]-1?r.dims[p[i]]:C.normalizeAxis(u,r.dims[p[i]])),c=n.ends.map((u,i)=>u>r.dims[p[i]]-1?r.dims[p[i]]:C.normalizeAxis(u,r.dims[p[i]])),o=r.dims.slice(),a=[];for(let u=0;u<p.length;u++)o[p[u]]=c[u]-l[u],l[u]>0&&a.push(`outputIdx[${p[u]}] += ${l[u]};`);let e=`
|
|
1229
|
+
float process(int outputIdx[${o.length}]) {
|
|
1230
|
+
${a.join(`
|
|
1231
|
+
`)}
|
|
1232
|
+
return _A(outputIdx);
|
|
1233
|
+
}`;return{...Lr,output:{dims:o,type:r.type,textureType:0},shaderSource:e}},su=t=>{if(!t||t.length!==1)throw new Error("Slice requires 1 input.");if(wr.indexOf(t[0].type)===-1)throw new Error("Invalid input type.")},Sc=(t,r)=>{lu(r);let n=uu(t,r);return[t.run({...Lr,cacheHint:n.cacheKey,get:()=>jn(t,r[0],n)},[r[0]])]},uu=(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(c=>c!==1))throw new Error("currently non-1 steps is not supported for Slice");let n=Array.from(r[1].integerData),s=Array.from(r[2].integerData),p=r.length>=4?Array.from(r[3].integerData):[],l=`${p};${n};${s}`;return{starts:n,ends:s,axes:p,cacheKey:l}},lu=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.")}}),Bn,Vn,Mn,Oc,Ec,Ic,Pc,zn,pu,cu,du,Un,Sg=I(()=>{"use strict";lt(),U(),Y(),V(),Zo(),Bn={name:"SoftmaxComputeMax",inputNames:["A"],inputTypes:[0]},Vn={name:"SoftmaxComputeScale",inputNames:["A","Max"],inputTypes:[0,0]},Mn={name:"SoftMax",inputNames:["A","Max","Norm"],inputTypes:[0,0,0]},Oc=(t,r,n)=>{Un(r);let s=r[0].dims.slice(),p=C.normalizeAxis(n.axis,s.length),l=C.sizeToDimension(s,p),c=C.sizeFromDimension(s,p);return zn(t,r,n,l,c)},Ec=t=>X({axis:t.attributes.getInt("axis",1)}),Ic=t=>X({axis:t.attributes.getInt("axis",-1)}),Pc=(t,r,n)=>{Un(r);let s=r[0].dims.slice(),p=C.normalizeAxis(n.axis,s.length),l=s.length,c=p!==l-1,o=[],a=[],e=[],u;c&&(a=Array.from({length:l}).map((m,b)=>b),a[p]=l-1,a[l-1]=p,a.map(m=>o.push(s[m])),u=X({perm:a}),e=fr(t,r,u));let i=c?C.sizeToDimension(o,l-1):C.sizeToDimension(s,l-1),d=c?C.sizeFromDimension(o,l-1):C.sizeFromDimension(s,l-1),h=zn(t,c?e:r,n,i,d);return c?fr(t,h,u):h},zn=(t,r,n,s,p)=>{let l=pu(t,r[0],s,p,[s]),c=t.run({...Bn,cacheHint:n.cacheKey,get:()=>l},r),o=cu(t,r[0],s,p,l.output.dims,[s]),a=t.run({...Vn,cacheHint:n.cacheKey,get:()=>o},[r[0],c]),e=du(t,r[0],s,p,l.output.dims,o.output.dims);return[t.run({...Mn,cacheHint:n.cacheKey,get:()=>e},[r[0],c,a])]},pu=(t,r,n,s,p)=>{let[l,c]=t.calculateTextureWidthAndHeight(r.dims,0),o=p.length;if(n<1||s<1)throw new Error("Logical row count N and feature count D must be greater than or equal to 1");if(p.length!==1)throw new Error("Dimensionality of the output should be 1");if(p[0]!==n)throw new Error("Shape of the output should be equal to logical row count");let a=B(t.session.backend.glContext.version),e=`
|
|
1234
|
+
float process(int[${o}] indices) {
|
|
1235
|
+
int logical_row_start_offset = indices[0] * ${s};
|
|
1236
|
+
|
|
1237
|
+
float max = getColorAsFloat(${a.texture2D}(A, offsetToCoords(logical_row_start_offset, ${l},
|
|
1238
|
+
${c} )));
|
|
1239
|
+
for(int i=1; i<${s}; ++i)
|
|
1240
|
+
{
|
|
1241
|
+
float current = getColorAsFloat(${a.texture2D}(A, offsetToCoords(logical_row_start_offset + i,
|
|
1242
|
+
${l}, ${c})));
|
|
1243
|
+
if(current > max)
|
|
1244
|
+
max = current;
|
|
1245
|
+
}
|
|
1246
|
+
|
|
1247
|
+
return max;
|
|
1248
|
+
}`;return{...Bn,output:{dims:p,type:r.type,textureType:0},shaderSource:e}},cu=(t,r,n,s,p,l)=>{let[c,o]=t.calculateTextureWidthAndHeight(r.dims,0),a=l.length;if(n<1||s<1)throw new Error("Logical row count N and feature count D must be greater than or equal to 1");if(l.length!==1)throw new Error("Dimensionality of the output should be 1");if(l[0]!==n)throw new Error("Shape of the output should be equal to logical row count");if(p.length!==1)throw new Error("Dimensionality of the intermediate results should be 1");if(p[0]!==n)throw new Error("Shape of the intermediate results should be equal to logical row count");let e=B(t.session.backend.glContext.version),u=`
|
|
1249
|
+
float process(int[${a}] indices) {
|
|
1250
|
+
int logical_row_start_offset = indices[0] * ${s};
|
|
1251
|
+
|
|
1252
|
+
float norm_factor = 0.0;
|
|
1253
|
+
float max = _Max(indices);
|
|
1254
|
+
for(int i=0; i<${s}; ++i)
|
|
1255
|
+
{
|
|
1256
|
+
norm_factor += exp(getColorAsFloat(${e.texture2D}(A, offsetToCoords(logical_row_start_offset + i,
|
|
1257
|
+
${c}, ${o}))) - max);
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1260
|
+
return norm_factor;
|
|
1261
|
+
}`;return{...Vn,output:{dims:l,type:r.type,textureType:0},shaderSource:u}},du=(t,r,n,s,p,l)=>{let[c,o]=t.calculateTextureWidthAndHeight(r.dims,0),a=r.dims.length;if(n<1||s<1)throw new Error("Logical row count N and feature count D must be greater than or equal to 1");if(p.length!==1||l.length!==1)throw new Error("Dimensionality of the intermediate results should be 1");if(p[0]!==n||l[0]!==n)throw new Error("Shape of the intermediate results should be equal to logical row count");let e=`
|
|
1262
|
+
float process(int[${a}] indices) {
|
|
1263
|
+
|
|
1264
|
+
// get offset of current logical tensor index from the 2-D texture coordinates (TexCoords)
|
|
1265
|
+
int offset = coordsToOffset(TexCoords, ${c}, ${o});
|
|
1266
|
+
|
|
1267
|
+
//determine the logical row for this index
|
|
1268
|
+
int logical_row_index[1];
|
|
1269
|
+
logical_row_index[0] = offset / ${s};
|
|
1270
|
+
|
|
1271
|
+
float norm_factor = _Norm(logical_row_index);
|
|
1272
|
+
|
|
1273
|
+
// avoid possible division by 0
|
|
1274
|
+
// if norm_facor is 0, all elements are zero
|
|
1275
|
+
// if so, return 0
|
|
1276
|
+
if(norm_factor == 0.0)
|
|
1277
|
+
return 0.0;
|
|
1278
|
+
|
|
1279
|
+
return exp(_A(indices) - _Max(logical_row_index)) / norm_factor;
|
|
1280
|
+
}`;return{...Mn,output:{dims:r.dims,type:r.type,textureType:0},shaderSource:e}},Un=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")}}),Gn,Ac,$c,hu,fu,gu,Og=I(()=>{"use strict";lt(),U(),V(),Gn={name:"Split",inputNames:["A"],inputTypes:[0]},Ac=(t,r,n)=>{gu(r);let s=C.normalizeAxis(n.axis,r[0].dims.length),p=hu(t,r,s,n),l=[];for(let c=0;c<p;++c)l.push(t.run({...Gn,cacheHint:`${n.cacheKey};${c}`,get:()=>fu(t,r[0],n,s,c)},r));return l},$c=t=>{let r=t.attributes.getInt("axis",0),n=t.attributes.getInts("split",[]),s=t.outputs.length;return X({axis:r,split:n,numOutputs:s})},hu=(t,r,n,s)=>{let[,p]=ho.splitShape(r[0].dims,n,s.split,s.numOutputs);return p.length},fu=(t,r,n,s,p)=>{let[l,c]=ho.splitShape(r.dims,s,n.split,n.numOutputs),o=c[p],a=l[p],e=`
|
|
1281
|
+
float process(int indices[${a.length}]) {
|
|
1282
|
+
indices[${s}] += ${o};
|
|
1283
|
+
return _A(indices);
|
|
1284
|
+
}
|
|
1285
|
+
`;return{...Gn,cacheHint:`${n.cacheKey}:${p}`,output:{dims:a,type:r.type,textureType:0},shaderSource:e}},gu=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.")}}),$o,Dc,Nc,mu,bu,Eg=I(()=>{"use strict";U(),$o=(t,r,n)=>{mu(r);let s=C.squeezeShape(r[0].dims,n);return[t.reshapeUnpacked(r[0],s)]},Dc=(t,r)=>(bu(r),$o(t,[r[0]],Array.from(r[1].integerData))),Nc=t=>t.attributes.getInts("axes"),mu=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.")},bu=t=>{if(!t||t.length!==2)throw new Error("Squeeze requires 2 inputs.");if(t[1].type!=="int32")throw new Error("Invalid input type.")}}),kc,yu,wu,Ig=I(()=>{"use strict";Y(),V(),kc=(t,r)=>{wu(r);let n={name:"Sum",inputNames:r.map((s,p)=>`X${p}`),inputTypes:new Array(r.length).fill(0)};return[t.run({...n,get:()=>yu(t,r,n)},r)]},yu=(t,r,n)=>{let s=B(t.session.backend.glContext.version),p=r[0].dims.slice(),l=`
|
|
1286
|
+
void main() {
|
|
1287
|
+
vec4 result = ${r.map((c,o)=>`${s.texture2D}(X${o},TexCoords)`).join(" + ")};
|
|
1288
|
+
${s.output} = result;
|
|
1289
|
+
}
|
|
1290
|
+
`;return{...n,output:{dims:p,type:r[0].type,textureType:0},hasMain:!0,shaderSource:l}},wu=t=>{if(!t||t.length===0)throw new Error("Sum requires inputs.");let r=t[0].dims.length;for(let n=1;n<t.length;n++){if(r!==t[n].dims.length)throw new Error("Input shapes are mismatched.");for(let s=0;s<r;s++)if(t[0].dims[s]!==t[n].dims[s])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 n=1;n<t.length;n++)if(t[0].type!==t[n].type)throw new Error("Input types are not matched.")}}),Fc,vu,xu,Pg=I(()=>{"use strict";Yr(),V(),Fc=(t,r)=>{xu(r);let n={name:"Tile",inputNames:["A"],inputTypes:[0]};return[t.run({...n,get:()=>vu(t,r,n)},r)]},vu=(t,r,n)=>{let s=r[0].dims.slice(),p=new Array(s.length),l=[];for(let a=0;a<s.length;a++)p[a]=s[a]*r[1].numberData[a],l.push(`inputIdx[${a}] = int(mod(float(outputIdx[${a}]), ${s[a]}.));`);let c=p.length,o=`
|
|
1291
|
+
float process(int outputIdx[${c}]) {
|
|
1292
|
+
int inputIdx[${c}];
|
|
1293
|
+
${l.join(`
|
|
1294
|
+
`)}
|
|
1295
|
+
return _A(inputIdx);
|
|
1296
|
+
}
|
|
1297
|
+
`;return{...n,output:{dims:p,type:r[0].type,textureType:0},shaderSource:o}},xu=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(wr.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.")}}),Do,Cc,Lc,Tu,_u,Ag=I(()=>{"use strict";U(),Do=(t,r,n)=>{Tu(r);let s=C.unsqueezeShape(r[0].dims,n);return[t.reshapeUnpacked(r[0],s)]},Cc=(t,r)=>(_u(r),Do(t,[r[0]],Array.from(r[1].integerData))),Lc=t=>t.attributes.getInts("axes"),Tu=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.")},_u=t=>{if(!t||t.length!==2)throw new Error("Unsqueeze requires 2 inputs.");if(t[1].type!=="int32")throw new Error("Invalid input type.")}}),Rc,$g=I(()=>{"use strict";bf(),Df(),Nf(),Ff(),Ko(),sg(),ug(),lg(),pg(),cg(),dg(),hg(),mg(),Wo(),bg(),yg(),wg(),vg(),xg(),Tg(),_g(),Sg(),Og(),Eg(),Ig(),Pg(),Zo(),Tp(),Ag(),yc(),Rc=[["Abs","","6+",Ql],["Acos","","7+",tp],["Add","","7+",kl],["And","","7+",Fl],["Asin","","7+",ep],["Atan","","7+",rp],["AveragePool","","7+",ec,rc],["BatchNormalization","","7+",Al,$l],["Cast","","6+",Hl,ql],["Ceil","","6+",ip],["Clip","","6-10",vo,np],["Clip","","11+",op],["Concat","","4+",Xl,Kl],["Conv","","1+",_o,So],["ConvTranspose","","1+",Cp,Lp],["Cos","","7+",ap],["Div","","7+",Cl],["Dropout","","7+",xo],["DepthToSpace","","1+",jp,Bp],["Equal","","7+",Ll],["Elu","","6+",sp,up],["Exp","","6+",lp],["Flatten","","1+",Vp,Mp],["Floor","","6+",pp],["FusedConv","com.microsoft","1+",_o,So],["Gather","","1+",zp,Up],["Gemm","","7-10",Oo,Gp],["Gemm","","11+",Oo,Hp],["GlobalAveragePool","","1+",nc,oc],["GlobalMaxPool","","1+",sc],["Greater","","7+",Rl],["Identity","","1+",xo],["ImageScaler","","1+",qp,Wp],["InstanceNormalization","","6+",Xp,Kp],["LeakyRelu","","6+",cp,dp],["Less","","7+",jl],["LRN","","1+",Zp,Jp],["Log","","6+",hp],["MatMul","","1+",Ip,Pp],["MaxPool","","1+",ic,ac],["Mul","","7+",Bl],["Neg","","6+",fp],["Not","","1+",gp],["Or","","7+",Vl],["Pad","","2-10",Eo,Yp],["Pad","","11+",Qp,tc],["Pow","","7+",Ml],["PRelu","","7+",zl],["ReduceLogSum","","1+",hc,te],["ReduceMax","","1+",pc,te],["ReduceMean","","1+",lc,te],["ReduceMin","","1+",cc,te],["ReduceProd","","1+",dc,te],["ReduceSum","","1-12",uc,te],["ReduceSumSquare","","1+",fc,te],["Relu","","6+",mp],["Reshape","","5+",gc],["Resize","","10",Ao,wc],["Resize","","11+",Ao,vc],["Shape","","1+",xc],["Sigmoid","","6+",bp],["Sin","","7+",yp],["Slice","","10+",Sc],["Slice","","1-9",Tc,_c],["Softmax","","1-12",Oc,Ec],["Softmax","","13+",Pc,Ic],["Split","","2-12",Ac,$c],["Sqrt","","6+",wp],["Squeeze","","1-12",$o,Nc],["Squeeze","","13+",Dc],["Sub","","7+",Ul],["Sum","","6+",kc],["Tan","","7+",vp],["Tanh","","6+",xp],["Tile","","6+",Fc],["Transpose","","1+",fr,Rp],["Upsample","","7-8",Io,mc],["Upsample","","9",Io,bc],["Unsqueeze","","1-12",Do,Lc],["Unsqueeze","","13+",Cc],["Xor","","7+",Gl]]});function Dg(t){let r={},n;for(;(n=No.exec(t))!==null;){let s=n[3].split(",").map(p=>{let l=p.trim().split(" ");return l&&l.length===2?{type:l[0],name:l[1]}:null}).filter(p=>p!==null);r[n[2]]={params:s,body:n[4]}}for(let s in r){let p=jc.replace("__FUNC__",s),l=new RegExp(p,"gm");for(;(n=l.exec(t))!==null;){let c=n[1],o=n[2],a=n[3].split(","),e=c?`${c} ${o};`:"",u=r[s].body,i="";r[s].params.forEach((h,m)=>{h&&(i+=`${h.type} ${h.name} = ${a[m]};
|
|
1298
|
+
`)}),u=`${i}
|
|
1299
|
+
${u}`,u=u.replace("return",`${o} = `);let d=`
|
|
1300
|
+
${e}
|
|
1301
|
+
{
|
|
1302
|
+
${u}
|
|
1303
|
+
}
|
|
1304
|
+
`;t=t.replace(n[0],d)}}return t=t.replace(No,""),t}var No,jc,Ng=I(()=>{"use strict";No=/@inline[\s\n\r]+(\w+)[\s\n\r]+([0-9a-zA-Z_]+)\s*\(([^)]*)\)\s*{(([^}]|[\n\r])*)}/gm,jc="(\\w+)?\\s+([_0-9a-zA-Z]+)\\s+=\\s+__FUNC__\\((.*)\\)\\s*;"});function rr(t,r){let n=[],s=[],p=r!=null&&Array.isArray(r)&&r.length===0,l=r==null||p?null:kg(r,t).sort(),c=0;for(let o=0;o<t.length;++o){if(l!=null){if(l[c]===o&&t[o]!==1)throw new Error(`Can't squeeze axis ${o} since its dim '${t[o]}' is not 1`);(l[c]==null||l[c]>o)&&t[o]===1&&(n.push(t[o]),s.push(o)),l[c]<=o&&c++}t[o]!==1&&(n.push(t[o]),s.push(o))}return{newShape:n,keptDims:s}}function kg(t,r){let n=r.length;return t=t==null?r.map((s,p)=>p):[].concat(t),Ur(t.every(s=>s>=-n&&s<n),()=>`All values in axis param must be in range [-${n}, ${n}) but got axis ${t}`),Ur(t.every(Fg),()=>`All values in axis param must be integers but got axis ${t}`),t.map(s=>s<0?n+s:s)}function Fg(t){return t%1===0}function Cg(t){if(t.length===0)return 1;let r=t[0];for(let n=1;n<t.length;n++)r*=t[n];return r}function Su(t){let r=Math.ceil(Math.sqrt(t));return[r,Math.ceil(t/r)]}var Bc,Vc=I(()=>{"use strict";Rt(),U(),Bc=class{constructor(t){this.maxTextureSize=t}computeTextureWH(t,r){let n=this.computeTexture(t,r);return r&&r.isPacked&&(n[0]/=2,n[1]/=2),r&&r.reverseWH?[n[1],n[0]]:n}computeTexture(t,r){let n=r&&r.isPacked;if(t.length===0)return n?[2,2]:[1,1];let s=this.maxTextureSize;if(r&&r.breakAxis!==void 0){let c=r.breakAxis>=t.length?1:t.slice(r.breakAxis).reduce((a,e)=>a*e),o=r.breakAxis<=0?1:t.slice(0,r.breakAxis).reduce((a,e)=>a*e);if(c>s||o>s)tt.verbose("TextureLayout",`Given width/height preferences were unattainable: shape:${t}, breakAxis:${r.breakAxis}`);else return[c,o]}let p=t.slice(0);n&&(s=s*2,p=p.map((c,o)=>o>=p.length-2?p[o]%2===0?p[o]:p[o]+1:p[o]),p.length===1&&(p=[2,p[0]])),p.length!==2&&(p=rr(p).newShape);let l=Cg(p);return p.length<=1&&l<=s?[1,l]:p.length===2&&p[0]<=s&&p[1]<=s?p:p.length===3&&p[0]*p[1]<=s&&p[2]<=s?[p[0]*p[1],p[2]]:p.length===3&&p[0]<=s&&p[1]*p[2]<=s?[p[0],p[1]*p[2]]:p.length===4&&p[0]*p[1]*p[2]<=s&&p[3]<=s?[p[0]*p[1]*p[2],p[3]]:p.length===4&&p[0]<=s&&p[1]*p[2]*p[3]<=s?[p[0],p[1]*p[2]*p[3]]:n?Su(l/4).map(c=>c*2):Su(l)}}}),Mc,Lg=I(()=>{"use strict";U(),ne(),Y(),Vc(),qt(),Mc=class extends ke{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 D(`
|
|
1305
|
+
vec2 ${t}(int offset, int width, int height) {
|
|
1306
|
+
int t = offset / width;
|
|
1307
|
+
int s = offset - t*width;
|
|
1308
|
+
vec2 coords = (vec2(s,t) + vec2(0.5,0.5)) / vec2(width, height);
|
|
1309
|
+
return coords;
|
|
1310
|
+
}
|
|
1311
|
+
`)}}coordsToOffset(){let t="coordsToOffset";return{coordsToOffset:new D(`
|
|
1312
|
+
int ${t}(vec2 coords, int width, int height) {
|
|
1313
|
+
float s = coords.s * float(width);
|
|
1314
|
+
float t = coords.t * float(height);
|
|
1315
|
+
int offset = int(t) * width + int(s);
|
|
1316
|
+
return offset;
|
|
1317
|
+
}
|
|
1318
|
+
`)}}getOutputSamplingSnippet(){let t=this.context.outputTextureLayout;return t.isPacked?this.getPackedOutputSamplingSnippet(t):this.getUnpackedOutputSamplingSnippet(t)}getPackedOutputSamplingSnippet(t){let r=t.unpackedShape,n=[t.width,t.height],s={},p="getOutputCoords";switch(r.length){case 0:s[p]=this.getOutputScalarCoords();break;case 1:s[p]=this.getOutputPacked1DCoords(r,n);break;case 2:s[p]=this.getOutputPacked2DCoords(r,n);break;case 3:s[p]=this.getOutputPacked3DCoords(r,n);break;default:s[p]=this.getOutputPackedNDCoords(r,n)}let l=`
|
|
1319
|
+
void setOutput(vec4 val) {
|
|
1320
|
+
${B(this.context.glContext.version).output} = val;
|
|
1321
|
+
}
|
|
1322
|
+
`,c="floatTextureSetRGBA";return s[c]=new D(l),s}getUnpackedOutputSamplingSnippet(t){let r=t.unpackedShape,n=[t.width,t.height],s={},p="getOutputCoords";switch(r.length){case 0:s[p]=this.getOutputScalarCoords();break;case 1:s[p]=this.getOutputUnpacked1DCoords(r,n);break;case 2:s[p]=this.getOutputUnpacked2DCoords(r,n);break;case 3:s[p]=this.getOutputUnpacked3DCoords(r,n);break;case 4:s[p]=this.getOutputUnpacked4DCoords(r,n);break;case 5:s[p]=this.getOutputUnpacked5DCoords(r,n);break;case 6:s[p]=this.getOutputUnpacked6DCoords(r,n);break;default:throw new Error(`Unsupported output dimensionality: ${r.length}`)}let l=`
|
|
1323
|
+
void setOutput(float val) {
|
|
1324
|
+
${B(this.context.glContext.version).output} = vec4(val, 0, 0, 0);
|
|
1325
|
+
}
|
|
1326
|
+
`,c="floatTextureSetR";return s[c]=new D(l),s}getOutputScalarCoords(){return new D(`
|
|
1327
|
+
int getOutputCoords() {
|
|
1328
|
+
return 0;
|
|
1329
|
+
}
|
|
1330
|
+
`)}getOutputPacked1DCoords(t,r){let n=r,s="";return n[0]===1?(s=`
|
|
1331
|
+
int getOutputCoords() {
|
|
1332
|
+
return 2 * int(TexCoords.y * ${n[1]}.0);
|
|
1333
|
+
}
|
|
1334
|
+
`,new D(s)):n[1]===1?(s=`
|
|
1335
|
+
int getOutputCoords() {
|
|
1336
|
+
return 2 * int(TexCoords.x * ${n[0]}.0);
|
|
1337
|
+
}
|
|
1338
|
+
`,new D(s)):(s=`
|
|
1339
|
+
int getOutputCoords() {
|
|
1340
|
+
ivec2 resTexRC = ivec2(TexCoords.xy *
|
|
1341
|
+
vec2(${n[0]}, ${n[1]}));
|
|
1342
|
+
return 2 * (resTexRC.y * ${n[0]} + resTexRC.x);
|
|
1343
|
+
}
|
|
1344
|
+
`,new D(s))}getOutputPacked2DCoords(t,r){let n="";if(Qe.arraysEqual(t,r))return n=`
|
|
1345
|
+
ivec2 getOutputCoords() {
|
|
1346
|
+
return 2 * ivec2(TexCoords.xy * vec2(${r[0]}, ${r[1]}));
|
|
1347
|
+
}
|
|
1348
|
+
`,new D(n);let s=r,p=Math.ceil(t[1]/2);return n=`
|
|
1349
|
+
ivec2 getOutputCoords() {
|
|
1350
|
+
ivec2 resTexRC = ivec2(TexCoords.xy *
|
|
1351
|
+
vec2(${s[0]}, ${s[1]}));
|
|
1352
|
+
|
|
1353
|
+
int index = resTexRC.y * ${s[0]} + resTexRC.x;
|
|
1354
|
+
|
|
1355
|
+
// reverse r and c order for packed texture
|
|
1356
|
+
int r = imod(index, ${p}) * 2;
|
|
1357
|
+
int c = 2 * (index / ${p});
|
|
1358
|
+
|
|
1359
|
+
return ivec2(r, c);
|
|
1360
|
+
}
|
|
1361
|
+
`,new D(n)}getOutputPacked3DCoords(t,r){let n=[r[0],r[1]],s=Math.ceil(t[2]/2),p=s*Math.ceil(t[1]/2),l=`
|
|
1362
|
+
ivec3 getOutputCoords() {
|
|
1363
|
+
ivec2 resTexRC = ivec2(TexCoords.xy *
|
|
1364
|
+
vec2(${n[0]}, ${n[1]}));
|
|
1365
|
+
int index = resTexRC.y * ${n[0]} + resTexRC.x;
|
|
1366
|
+
|
|
1367
|
+
int b = index / ${p};
|
|
1368
|
+
index -= b * ${p};
|
|
1369
|
+
|
|
1370
|
+
// reverse r and c order for packed texture
|
|
1371
|
+
int r = imod(index, ${s}) * 2;
|
|
1372
|
+
int c = 2 * (index / ${s});
|
|
1373
|
+
|
|
1374
|
+
return ivec3(b, r, c);
|
|
1375
|
+
}
|
|
1376
|
+
`;return new D(l)}getOutputPackedNDCoords(t,r){let n=[r[0],r[1]],s=Math.ceil(t[t.length-1]/2),p=s*Math.ceil(t[t.length-2]/2),l=p,c="",o="b, r, c";for(let e=2;e<t.length-1;e++)l*=t[t.length-e-1],c=`
|
|
1377
|
+
int b${e} = index / ${l};
|
|
1378
|
+
index -= b${e} * ${l};
|
|
1379
|
+
`+c,o=`b${e}, `+o;let a=`
|
|
1380
|
+
ivec${t.length} getOutputCoords() {
|
|
1381
|
+
ivec2 resTexRC = ivec2(TexCoords.xy *
|
|
1382
|
+
vec2(${n[0]}, ${n[1]}));
|
|
1383
|
+
int index = resTexRC.y * ${n[0]} + resTexRC.x;
|
|
1384
|
+
|
|
1385
|
+
${c}
|
|
1386
|
+
|
|
1387
|
+
int b = index / ${p};
|
|
1388
|
+
index -= b * ${p};
|
|
1389
|
+
|
|
1390
|
+
// reverse r and c order for packed texture
|
|
1391
|
+
int r = imod(index, ${s}) * 2;
|
|
1392
|
+
int c = 2 * (index / ${s});
|
|
1393
|
+
|
|
1394
|
+
return ivec${t.length}(${o});
|
|
1395
|
+
}
|
|
1396
|
+
`;return new D(a)}getOutputUnpacked1DCoords(t,r){let n=`
|
|
1397
|
+
int getOutputCoords() {
|
|
1398
|
+
ivec2 resTexRC = ivec2(TexCoords.xy *
|
|
1399
|
+
vec2(${r[0]}, ${r[1]}));
|
|
1400
|
+
return resTexRC.y * ${r[0]} + resTexRC.x;
|
|
1401
|
+
}
|
|
1402
|
+
`;return new D(n)}getOutputUnpacked2DCoords(t,r){let n=`
|
|
1403
|
+
ivec2 getOutputCoords() {
|
|
1404
|
+
ivec2 resTexRC = ivec2(TexCoords.xy *
|
|
1405
|
+
vec2(${r[0]}, ${r[1]}));
|
|
1406
|
+
int index = resTexRC.y * ${r[0]} + resTexRC.x;
|
|
1407
|
+
int r = index / ${t[1]};
|
|
1408
|
+
int c = index - r * ${t[1]};
|
|
1409
|
+
return ivec2(r, c);
|
|
1410
|
+
}
|
|
1411
|
+
`;return new D(n)}getOutputUnpacked3DCoords(t,r){let n="",s=t.length,p=null;s<2&&(p=[]),p=new Array(s-1),p[s-2]=t[s-1];for(let o=s-3;o>=0;--o)p[o]=p[o+1]*t[o+1];let l=["r","c","d"],c=p.map((o,a)=>{let e=`int ${l[a]} = index / ${o}`,u=a===p.length-1?`int ${l[a+1]} = index - ${l[a]} * ${o}`:`index -= ${l[a]} * ${o}`;return`${e}; ${u};`}).join("");return n=`
|
|
1412
|
+
ivec3 getOutputCoords() {
|
|
1413
|
+
ivec2 resTexRC = ivec2(TexCoords.xy *
|
|
1414
|
+
vec2(${r[0]}, ${r[1]}));
|
|
1415
|
+
int index = resTexRC.y * ${r[0]} + resTexRC.x;
|
|
1416
|
+
${c}
|
|
1417
|
+
return ivec3(r, c, d);
|
|
1418
|
+
}
|
|
1419
|
+
`,new D(n)}getOutputUnpacked4DCoords(t,r){let n="",s=t.length,p=null;s<2&&(p=[]),p=new Array(s-1),p[s-2]=t[s-1];for(let o=s-3;o>=0;--o)p[o]=p[o+1]*t[o+1];let l=["r","c","d","d2"],c=p.map((o,a)=>{let e=`int ${l[a]} = index / ${o}`,u=a===p.length-1?`int ${l[a+1]} = index - ${l[a]} * ${o}`:`index -= ${l[a]} * ${o}`;return`${e}; ${u};`}).join("");return n=`
|
|
1420
|
+
ivec4 getOutputCoords() {
|
|
1421
|
+
ivec2 resTexRC = ivec2(TexCoords.xy *
|
|
1422
|
+
vec2(${r[0]}, ${r[1]}));
|
|
1423
|
+
int index = resTexRC.y * ${r[0]} + resTexRC.x;
|
|
1424
|
+
${c}
|
|
1425
|
+
return ivec4(r, c, d, d2);
|
|
1426
|
+
}
|
|
1427
|
+
`,new D(n)}getOutputUnpacked5DCoords(t,r){let n="",s=t.length,p=null;s<2&&(p=[]),p=new Array(s-1),p[s-2]=t[s-1];for(let o=s-3;o>=0;--o)p[o]=p[o+1]*t[o+1];let l=["r","c","d","d2","d3"],c=p.map((o,a)=>{let e=`int ${l[a]} = index / ${o}`,u=a===p.length-1?`int ${l[a+1]} = index - ${l[a]} * ${o}`:`index -= ${l[a]} * ${o}`;return`${e}; ${u};`}).join("");return n=`
|
|
1428
|
+
ivec5 getOutputCoords() {
|
|
1429
|
+
ivec2 resTexRC = ivec2(TexCoords.xy *
|
|
1430
|
+
vec2(${r[0]}, ${r[1]}));
|
|
1431
|
+
int index = resTexRC.y * ${r[0]} + resTexRC.x;
|
|
1432
|
+
${c}
|
|
1433
|
+
return ivec5(r, c, d, d2, d3);
|
|
1434
|
+
}
|
|
1435
|
+
`,new D(n)}getOutputUnpacked6DCoords(t,r){let n="",s=t.length,p=null;s<2&&(p=[]),p=new Array(s-1),p[s-2]=t[s-1];for(let o=s-3;o>=0;--o)p[o]=p[o+1]*t[o+1];let l=["r","c","d","d2","d3","d4"],c=p.map((o,a)=>{let e=`int ${l[a]} = index / ${o}`,u=a===p.length-1?`int ${l[a+1]} = index - ${l[a]} * ${o}`:`index -= ${l[a]} * ${o}`;return`${e}; ${u};`}).join("");return n=`
|
|
1436
|
+
ivec6 getOutputCoords() {
|
|
1437
|
+
ivec2 resTexRC = ivec2(TexCoords.xy *
|
|
1438
|
+
vec2(${r[0]}, ${r[1]}));
|
|
1439
|
+
int index = resTexRC.y * ${r[0]} + resTexRC.x;
|
|
1440
|
+
${c}
|
|
1441
|
+
return ivec6(r, c, d, d2, d3, d4);
|
|
1442
|
+
}
|
|
1443
|
+
`,new D(n)}getCommonUtilFuncs(){let t={},r="uvFromFlat";t[r]=new D(`
|
|
1444
|
+
vec2 uvFromFlat(int texNumR, int texNumC, int index) {
|
|
1445
|
+
int texC = index / texNumR;
|
|
1446
|
+
int texR = index - texC * texNumR;
|
|
1447
|
+
// TODO: swap texR, texC order in following function so row is corresponding to u and column is corresponding to
|
|
1448
|
+
// v.
|
|
1449
|
+
return (vec2(texR, texC) + halfCR) / vec2(texNumR, texNumC);
|
|
1450
|
+
}
|
|
1451
|
+
`),r="packedUVfrom1D",t[r]=new D(`
|
|
1452
|
+
vec2 packedUVfrom1D(int texNumR, int texNumC, int index) {
|
|
1453
|
+
int texelIndex = index / 2;
|
|
1454
|
+
int texR = texelIndex / texNumC;
|
|
1455
|
+
int texC = texelIndex - texR * texNumC;
|
|
1456
|
+
return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);
|
|
1457
|
+
}
|
|
1458
|
+
`),r="packedUVfrom2D",t[r]=new D(`
|
|
1459
|
+
vec2 packedUVfrom2D(int texNumR, int texNumC, int texelsInLogicalRow, int row, int col) {
|
|
1460
|
+
int texelIndex = (row / 2) * texelsInLogicalRow + (col / 2);
|
|
1461
|
+
int texR = texelIndex / texNumC;
|
|
1462
|
+
int texC = texelIndex - texR * texNumC;
|
|
1463
|
+
return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);
|
|
1464
|
+
}
|
|
1465
|
+
`),r="packedUVfrom3D",t[r]=new D(`
|
|
1466
|
+
vec2 packedUVfrom3D(int texNumR, int texNumC,
|
|
1467
|
+
int texelsInBatch, int texelsInLogicalRow, int b,
|
|
1468
|
+
int row, int col) {
|
|
1469
|
+
int index = b * texelsInBatch + (row / 2) * texelsInLogicalRow + (col / 2);
|
|
1470
|
+
int texR = index / texNumC;
|
|
1471
|
+
int texC = index - texR * texNumC;
|
|
1472
|
+
return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);
|
|
1473
|
+
}
|
|
1474
|
+
`),r="sampleTexture";let n=B(this.context.glContext.version);return t[r]=new D(`
|
|
1475
|
+
float sampleTexture(sampler2D textureSampler, vec2 uv) {
|
|
1476
|
+
return ${n.texture2D}(textureSampler, uv).r;
|
|
1477
|
+
}`),t}getInputsSamplingSnippets(){let t={},r=this.context.outputTextureLayout;return this.context.programInfo.inputNames.forEach((n,s)=>{let p=this.context.inputTextureLayouts[s],l=_n(n);p.isPacked?t[l]=this.getPackedSamplerFromInput(l,n,p):t[l]=this.getUnpackedSamplerFromInput(l,n,p);let c=ef(n);p.unpackedShape.length<=r.unpackedShape.length&&(p.isPacked?t[c]=this.getPackedSamplerAtOutputCoords(c,p,r,n):t[c]=this.getUnpackedSamplerAtOutputCoords(c,p,r,n))}),t}getPackedSamplerAtOutputCoords(t,r,n,s){let p=r.unpackedShape,l=n.unpackedShape,c=_n(s),o=p.length,a=l.length,e=Mt.getBroadcastDims(p,l),u=re(a),i=a-o,d,h=$e();o===0?d="":a<2&&e.length>=1?d="coords = 0;":d=e.map($=>`coords.${h[$+i]} = 0;`).join(`
|
|
1478
|
+
`);let m="";a<2&&o>0?m="coords":m=p.map(($,F)=>`coords.${h[F+i]}`).join(", ");let b="return outputValue;",x=C.size(p)===1,E=C.size(l)===1;if(o===1&&!x&&!E)b=`
|
|
1479
|
+
return vec4(outputValue.xy, outputValue.xy);
|
|
1480
|
+
`;else if(x&&!E)a===1?b=`
|
|
1481
|
+
return vec4(outputValue.x, outputValue.x, 0., 0.);
|
|
1482
|
+
`:b=`
|
|
1483
|
+
return vec4(outputValue.x);
|
|
1484
|
+
`;else if(e.length){let $=o-2,F=o-1;e.indexOf($)>-1&&e.indexOf(F)>-1?b="return vec4(outputValue.x);":e.indexOf($)>-1?b="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":e.indexOf(F)>-1&&(b="return vec4(outputValue.xx, outputValue.zz);")}let w=`
|
|
1485
|
+
int lastDim = coords.${h[a-1]};
|
|
1486
|
+
coords.${h[a-1]} = coords.${h[a-2]};
|
|
1487
|
+
coords.${h[a-2]} = lastDim;
|
|
1488
|
+
`,S=`
|
|
1489
|
+
vec4 ${t}() {
|
|
1490
|
+
${u} coords = getOutputCoords();
|
|
1491
|
+
${w}
|
|
1492
|
+
${d}
|
|
1493
|
+
vec4 outputValue = ${c}(${m});
|
|
1494
|
+
${b}
|
|
1495
|
+
}
|
|
1496
|
+
`;return new D(S,["coordinates.getOutputCoords"])}getUnpackedSamplerAtOutputCoords(t,r,n,s){let p=[n.width,n.height],l=[r.width,r.height],c=r.unpackedShape.length,o=n.unpackedShape.length,a=r.unpackedShape,e=n.unpackedShape,u=_n(s);if(c===o&&Qe.arraysEqual(l,p)){let w=`
|
|
1497
|
+
float ${t}() {
|
|
1498
|
+
return sampleTexture(${s}, TexCoords);
|
|
1499
|
+
}
|
|
1500
|
+
`;return new D(w,["coordinates.sampleTexture"])}let i=re(o),d=Mt.getBroadcastDims(a,e),h=o-c,m,b=$e();c===0?m="":o<2&&d.length>=1?m="coords = 0;":m=d.map(w=>`coords.${b[w+h]} = 0;`).join(`
|
|
1501
|
+
`);let x="";o<2&&c>0?x="coords":x=r.unpackedShape.map((w,S)=>`coords.${b[S+h]}`).join(", ");let E=`
|
|
1502
|
+
float ${t}() {
|
|
1503
|
+
${i} coords = getOutputCoords();
|
|
1504
|
+
${m}
|
|
1505
|
+
return ${u}(${x});
|
|
1506
|
+
}
|
|
1507
|
+
`;return new D(E,["coordinates.getOutputCoords"])}getPackedSamplerFromInput(t,r,n){switch(n.unpackedShape.length){case 0:return this.getPackedSamplerScalar(t,r);case 1:return this.getPackedSampler1D(t,r,n);case 2:return this.getPackedSampler2D(t,r,n);case 3:return this.getPackedSampler3D(t,r,n);default:return this.getPackedSamplerND(t,r,n)}}getUnpackedSamplerFromInput(t,r,n){let s=n.unpackedShape;switch(s.length){case 0:return this.getUnpackedSamplerScalar(t,r,n);case 1:return this.getUnpackedSampler1D(t,r,n);case 2:return this.getUnpackedSampler2D(t,r,n);case 3:return this.getUnpackedSampler3D(t,r,n);case 4:return this.getUnpackedSampler4D(t,r,n);case 5:return this.getUnpackedSampler5D(t,r,n);case 6:return this.getUnpackedSampler6D(t,r,n);default:throw new Error(`Unsupported dimension ${s.length}-D`)}}getPackedSamplerScalar(t,r){let n=B(this.context.glContext.version),s=`
|
|
1508
|
+
vec4 ${t}() {
|
|
1509
|
+
return ${n.texture2D}(${r}, halfCR);
|
|
1510
|
+
}
|
|
1511
|
+
`;return new D(s)}getPackedSampler1D(t,r,n){let s=[n.width,n.height],p=[s[1],s[0]],l=B(this.context.glContext.version),c=`vec4 ${t}(int index) {
|
|
1512
|
+
vec2 uv = packedUVfrom1D(
|
|
1513
|
+
${p[0]}, ${p[1]}, index);
|
|
1514
|
+
return ${l.texture2D}(${r}, uv);
|
|
1515
|
+
}`;return new D(c,["coordinates.packedUVfrom1D"])}getPackedSampler2D(t,r,n){let s=n.unpackedShape,p=[n.width,n.height],l=B(this.context.glContext.version),c=p[0],o=p[1];if(p!=null&&Qe.arraysEqual(s,p)){let i=`vec4 ${t}(int row, int col) {
|
|
1516
|
+
vec2 uv = (vec2(col, row) + halfCR) / vec2(${o}.0, ${c}.0);
|
|
1517
|
+
return ${l.texture2D}(${r}, uv);
|
|
1518
|
+
}`;return new D(i)}let a=p,e=Math.ceil(s[1]/2),u=`vec4 ${t}(int row, int col) {
|
|
1519
|
+
vec2 uv = packedUVfrom2D(${a[1]}, ${a[0]}, ${e}, row, col);
|
|
1520
|
+
return ${l.texture2D}(${r}, uv);
|
|
1521
|
+
}`;return new D(u,["coordinates.packedUVfrom2D"])}getPackedSampler3D(t,r,n){let s=n.unpackedShape,p=[n.width,n.height],l=[p[0],p[1]],c=B(this.context.glContext.version);if(s[0]===1){let d=s.slice(1),h=[1,2],m=Ue(s,d),b=["b","row","col"],x=JSON.parse(JSON.stringify(n));x.unpackedShape=m;let E=this.getPackedSamplerFromInput(t,r,x),w=`${E.routineBody}
|
|
1522
|
+
vec4 ${t}(int b, int row, int col) {
|
|
1523
|
+
return ${t}(${Ge(b,h)});
|
|
1524
|
+
} `;return new D(w,E.dependencies)}let o=l[0],a=l[1],e=Math.ceil(s[2]/2),u=e*Math.ceil(s[1]/2),i=`vec4 ${t}(int b, int row, int col) {
|
|
1525
|
+
vec2 uv = packedUVfrom3D(
|
|
1526
|
+
${a}, ${o}, ${u}, ${e}, b, row, col);
|
|
1527
|
+
return ${c.texture2D}(${r}, uv);}`;return new D(i,["coordinates.packedUVfrom3D"])}getPackedSamplerND(t,r,n){let s=n.unpackedShape,p=s.length,l=[n.width,n.height],c=B(this.context.glContext.version),o=[l[0],l[1]],a=o[1],e=o[0],u=Math.ceil(s[p-1]/2),i=u*Math.ceil(s[p-2]/2),d="int b, int row, int col",h=`b * ${i} + (row / 2) * ${u} + (col / 2)`;for(let b=2;b<p-1;b++)d=`int b${b}, `+d,i*=s[p-b-1],h=`b${b} * ${i} + `+h;let m=`vec4 ${t}(${d}) {
|
|
1528
|
+
int index = ${h};
|
|
1529
|
+
int texR = index / ${e};
|
|
1530
|
+
int texC = index - texR * ${e};
|
|
1531
|
+
vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${e}, ${a});
|
|
1532
|
+
return ${c.texture2D}(${r}, uv);
|
|
1533
|
+
}`;return new D(m)}getUnpackedSamplerScalar(t,r,n){let[s,p]=[n.width,n.height];if(s===1&&p===1){let c=`
|
|
1534
|
+
float ${t}() {
|
|
1535
|
+
return sampleTexture(${r}, halfCR);
|
|
1536
|
+
}
|
|
1537
|
+
`;return new D(c,["coordinates.sampleTexture"])}let l=`
|
|
1538
|
+
float ${t}() {
|
|
1539
|
+
int offset_${r} = coordsToOffset(TexCoords, ${s}, ${p});
|
|
1540
|
+
vec2 uv = uvFromFlat(${s}, ${p}, offset_${r});
|
|
1541
|
+
return sampleTexture(${r}, uv);
|
|
1542
|
+
}
|
|
1543
|
+
`;return new D(l,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}getUnpackedSampler1D(t,r,n){let s=n.width,p=n.height;if(p===1&&s===1){let c=`
|
|
1544
|
+
float ${t}(int index) {
|
|
1545
|
+
return sampleTexture(${r}, halfCR);
|
|
1546
|
+
}
|
|
1547
|
+
`;return new D(c,["coordinates.sampleTexture"])}if(p===1){let c=`
|
|
1548
|
+
float ${t}(int index) {
|
|
1549
|
+
vec2 uv = vec2((float(index) + 0.5) / ${s}.0, 0.5);
|
|
1550
|
+
return sampleTexture(${r}, uv);
|
|
1551
|
+
}
|
|
1552
|
+
`;return new D(c,["coordinates.sampleTexture"])}if(s===1){let c=`
|
|
1553
|
+
float ${t}(int index) {
|
|
1554
|
+
vec2 uv = vec2(0.5, (float(index) + 0.5) / ${p}.0);
|
|
1555
|
+
return sampleTexture(${r}, uv);
|
|
1556
|
+
}
|
|
1557
|
+
`;return new D(c,["coordinates.sampleTexture"])}let l=`
|
|
1558
|
+
float ${t}(int index) {
|
|
1559
|
+
vec2 uv = uvFromFlat(${s}, ${p}, index);
|
|
1560
|
+
return sampleTexture(${r}, uv);
|
|
1561
|
+
}
|
|
1562
|
+
`;return new D(l,["coordinates.uvFromFlat","coordinates.sampleTexture"])}getUnpackedSampler2D(t,r,n){let s=n.unpackedShape,p=[n.height,n.width];if(p!=null&&Qe.arraysEqual(s,p)){let i=p[1],d=p[0],h=`
|
|
1563
|
+
float ${t}(int row, int col) {
|
|
1564
|
+
vec2 uv = (vec2(row, col) + halfCR) / vec2(${i}.0, ${d}.0);
|
|
1565
|
+
return sampleTexture(${r}, uv);
|
|
1566
|
+
}
|
|
1567
|
+
`;return new D(h,["coordinates.sampleTexture"])}let{newShape:l,keptDims:c}=rr(s),o=l;if(o.length<s.length){let i=Ue(s,o),d=JSON.parse(JSON.stringify(n));d.unpackedShape=i;let h=["col","row"],m=`
|
|
1568
|
+
${this.getUnpackedSamplerFromInput(t,r,d).routineBody}
|
|
1569
|
+
float ${t}(int row, int col) {
|
|
1570
|
+
return ${t}(${Ge(h,c)});
|
|
1571
|
+
}
|
|
1572
|
+
`;return new D(m,["coordinates.sampleTexture"])}let a=p[1],e=p[0];if(e===1){let i=`
|
|
1573
|
+
float ${t}(int row, int col) {
|
|
1574
|
+
int offset_${r} = coordsToOffset(TexCoords, ${a}, ${e});
|
|
1575
|
+
float index = dot(vec3(row, col, offset_${r}), vec3(${s[1]}, 1, 1));
|
|
1576
|
+
vec2 uv = vec2(0.5, (index + 0.5) / ${a}.0);
|
|
1577
|
+
return sampleTexture(${r}, uv);
|
|
1578
|
+
}
|
|
1579
|
+
`;return new D(i,["coordinates.sampleTexture","coordinates.coordsToOffset"])}if(a===1){let i=`
|
|
1580
|
+
float ${t}(int row, int col) {
|
|
1581
|
+
int offset_${r} = coordsToOffset(TexCoords, ${a}, ${e});
|
|
1582
|
+
float index = dot(vec3(row, col, offset_${r}), vec3(${s[1]}, 1, 1));
|
|
1583
|
+
vec2 uv = vec2((index + 0.5) / ${e}.0, 0.5);
|
|
1584
|
+
return sampleTexture(${r}, uv);
|
|
1585
|
+
}
|
|
1586
|
+
`;return new D(i,["coordinates.sampleTexture","coordinates.coordsToOffset"])}let u=`
|
|
1587
|
+
float ${t}(int row, int col) {
|
|
1588
|
+
int index = col * ${s[1]} + row;
|
|
1589
|
+
vec2 uv = uvFromFlat(${a}, ${e}, index);
|
|
1590
|
+
return sampleTexture(${r}, uv);
|
|
1591
|
+
}
|
|
1592
|
+
`;return new D(u,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}getUnpackedSampler3D(t,r,n){let s=n.unpackedShape,p=s[1]*s[2],l=s[2],{newShape:c,keptDims:o}=rr(s),a=c;if(a.length<s.length){let d=Ue(s,a),h=["batch","col","row"],m=JSON.parse(JSON.stringify(n));m.unpackedShape=d;let b=this.getUnpackedSamplerFromInput(t,r,m),x=o.reverse(),E=`
|
|
1593
|
+
${b.routineBody}
|
|
1594
|
+
float ${t}(int batch, int row, int col) {
|
|
1595
|
+
return ${t}(${Ge(h,x)});
|
|
1596
|
+
}
|
|
1597
|
+
`;return new D(E,b.dependencies)}let e=n.width,u=n.height,i=`
|
|
1598
|
+
float ${t}(int depth, int row, int col) {
|
|
1599
|
+
// Explicitly use integer operations as dot() only works on floats.
|
|
1600
|
+
int index = depth * ${p} + col * ${l} + row;
|
|
1601
|
+
vec2 uv = uvFromFlat(${e}, ${u}, index);
|
|
1602
|
+
return sampleTexture(${r}, uv);
|
|
1603
|
+
}
|
|
1604
|
+
`;return new D(i,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}getUnpackedSampler4D(t,r,n){let s=n.unpackedShape,p=s[3],l=s[2]*p,c=s[1]*l,o=n.width,a=n.height,e=`
|
|
1605
|
+
float ${t}(int row, int col, int depth, int depth2) {
|
|
1606
|
+
int index = row * ${c} + col * ${l} +
|
|
1607
|
+
depth2 * ${p} + depth;
|
|
1608
|
+
vec2 uv = uvFromFlat(${o}, ${a}, index);
|
|
1609
|
+
return sampleTexture(${r}, uv);
|
|
1610
|
+
}
|
|
1611
|
+
`;return new D(e,["coordinates.uvFromFlat","coordinates.sampleTexture"])}getUnpackedSampler5D(t,r,n){let s=n.unpackedShape,p=s[4],l=s[3]*p,c=s[2]*l,o=s[1]*c,{newShape:a,keptDims:e}=rr(s);if(a.length<s.length){let h=Ue(s,a),m=["row","col","depth","depth2","depth3"],b=JSON.parse(JSON.stringify(n));b.unpackedShape=h;let x=`
|
|
1612
|
+
${this.getUnpackedSamplerFromInput(t,r,b).routineBody}
|
|
1613
|
+
float ${t}(int row, int col, int depth, int depth2, int depth3) {
|
|
1614
|
+
return ${t}(${Ge(m,e)});
|
|
1615
|
+
}
|
|
1616
|
+
`;return new D(x,["coordinates.sampleTexture","coordinates.uvFromFlat"])}let u=n.width,i=n.height,d=`
|
|
1617
|
+
float ${t}(int row, int col, int depth, int depth2, int depth3) {
|
|
1618
|
+
int index = row * ${o} + col * ${c} + depth * ${l} +
|
|
1619
|
+
depth3 * ${p} + depth2;
|
|
1620
|
+
vec2 uv = uvFromFlat(${u}, ${i}, index);
|
|
1621
|
+
return sampleTexture(${r}, uv);
|
|
1622
|
+
}
|
|
1623
|
+
`;return new D(d,["coordinates.sampleTexture","coordinates.uvFromFlat"])}getUnpackedSampler6D(t,r,n){let s=n.unpackedShape,p=s[5],l=s[4]*p,c=s[3]*l,o=s[2]*c,a=s[1]*o,{newShape:e,keptDims:u}=rr(s);if(e.length<s.length){let m=Ue(s,e),b=["row","col","depth","depth2","depth3","depth4"],x=JSON.parse(JSON.stringify(n));x.unpackedShape=m;let E=`
|
|
1624
|
+
${this.getUnpackedSamplerFromInput(t,r,x).routineBody}
|
|
1625
|
+
float ${t}(int row, int col, int depth,
|
|
1626
|
+
int depth2, int depth3, int depth4) {
|
|
1627
|
+
return ${t}(${Ge(b,u)});
|
|
1628
|
+
}
|
|
1629
|
+
`;return new D(E,["coordinates.sampleTexture","coordinates.uvFromFlat"])}let i=n.width,d=n.height,h=`
|
|
1630
|
+
float ${t}(int row, int col, int depth,
|
|
1631
|
+
int depth2, int depth3, int depth4) {
|
|
1632
|
+
int index = row * ${a} + col * ${o} + depth * ${c} +
|
|
1633
|
+
depth2 * ${l} + depth3 * ${p} + depth4;
|
|
1634
|
+
vec2 uv = uvFromFlat(${i}, ${d}, index);
|
|
1635
|
+
return sampleTexture(${r}, uv);
|
|
1636
|
+
}
|
|
1637
|
+
`;return new D(h,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}toVec(){let t=this.context.outputTextureLayout,r=t.shape.length,n=t.strides,s=t.width,p=t.height,l=[];for(let o=0;o<r-1;++o)l.push(`
|
|
1638
|
+
c[${o}] = offset / ${n[o]};`),l.push(`
|
|
1639
|
+
offset -= c[${o}] * ${n[o]};`);l.push(`
|
|
1640
|
+
c[${r-1}] = offset;`);let c=`
|
|
1641
|
+
void toVec(vec2 texCoords, out int c[${r}]) {
|
|
1642
|
+
int offset = coordsToOffset(texCoords, ${s}, ${p});
|
|
1643
|
+
${l.join("")}
|
|
1644
|
+
}
|
|
1645
|
+
void toVec(int offset, out int c[${r}]) {
|
|
1646
|
+
${l.join("")}
|
|
1647
|
+
}
|
|
1648
|
+
`;return{toVec:new D(c,["coordinates.coordsToOffset"])}}valueFrom(){let t={};return this.context.programInfo.inputNames.forEach((r,n)=>{let s=this.context.inputTextureLayouts[n],p=(s.unpackedShape.length>0?s.unpackedShape:s.shape).length,l=`_${r}`;t[l]=new D(this.getValueFromSingle(r,p,s.width,s.height,!1),[`shapeUtils.indicesToOffset${l}`,"coordinates.offsetToCoords","fragcolor.getColorAsFloat"]),l=l+"_T",t[l]=new D(this.getValueFromSingle(r,p,s.width,s.height,!0),[`shapeUtils.indicesToOffset${l}`,"coordinates.offsetToCoords","fragcolor.getColorAsFloat"])}),t}getValueFromSingle(t,r,n,s,p){let l=`_${t}`;p&&(l=l+"_T");let c=B(this.context.glContext.version);return`
|
|
1649
|
+
float ${l}(int m[${r}]) {
|
|
1650
|
+
int offset = indicesToOffset${l}(m);
|
|
1651
|
+
vec2 coords = offsetToCoords(offset, ${n}, ${s});
|
|
1652
|
+
float value = getColorAsFloat(${c.texture2D}(${t}, coords));
|
|
1653
|
+
return value;
|
|
1654
|
+
}
|
|
1655
|
+
`}getPackedValueFrom(t,r,n,s,p){let l=`_${t}_Pack`;p&&(l=l+"_T");let c=B(this.context.glContext.version);return`
|
|
1656
|
+
vec4 ${l}(int m[${r}]) {
|
|
1657
|
+
int offset = indicesToOffset_${t}(m);
|
|
1658
|
+
vec2 coords = offsetToCoords(offset, ${n}, ${s});
|
|
1659
|
+
return ${c.texture2D}(${t}, coords);
|
|
1660
|
+
}
|
|
1661
|
+
`}}}),zc,Rg=I(()=>{"use strict";ne(),zc=class ko extends ke{constructor(r){super(r)}getFunctions(){return{...this.encodeFloat32(),...this.decodeFloat32()}}getCustomTypes(){return{}}encodeFloat32(){return{encode:new D(`highp vec4 encode(highp float f) {
|
|
1662
|
+
return vec4(f, 0.0, 0.0, 0.0);
|
|
1663
|
+
}
|
|
1664
|
+
`)}}decodeFloat32(){return{decode:new D(`highp float decode(highp vec4 rgba) {
|
|
1665
|
+
return rgba.r;
|
|
1666
|
+
}
|
|
1667
|
+
`)}}encodeUint8(){let r=ko.isLittleEndian()?"rgba.rgba=rgba.abgr;":"";return{encode:new D(`
|
|
1668
|
+
highp vec4 encode(highp float f) {
|
|
1669
|
+
highp float F = abs(f);
|
|
1670
|
+
highp float Sign = step(0.0,-f);
|
|
1671
|
+
highp float Exponent = floor(log2(F));
|
|
1672
|
+
highp float Mantissa = (exp2(- Exponent) * F);
|
|
1673
|
+
Exponent = floor(log2(F) + 127.0) + floor(log2(Mantissa));
|
|
1674
|
+
highp vec4 rgba;
|
|
1675
|
+
rgba[0] = 128.0 * Sign + floor(Exponent*exp2(-1.0));
|
|
1676
|
+
rgba[1] = 128.0 * mod(Exponent,2.0) + mod(floor(Mantissa*128.0),128.0);
|
|
1677
|
+
rgba[2] = floor(mod(floor(Mantissa*exp2(23.0 -8.0)),exp2(8.0)));
|
|
1678
|
+
rgba[3] = floor(exp2(23.0)*mod(Mantissa,exp2(-15.0)));
|
|
1679
|
+
${r}
|
|
1680
|
+
rgba = rgba / 255.0; // values need to be normalized to [0,1]
|
|
1681
|
+
return rgba;
|
|
1682
|
+
}
|
|
1683
|
+
`)}}decodeUint8(){let r=ko.isLittleEndian()?"rgba.rgba=rgba.abgr;":"";return{decode:new D(`
|
|
1684
|
+
highp float decode(highp vec4 rgba) {
|
|
1685
|
+
rgba = rgba * 255.0; // values need to be de-normalized from [0,1] to [0,255]
|
|
1686
|
+
${r}
|
|
1687
|
+
highp float Sign = 1.0 - step(128.0,rgba[0])*2.0;
|
|
1688
|
+
highp float Exponent = 2.0 * mod(rgba[0],128.0) + step(128.0,rgba[1]) - 127.0;
|
|
1689
|
+
highp float Mantissa = mod(rgba[1],128.0)*65536.0 + rgba[2]*256.0 +rgba[3] + float(0x800000);
|
|
1690
|
+
highp float Result = Sign * exp2(Exponent) * (Mantissa * exp2(-23.0 ));
|
|
1691
|
+
return Result;
|
|
1692
|
+
}
|
|
1693
|
+
`)}}static isLittleEndian(){let r=new ArrayBuffer(4),n=new Uint32Array(r),s=new Uint8Array(r);if(n[0]=3735928559,s[0]===239)return!0;if(s[0]===222)return!1;throw new Error("unknown endianness")}}}),Uc,jg=I(()=>{"use strict";ne(),Y(),Uc=class extends ke{constructor(t){super(t)}getFunctions(){return{...this.setFragColor(),...this.getColorAsFloat()}}getCustomTypes(){return{}}setFragColor(){let t=B(this.context.glContext.version);return{setFragColor:new D(`
|
|
1694
|
+
void setFragColor(float value) {
|
|
1695
|
+
${t.output} = encode(value);
|
|
1696
|
+
}
|
|
1697
|
+
`,["encoding.encode"])}}getColorAsFloat(){return{getColorAsFloat:new D(`
|
|
1698
|
+
float getColorAsFloat(vec4 color) {
|
|
1699
|
+
return decode(color);
|
|
1700
|
+
}
|
|
1701
|
+
`,["encoding.decode"])}}}}),Gc,Bg=I(()=>{"use strict";ne(),Gc=class nr extends ke{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,n={};return this.context.programInfo.inputNames.forEach((s,p)=>{let l=this.context.inputTextureLayouts[p].unpackedShape;if(l.length<=r){let c=l.length,o=r-c,a=`bcastIndices_${s}`,e="";for(let i=0;i<c;++i)e+=`
|
|
1702
|
+
realIndices[${i}] = int( mod(float(bcastedIndices[${o+i}]), ${l[i]}.0) );
|
|
1703
|
+
`;let u=`
|
|
1704
|
+
void ${a} (int bcastedIndices[${r}], out int realIndices[${c}]) {
|
|
1705
|
+
${e}
|
|
1706
|
+
}
|
|
1707
|
+
`;n[a]=new D(u)}}),n}bcastMatmulIndex(){let r=this.context.outputTextureLayout.shape.length,n={};return this.context.programInfo.inputNames.forEach((s,p)=>{let l=this.context.inputTextureLayouts[p].shape;if(!(l.length<2||l.length>r)){let c=l.length,o=r-c,a=`bcastMatmulIndices_${s}`,e="";for(let i=0;i<c-2;++i)e+=`
|
|
1708
|
+
realIndices[${i}] = int( mod(float(bcastedIndices[${o+i}]), ${l[i]}.0) );
|
|
1709
|
+
`;let u=`
|
|
1710
|
+
void ${a}(int bcastedIndices[${r}], out int realIndices[${c}]) {
|
|
1711
|
+
${e}
|
|
1712
|
+
realIndices[${c-1}] = bcastedIndices[${r-1}];
|
|
1713
|
+
realIndices[${c-2}] = bcastedIndices[${r-2}];
|
|
1714
|
+
}
|
|
1715
|
+
`;n[a]=new D(u)}}),n}indicesToOffset(){let r={};return this.context.programInfo.inputNames.forEach((n,s)=>{let p=this.context.inputTextureLayouts[s].shape,l=this.context.inputTextureLayouts[s].strides,c=p.length,o=`indicesToOffset_${n}`;r[o]=new D(nr.indexToOffsetSingle(o,c,l)),o=`indicesToOffset_${n}_T`,r[o]=new D(nr.indexToOffsetSingle(o,c,l.slice().reverse()))}),r}static indexToOffsetSingle(r,n,s){let p="";for(let l=n-1;l>=0;--l)p+=`
|
|
1716
|
+
offset += indices[${l}] * ${s[l]};
|
|
1717
|
+
`;return`
|
|
1718
|
+
int ${r}(int indices[${n}]) {
|
|
1719
|
+
int offset = 0;
|
|
1720
|
+
${p}
|
|
1721
|
+
return offset;
|
|
1722
|
+
}
|
|
1723
|
+
`}offsetToIndices(){let r={};return this.context.programInfo.inputNames.forEach((n,s)=>{let p=this.context.inputTextureLayouts[s].shape,l=this.context.inputTextureLayouts[s].strides,c=p.length,o=`offsetToIndices_${n}`;r[o]=new D(nr.offsetToIndicesSingle(o,c,l)),o=`offsetToIndices_${n}_T`,r[o]=new D(nr.offsetToIndicesSingle(o,c,l.slice().reverse()))}),r}static offsetToIndicesSingle(r,n,s){let p=[];for(let l=0;l<n-1;++l)p.push(`
|
|
1724
|
+
indices[${l}] = offset / ${s[l]};`),p.push(`
|
|
1725
|
+
offset -= indices[${l}] * ${s[l]};`);return p.push(`
|
|
1726
|
+
indices[${n-1}] = offset;`),`
|
|
1727
|
+
void ${r}(int offset, out int indices[${n}]) {
|
|
1728
|
+
${p.join("")}
|
|
1729
|
+
}
|
|
1730
|
+
`}incrementIndices(){let r={};return this.context.programInfo.inputNames.forEach((n,s)=>{let p=this.context.inputTextureLayouts[s].shape,l=p.length,c=`incrementIndices_${n}`,o="";for(let e=0;e<l;++e)o+=`
|
|
1731
|
+
shape[${e}] = ${p[e]};`;let a=`
|
|
1732
|
+
void ${c}(int axis, out int indices[${l}]) {
|
|
1733
|
+
int shape[${l}];
|
|
1734
|
+
${o};
|
|
1735
|
+
for(int i = ${l} -1 ; i >= 0; --i) {
|
|
1736
|
+
if(i > axis) continue;
|
|
1737
|
+
indices[i] += 1;
|
|
1738
|
+
if(indices[i] < shape[i]) {
|
|
1739
|
+
break;
|
|
1740
|
+
}
|
|
1741
|
+
indices[i] = 0;
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1744
|
+
`;r[c]=new D(a)}),r}}}),Hc,Vg=I(()=>{"use strict";ne(),Hc=class extends ke{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:"/="},n={};for(let s in r){let p=`${s}Vec`,l="";for(let o=0;o<t;++o)l+=`
|
|
1745
|
+
dest[${o}] ${r[s]} src[${o}];
|
|
1746
|
+
`;let c=`
|
|
1747
|
+
void ${p}(int src[${t}], out int dest[${t}]) {
|
|
1748
|
+
${l}
|
|
1749
|
+
}
|
|
1750
|
+
`;n[p]=new D(c)}return n}copyVec(){let t=this.context.outputTextureLayout.shape.length,r="";for(let s=0;s<t;++s)r+=`
|
|
1751
|
+
dest[${s}] = src[${s}];
|
|
1752
|
+
`;let n=`
|
|
1753
|
+
void copyVec(int src[${t}], out int dest[${t}]) {
|
|
1754
|
+
${r}
|
|
1755
|
+
}
|
|
1756
|
+
`;return{copyVec:new D(n)}}setVecItem(){let t=this.context.outputTextureLayout.shape.length,r=`
|
|
1757
|
+
if(index < 0)
|
|
1758
|
+
index =${t} + index;
|
|
1759
|
+
if (index == 0)
|
|
1760
|
+
m[0] = value;
|
|
1761
|
+
`;for(let s=1;s<t-1;++s)r+=`
|
|
1762
|
+
else if (index == ${s})
|
|
1763
|
+
m[${s}] = value;
|
|
1764
|
+
`;r+=`
|
|
1765
|
+
else
|
|
1766
|
+
m[${t-1}] = value;
|
|
1767
|
+
`;let n=`
|
|
1768
|
+
void setVecItem(out int m[${t}], int index, int value) {
|
|
1769
|
+
${r}
|
|
1770
|
+
}
|
|
1771
|
+
`;return{setVecItem:new D(n)}}getVecItem(){let t=this.context.outputTextureLayout.shape.length,r=`
|
|
1772
|
+
if(index < 0)
|
|
1773
|
+
index = ${t} + index;
|
|
1774
|
+
if (index == 0)
|
|
1775
|
+
return m[0];
|
|
1776
|
+
`;for(let s=1;s<t-1;++s)r+=`
|
|
1777
|
+
else if (index == ${s})
|
|
1778
|
+
return m[${s}];
|
|
1779
|
+
`;r+=`
|
|
1780
|
+
else
|
|
1781
|
+
return m[${t-1}];
|
|
1782
|
+
`;let n=`
|
|
1783
|
+
int getVecItem(int m[${t}], int index) {
|
|
1784
|
+
${r}
|
|
1785
|
+
}
|
|
1786
|
+
`;return{getVecItem:new D(n)}}}}),Fo,Mg=I(()=>{"use strict";Lg(),Rg(),jg(),Bg(),Vg(),Fo={encoding:zc,fragcolor:Uc,vec:Hc,shapeUtils:Gc,coordinates:Mc}}),qc,zg=I(()=>{"use strict";ne(),Ng(),Mg(),Y(),qc=class{constructor(t,r,n,s){this.libs={},this.glslLibRoutineDependencyGraph={},this.context=new Dl(t,r,n,s),Object.keys(Fo).forEach(l=>{let c=new Fo[l](this.context);this.libs[l]=c});let p=this.glslLibRoutineDependencyGraph;for(let l in this.libs){let c=this.libs[l].getFunctions();for(let o in c){let a=l+"."+o,e;p[a]?(e=p[a],e.routineBody=c[o].routineBody):(e=new wo(a,c[o].routineBody),p[a]=e);let u=c[o].dependencies;if(u)for(let i=0;i<u.length;++i)if(p[u[i]])e.addDependency(p[u[i]]);else{let d=new wo(u[i]);p[u[i]]=d,e.addDependency(d)}}}}preprocess(){let t=this.context.programInfo,r=t.shaderSource;return this.context.programInfo.hasMain||(r=`${r}
|
|
1787
|
+
${tf(this.context.glContext.version,this.context.outputTextureLayout.shape.length)}`),r=Dg(r),`${Qh(this.context.glContext.version)}
|
|
1788
|
+
${this.getUniforms(t.inputNames,t.variables)}
|
|
1789
|
+
${this.getImports(r)}
|
|
1790
|
+
${r}`}getImports(t){let r=this.selectGlslLibRoutinesToBeIncluded(t);if(r.length===0)return"";let n="";for(let s=0;s<r.length;++s)if(r[s].routineBody)n+=r[s].routineBody+`
|
|
1791
|
+
`;else throw new Error(`Missing body for the Glsl Library routine: ${r[s].name}`);return n}selectGlslLibRoutinesToBeIncluded(t){let r=[];return Object.keys(this.glslLibRoutineDependencyGraph).forEach(n=>{let s=n.split(".")[1];t.indexOf(s)!==-1&&r.push(this.glslLibRoutineDependencyGraph[n])}),Nl.returnOrderedNodes(r)}getUniforms(t,r){let n=[];if(t)for(let s of t)n.push(`uniform sampler2D ${s};`);if(r)for(let s of r)n.push(`uniform ${s.type} ${s.name}${s.arrayLength?`[${s.arrayLength}]`:""};`);return n.join(`
|
|
1792
|
+
`)}}}),Wc,Ug=I(()=>{"use strict";zt(),Rt(),zg(),Y(),Wc=class{constructor(t,r,n){this.profiler=t,this.glContext=r,this.textureLayoutStrategy=n,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,n){this.profiler.event("op",`ProgramManager.run ${t.programInfo.name??"unknown kernel"}`,()=>{let s=this.glContext.gl,p=t.program;s.useProgram(p);try{this.bindOutput(n),this.attributesBound||this.bindAttributes(t.attribLocations),this.bindUniforms(t.uniformLocations,t.programInfo.variables??[],r)}catch(l){throw tt.error("ProgramManager",t.programInfo.shaderSource),l}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,n){return this.profiler.event("backend","ProgramManager.build",()=>{let s=new qc(this.glContext,t,r,n),p=s.preprocess(),l=this.compile(p);return{programInfo:t,program:l,uniformLocations:this.getUniformLocations(l,s.context.programInfo.inputNames,s.context.programInfo.variables),attribLocations:this.getAttribLocations(l)}})}compile(t){if(!this.vertexShader){tt.verbose("ProrgramManager","Compiling and caching Vertex shader for the first time");let s=Yh(this.glContext.version);this.vertexShader=this.glContext.compileShader(s,this.glContext.gl.VERTEX_SHADER)}j.debug&&tt.verbose("ProrgramManager",`FragShader:
|
|
1793
|
+
${t}
|
|
1794
|
+
`);let r=this.glContext.compileShader(t,this.glContext.gl.FRAGMENT_SHADER),n=this.glContext.createProgram(this.vertexShader,r);return this.glContext.deleteShader(r),n}bindOutput(t){let r=t.width,n=t.height;tt.verbose("ProrgramManager",`Binding output texture to Framebuffer: w/h=${r}/${n}, shape=${t.shape}, type=${t.tensor.type}`),this.glContext.attachFramebuffer(t.texture,r,n)}bindAttributes(t){let r=t.position,n=t.textureCoord;this.glContext.setVertexAttributes(r,n),this.attributesBound=!0}bindUniforms(t,r,n){let s=this.glContext.gl,p=0;for(let{name:l,type:c,location:o,arrayLength:a}of t){let e=r.find(u=>u.name===l)?.data;if(c!=="sampler2D"&&!e)throw new Error(`variable '${l}' does not have data defined in program info`);switch(c){case"sampler2D":this.bindTexture(n[p],o,p),p++;break;case"float":a?s.uniform1fv(o,e):s.uniform1f(o,e);break;case"int":a?s.uniform1iv(o,e):s.uniform1i(o,e);break;default:throw new Error(`Uniform not implemented: ${c}`)}}}bindTexture(t,r,n){this.glContext.bindTextureToUniform(t.texture,n,r)}getAttribLocations(t){return{position:this.getAttribLocation(t,"position"),textureCoord:this.getAttribLocation(t,"textureCoord")}}getUniformLocations(t,r,n){let s=[];if(r)for(let p of r)s.push({name:p,type:"sampler2D",location:this.getUniformLocation(t,p)});if(n)for(let p of n)s.push({...p,location:this.getUniformLocation(t,p.name)});return s}getUniformLocation(t,r){let n=this.glContext.gl.getUniformLocation(t,r);if(n===null)throw new Error(`Uniform ${r} not found.`);return n}getAttribLocation(t,r){return this.glContext.gl.getAttribLocation(t,r)}}}),Xc,Gg=I(()=>{"use strict";Rt(),Hr(),Xc=class{constructor(t,r,n,s){this.glContext=t,this.layoutStrategy=r,this.profiler=n,this.config=s,this.pendingRead=new Map,s.reuseTextures&&(this.inUseTextures=new Map,this.idleTextures=new Map,this.textureLookup=new Map)}createTextureFromLayout(t,r,n,s){let p=this.toEncoderType(t),l=this.glContext.getEncoder(p,r.channels||1,s);if(r.isPacked&&s===1)throw new Error("not implemented");let c=r.width,o=r.height,a,e;if(this.config.reuseTextures){a=`${c}x${o}_${l.format}_${l.internalFormat}_${l.textureType}`,e=this.inUseTextures.get(a),e||(e=[],this.inUseTextures.set(a,e));let i=this.idleTextures.get(a);if(i&&i.length>0){let d=i.pop();return e.push(d),s===1&&this.glContext.updateTexture(d,c,o,l,this.toTextureData(t,n)),d}}tt.verbose("TextureManager",`Creating new texture of size ${r.width}x${r.height}`);let u=this.glContext.allocateTexture(c,o,l,this.toTextureData(t,n));return this.config.reuseTextures&&(e.push(u),this.textureLookup.set(u,a)),u}readTexture(t,r,n){return n||(n=1),this.profiler.event("backend","TextureManager.readTexture",()=>{let s=t.shape.reduce((l,c)=>l*c)*n,p=this.glContext.readTexture(t.texture,t.width,t.height,s,this.toEncoderType(r),n);return this.toTensorData(r,p)})}async readTextureAsync(t,r,n){let s=t.tensor.dataId;if(n||(n=1),this.pendingRead.has(s)){let p=this.pendingRead.get(s);return new Promise(l=>p?.push(l))}return this.profiler.event("backend","TextureManager.readTextureAsync",async()=>{this.pendingRead.set(s,[]);let p=t.shape.reduce((a,e)=>a*e)*n;await this.glContext.createAndWaitForFence();let l=this.glContext.readTexture(t.texture,t.width,t.height,p,this.toEncoderType(r),n),c=this.toTensorData(r,l),o=this.pendingRead.get(s);return this.pendingRead.delete(s),o?.forEach(a=>a(c)),c})}readUint8TextureAsFloat(t){return this.profiler.event("backend","TextureManager.readUint8TextureAsFloat",()=>{let r=t.shape.reduce((s,p)=>s*p),n=this.glContext.readTexture(t.texture,t.width,t.height,r*4,"byte",4);return new Float32Array(n.buffer,n.byteOffset,r)})}releaseTexture(t,r){let n;if(this.config.reuseTextures&&(n=this.textureLookup.get(t.texture),n)){r&&this.textureLookup.delete(n);let s=this.inUseTextures.get(n);if(s){let p=s.indexOf(t.texture);if(p!==-1){s.splice(p,1);let l=this.idleTextures.get(n);l||(l=[],this.idleTextures.set(n,l)),l.push(t.texture)}}}(!n||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()}}}),Kc,Hg=I(()=>{"use strict";Rt(),kh(),mf(),$g(),Ug(),Vc(),Gg(),Kc=class{constructor(t,r){this.backend=t,this.context=r,this.layoutStrategy=new Bc(t.glContext.maxTextureSize),this.programManager=new Wc(this.context.profiler,t.glContext,this.layoutStrategy),this.textureManager=new Xc(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 Pl(this)}onGraphInitialized(t){let r=t.getValues().filter(n=>n.from===-1&&n.tensor).map(n=>n.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,n=!1){tt.verbose("WebGLSessionHandler","Storing Texture data in cache"),n?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,n){let s=Dh(t,r,Rc);return{impl:s.opImpl,context:s.opInit?s.opInit(t,n):t}}}});function qg(t){let r=0;for(;r<t.length&&t[r]();++r);return r-1}var Co,Wg=I(()=>{"use strict";zt(),Hr(),Hr(),qt(),Co=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,n,s){let p=this.gl,l=p.createTexture();p.bindTexture(p.TEXTURE_2D,l),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MIN_FILTER,p.NEAREST),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MAG_FILTER,p.NEAREST),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_S,p.CLAMP_TO_EDGE),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_T,p.CLAMP_TO_EDGE);let c=s?n.encode(s,t*r):null;return p.texImage2D(p.TEXTURE_2D,0,n.internalFormat,t,r,0,n.format,n.textureType,c),this.checkError(),l}updateTexture(t,r,n,s,p){let l=this.gl;l.bindTexture(l.TEXTURE_2D,t);let c=s.encode(p,r*n);l.texSubImage2D(l.TEXTURE_2D,0,0,0,r,n,s.format,s.textureType,c),this.checkError()}attachFramebuffer(t,r,n){let s=this.gl;s.bindTexture(s.TEXTURE_2D,t),s.bindFramebuffer(s.FRAMEBUFFER,this.framebuffer),s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,t,0),this.checkError(),s.viewport(0,0,r,n),s.scissor(0,0,r,n)}readTexture(t,r,n,s,p,l){let c=this.gl;l||(l=1),this.frameBufferBound||this.attachFramebuffer(t,r,n);let o=this.getEncoder(p,l),a=o.allocate(r*n);return c.bindTexture(c.TEXTURE_2D,t),c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_2D,t,0),c.readPixels(0,0,r,n,c.RGBA,o.textureType,a),this.checkError(),o.decode(a,s)}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 n=this.gl;n.vertexAttribPointer(t,3,n.FLOAT,!1,20,0),n.enableVertexAttribArray(t),r!==-1&&(n.vertexAttribPointer(r,2,n.FLOAT,!1,20,12),n.enableVertexAttribArray(r)),this.checkError()}createProgram(t,r){let n=this.gl,s=n.createProgram();return n.attachShader(s,t),n.attachShader(s,r),n.linkProgram(s),s}compileShader(t,r){let n=this.gl,s=n.createShader(r);if(!s)throw new Error(`createShader() returned null with type ${r}`);if(n.shaderSource(s,t),n.compileShader(s),n.getShaderParameter(s,n.COMPILE_STATUS)===!1)throw new Error(`Failed to compile shader: ${n.getShaderInfoLog(s)}
|
|
1795
|
+
Shader source:
|
|
1796
|
+
${t}`);return s}deleteShader(t){this.gl.deleteShader(t)}bindTextureToUniform(t,r,n){let s=this.gl;s.activeTexture(s.TEXTURE0+r),this.checkError(),s.bindTexture(s.TEXTURE_2D,t),this.checkError(),s.uniform1i(n,r),this.checkError()}draw(){this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4),this.checkError()}checkError(){if(j.debug){let t=this.gl,r=t.getError(),n="";switch(r){case t.NO_ERROR:return;case t.INVALID_ENUM:n="INVALID_ENUM";break;case t.INVALID_VALUE:n="INVALID_VALUE";break;case t.INVALID_OPERATION:n="INVALID_OPERATION";break;case t.INVALID_FRAMEBUFFER_OPERATION:n="INVALID_FRAMEBUFFER_OPERATION";break;case t.OUT_OF_MEMORY:n="OUT_OF_MEMORY";break;case t.CONTEXT_LOST_WEBGL:n="CONTEXT_LOST_WEBGL";break;default:n=`Unknown WebGL Error: ${r.toString(16)}`}throw new Error(n)}}deleteTexture(t){this.gl.deleteTexture(t)}deleteProgram(t){this.gl.deleteProgram(t)}getEncoder(t,r,n=0){if(this.version===2)return new Ol(this.gl,r);switch(t){case"float":return n===1||this.isRenderFloat32Supported?new bo(this.gl,r):new bo(this.gl,r,this.textureHalfFloatExtension.HALF_FLOAT_OES);case"int":throw new Error("not implemented");case"byte":return new El(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 n=this.createDefaultGeometry();return t.bindBuffer(t.ARRAY_BUFFER,r),t.bufferData(t.ARRAY_BUFFER,n,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 n=this.version===2?t.RGBA32F:t.RGBA;t.texImage2D(t.TEXTURE_2D,0,n,1,1,0,t.RGBA,t.FLOAT,null);let s=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,s),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,r,0);let p=t.checkFramebufferStatus(t.FRAMEBUFFER)===t.FRAMEBUFFER_COMPLETE;return t.bindTexture(t.TEXTURE_2D,null),t.bindFramebuffer(t.FRAMEBUFFER,null),t.deleteTexture(r),t.deleteFramebuffer(s),p}checkRenderFloat32(){if(this.version===2){if(!this.colorBufferFloatExtension)return!1}else if(!this.textureFloatExtension)return!1;return this.isFloatTextureAttachableToFrameBuffer}checkFloat32Download(){if(this.version===2){if(!this.colorBufferFloatExtension)return!1}else if(!this.textureFloatExtension||!this.gl.getExtension("WEBGL_color_buffer_float"))return!1;return this.isFloatTextureAttachableToFrameBuffer}checkFloat32Blend(){let t=this.gl,r,n,s,p,l;try{r=t.createTexture(),n=t.createFramebuffer(),t.bindTexture(t.TEXTURE_2D,r);let c=this.version===2?t.RGBA32F:t.RGBA;return t.texImage2D(t.TEXTURE_2D,0,c,1,1,0,t.RGBA,t.FLOAT,null),t.bindFramebuffer(t.FRAMEBUFFER,n),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,r,0),t.enable(t.BLEND),s=t.createShader(t.VERTEX_SHADER),!s||(t.shaderSource(s,"void main(){}"),t.compileShader(s),p=t.createShader(t.FRAGMENT_SHADER),!p)||(t.shaderSource(p,"precision highp float;void main(){gl_FragColor=vec4(0.5);}"),t.compileShader(p),l=t.createProgram(),!l)?!1:(t.attachShader(l,s),t.attachShader(l,p),t.linkProgram(l),t.useProgram(l),t.drawArrays(t.POINTS,0,1),t.getError()===t.NO_ERROR)}finally{t.disable(t.BLEND),l&&t.deleteProgram(l),s&&t.deleteShader(s),p&&t.deleteShader(p),n&&(t.bindFramebuffer(t.FRAMEBUFFER,null),t.deleteFramebuffer(n)),r&&(t.bindTexture(t.TEXTURE_2D,null),t.deleteTexture(r))}}beginTimer(){if(this.version===2&&this.disjointTimerQueryWebgl2Extension){let t=this.gl,r=this.disjointTimerQueryWebgl2Extension,n=t.createQuery();return t.beginQuery(r.TIME_ELAPSED_EXT,n),n}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,n=!1;if(this.version===2&&this.disjointTimerQueryWebgl2Extension){let s=this.gl,p=this.disjointTimerQueryWebgl2Extension;r=s.getQueryParameter(t,s.QUERY_RESULT_AVAILABLE),n=s.getParameter(p.GPU_DISJOINT_EXT)}else throw new Error("WebGL1 profiling currently not supported");return r&&!n}getTimerResult(t){let r=0;if(this.version===2){let n=this.gl;r=n.getQueryParameter(t,n.QUERY_RESULT),n.deleteQuery(t)}else throw new Error("WebGL1 profiling currently not supported");return r/1e6}async waitForQueryAndGetTime(t){return await Ta(()=>this.isTimerResultAvailable(t)),this.getTimerResult(t)}async createAndWaitForFence(){let t=this.createFence(this.gl);return this.pollFence(t)}createFence(t){let r,n=t,s=n.fenceSync(n.SYNC_GPU_COMMANDS_COMPLETE,0);return t.flush(),s===null?r=()=>!0:r=()=>{let p=n.clientWaitSync(s,0,0);return p===n.ALREADY_SIGNALED||p===n.CONDITION_SATISFIED},{query:s,isFencePassed:r}}async pollFence(t){return new Promise(r=>{this.addItemToPoll(()=>t.isFencePassed(),()=>r())})}pollItems(){let t=qg(this.itemsToPoll.map(r=>r.isDoneFn));for(let r=0;r<=t;++r){let{resolveFn:n}=this.itemsToPoll[r];n()}this.itemsToPoll=this.itemsToPoll.slice(t+1)}async addItemToPoll(t,r){this.itemsToPoll.push({isDoneFn:t,resolveFn:r}),!(this.itemsToPoll.length>1)&&await Ta(()=>(this.pollItems(),this.itemsToPoll.length===0))}}});function Zc(t){let r;if((!t||t==="webgl2")&&"webgl2"in ge?r=ge.webgl2:(!t||t==="webgl")&&"webgl"in ge&&(r=ge.webgl),!r)try{let s=Kg();r=Ou(s,t)}catch{let s=Xg();r=Ou(s,t)}t=t||r.version===1?"webgl":"webgl2";let n=r.gl;return ge[t]=r,n.isContextLost()?(delete ge[t],Zc(t)):(n.disable(n.DEPTH_TEST),n.disable(n.STENCIL_TEST),n.disable(n.BLEND),n.disable(n.DITHER),n.disable(n.POLYGON_OFFSET_FILL),n.disable(n.SAMPLE_COVERAGE),n.enable(n.SCISSOR_TEST),n.enable(n.CULL_FACE),n.cullFace(n.BACK),r)}function Ou(t,r){let n={alpha:!1,depth:!1,antialias:!1,stencil:!1,preserveDrawingBuffer:!1,premultipliedAlpha:!1,failIfMajorPerformanceCaveat:!1},s,p=n;if((!r||r==="webgl2")&&(s=t.getContext("webgl2",p),s))try{return new Co(s,2)}catch(l){tt.warning("GlContextFactory",`failed to create WebGLContext using contextId 'webgl2'. Error: ${l}`)}if((!r||r==="webgl")&&(s=t.getContext("webgl",p)||t.getContext("experimental-webgl",p),s))try{return new Co(s,1)}catch(l){tt.warning("GlContextFactory",`failed to create WebGLContext using contextId 'webgl' or 'experimental-webgl'. Error: ${l}`)}throw new Error("WebGL is not supported")}function Xg(){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 Kg(){if(typeof OffscreenCanvas>"u")throw new TypeError("failed to create offscreen canvas: OffscreenCanvas is not supported");return new OffscreenCanvas(1,1)}var ge,Zg=I(()=>{"use strict";Rt(),Wg(),ge={}}),Jc,Jg=I(()=>{"use strict";zt(),Rt(),Hg(),Zg(),Jc=class{get contextId(){return j.webgl.contextId}set contextId(t){j.webgl.contextId=t}get matmulMaxBatchSize(){return j.webgl.matmulMaxBatchSize}set matmulMaxBatchSize(t){j.webgl.matmulMaxBatchSize=t}get textureCacheMode(){return j.webgl.textureCacheMode}set textureCacheMode(t){j.webgl.textureCacheMode=t}get pack(){return j.webgl.pack}set pack(t){j.webgl.pack=t}get async(){return j.webgl.async}set async(t){j.webgl.async=t}initialize(){try{return this.glContext=Zc(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(j),j.webgl.context||Object.defineProperty(j.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 Kc(this,t)}dispose(){this.glContext.dispose()}}});async function Yc(t){if(t){let r=typeof t=="string"?[t]:t;for(let n of r){let s=Yo.get(n);if(s)return s;let p=await Yg(n);if(p)return p}}else return Yc(["webgl"]);throw new Error("no available backend to use")}async function Yg(t){let r=Qc;if(typeof r[t]<"u"&&Qg(r[t])){let n=r[t],s=n.initialize();if(typeof s=="object"&&"then"in s&&(s=await s),s)return Yo.set(t,n),n}}function Qg(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 Yo,Qc,tm=I(()=>{"use strict";Jg(),Yo=new Map,Qc={webgl:new Jc}}),Eu,td,em=I(()=>{"use strict";Rt(),Eu=class{constructor(t,r){this.op=t,this.node=r}},td=class{constructor(t,r,n){this.graph=t,this.profiler=n,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((n,s)=>new Eu(n,r[s])),this.reset(),this._starter=[],this._ops.forEach((n,s)=>{let p=!0;for(let l of n.node.inputs)if(!this._values[l]&&this.graph.getInputIndices().indexOf(l)===-1){p=!1;break}p&&this._starter.push(s)})})}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 n=t.createInferenceHandler(),s=this.graph.getInputIndices();if(r.length!==s.length)throw new Error(`number of input tensors don't match the number of inputs to the model: actual: ${r.length} expected: ${s.length}`);r.forEach((e,u)=>{let i=s[u];this._values[i]=e});let p=this._starter.slice(0),l=this.graph.getValues(),c=this.graph.getNodes(),o=0;for(;o<p.length;){let e=p[o++],u=this._ops[e],i=u.node.inputs.map(b=>this._values[b]);if(i.indexOf(void 0)!==-1)throw new Error(`unresolved input detected: op: ${u.node}`);let d=i;tt.verbose("ExecPlan",`Running op:${u.node.name} (${d.map((b,x)=>`'${u.node.inputs[x]}': ${b.type}[${b.dims.join(",")}]`).join(", ")})`);let h=await this.profiler.event("node",u.node.name,async()=>u.op.impl(n,d,u.op.context));if(h.length!==u.node.outputs.length)throw new Error("the size of output does not match model definition.");h.forEach((b,x)=>{let E=u.node.outputs[x];if(this._values[E])throw new Error(`output [${E}] already has value: op:${u.node.name}`);this._values[E]=b});let m=new Set;h.forEach((b,x)=>{let E=u.node.outputs[x];for(let w of l[E].to){let S=c[w],$=!0;for(let F of S.inputs)if(!this._values[F]){$=!1;break}$&&m.add(w)}}),p.push(...m)}let a=[];for(let e=0;e<this.graph.getOutputIndices().length;e++){let u=this.graph.getOutputIndices()[e],i=this._values[u];if(i===void 0)throw new Error(`required output [${u}] does not have value`);u===0?await i.getData():i.data,a.push(i)}return tt.verbose("ExecPlan","disposing of inferenceHandler"),n.dispose(),a})}}}),R,Ot,Lo,rm=I(()=>{"use strict";Zr(),R=Ie(mr()),De(),U(),Ot=H.experimental.fbs,Lo=class or{constructor(r){if(this._attributes=new Map,r!=null){for(let n of r)n instanceof R.onnx.AttributeProto?this._attributes.set(n.name,[or.getValue(n),or.getType(n)]):n instanceof Ot.Attribute&&this._attributes.set(n.name(),[or.getValue(n),or.getType(n)]);if(this._attributes.size<r.length)throw new Error("duplicated attribute names")}}set(r,n,s){this._attributes.set(r,[s,n])}delete(r){this._attributes.delete(r)}getFloat(r,n){return this.get(r,"float",n)}getInt(r,n){return this.get(r,"int",n)}getString(r,n){return this.get(r,"string",n)}getTensor(r,n){return this.get(r,"tensor",n)}getFloats(r,n){return this.get(r,"floats",n)}getInts(r,n){return this.get(r,"ints",n)}getStrings(r,n){return this.get(r,"strings",n)}getTensors(r,n){return this.get(r,"tensors",n)}get(r,n,s){let p=this._attributes.get(r);if(p===void 0){if(s!==void 0)return s;throw new Error(`required attribute not found: ${r}`)}if(p[1]!==n)throw new Error(`type mismatch: expected ${n} but got ${p[1]}`);return p[0]}static getType(r){let n=r instanceof R.onnx.AttributeProto?r.type:r.type();switch(n){case R.onnx.AttributeProto.AttributeType.FLOAT:return"float";case R.onnx.AttributeProto.AttributeType.INT:return"int";case R.onnx.AttributeProto.AttributeType.STRING:return"string";case R.onnx.AttributeProto.AttributeType.TENSOR:return"tensor";case R.onnx.AttributeProto.AttributeType.FLOATS:return"floats";case R.onnx.AttributeProto.AttributeType.INTS:return"ints";case R.onnx.AttributeProto.AttributeType.STRINGS:return"strings";case R.onnx.AttributeProto.AttributeType.TENSORS:return"tensors";default:throw new Error(`attribute type is not supported yet: ${R.onnx.AttributeProto.AttributeType[n]}`)}}static getValue(r){let n=r instanceof R.onnx.AttributeProto?r.type:r.type();if(n===R.onnx.AttributeProto.AttributeType.GRAPH||n===R.onnx.AttributeProto.AttributeType.GRAPHS)throw new Error("graph attribute is not supported yet");let s=this.getValueNoCheck(r);if(n===R.onnx.AttributeProto.AttributeType.INT&&Vt.isLong(s))return Vt.longToNumber(s);if(n===R.onnx.AttributeProto.AttributeType.INTS){let p=s,l=new Array(p.length);for(let c=0;c<p.length;c++){let o=p[c];l[c]=Vt.longToNumber(o)}return l}if(n===R.onnx.AttributeProto.AttributeType.TENSOR)return r instanceof R.onnx.AttributeProto?Pt.fromProto(s):Pt.fromOrtTensor(s);if(n===R.onnx.AttributeProto.AttributeType.TENSORS){if(r instanceof R.onnx.AttributeProto)return s.map(p=>Pt.fromProto(p));if(r instanceof Ot.Attribute)return s.map(p=>Pt.fromOrtTensor(p))}return n===R.onnx.AttributeProto.AttributeType.STRING&&r instanceof R.onnx.AttributeProto?co(s):n===R.onnx.AttributeProto.AttributeType.STRINGS&&r instanceof R.onnx.AttributeProto?s.map(co):s}static getValueNoCheck(r){return r instanceof R.onnx.AttributeProto?this.getValueNoCheckFromOnnxFormat(r):this.getValueNoCheckFromOrtFormat(r)}static getValueNoCheckFromOnnxFormat(r){switch(r.type){case R.onnx.AttributeProto.AttributeType.FLOAT:return r.f;case R.onnx.AttributeProto.AttributeType.INT:return r.i;case R.onnx.AttributeProto.AttributeType.STRING:return r.s;case R.onnx.AttributeProto.AttributeType.TENSOR:return r.t;case R.onnx.AttributeProto.AttributeType.GRAPH:return r.g;case R.onnx.AttributeProto.AttributeType.FLOATS:return r.floats;case R.onnx.AttributeProto.AttributeType.INTS:return r.ints;case R.onnx.AttributeProto.AttributeType.STRINGS:return r.strings;case R.onnx.AttributeProto.AttributeType.TENSORS:return r.tensors;case R.onnx.AttributeProto.AttributeType.GRAPHS:return r.graphs;default:throw new Error(`unsupported attribute type: ${R.onnx.AttributeProto.AttributeType[r.type]}`)}}static getValueNoCheckFromOrtFormat(r){switch(r.type()){case Ot.AttributeType.FLOAT:return r.f();case Ot.AttributeType.INT:return r.i();case Ot.AttributeType.STRING:return r.s();case Ot.AttributeType.TENSOR:return r.t();case Ot.AttributeType.GRAPH:return r.g();case Ot.AttributeType.FLOATS:return r.floatsArray();case Ot.AttributeType.INTS:{let n=[];for(let s=0;s<r.intsLength();s++)n.push(r.ints(s));return n}case Ot.AttributeType.STRINGS:{let n=[];for(let s=0;s<r.stringsLength();s++)n.push(r.strings(s));return n}case Ot.AttributeType.TENSORS:{let n=[];for(let s=0;s<r.tensorsLength();s++)n.push(r.tensors(s));return n}default:throw new Error(`unsupported attribute type: ${Ot.AttributeType[r.type()]}`)}}}}),Hn,Xe,Ro,Ht,qn,Iu,nm=I(()=>{"use strict";rm(),Zr(),Hn=Ie(mr()),De(),U(),Xe=H.experimental.fbs,Ro={from:(t,r)=>new Iu(t,r)},Ht=class{constructor(t){this._from=void 0,this._to=[],this.tensor=void 0,this.type=void 0,t&&(this.type=Et.tensorValueTypeFromProto(t.type.tensorType))}get from(){return this._from}get to(){return this._to}},qn=class{constructor(t,r){t instanceof Hn.onnx.NodeProto?(this.name=t.name,this.opType=t.opType,this.attributes=new Lo(t.attribute)):t instanceof Xe.Node&&(this.name=r??t.name(),this.opType=t.opType(),this.attributes=new Lo(Et.tensorAttributesFromORTFormat(t))),this.inputs=[],this.outputs=[],this.executeNode=!0}},Iu=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 Hn.onnx.GraphProto)this.buildGraphFromOnnxFormat(t);else if(t instanceof Xe.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 n=new Map;if(!t.input)throw new Error("missing information in graph: input");let s=[];for(let p of t.input){if(r.has(p.name))throw new Error(`duplicated input name: ${p.name}`);let l=this._allData.push(new Ht(p))-1;r.set(p.name,l),s.push(p.name)}if(!t.initializer)throw new Error("missing information in graph: initializer");for(let p of t.initializer){let l=r.get(p.name);if(l===void 0){let c=new Ht;c.type={shape:{dims:Et.tensorDimsFromProto(p.dims)},tensorType:Et.tensorDataTypeFromProto(p.dataType)},l=this._allData.push(c)-1,r.set(p.name,l)}this._allData[l]._from=-1,this._allData[l].tensor=Pt.fromProto(p)}for(let p=0;p<this._allData.length;p++)this._allData[p].tensor||(this._allInputIndices.push(p),this._allInputNames.push(s[p]));if(!t.output)throw new Error("missing information in graph: output");for(let p of t.output){if(r.has(p.name))throw new Error(`duplicated output name: ${p.name}`);let l=this._allData.push(new Ht(p))-1;r.set(p.name,l),this._allOutputIndices.push(l),this._allOutputNames.push(p.name)}if(!t.node)throw new Error("missing information in graph: node");for(let p of t.node){if(!p.name)for(let c=0;;c++){let o=`unnamed_${p.opType}_${c}`;if(!n.has(o)){p.name=o;break}}if(n.has(p.name))throw new Error(`duplicated node name: ${p.name}`);let l=this._nodes.push(new qn(p))-1;n.set(p.name,l)}for(let p=0;p<this._nodes.length;p++){let l=this._nodes[p],c=t.node[p];if(!c.output)throw new Error(`missing output for node: ${c.name}`);for(let o of c.output){let a=r.get(o);if(typeof a>"u"&&(a=this._allData.push(new Ht)-1,r.set(o,a)),l.outputs.push(a),this._allData[a]._from!==void 0)throw new Error(`multiple nodes output to one data value: ${a}`);if(this._allData[a]._from=p,c.opType==="Constant"){if(!c.attribute||c.attribute.length!==1||!c.attribute[0].t)throw new Error("missing attributes or missing tensor value in attributes for this Constant operator");if(!c.output||c.output.length!==1)throw new Error("missing output or incorrect number of outputs for this Constant operator");l.outputs.pop(),l.executeNode=!1,this._allData[a]._from=-1,this._allData[a].tensor=Pt.fromProto(c.attribute[0].t)}}}for(let p=0;p<this._nodes.length;p++){let l=this._nodes[p],c=t.node[p];if(!c.input)throw new Error(`missing input for node: ${c.name}`);for(let o of c.input){let a=r.get(o);if(typeof a>"u"){if(o===""&&(c.input.length===3||c.input.length===4)&&c.opType==="Resize")continue;throw new Error(`unrecognized input '${o}' for node: ${c.name}`)}l.inputs.push(a),this._allData[a]._to.push(p)}}return!0}buildGraphFromOrtFormat(t){let r=new Map;this._allData=[],this._allInputIndices=[],this._allInputNames=[],this._allOutputIndices=[],this._allOutputNames=[],this._nodes=[];let n=new Map,s=[];for(let p=0;p<t.inputsLength();p++){let l=t.inputs(p);if(r.has(l))throw new Error(`duplicated input name: ${l}`);for(let c=0;c<t.nodeArgsLength();c++)if(t.nodeArgs(c)?.name()===l){let o=new Ht;if(t.nodeArgs(c)?.type()?.valueType()!==Xe.TypeInfoValue.tensor_type)throw new Error("Unexpected value type for the nodeArg.");let a=t.nodeArgs(c).type().value(new Xe.TensorTypeAndShape),e=Et.tensorDataTypeFromProto(a.elemType()),u=a.shape(),i=[];for(let h=0;h<u.dimLength();h++)i.push(Vt.longToNumber(u.dim(h).value().dimValue()));o.type={shape:{dims:i},tensorType:e};let d=this._allData.push(o)-1;r.set(l,d),s.push(l)}}for(let p=0;p<t.initializersLength();p++){let l=t.initializers(p),c=r.get(l.name());if(c===void 0){let o=new Ht,a=Et.tensorDimsFromORTFormat(l),e=Et.tensorDataTypeFromProto(l.dataType());o.type={shape:{dims:a},tensorType:e},c=this._allData.push(o)-1,r.set(l.name(),c)}this._allData[c]._from=-1,this._allData[c].tensor=Pt.fromOrtTensor(l)}for(let p=0;p<this._allData.length;p++)this._allData[p].tensor||(this._allInputIndices.push(p),this._allInputNames.push(s[p]));for(let p=0;p<t.outputsLength();p++){let l=t.outputs(p);if(r.has(l))throw new Error(`duplicated output name: ${l}`);let c=this._allData.push(new Ht)-1;r.set(l,c),this._allOutputIndices.push(c),this._allOutputNames.push(l)}if(!t.nodes)throw new Error("missing information in graph: node");for(let p=0;p<t.nodesLength();p++){let l=t.nodes(p),c=l.name();if(!c)for(let a=0;c=`unnamed_${l.opType()}_${a}`,!!n.has(c);a++);if(n.has(c))throw new Error(`duplicated node name: ${c}`);let o=this._nodes.push(new qn(l,c))-1;n.set(c,o)}for(let p=0;p<this._nodes.length;p++){let l=this._nodes[p],c=t.nodes(p);if(c==null)throw new Error(`No node exists at index ${p}`);if(c?.outputsLength()===0)throw new Error(`missing output for node: ${c.name}`);for(let o=0;o<c?.outputsLength();o++){let a=c?.outputs(o),e=r.get(a);if(typeof e>"u"&&(e=this._allData.push(new Ht)-1,r.set(a,e)),l.outputs.push(e),this._allData[e]._from!==void 0)throw new Error(`multiple nodes output to one data value: ${e}`);if(this._allData[e]._from=p,c.opType()==="Constant"){if(c.attributesLength()!==1||!c.attributes(0).t())throw new Error("missing attributes or missing tensor value in attributes for this Constant operator");if(c.outputsLength()!==1)throw new Error("missing output or incorrect number of outputs for this Constant operator");l.outputs.pop(),l.executeNode=!1,this._allData[e]._from=-1,this._allData[e].tensor=Pt.fromOrtTensor(c.attributes(0).t())}}}for(let p=0;p<this._nodes.length;p++){let l=this._nodes[p],c=t.nodes(p);if(c.inputsLength()===0)throw new Error(`missing input for node: ${c.name}`);for(let o=0;o<c.inputsLength();o++){let a=c.inputs(o),e=r.get(a);if(typeof e>"u")throw new Error(`unrecognized input '${a}' for node: ${c.name()}`);l.inputs.push(e),this._allData[e]._to.push(p)}}}checkIsAcyclic(){let t=new Set;this._allInputIndices.forEach(s=>{this._allData[s]._to.forEach(p=>{t.add(p)})});let r=Array.from(t),n=new Array(this._nodes.length).fill("white");for(;r.length>0;){let s=r.pop();n[s]==="gray"?n[s]="black":(r.push(s),n[s]="gray",this._nodes[s].outputs.forEach(p=>{let l=this._allData[p];if(typeof l.tensor<"u")throw new Error("node outputs should not be initialized");if(l._from!==s)throw new Error("from property of the Value object doesn't match index of Node being processed");l._to.forEach(c=>{if(n[c]==="gray")throw new Error("model graph is cyclic");n[c]==="white"&&r.push(c)})}))}}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),n=0;for(let s=0;s<this._nodes.length;s++)r[s]=n,this._nodes[s].executeNode?(n!==s&&(this._nodes[n]=this._nodes[s]),n++):this._nodes[s].outputs.forEach(p=>{this._allData[p]._from=-2});this._nodes.splice(n,this._nodes.length-n);for(let s=0;s<this._allData.length;s++){let p=this._allData[s];p._from!==void 0&&p._from!==-1&&p._from!==-2&&(p._from=r[p._from]);for(let l=0;l<p._to.length;l++)if(p._to[l]>=0)p._to[l]=r[p._to[l]];else throw new Error("Trying to update a removed node")}t=0;for(let s=0;s<this._allData.length;s++){if(this._allData[s].from===-2&&this._allOutputIndices.indexOf(s+t)===-1){t++,this._allData.splice(s,1),s--;continue}if(t>0){let p=-1;this._allData[s].from!==void 0&&this._allData[s].from!==-1?(p=this._nodes[this._allData[s].from].outputs.indexOf(s+t),p!==-1&&(this._nodes[this._allData[s].from].outputs[p]=s)):(p=this._allInputIndices.indexOf(s+t),p!==-1&&(this._allInputIndices[p]=s)),this._allData[s].to.forEach(l=>{p=this._nodes[l].inputs.indexOf(s+t),p!==-1&&(this._nodes[l].inputs[p]=s)}),this._allData[s].to.length===0&&(p=this._allOutputIndices.indexOf(s+t),p!==-1&&(this._allOutputIndices[p]=s))}}}deleteNode(t){let r=this._nodes[t];if(r.outputs.length>1){for(let c=1;c<r.outputs.length;c++)if(this._allData[r.outputs[c]].to.length>0)throw new Error("Node deletion with more than one output connected to other nodes is not supported. ")}r.executeNode=!1;let n=r.inputs[0],s=r.outputs[0],p=this._allData[s].to;for(let c=0;c<r.inputs.length;c++){let o=this._allData[r.inputs[c]].to.indexOf(t);if(o===-1)throw new Error("The Value object doesn't have the current Node in it's 'to' property ");this._allData[r.inputs[c]].to.splice(o,1)}this._allData[s]._to=[];let l=this._allOutputIndices.indexOf(s);if(l!==-1&&(this._allOutputIndices[l]=n),p&&p.length>0)for(let c of p){let o=this._nodes[c].inputs.indexOf(s);if(o===-1)throw new Error("The Node object doesn't have the output Value in it's 'inputs' property ");this._nodes[c].inputs[o]=n,this._allData[n].to.push(c)}}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 n=this._nodes[r[0]];if(n.opType==="Clip")if(n.inputs.length===1)try{t.attributes.set("activation_params","floats",[n.attributes.getFloat("min"),n.attributes.getFloat("max")])}catch{t.attributes.set("activation_params","floats",[dr,hr])}else if(n.inputs.length>=3&&this._allData[n.inputs[1]].tensor!==void 0&&this._allData[n.inputs[2]].tensor!==void 0)t.attributes.set("activation_params","floats",[this._allData[n.inputs[1]].tensor.floatData[0],this._allData[n.inputs[2]].tensor.floatData[0]]);else continue;t.attributes.set("activation","string",n.opType),this.deleteNode(r[0])}}}}}),Pu,Au,ed,om=I(()=>{"use strict";Ho(),nm(),Zr(),Pu=Ie(mr()),U(),Au=H.experimental.fbs,ed=class{constructor(){}load(t,r,n){let s;if(!n)try{this.loadFromOnnxFormat(t,r);return}catch(p){if(n!==void 0)throw p;s=p}try{this.loadFromOrtFormat(t,r)}catch(p){throw n!==void 0?p:new Error(`Failed to load model as ONNX format: ${s}
|
|
1797
|
+
as ORT format: ${p}`)}}loadFromOnnxFormat(t,r){let n=Pu.onnx.ModelProto.decode(t);if(Vt.longToNumber(n.irVersion)<3)throw new Error("only support ONNX model with IR_VERSION>=3");this._opsets=n.opsetImport.map(s=>({domain:s.domain,version:Vt.longToNumber(s.version)})),this._graph=Ro.from(n.graph,r)}loadFromOrtFormat(t,r){let n=new T.ByteBuffer(t),s=Au.InferenceSession.getRootAsInferenceSession(n).model();if(Vt.longToNumber(s.irVersion())<3)throw new Error("only support ONNX model with IR_VERSION>=3");this._opsets=[];for(let p=0;p<s.opsetImportLength();p++){let l=s.opsetImport(p);this._opsets.push({domain:l?.domain(),version:Vt.longToNumber(l.version())})}this._graph=Ro.from(s.graph(),r)}get graph(){return this._graph}get opsets(){return this._opsets}}}),rd,im=I(()=>{"use strict";tm(),em(),Rt(),om(),rd=class{constructor(t={}){this._initialized=!1,this.backendHint=t.backendHint,this.profiler=hl.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,n){await this.profiler.event("session","Session.loadModel",async()=>{let s=await Yc(this.backendHint);if(this.sessionHandler=s.createSessionHandler(this.context),this._model=new ed,typeof t=="string"){let p=t.endsWith(".ort");{let l=await(await fetch(t)).arrayBuffer();this.initialize(new Uint8Array(l),p)}}else if(ArrayBuffer.isView(t))this.initialize(t);else{let p=new Uint8Array(t,r||0,n||t.byteLength);this.initialize(p)}})}initialize(t,r){if(this._initialized)throw new Error("already initialized");this.profiler.event("session","Session.initialize",()=>{let n=this.sessionHandler.transformGraph?this.sessionHandler:void 0;this._model.load(t,n,r),this.sessionHandler.onGraphInitialized&&this.sessionHandler.onGraphInitialized(this._model.graph),this.initializeOps(this._model.graph),this._executionPlan=new td(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),n=await this._executionPlan.execute(this.sessionHandler,r);return this.createOutput(n)})}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 n=new Array(t.size),s=0;for(let p=0;p<r.length;++p){let l=t.get(r[p]);if(!l)throw new Error(`missing input tensor for: '${name}'`);n[s++]=l}t=n}if(!this.context.graphInputTypes||this.context.graphInputTypes.length===0||!this.context.graphInputDims||this.context.graphInputDims.length===0){let n=this._model.graph.getInputIndices(),s=this._model.graph.getValues(),p=new Array(n.length);for(let l=0;l<n.length;++l){let c=s[n[l]];p[l]=c.type.shape.dims,this.context.graphInputTypes.push(c.type.tensorType),this.context.graphInputDims.push(t[l].dims)}this.validateInputTensorDims(p,t,!0)}else this.validateInputTensorDims(this.context.graphInputDims,t,!1);return this.validateInputTensorTypes(this.context.graphInputTypes,t),t}validateInputTensorTypes(t,r){for(let n=0;n<r.length;n++){let s=t[n],p=r[n].type;if(s!==p)throw new Error(`input tensor[${n}] check failed: expected type '${s}' but got ${p}`)}}validateInputTensorDims(t,r,n){for(let s=0;s<r.length;s++){let p=t[s],l=r[s].dims;if(!this.compareTensorDims(p,l,n))throw new Error(`input tensor[${s}] check failed: expected shape '[${p.join(",")}]' but got [${l.join(",")}]`)}}compareTensorDims(t,r,n){if(t.length!==r.length)return!1;for(let s=0;s<t.length;++s)if(t[s]!==r[s]&&(!n||t[s]!==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 n=new Map;for(let s=0;s<r.length;++s)n.set(r[s],t[s]);return n}initializeOps(t){let r=t.getNodes();this._ops=new Array(r.length);for(let n=0;n<r.length;n++)this._ops[n]=this.sessionHandler.resolve(r[n],this._model.opsets,t)}}}),nd,am=I(()=>{"use strict";zt(),De(),nd=class{constructor(t){this.session=t,this.inputNames=this.session.inputNames,this.outputNames=this.session.outputNames}async dispose(){}async run(t,r,n){let s=new Map;for(let c in t)if(Object.hasOwnProperty.call(t,c)){let o=t[c];s.set(c,new Pt(o.dims,o.type,void 0,void 0,o.data))}let p=await this.session.run(s),l={};return p.forEach((c,o)=>{l[o]=new ft(c.type,c.data,c.dims)}),l}startProfiling(){this.session.startProfiling()}endProfiling(){this.session.endProfiling()}}}),od={};gr(od,{onnxjsBackend:()=>id});var $u,id,sm=I(()=>{"use strict";im(),am(),$u=class{async init(){}async createInferenceSessionHandler(t,r){let n=new rd(r);return typeof t=="string"?await n.loadModel(t):await n.loadModel(t),new nd(n)}},id=new $u}),Qo=I(()=>{"use strict"}),ad={};gr(ad,{default:()=>sd});var Wn,Xn,sd,um=I(()=>{"use strict";vd(),Ce(),Qr(),Wn="ort-wasm-proxy-worker",Xn=globalThis.self?.name===Wn,Xn&&(self.onmessage=t=>{let{type:r,in:n}=t.data;try{switch(r){case"init-wasm":ti(n.wasm).then(()=>{ii(n).then(()=>{postMessage({type:r})},s=>{postMessage({type:r,err:s})})},s=>{postMessage({type:r,err:s})});break;case"init-ep":{let{epName:s,env:p}=n;ai(p,s).then(()=>{postMessage({type:r})},l=>{postMessage({type:r,err:l})});break}case"copy-from":{let{buffer:s}=n,p=Xr(s);postMessage({type:r,out:p});break}case"create":{let{model:s,options:p}=n;si(s,p).then(l=>{postMessage({type:r,out:l})},l=>{postMessage({type:r,err:l})});break}case"release":ui(n),postMessage({type:r});break;case"run":{let{sessionId:s,inputIndices:p,inputs:l,outputIndices:c,options:o}=n;li(s,p,l,c,new Array(c.length).fill(null),o).then(a=>{a.some(e=>e[3]!=="cpu")?postMessage({type:r,err:"Proxy does not support non-cpu tensor location."}):postMessage({type:r,out:a},ci([...l,...a]))},a=>{postMessage({type:r,err:a})});break}case"end-profiling":pi(n),postMessage({type:r});break;default:}}catch(s){postMessage({type:r,err:s})}}),sd=Xn?null:t=>new Worker(t??Oe,{type:"module",name:Wn})}),ud={};gr(ud,{default:()=>ld});var Kn,Zn,ld,lm=I(()=>{"use strict";Zn=(Kn=import.meta.url,async function(t={}){function r(){return yt.buffer!=wt.buffer&&it(),wt}function n(){return yt.buffer!=wt.buffer&&it(),G}function s(){return yt.buffer!=wt.buffer&&it(),Wt}function p(){return yt.buffer!=wt.buffer&&it(),Tr}function l(){return yt.buffer!=wt.buffer&&it(),ve}var c,o,a=Object.assign({},t),e=new Promise((f,g)=>{c=f,o=g}),u=typeof window=="object",i=typeof importScripts=="function",d=i&&self.name=="em-pthread";a.mountExternalData=(f,g)=>{f.startsWith("./")&&(f=f.substring(2)),(a.Ua||(a.Ua=new Map)).set(f,g)},a.unmountExternalData=()=>{delete a.Ua};var h,m,b=globalThis.SharedArrayBuffer??new WebAssembly.Memory({initial:0,maximum:0,shared:!0}).buffer.constructor,x=Object.assign({},a),E="./this.program",w=(f,g)=>{throw g},S="";(u||i)&&(i?S=self.location.href:typeof document<"u"&&document.currentScript&&(S=document.currentScript.src),Kn&&(S=Kn),S=S.startsWith("blob:")?"":S.substr(0,S.replace(/[?#].*/,"").lastIndexOf("/")+1),i&&(m=f=>{var g=new XMLHttpRequest;return g.open("GET",f,!1),g.responseType="arraybuffer",g.send(null),new Uint8Array(g.response)}),h=(f,g,y)=>{var v=new XMLHttpRequest;v.open("GET",f,!0),v.responseType="arraybuffer",v.onload=()=>{v.status==200||v.status==0&&v.response?g(v.response):y()},v.onerror=y,v.send(null)});var $,F=console.log.bind(console),bt=console.error.bind(console),pt=F,Z=bt;if(Object.assign(a,x),x=null,d){let f=function(g){try{var y=g.data,v=y.cmd;if(v==="load"){let _=[];self.onmessage=P=>_.push(P),self.startWorker=()=>{postMessage({cmd:"loaded"});for(let P of _)f(P);self.onmessage=f};for(let P of y.handlers)a[P]&&!a[P].proxy||(a[P]=(...N)=>{postMessage({Za:"callHandler",kb:P,args:N})},P=="print"&&(pt=a[P]),P=="printErr"&&(Z=a[P]));yt=y.wasmMemory,it(),At(y.wasmModule)}else if(v==="run"){pn(y.pthread_ptr,0,0,1,0,0),on(y.pthread_ptr),kd(),wi(),vr||(vr=!0);try{Fd(y.start_routine,y.arg)}catch(_){if(_!="unwind")throw _}}else v==="cancel"?_e()&&$r(-1):y.target!=="setimmediate"&&(v==="checkMailbox"?vr&&Ir():v&&(Z(`worker: received unknown command ${v}`),Z(y)))}catch(_){throw oa(),_}};var Le=f,At,vr=!1;Z=function(...g){g=g.join(" "),console.error(g)},self.alert=function(...g){postMessage({Za:"alert",text:g.join(" "),nb:_e()})},a.instantiateWasm=(g,y)=>new Promise(v=>{At=_=>{_=new WebAssembly.Instance(_,hi()),y(_),v()}}),self.onunhandledrejection=g=>{throw g.reason||g},self.onmessage=f}a.wasmBinary&&($=a.wasmBinary);var yt,xr,Ut,wt,G,Wt,Tr,xt,ve,ot=!1;function it(){var f=yt.buffer;a.HEAP8=wt=new Int8Array(f),a.HEAP16=new Int16Array(f),a.HEAPU8=G=new Uint8Array(f),a.HEAPU16=new Uint16Array(f),a.HEAP32=Wt=new Int32Array(f),a.HEAPU32=Tr=new Uint32Array(f),a.HEAPF32=new Float32Array(f),a.HEAPF64=ve=new Float64Array(f),a.HEAP64=xt=new BigInt64Array(f),a.HEAPU64=new BigUint64Array(f)}if(!d){if(!((yt=new WebAssembly.Memory({initial:256,maximum:65536,shared:!0})).buffer instanceof b))throw Z("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");it()}var oe=[],Xt=[],_r=[],ie=0,Ct=null,Tt=null;function ae(){if(--ie==0&&(Ct!==null&&(clearInterval(Ct),Ct=null),Tt)){var f=Tt;Tt=null,f()}}function et(f){throw Z(f="Aborted("+f+")"),ot=!0,Ut=1,f=new WebAssembly.RuntimeError(f+". Build with -sASSERTIONS for more info."),o(f),f}var at,Gt=f=>f.startsWith("data:application/octet-stream;base64,"),Re=f=>f.startsWith("file://");function Sr(f){if(f==at&&$)return new Uint8Array($);if(m)return m(f);throw"both async and sync fetching of the wasm failed"}function di(f,g,y){return function(v){if(!$&&(u||i)){if(typeof fetch=="function"&&!Re(v))return fetch(v,{credentials:"same-origin"}).then(_=>{if(!_.ok)throw`failed to load wasm binary file at '${v}'`;return _.arrayBuffer()}).catch(()=>Sr(v));if(h)return new Promise((_,P)=>{h(v,N=>_(new Uint8Array(N)),P)})}return Promise.resolve().then(()=>Sr(v))}(f).then(v=>WebAssembly.instantiate(v,g)).then(y,v=>{Z(`failed to asynchronously prepare wasm: ${v}`),et(v)})}function hi(){return{a:{j:Nd,b:Ld,E:Si,g:Ii,V:Pi,A:Di,C:Ni,W:ki,T:Fi,L:Ci,S:Li,o:Ri,B:ji,y:Bi,U:Vi,z:Mi,_:Rd,Z:jd,P:Bd,w:Vd,F:Md,k:zd,O:on,Y:Ud,I:Gd,J:Hd,K:qd,G:Gi,H:Hi,v:Wd,q:Xd,l:Kd,p:Zd,e:Jd,X:Yd,x:Qd,d:qi,f:th,i:eh,u:rh,t:nh,s:oh,Q:Ki,R:Zi,D:nn,h:Ji,n:Yi,M:Qi,m:ta,a:yt,r:rn,N:na,c:sh}}}var fi={836900:(f,g,y,v,_)=>{if(a===void 0||!a.Ua)return 1;if((f=Be(f>>>0)).startsWith("./")&&(f=f.substring(2)),!(f=a.Ua.get(f)))return 2;if(v>>>=0,(g>>>=0)+(y>>>=0)>f.byteLength)return 3;try{let P=f.subarray(g,g+y);switch(_){case 0:n().set(P,v>>>0);break;case 1:a.mb(v,P);break;default:return 4}return 0}catch{return 4}},837583:()=>typeof wasmOffsetConverter<"u"};function Nd(){return typeof wasmOffsetConverter<"u"}function tn(f){this.name="ExitStatus",this.message=`Program terminated with exit(${f})`,this.status=f}var en=f=>{f.terminate(),f.onmessage=()=>{}},gi=f=>{Kt.length==0&&(xi(),vi(Kt[0]));var g=Kt.pop();if(!g)return 6;se.push(g),jt[f.Ra]=g,g.Ra=f.Ra;var y={cmd:"run",start_routine:f.cb,arg:f.ab,pthread_ptr:f.Ra};return g.postMessage(y,f.ib),0},je=0,J=(f,g,...y)=>{for(var v=2*y.length,_=hn(),P=dn(8*v),N=P>>>3,K=0;K<y.length;K++){var ct=y[K];typeof ct=="bigint"?(xt[N+2*K]=1n,xt[N+2*K+1]=ct):(xt[N+2*K]=0n,l()[N+2*K+1>>>0]=ct)}return f=ia(f,0,v,P,g),Dr(_),f};function rn(f){if(d)return J(0,1,f);if(Ut=f,!(0<je)){for(var g of se)en(g);for(g of Kt)en(g);Kt=[],se=[],jt=[],ot=!0}w(f,new tn(f))}function mi(f){if(d)return J(1,0,f);nn(f)}var nn=f=>{if(Ut=f,d)throw mi(f),"unwind";rn(f)},Kt=[],se=[],bi=[],jt={},yi=f=>{var g=f.Ra;delete jt[g],Kt.push(f),se.splice(se.indexOf(f),1),f.Ra=0,cn(g)};function wi(){bi.forEach(f=>f())}var vi=f=>new Promise(g=>{f.onmessage=_=>{var P=(_=_.data).cmd;if(_.targetThread&&_.targetThread!=_e()){var N=jt[_.targetThread];N?N.postMessage(_,_.transferList):Z(`Internal error! Worker sent a message "${P}" to target pthread ${_.targetThread}, but that thread no longer exists!`)}else P==="checkMailbox"?Ir():P==="spawnThread"?gi(_):P==="cleanupThread"?yi(jt[_.thread]):P==="killThread"?(_=_.thread,P=jt[_],delete jt[_],en(P),cn(_),se.splice(se.indexOf(P),1),P.Ra=0):P==="cancelThread"?jt[_.thread].postMessage({cmd:"cancel"}):P==="loaded"?(f.loaded=!0,g(f)):P==="alert"?alert(`Thread ${_.threadId}: ${_.text}`):_.target==="setimmediate"?f.postMessage(_):P==="callHandler"?a[_.handler](..._.args):P&&Z(`worker sent an unknown command ${P}`)},f.onerror=_=>{throw Z(`worker sent an error! ${_.filename}:${_.lineno}: ${_.message}`),_};var y,v=[];for(y of[])a.hasOwnProperty(y)&&v.push(y);f.postMessage({cmd:"load",handlers:v,wasmMemory:yt,wasmModule:xr})});function xi(){var f=new Worker(new URL(import.meta.url),{type:"module",workerData:"em-pthread",name:"em-pthread"});Kt.push(f)}var Ti,Or=f=>{for(;0<f.length;)f.shift()(a)},kd=()=>{var f=_e(),g=p()[f+52>>>2>>>0];f=p()[f+56>>>2>>>0],sa(g,g-f),Dr(g)},Er=[],Fd=(f,g)=>{je=0;var y=Er[f];y||(f>=Er.length&&(Er.length=f+1),Er[f]=y=Ti.get(f)),f=y(g),0<je?Ut=f:$r(f)};class Cd{constructor(g){this.Xa=g-24}}function Ld(f,g,y){var v=new Cd(f>>>=0);throw g>>>=0,y>>>=0,p()[v.Xa+16>>>2>>>0]=0,p()[v.Xa+4>>>2>>>0]=g,p()[v.Xa+8>>>2>>>0]=y,f}function _i(f,g,y,v){return d?J(2,1,f,g,y,v):Si(f,g,y,v)}function Si(f,g,y,v){if(f>>>=0,g>>>=0,y>>>=0,v>>>=0,b===void 0)return Z("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var _=[];return d&&_.length===0?_i(f,g,y,v):(f={cb:y,Ra:f,ab:v,ib:_},d?(f.Za="spawnThread",postMessage(f,_),0):gi(f))}var Oi=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,Ei=(f,g,y)=>{var v=(g>>>=0)+y;for(y=g;f[y]&&!(y>=v);)++y;if(16<y-g&&f.buffer&&Oi)return Oi.decode(f.buffer instanceof b?f.slice(g,y):f.subarray(g,y));for(v="";g<y;){var _=f[g++];if(128&_){var P=63&f[g++];if((224&_)==192)v+=String.fromCharCode((31&_)<<6|P);else{var N=63&f[g++];65536>(_=(240&_)==224?(15&_)<<12|P<<6|N:(7&_)<<18|P<<12|N<<6|63&f[g++])?v+=String.fromCharCode(_):(_-=65536,v+=String.fromCharCode(55296|_>>10,56320|1023&_))}}else v+=String.fromCharCode(_)}return v},Be=(f,g)=>(f>>>=0)?Ei(n(),f,g):"";function Ii(f,g,y){return d?J(3,1,f,g,y):0}function Pi(f,g){if(d)return J(4,1,f,g)}var Ai=f=>{for(var g=0,y=0;y<f.length;++y){var v=f.charCodeAt(y);127>=v?g++:2047>=v?g+=2:55296<=v&&57343>=v?(g+=4,++y):g+=3}return g},$i=(f,g,y,v)=>{if(!(0<v))return 0;var _=y>>>=0;v=y+v-1;for(var P=0;P<f.length;++P){var N=f.charCodeAt(P);if(55296<=N&&57343>=N&&(N=65536+((1023&N)<<10)|1023&f.charCodeAt(++P)),127>=N){if(y>=v)break;g[y++>>>0]=N}else{if(2047>=N){if(y+1>=v)break;g[y++>>>0]=192|N>>6}else{if(65535>=N){if(y+2>=v)break;g[y++>>>0]=224|N>>12}else{if(y+3>=v)break;g[y++>>>0]=240|N>>18,g[y++>>>0]=128|N>>12&63}g[y++>>>0]=128|N>>6&63}g[y++>>>0]=128|63&N}}return g[y>>>0]=0,y-_},Ve=(f,g,y)=>$i(f,n(),g,y);function Di(f,g){if(d)return J(5,1,f,g)}function Ni(f,g,y){if(d)return J(6,1,f,g,y)}function ki(f,g,y){return d?J(7,1,f,g,y):0}function Fi(f,g){if(d)return J(8,1,f,g)}function Ci(f,g,y){if(d)return J(9,1,f,g,y)}function Li(f,g,y,v){if(d)return J(10,1,f,g,y,v)}function Ri(f,g,y,v){if(d)return J(11,1,f,g,y,v)}function ji(f,g,y,v){if(d)return J(12,1,f,g,y,v)}function Bi(f){if(d)return J(13,1,f)}function Vi(f,g){if(d)return J(14,1,f,g)}function Mi(f,g,y){if(d)return J(15,1,f,g,y)}var Rd=()=>{et("")},jd=()=>1;function Bd(f){pn(f>>>0,!i,1,!u,131072,!1),wi()}function on(f){f>>>=0,typeof Atomics.jb=="function"&&(Atomics.jb(s(),f>>>2,f).value.then(Ir),f+=128,Atomics.store(s(),f>>>2,1))}var Ir=()=>{var f=_e();if(f&&(on(f),f=aa,!ot))try{if(f(),!(0<je))try{d?$r(Ut):nn(Ut)}catch(g){g instanceof tn||g=="unwind"||w(1,g)}}catch(g){g instanceof tn||g=="unwind"||w(1,g)}};function Vd(f,g){(f>>>=0)==g>>>0?setTimeout(Ir):d?postMessage({targetThread:f,cmd:"checkMailbox"}):(f=jt[f])&&f.postMessage({cmd:"checkMailbox"})}var an=[];function Md(f,g,y,v,_){for(g>>>=0,v/=2,an.length=v,y=_>>>0>>>3,_=0;_<v;_++)an[_]=xt[y+2*_]?xt[y+2*_+1]:l()[y+2*_+1>>>0];return(g?fi[g]:uh[f])(...an)}function zd(f){f>>>=0,d?postMessage({cmd:"cleanupThread",thread:f}):yi(jt[f])}function Ud(f){}function Gd(f,g){f=-9007199254740992>f||9007199254740992<f?NaN:Number(f),g>>>=0,f=new Date(1e3*f),s()[g>>>2>>>0]=f.getUTCSeconds(),s()[g+4>>>2>>>0]=f.getUTCMinutes(),s()[g+8>>>2>>>0]=f.getUTCHours(),s()[g+12>>>2>>>0]=f.getUTCDate(),s()[g+16>>>2>>>0]=f.getUTCMonth(),s()[g+20>>>2>>>0]=f.getUTCFullYear()-1900,s()[g+24>>>2>>>0]=f.getUTCDay(),f=(f.getTime()-Date.UTC(f.getUTCFullYear(),0,1,0,0,0,0))/864e5|0,s()[g+28>>>2>>>0]=f}var xe=f=>f%4==0&&(f%100!=0||f%400==0),zi=[0,31,60,91,121,152,182,213,244,274,305,335],Ui=[0,31,59,90,120,151,181,212,243,273,304,334];function Hd(f,g){f=-9007199254740992>f||9007199254740992<f?NaN:Number(f),g>>>=0,f=new Date(1e3*f),s()[g>>>2>>>0]=f.getSeconds(),s()[g+4>>>2>>>0]=f.getMinutes(),s()[g+8>>>2>>>0]=f.getHours(),s()[g+12>>>2>>>0]=f.getDate(),s()[g+16>>>2>>>0]=f.getMonth(),s()[g+20>>>2>>>0]=f.getFullYear()-1900,s()[g+24>>>2>>>0]=f.getDay();var y=(xe(f.getFullYear())?zi:Ui)[f.getMonth()]+f.getDate()-1|0;s()[g+28>>>2>>>0]=y,s()[g+36>>>2>>>0]=-60*f.getTimezoneOffset(),y=new Date(f.getFullYear(),6,1).getTimezoneOffset();var v=new Date(f.getFullYear(),0,1).getTimezoneOffset();f=0|(y!=v&&f.getTimezoneOffset()==Math.min(v,y)),s()[g+32>>>2>>>0]=f}function qd(f){f>>>=0;var g=new Date(s()[f+20>>>2>>>0]+1900,s()[f+16>>>2>>>0],s()[f+12>>>2>>>0],s()[f+8>>>2>>>0],s()[f+4>>>2>>>0],s()[f>>>2>>>0],0),y=s()[f+32>>>2>>>0],v=g.getTimezoneOffset(),_=new Date(g.getFullYear(),6,1).getTimezoneOffset(),P=new Date(g.getFullYear(),0,1).getTimezoneOffset(),N=Math.min(P,_);return 0>y?s()[f+32>>>2>>>0]=+(_!=P&&N==v):0<y!=(N==v)&&(_=Math.max(P,_),g.setTime(g.getTime()+6e4*((0<y?N:_)-v))),s()[f+24>>>2>>>0]=g.getDay(),y=(xe(g.getFullYear())?zi:Ui)[g.getMonth()]+g.getDate()-1|0,s()[f+28>>>2>>>0]=y,s()[f>>>2>>>0]=g.getSeconds(),s()[f+4>>>2>>>0]=g.getMinutes(),s()[f+8>>>2>>>0]=g.getHours(),s()[f+12>>>2>>>0]=g.getDate(),s()[f+16>>>2>>>0]=g.getMonth(),s()[f+20>>>2>>>0]=g.getYear(),f=g.getTime(),BigInt(isNaN(f)?-1:f/1e3)}function Gi(f,g,y,v,_,P,N){return d?J(16,1,f,g,y,v,_,P,N):-52}function Hi(f,g,y,v,_,P){if(d)return J(17,1,f,g,y,v,_,P)}function Wd(f,g,y,v){f>>>=0,g>>>=0,y>>>=0,v>>>=0;var _=new Date().getFullYear(),P=new Date(_,0,1),N=new Date(_,6,1);_=P.getTimezoneOffset();var K=N.getTimezoneOffset(),ct=Math.max(_,K);p()[f>>>2>>>0]=60*ct,s()[g>>>2>>>0]=+(_!=K),P=(f=gt=>gt.toLocaleTimeString(void 0,{hour12:!1,timeZoneName:"short"}).split(" ")[1])(P),N=f(N),K<_?(Ve(P,y,17),Ve(N,v,17)):(Ve(P,v,17),Ve(N,y,17))}var sn=[];function Xd(f,g,y){f>>>=0,g>>>=0,y>>>=0,sn.length=0;for(var v;v=n()[g++>>>0];){var _=v!=105;y+=(_&=v!=112)&&y%8?4:0,sn.push(v==112?p()[y>>>2>>>0]:v==106?xt[y>>>3]:v==105?s()[y>>>2>>>0]:l()[y>>>3>>>0]),y+=_?8:4}return fi[f](...sn)}var Kd=()=>{},Zd=()=>Date.now();function Jd(f,g){return Z(Be(f>>>0,g>>>0))}var qi,Yd=()=>{throw je+=1,"unwind"};function Qd(){return 4294901760}qi=()=>performance.timeOrigin+performance.now();var th=()=>navigator.hardwareConcurrency;function eh(){return et("Cannot use emscripten_pc_get_function without -sUSE_OFFSET_CONVERTER"),0}function rh(f){f>>>=0;var g=n().length;if(f<=g||4294901760<f)return!1;for(var y=1;4>=y;y*=2){var v=g*(1+.2/y);v=Math.min(v,f+100663296);var _=Math;v=Math.max(f,v);t:{_=(_.min.call(_,4294901760,v+(65536-v%65536)%65536)-yt.buffer.byteLength+65535)/65536;try{yt.grow(_),it();var P=1;break t}catch{}P=void 0}if(P)return!0}return!1}var Pr=()=>(et("Cannot use convertFrameToPC (needed by __builtin_return_address) without -sUSE_OFFSET_CONVERTER"),0),Te={},Wi=f=>{f.forEach(g=>{var y=Pr();y&&(Te[y]=g)})};function nh(){var f=Error().stack.toString().split(`
|
|
1798
|
+
`);return f[0]=="Error"&&f.shift(),Wi(f),Te.$a=Pr(),Te.bb=f,Te.$a}function oh(f,g,y){if(f>>>=0,g>>>=0,Te.$a==f)var v=Te.bb;else(v=Error().stack.toString().split(`
|
|
1799
|
+
`))[0]=="Error"&&v.shift(),Wi(v);for(var _=3;v[_]&&Pr()!=f;)++_;for(f=0;f<y&&v[f+_];++f)s()[g+4*f>>>2>>>0]=Pr();return f}var un,ln={},Xi=()=>{if(!un){var f,g={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:E||"./this.program"};for(f in ln)ln[f]===void 0?delete g[f]:g[f]=ln[f];var y=[];for(f in g)y.push(`${f}=${g[f]}`);un=y}return un};function Ki(f,g){if(d)return J(18,1,f,g);f>>>=0,g>>>=0;var y=0;return Xi().forEach((v,_)=>{var P=g+y;for(_=p()[f+4*_>>>2>>>0]=P,P=0;P<v.length;++P)r()[_++>>>0]=v.charCodeAt(P);r()[_>>>0]=0,y+=v.length+1}),0}function Zi(f,g){if(d)return J(19,1,f,g);f>>>=0,g>>>=0;var y=Xi();p()[f>>>2>>>0]=y.length;var v=0;return y.forEach(_=>v+=_.length+1),p()[g>>>2>>>0]=v,0}function Ji(f){return d?J(20,1,f):52}function Yi(f,g,y,v){return d?J(21,1,f,g,y,v):52}function Qi(f,g,y,v){return d?J(22,1,f,g,y,v):70}var ih=[null,[],[]];function ta(f,g,y,v){if(d)return J(23,1,f,g,y,v);g>>>=0,y>>>=0,v>>>=0;for(var _=0,P=0;P<y;P++){var N=p()[g>>>2>>>0],K=p()[g+4>>>2>>>0];g+=8;for(var ct=0;ct<K;ct++){var gt=n()[N+ct>>>0],vt=ih[f];gt===0||gt===10?((f===1?pt:Z)(Ei(vt,0)),vt.length=0):vt.push(gt)}_+=K}return p()[v>>>2>>>0]=_,0}var ea=[31,29,31,30,31,30,31,31,30,31,30,31],ra=[31,28,31,30,31,30,31,31,30,31,30,31],ah=(f,g)=>{r().set(f,g>>>0)};function na(f,g,y,v){function _(O,z,rt){for(O=typeof O=="number"?O.toString():O||"";O.length<z;)O=rt[0]+O;return O}function P(O,z){return _(O,z,"0")}function N(O,z){function rt(ca){return 0>ca?-1:0<ca?1:0}var ue;return(ue=rt(O.getFullYear()-z.getFullYear()))===0&&(ue=rt(O.getMonth()-z.getMonth()))===0&&(ue=rt(O.getDate()-z.getDate())),ue}function K(O){switch(O.getDay()){case 0:return new Date(O.getFullYear()-1,11,29);case 1:return O;case 2:return new Date(O.getFullYear(),0,3);case 3:return new Date(O.getFullYear(),0,2);case 4:return new Date(O.getFullYear(),0,1);case 5:return new Date(O.getFullYear()-1,11,31);case 6:return new Date(O.getFullYear()-1,11,30)}}function ct(O){var z=O.Sa;for(O=new Date(new Date(O.Ta+1900,0,1).getTime());0<z;){var rt=O.getMonth(),ue=(xe(O.getFullYear())?ea:ra)[rt];if(!(z>ue-O.getDate())){O.setDate(O.getDate()+z);break}z-=ue-O.getDate()+1,O.setDate(1),11>rt?O.setMonth(rt+1):(O.setMonth(0),O.setFullYear(O.getFullYear()+1))}return rt=new Date(O.getFullYear()+1,0,4),z=K(new Date(O.getFullYear(),0,4)),rt=K(rt),0>=N(z,O)?0>=N(rt,O)?O.getFullYear()+1:O.getFullYear():O.getFullYear()-1}f>>>=0,g>>>=0,y>>>=0,v>>>=0;var gt=p()[v+40>>>2>>>0];for(var vt in v={gb:s()[v>>>2>>>0],fb:s()[v+4>>>2>>>0],Va:s()[v+8>>>2>>>0],Ya:s()[v+12>>>2>>>0],Wa:s()[v+16>>>2>>>0],Ta:s()[v+20>>>2>>>0],Qa:s()[v+24>>>2>>>0],Sa:s()[v+28>>>2>>>0],ob:s()[v+32>>>2>>>0],eb:s()[v+36>>>2>>>0],hb:gt?Be(gt):""},y=Be(y),gt={"%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"})y=y.replace(new RegExp(vt,"g"),gt[vt]);var la="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),pa="January February March April May June July August September October November December".split(" ");for(vt in gt={"%a":O=>la[O.Qa].substring(0,3),"%A":O=>la[O.Qa],"%b":O=>pa[O.Wa].substring(0,3),"%B":O=>pa[O.Wa],"%C":O=>P((O.Ta+1900)/100|0,2),"%d":O=>P(O.Ya,2),"%e":O=>_(O.Ya,2," "),"%g":O=>ct(O).toString().substring(2),"%G":ct,"%H":O=>P(O.Va,2),"%I":O=>((O=O.Va)==0?O=12:12<O&&(O-=12),P(O,2)),"%j":O=>{for(var z=0,rt=0;rt<=O.Wa-1;z+=(xe(O.Ta+1900)?ea:ra)[rt++]);return P(O.Ya+z,3)},"%m":O=>P(O.Wa+1,2),"%M":O=>P(O.fb,2),"%n":()=>`
|
|
1800
|
+
`,"%p":O=>0<=O.Va&&12>O.Va?"AM":"PM","%S":O=>P(O.gb,2),"%t":()=>" ","%u":O=>O.Qa||7,"%U":O=>P(Math.floor((O.Sa+7-O.Qa)/7),2),"%V":O=>{var z=Math.floor((O.Sa+7-(O.Qa+6)%7)/7);if(2>=(O.Qa+371-O.Sa-2)%7&&z++,z)z==53&&((rt=(O.Qa+371-O.Sa)%7)==4||rt==3&&xe(O.Ta)||(z=1));else{z=52;var rt=(O.Qa+7-O.Sa-1)%7;(rt==4||rt==5&&xe(O.Ta%400-1))&&z++}return P(z,2)},"%w":O=>O.Qa,"%W":O=>P(Math.floor((O.Sa+7-(O.Qa+6)%7)/7),2),"%y":O=>(O.Ta+1900).toString().substring(2),"%Y":O=>O.Ta+1900,"%z":O=>{var z=0<=(O=O.eb);return O=Math.abs(O)/60,(z?"+":"-")+("0000"+(O/60*100+O%60)).slice(-4)},"%Z":O=>O.hb,"%%":()=>"%"},y=y.replace(/%%/g,"\0\0"),gt)y.includes(vt)&&(y=y.replace(new RegExp(vt,"g"),gt[vt](v)));return vt=function(O){var z=Array(Ai(O)+1);return $i(O,z,0,z.length),z}(y=y.replace(/\0\0/g,"%")),vt.length>g?0:(ah(vt,f),vt.length-1)}function sh(f,g,y,v){return na(f>>>0,g>>>0,y>>>0,v>>>0)}d||function(){for(var f=a.numThreads-1;f--;)xi();oe.unshift(()=>{ie++,function(g){d?g():Promise.all(Kt.map(vi)).then(g)}(()=>ae())})}();var uh=[rn,mi,_i,Ii,Pi,Di,Ni,ki,Fi,Ci,Li,Ri,ji,Bi,Vi,Mi,Gi,Hi,Ki,Zi,Ji,Yi,Qi,ta],k=function(){function f(y,v){return k=y.exports,k=function(){var _=k,P=K=>()=>K()>>>0,N=K=>ct=>K(ct)>>>0;return(_=Object.assign({},_)).Ba=P(_.Ba),_.Ca=N(_.Ca),_.emscripten_main_runtime_thread_id=P(_.emscripten_main_runtime_thread_id),_.Oa=N(_.Oa),_.Pa=P(_.Pa),_}(),bi.push(k.Ea),Ti=k.Fa,Xt.unshift(k.$),xr=v,ae(),k}var g=hi();if(ie++,a.instantiateWasm)try{return a.instantiateWasm(g,f)}catch(y){Z(`Module.instantiateWasm callback failed with error: ${y}`),o(y)}return at||(at=a.locateFile?Gt("ort-wasm-simd-threaded.wasm")?"ort-wasm-simd-threaded.wasm":a.locateFile?a.locateFile("ort-wasm-simd-threaded.wasm",S):S+"ort-wasm-simd-threaded.wasm":new URL("ort-wasm-simd-threaded.wasm",import.meta.url).href),function(y,v){var _=at;return $||typeof WebAssembly.instantiateStreaming!="function"||Gt(_)||Re(_)||typeof fetch!="function"?di(_,y,v):fetch(_,{credentials:"same-origin"}).then(P=>WebAssembly.instantiateStreaming(P,y).then(v,function(N){return Z(`wasm streaming compile failed: ${N}`),Z("falling back to ArrayBuffer instantiation"),di(_,y,v)}))}(g,function(y){f(y.instance,y.module)}).catch(o),{}}();a._OrtInit=(f,g)=>(a._OrtInit=k.aa)(f,g),a._OrtGetLastError=(f,g)=>(a._OrtGetLastError=k.ba)(f,g),a._OrtCreateSessionOptions=(f,g,y,v,_,P,N,K,ct,gt)=>(a._OrtCreateSessionOptions=k.ca)(f,g,y,v,_,P,N,K,ct,gt),a._OrtAppendExecutionProvider=(f,g)=>(a._OrtAppendExecutionProvider=k.da)(f,g),a._OrtAddFreeDimensionOverride=(f,g,y)=>(a._OrtAddFreeDimensionOverride=k.ea)(f,g,y),a._OrtAddSessionConfigEntry=(f,g,y)=>(a._OrtAddSessionConfigEntry=k.fa)(f,g,y),a._OrtReleaseSessionOptions=f=>(a._OrtReleaseSessionOptions=k.ga)(f),a._OrtCreateSession=(f,g,y)=>(a._OrtCreateSession=k.ha)(f,g,y),a._OrtReleaseSession=f=>(a._OrtReleaseSession=k.ia)(f),a._OrtGetInputOutputCount=(f,g,y)=>(a._OrtGetInputOutputCount=k.ja)(f,g,y),a._OrtGetInputName=(f,g)=>(a._OrtGetInputName=k.ka)(f,g),a._OrtGetOutputName=(f,g)=>(a._OrtGetOutputName=k.la)(f,g),a._OrtFree=f=>(a._OrtFree=k.ma)(f),a._OrtCreateTensor=(f,g,y,v,_,P)=>(a._OrtCreateTensor=k.na)(f,g,y,v,_,P),a._OrtGetTensorData=(f,g,y,v,_)=>(a._OrtGetTensorData=k.oa)(f,g,y,v,_),a._OrtReleaseTensor=f=>(a._OrtReleaseTensor=k.pa)(f),a._OrtCreateRunOptions=(f,g,y,v)=>(a._OrtCreateRunOptions=k.qa)(f,g,y,v),a._OrtAddRunConfigEntry=(f,g,y)=>(a._OrtAddRunConfigEntry=k.ra)(f,g,y),a._OrtReleaseRunOptions=f=>(a._OrtReleaseRunOptions=k.sa)(f),a._OrtCreateBinding=f=>(a._OrtCreateBinding=k.ta)(f),a._OrtBindInput=(f,g,y)=>(a._OrtBindInput=k.ua)(f,g,y),a._OrtBindOutput=(f,g,y,v)=>(a._OrtBindOutput=k.va)(f,g,y,v),a._OrtClearBoundOutputs=f=>(a._OrtClearBoundOutputs=k.wa)(f),a._OrtReleaseBinding=f=>(a._OrtReleaseBinding=k.xa)(f),a._OrtRunWithBinding=(f,g,y,v,_)=>(a._OrtRunWithBinding=k.ya)(f,g,y,v,_),a._OrtRun=(f,g,y,v,_,P,N,K)=>(a._OrtRun=k.za)(f,g,y,v,_,P,N,K),a._OrtEndProfiling=f=>(a._OrtEndProfiling=k.Aa)(f);var _e=()=>(_e=k.Ba)();a._malloc=f=>(a._malloc=k.Ca)(f),a._free=f=>(a._free=k.Da)(f);var Ar,pn=(f,g,y,v,_,P)=>(pn=k.Ga)(f,g,y,v,_,P),oa=()=>(oa=k.Ha)(),ia=(f,g,y,v,_)=>(ia=k.Ia)(f,g,y,v,_),cn=f=>(cn=k.Ja)(f),$r=f=>($r=k.Ka)(f),aa=()=>(aa=k.La)(),sa=(f,g)=>(sa=k.Ma)(f,g),Dr=f=>(Dr=k.Na)(f),dn=f=>(dn=k.Oa)(f),hn=()=>(hn=k.Pa)();function ua(){0<ie||(d?(c(a),d||Or(Xt),startWorker(a)):(Or(oe),0<ie||Ar||(Ar=!0,a.calledRun=!0,ot||(d||Or(Xt),c(a),d||Or(_r)))))}return a.___start_em_js=837640,a.___stop_em_js=837701,a.stackSave=()=>hn(),a.stackRestore=f=>Dr(f),a.stackAlloc=f=>dn(f),a.UTF8ToString=Be,a.stringToUTF8=Ve,a.lengthBytesUTF8=Ai,Tt=function f(){Ar||ua(),Ar||(Tt=f)},ua(),e}),ld=Zn,globalThis.self?.name==="em-pthread"&&Zn()}),Oe,Du,Nu,ku,Jn,pd,Fu,cd,Qr=I(()=>{"use strict";Qo(),Oe=import.meta.url??(typeof document<"u"?document.currentScript?.src:typeof self<"u"?self.location?.href:void 0),Du=typeof location>"u"?void 0:location.origin,Nu=(t,r)=>{try{let n=r??Oe;return(n?new URL(t,n):new URL(t)).origin===Du}catch{return!1}},ku=async t=>{let r=await(await fetch(t,{credentials:"same-origin"})).blob();return URL.createObjectURL(r)},Jn=(um(),zr(ad)).default,pd=async()=>{if(!Oe)throw new Error("Failed to load proxy worker: cannot determine the script source URL.");if(Nu(Oe))return[void 0,Jn()];let t=await ku(Oe);return[t,Jn(t)]},Fu=(lm(),zr(ud)).default,cd=async(t,r,n)=>[void 0,Fu]}),Yn,Rr,Ke,Qn,Cu,Lu,ti,ht,Ce=I(()=>{"use strict";Qr(),Rr=!1,Ke=!1,Qn=!1,Cu=()=>{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}},Lu=()=>{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}},ti=async t=>{if(Rr)return Promise.resolve();if(Ke)throw new Error("multiple calls to 'initializeWebAssembly()' detected.");if(Qn)throw new Error("previous call to 'initializeWebAssembly()' failed.");Ke=!0;let r=t.initTimeout,n=t.numThreads;if(!Lu())throw new Error("WebAssembly SIMD is not supported in the current environment.");let s=Cu();n>1&&!s&&(typeof self<"u"&&!self.crossOriginIsolated&&console.warn("env.wasm.numThreads is set to "+n+", 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=n=1);let p=t.wasmPaths,l=typeof p=="string"?p:void 0,c=p?.mjs,o=c?.href??c,a=p?.wasm,e=a?.href??a,u=t.wasmBinary,[i,d]=await cd(o,l,n>1),h=!1,m=[];if(r>0&&m.push(new Promise(b=>{setTimeout(()=>{h=!0,b()},r)})),m.push(new Promise((b,x)=>{let E={numThreads:n};u?E.wasmBinary=u:(e||l)&&(E.locateFile=(w,S)=>e??(l??S)+w),d(E).then(w=>{Ke=!1,Rr=!0,Yn=w,b(),i&&URL.revokeObjectURL(i)},w=>{Ke=!1,Qn=!0,x(w)})})),await Promise.race(m),h)throw new Error(`WebAssembly backend initializing failed due to timeout: ${r}ms`)},ht=()=>{if(Rr&&Yn)return Yn;throw new Error("WebAssembly is not initialized yet.")}}),ut,Wr,st,ei=I(()=>{"use strict";Ce(),ut=(t,r)=>{let n=ht(),s=n.lengthBytesUTF8(t)+1,p=n._malloc(s);return n.stringToUTF8(t,p,s),r.push(p),p},Wr=(t,r,n,s)=>{if(typeof t=="object"&&t!==null){if(n.has(t))throw new Error("Circular reference in options");n.add(t)}Object.entries(t).forEach(([p,l])=>{let c=r?r+p:p;if(typeof l=="object")Wr(l,c+".",n,s);else if(typeof l=="string"||typeof l=="number")s(c,l.toString());else if(typeof l=="boolean")s(c,l?"1":"0");else throw new Error(`Can't handle extra config type: ${typeof l}`)})},st=t=>{let r=ht(),n=r.stackSave();try{let s=r.stackAlloc(8);r._OrtGetLastError(s,s+4);let p=r.HEAP32[s/4],l=r.HEAPU32[s/4+1],c=l?r.UTF8ToString(l):"";throw new Error(`${t} ERROR_CODE: ${p}, ERROR_MESSAGE: ${c}`)}finally{r.stackRestore(n)}}}),dd,pm=I(()=>{"use strict";Ce(),ei(),dd=t=>{let r=ht(),n=0,s=[],p=t||{};try{if(t?.logSeverityLevel===void 0)p.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?.logVerbosityLevel===void 0)p.logVerbosityLevel=0;else if(typeof t.logVerbosityLevel!="number"||!Number.isInteger(t.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${t.logVerbosityLevel}`);t?.terminate===void 0&&(p.terminate=!1);let l=0;return t?.tag!==void 0&&(l=ut(t.tag,s)),n=r._OrtCreateRunOptions(p.logSeverityLevel,p.logVerbosityLevel,!!p.terminate,l),n===0&&st("Can't create run options."),t?.extra!==void 0&&Wr(t.extra,"",new WeakSet,(c,o)=>{let a=ut(c,s),e=ut(o,s);r._OrtAddRunConfigEntry(n,a,e)!==0&&st(`Can't set a run config entry: ${c} - ${o}.`)}),[n,s]}catch(l){throw n!==0&&r._OrtReleaseRunOptions(n),s.forEach(c=>r._free(c)),l}}}),Ru,ju,Bu,Vu,hd,cm=I(()=>{"use strict";Ce(),ei(),Ru=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}`)}},ju=t=>{switch(t){case"sequential":return 0;case"parallel":return 1;default:throw new Error(`unsupported execution mode: ${t}`)}},Bu=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(n=>(typeof n=="string"?n:n.name)==="webgpu")&&(t.enableMemPattern=!1)},Vu=(t,r,n)=>{for(let s of r){let p=typeof s=="string"?s:s.name;switch(p){case"webnn":if(p="WEBNN",typeof s!="string"){let c=s?.deviceType;if(c){let o=ut("deviceType",n),a=ut(c,n);ht()._OrtAddSessionConfigEntry(t,o,a)!==0&&st(`Can't set a session config entry: 'deviceType' - ${c}.`)}}break;case"webgpu":if(p="JS",typeof s!="string"){let c=s;if(c?.preferredLayout){if(c.preferredLayout!=="NCHW"&&c.preferredLayout!=="NHWC")throw new Error(`preferredLayout must be either 'NCHW' or 'NHWC': ${c.preferredLayout}`);let o=ut("preferredLayout",n),a=ut(c.preferredLayout,n);ht()._OrtAddSessionConfigEntry(t,o,a)!==0&&st(`Can't set a session config entry: 'preferredLayout' - ${c.preferredLayout}.`)}}break;case"wasm":case"cpu":continue;default:throw new Error(`not supported execution provider: ${p}`)}let l=ut(p,n);ht()._OrtAppendExecutionProvider(t,l)!==0&&st(`Can't append execution provider: ${p}.`)}},hd=t=>{let r=ht(),n=0,s=[],p=t||{};Bu(p);try{let l=Ru(p.graphOptimizationLevel??"all"),c=ju(p.executionMode??"sequential"),o=typeof p.logId=="string"?ut(p.logId,s):0,a=p.logSeverityLevel??2;if(!Number.isInteger(a)||a<0||a>4)throw new Error(`log serverity level is not valid: ${a}`);let e=p.logVerbosityLevel??0;if(!Number.isInteger(e)||e<0||e>4)throw new Error(`log verbosity level is not valid: ${e}`);let u=typeof p.optimizedModelFilePath=="string"?ut(p.optimizedModelFilePath,s):0;if(n=r._OrtCreateSessionOptions(l,!!p.enableCpuMemArena,!!p.enableMemPattern,c,!!p.enableProfiling,0,o,a,e,u),n===0&&st("Can't create session options."),p.executionProviders&&Vu(n,p.executionProviders,s),p.enableGraphCapture!==void 0){if(typeof p.enableGraphCapture!="boolean")throw new Error(`enableGraphCapture must be a boolean value: ${p.enableGraphCapture}`);let i=ut("enableGraphCapture",s),d=ut(p.enableGraphCapture.toString(),s);r._OrtAddSessionConfigEntry(n,i,d)!==0&&st(`Can't set a session config entry: 'enableGraphCapture' - ${p.enableGraphCapture}.`)}if(p.freeDimensionOverrides)for(let[i,d]of Object.entries(p.freeDimensionOverrides)){if(typeof i!="string")throw new Error(`free dimension override name must be a string: ${i}`);if(typeof d!="number"||!Number.isInteger(d)||d<0)throw new Error(`free dimension override value must be a non-negative integer: ${d}`);let h=ut(i,s);r._OrtAddFreeDimensionOverride(n,h,d)!==0&&st(`Can't set a free dimension override: ${i} - ${d}.`)}return p.extra!==void 0&&Wr(p.extra,"",new WeakSet,(i,d)=>{let h=ut(i,s),m=ut(d,s);r._OrtAddSessionConfigEntry(n,h,m)!==0&&st(`Can't set a session config entry: ${i} - ${d}.`)}),[n,s]}catch(l){throw n!==0&&r._OrtReleaseSessionOptions(n),s.forEach(c=>r._free(c)),l}}}),ir,fd,ar,gd,md,ri,ni,bd,yd=I(()=>{"use strict";ir=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}`)}},fd=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}`)}},ar=(t,r)=>{let n=[-1,4,1,1,2,2,4,8,-1,1,2,8,4,8,-1,-1,-1,-1,-1,-1,-1,.5,.5][t],s=typeof r=="number"?r:r.reduce((p,l)=>p*l,1);return n>0?Math.ceil(s*n):void 0},gd=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}`)}},md=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}`)}},ri=t=>t==="float32"||t==="float16"||t==="int32"||t==="int64"||t==="uint32"||t==="uint8"||t==="bool"||t==="uint4"||t==="int4",ni=t=>t==="float32"||t==="float16"||t==="int32"||t==="int64"||t==="uint32"||t==="uint64"||t==="int8"||t==="uint8"||t==="bool",bd=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}`)}}}),oi,wd=I(()=>{"use strict";Qo(),oi=async t=>{if(typeof t=="string")if(0)try{}catch(r){}else{let r=await fetch(t);if(!r.ok)throw new Error(`failed to load external data file: ${t}`);let n=r.headers.get("Content-Length"),s=n?parseInt(n,10):0;if(s<1073741824)return new Uint8Array(await r.arrayBuffer());{if(!r.body)throw new Error(`failed to load external data file: ${t}, no response body.`);let p=r.body.getReader(),l;try{l=new ArrayBuffer(s)}catch(o){if(o instanceof RangeError){let a=Math.ceil(s/65536);l=new WebAssembly.Memory({initial:a,maximum:a}).buffer}else throw o}let c=0;for(;;){let{done:o,value:a}=await p.read();if(o)break;let e=a.byteLength;new Uint8Array(l,c,e).set(a),c+=e}return new Uint8Array(l,0,s)}}else return t instanceof Blob?new Uint8Array(await t.arrayBuffer()):t instanceof Uint8Array?t:new Uint8Array(t)}}),Mu,ii,ai,de,zu,Xr,si,ui,to,li,pi,ci,vd=I(()=>{"use strict";pm(),cm(),yd(),Ce(),ei(),wd(),Mu=(t,r)=>{ht()._OrtInit(t,r)!==0&&st("Can't initialize onnxruntime.")},ii=async t=>{Mu(t.wasm.numThreads,md(t.logLevel))},ai=async(t,r)=>{},de=new Map,zu=t=>{let r=ht(),n=r.stackSave();try{let s=r.stackAlloc(8);return r._OrtGetInputOutputCount(t,s,s+4)!==0&&st("Can't get session input/output count."),[r.HEAP32[s/4],r.HEAP32[s/4+1]]}finally{r.stackRestore(n)}},Xr=t=>{let r=ht(),n=r._malloc(t.byteLength);if(n===0)throw new Error(`Can't create a session. failed to allocate a buffer of size ${t.byteLength}.`);return r.HEAPU8.set(t,n),[n,t.byteLength]},si=async(t,r)=>{let n,s,p=ht();Array.isArray(t)?[n,s]=t:t.buffer===p.HEAPU8.buffer?[n,s]=[t.byteOffset,t.byteLength]:[n,s]=Xr(t);let l=0,c=0,o=0,a=[],e=[],u=[];try{if([c,a]=hd(r),r?.externalData&&p.mountExternalData){let w=[];for(let S of r.externalData){let $=typeof S=="string"?S:S.path;w.push(oi(typeof S=="string"?S:S.data).then(F=>{p.mountExternalData($,F)}))}await Promise.all(w)}for(let w of r?.executionProviders??[])if((typeof w=="string"?w:w.name)==="webnn"){if(p.shouldTransferToMLTensor=!1,p.currentContext)throw new Error("WebNN execution provider is already set.");if(typeof w!="string"){let S=w,$=S?.context,F=S?.gpuDevice,bt=S?.deviceType,pt=S?.numThreads,Z=S?.powerPreference;$?p.currentContext=$:F?p.currentContext=await navigator.ml.createContext(F):p.currentContext=await navigator.ml.createContext({deviceType:bt,numThreads:pt,powerPreference:Z})}else p.currentContext=await navigator.ml.createContext();break}l=await p._OrtCreateSession(n,s,c),l===0&&st("Can't create a session."),p.currentContext&&(p.jsepRegisterMLContext(l,p.currentContext),p.currentContext=void 0,p.shouldTransferToMLTensor=!0);let[i,d]=zu(l),h=!!r?.enableGraphCapture,m=[],b=[],x=[];for(let w=0;w<i;w++){let S=p._OrtGetInputName(l,w);S===0&&st("Can't get an input name."),e.push(S),m.push(p.UTF8ToString(S))}for(let w=0;w<d;w++){let S=p._OrtGetOutputName(l,w);S===0&&st("Can't get an output name."),u.push(S);let $=p.UTF8ToString(S);b.push($)}return de.set(l,[l,e,u,null,h,!1]),[l,m,b]}catch(i){throw e.forEach(d=>p._OrtFree(d)),u.forEach(d=>p._OrtFree(d)),o!==0&&p._OrtReleaseBinding(o),l!==0&&p._OrtReleaseSession(l),i}finally{p._free(n),c!==0&&p._OrtReleaseSessionOptions(c),a.forEach(i=>p._free(i)),p.unmountExternalData?.()}},ui=t=>{let r=ht(),n=de.get(t);if(!n)throw new Error(`cannot release session. invalid session id: ${t}`);let[s,p,l,c,o]=n;c&&(o&&r._OrtClearBoundOutputs(c.handle),r._OrtReleaseBinding(c.handle)),r.jsepOnReleaseSession?.(t),p.forEach(a=>r._OrtFree(a)),l.forEach(a=>r._OrtFree(a)),r._OrtReleaseSession(s),de.delete(t)},to=(t,r,n,s,p,l=!1)=>{if(!t){r.push(0);return}let c=ht(),o=t[0],a=t[1],e=t[3],u,i;if(o==="string"&&(e==="gpu-buffer"||e==="ml-tensor"))throw new Error("String tensor is not supported on GPU.");if(l&&e!=="gpu-buffer")throw new Error(`External buffer must be provided for input/output index ${p} when enableGraphCapture is true.`);if(e==="gpu-buffer"){let m=t[2].gpuBuffer;i=ar(ir(o),a);let b=c.jsepRegisterBuffer;if(!b)throw new Error('Tensor location "gpu-buffer" is not supported without using WebGPU.');u=b(s,p,m,i)}else if(e==="ml-tensor"){let m=t[2].mlTensor;i=ar(ir(o),a);let b=c.jsepRegisterMLTensor;if(!b)throw new Error('Tensor location "ml-tensor" is not supported without using WebNN.');u=b(m,ir(o),a)}else{let m=t[2];if(Array.isArray(m)){i=4*m.length,u=c._malloc(i),n.push(u);let b=u/4;for(let x=0;x<m.length;x++){if(typeof m[x]!="string")throw new TypeError(`tensor data at index ${x} is not a string`);c.HEAPU32[b++]=ut(m[x],n)}}else i=m.byteLength,u=c._malloc(i),n.push(u),c.HEAPU8.set(new Uint8Array(m.buffer,m.byteOffset,i),u)}let d=c.stackSave(),h=c.stackAlloc(4*a.length);try{let m=h/4;a.forEach(x=>c.HEAP32[m++]=x);let b=c._OrtCreateTensor(ir(o),u,i,h,a.length,bd(e));b===0&&st(`Can't create tensor for input/output. session=${s}, index=${p}.`),r.push(b)}finally{c.stackRestore(d)}},li=async(t,r,n,s,p,l)=>{let c=ht(),o=de.get(t);if(!o)throw new Error(`cannot run inference. invalid session id: ${t}`);let a=o[0],e=o[1],u=o[2],i=o[3],d=o[4],h=o[5],m=r.length,b=s.length,x=0,E=[],w=[],S=[],$=[],F=c.stackSave(),bt=c.stackAlloc(m*4),pt=c.stackAlloc(m*4),Z=c.stackAlloc(b*4),Le=c.stackAlloc(b*4);try{c.jsepOnRunStart?.(a),[x,E]=dd(l);for(let G=0;G<m;G++)to(n[G],w,$,t,r[G],d);for(let G=0;G<b;G++)to(p[G],S,$,t,m+s[G],d);let At=bt/4,vr=pt/4,yt=Z/4,xr=Le/4;for(let G=0;G<m;G++)c.HEAPU32[At++]=w[G],c.HEAPU32[vr++]=e[r[G]];for(let G=0;G<b;G++)c.HEAPU32[yt++]=S[G],c.HEAPU32[xr++]=u[s[G]];let Ut;Ut=await c._OrtRun(a,pt,bt,m,Le,b,Z,x),Ut!==0&&st("failed to call OrtRun().");let wt=[];for(let G=0;G<b;G++){let Wt=c.HEAPU32[Z/4+G];if(Wt===S[G]){wt.push(p[G]);continue}let Tr=c.stackSave(),xt=c.stackAlloc(4*4),ve=!1,ot,it=0;try{c._OrtGetTensorData(Wt,xt,xt+4,xt+8,xt+12)!==0&&st(`Can't access output tensor data on index ${G}.`);let oe=xt/4,Xt=c.HEAPU32[oe++];it=c.HEAPU32[oe++];let _r=c.HEAPU32[oe++],ie=c.HEAPU32[oe++],Ct=[];for(let et=0;et<ie;et++)Ct.push(c.HEAPU32[_r/4+et]);c._OrtFree(_r);let Tt=Ct.reduce((et,at)=>et*at,1);ot=fd(Xt);let ae=i?.outputPreferredLocations[s[G]];if(ot==="string"){if(ae==="gpu-buffer"||ae==="ml-tensor")throw new Error("String tensor is not supported on GPU.");let et=[],at=it/4;for(let Gt=0;Gt<Tt;Gt++){let Re=c.HEAPU32[at++],Sr=Gt===Tt-1?void 0:c.HEAPU32[at]-Re;et.push(c.UTF8ToString(Re,Sr))}wt.push([ot,Ct,et,"cpu"])}else if(ae==="gpu-buffer"&&Tt>0){let et=c.jsepGetBuffer;if(!et)throw new Error('preferredLocation "gpu-buffer" is not supported without using WebGPU.');let at=et(it),Gt=ar(Xt,Tt);if(Gt===void 0||!ri(ot))throw new Error(`Unsupported data type: ${ot}`);ve=!0,wt.push([ot,Ct,{gpuBuffer:at,download:c.jsepCreateDownloader(at,Gt,ot),dispose:()=>{c._OrtReleaseTensor(Wt)}},"gpu-buffer"])}else if(ae==="ml-tensor"&&Tt>0){let et=c.jsepEnsureTensor;if(!et)throw new Error('preferredLocation "ml-tensor" is not supported without using WebNN.');if(ar(Xt,Tt)===void 0||!ni(ot))throw new Error(`Unsupported data type: ${ot}`);let at=await et(it,Xt,Ct,!1);ve=!0,wt.push([ot,Ct,{mlTensor:at,download:c.jsepCreateMLTensorDownloader(it,ot),dispose:()=>{c.jsepReleaseTensorId(it),c._OrtReleaseTensor(Wt)}},"ml-tensor"])}else{let et=gd(ot),at=new et(Tt);new Uint8Array(at.buffer,at.byteOffset,at.byteLength).set(c.HEAPU8.subarray(it,it+at.byteLength)),wt.push([ot,Ct,at,"cpu"])}}finally{c.stackRestore(Tr),ot==="string"&&it&&c._free(it),ve||c._OrtReleaseTensor(Wt)}}return i&&!d&&(c._OrtClearBoundOutputs(i.handle),de.set(t,[a,e,u,i,d,!1])),wt}finally{c.stackRestore(F),w.forEach(At=>c._OrtReleaseTensor(At)),S.forEach(At=>c._OrtReleaseTensor(At)),$.forEach(At=>c._free(At)),x!==0&&c._OrtReleaseRunOptions(x),E.forEach(At=>c._free(At))}},pi=t=>{let r=ht(),n=de.get(t);if(!n)throw new Error("invalid session id");let s=n[0],p=r._OrtEndProfiling(s);p===0&&st("Can't get an profile file name."),r._OrtFree(p)},ci=t=>{let r=[];for(let n of t){let s=n[2];!Array.isArray(s)&&"buffer"in s&&r.push(s.buffer)}return r}}),Yt,$t,Se,Ze,Je,jr,eo,Br,he,fe,Uu,xd,Td,_d,Sd,Od,Ed,Id,Pd=I(()=>{"use strict";zt(),vd(),Ce(),Qr(),Yt=()=>!!j.wasm.proxy&&typeof document<"u",Se=!1,Ze=!1,Je=!1,Br=new Map,he=(t,r)=>{let n=Br.get(t);n?n.push(r):Br.set(t,[r])},fe=()=>{if(Se||!Ze||Je||!$t)throw new Error("worker not ready")},Uu=t=>{switch(t.data.type){case"init-wasm":Se=!1,t.data.err?(Je=!0,eo[1](t.data.err)):(Ze=!0,eo[0]()),jr&&(URL.revokeObjectURL(jr),jr=void 0);break;case"init-ep":case"copy-from":case"create":case"release":case"run":case"end-profiling":{let r=Br.get(t.data.type);t.data.err?r.shift()[1](t.data.err):r.shift()[0](t.data.out);break}default:}},xd=async()=>{if(!Ze){if(Se)throw new Error("multiple calls to 'initWasm()' detected.");if(Je)throw new Error("previous call to 'initWasm()' failed.");if(Se=!0,Yt())return new Promise((t,r)=>{$t?.terminate(),pd().then(([n,s])=>{try{$t=s,$t.onerror=l=>r(l),$t.onmessage=Uu,eo=[t,r];let p={type:"init-wasm",in:j};$t.postMessage(p),jr=n}catch(p){r(p)}},r)});try{await ti(j.wasm),await ii(j),Ze=!0}catch(t){throw Je=!0,t}finally{Se=!1}}},Td=async t=>{if(Yt())return fe(),new Promise((r,n)=>{he("init-ep",[r,n]);let s={type:"init-ep",in:{epName:t,env:j}};$t.postMessage(s)});await ai(j,t)},_d=async t=>Yt()?(fe(),new Promise((r,n)=>{he("copy-from",[r,n]);let s={type:"copy-from",in:{buffer:t}};$t.postMessage(s,[t.buffer])})):Xr(t),Sd=async(t,r)=>{if(Yt()){if(r?.preferredOutputLocation)throw new Error('session option "preferredOutputLocation" is not supported for proxy.');return fe(),new Promise((n,s)=>{he("create",[n,s]);let p={type:"create",in:{model:t,options:{...r}}},l=[];t instanceof Uint8Array&&l.push(t.buffer),$t.postMessage(p,l)})}else return si(t,r)},Od=async t=>{if(Yt())return fe(),new Promise((r,n)=>{he("release",[r,n]);let s={type:"release",in:t};$t.postMessage(s)});ui(t)},Ed=async(t,r,n,s,p,l)=>{if(Yt()){if(n.some(c=>c[3]!=="cpu"))throw new Error("input tensor on GPU is not supported for proxy.");if(p.some(c=>c))throw new Error("pre-allocated output tensor is not supported for proxy.");return fe(),new Promise((c,o)=>{he("run",[c,o]);let a=n,e={type:"run",in:{sessionId:t,inputIndices:r,inputs:a,outputIndices:s,options:l}};$t.postMessage(e,ci(a))})}else return li(t,r,n,s,p,l)},Id=async t=>{if(Yt())return fe(),new Promise((r,n)=>{he("end-profiling",[r,n]);let s={type:"end-profiling",in:t};$t.postMessage(s)});pi(t)}}),ro,Gu,Ad,dm=I(()=>{"use strict";zt(),Pd(),yd(),Qo(),wd(),ro=(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()}`)}},Gu=t=>{switch(t[3]){case"cpu":return new ft(t[0],t[2],t[1]);case"gpu-buffer":{let r=t[0];if(!ri(r))throw new Error(`not supported data type: ${r} for deserializing GPU tensor`);let{gpuBuffer:n,download:s,dispose:p}=t[2];return ft.fromGpuBuffer(n,{dataType:r,dims:t[1],download:s,dispose:p})}case"ml-tensor":{let r=t[0];if(!ni(r))throw new Error(`not supported data type: ${r} for deserializing MLTensor tensor`);let{mlTensor:n,download:s,dispose:p}=t[2];return ft.fromMLTensor(n,{dataType:r,dims:t[1],download:s,dispose:p})}default:throw new Error(`invalid data location: ${t[3]}`)}},Ad=class{async fetchModelAndCopyToWasmMemory(t){return _d(await oi(t))}async loadModel(t,r){Pe();let n;typeof t=="string"?n=await this.fetchModelAndCopyToWasmMemory(t):n=t,[this.sessionId,this.inputNames,this.outputNames]=await Sd(n,r),Ae()}async dispose(){return Od(this.sessionId)}async run(t,r,n){Pe();let s=[],p=[];Object.entries(t).forEach(i=>{let d=i[0],h=i[1],m=this.inputNames.indexOf(d);if(m===-1)throw new Error(`invalid input '${d}'`);s.push(h),p.push(m)});let l=[],c=[];Object.entries(r).forEach(i=>{let d=i[0],h=i[1],m=this.outputNames.indexOf(d);if(m===-1)throw new Error(`invalid output '${d}'`);l.push(h),c.push(m)});let o=s.map((i,d)=>ro(i,()=>`input "${this.inputNames[p[d]]}"`)),a=l.map((i,d)=>i?ro(i,()=>`output "${this.outputNames[c[d]]}"`):null),e=await Ed(this.sessionId,p,o,c,a,n),u={};for(let i=0;i<e.length;i++)u[this.outputNames[c[i]]]=l[i]??Gu(e[i]);return Ae(),u}startProfiling(){}endProfiling(){Id(this.sessionId)}}}),$d={};gr($d,{OnnxruntimeWebAssemblyBackend:()=>Bo,initializeFlags:()=>jo,wasmBackend:()=>Dd});var jo,Bo,Dd,hm=I(()=>{"use strict";zt(),Pd(),dm(),Qr(),jo=()=>{if((typeof j.wasm.initTimeout!="number"||j.wasm.initTimeout<0)&&(j.wasm.initTimeout=0),j.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 j.wasm.proxy!="boolean"&&(j.wasm.proxy=!1),typeof j.wasm.trace!="boolean"&&(j.wasm.trace=!1),typeof j.wasm.numThreads!="number"||!Number.isInteger(j.wasm.numThreads)||j.wasm.numThreads<=0)if(typeof self<"u"&&!self.crossOriginIsolated)j.wasm.numThreads=1;else{let t=typeof navigator>"u"?fh("node:os").cpus().length:navigator.hardwareConcurrency;j.wasm.numThreads=Math.min(4,Math.ceil((t||1)/2))}},Bo=class{async init(t){jo(),await xd(),await Td(t)}async createInferenceSessionHandler(t,r){let n=new Ad;return await n.loadModel(t,r),Promise.resolve(n)}},Dd=new Bo});zt();zt();zt();var fm="1.20.0",gm=cl;{let t=(sm(),zr(od)).onnxjsBackend;cr("webgl",t,-10)}{let t=(hm(),zr($d)).wasmBackend;cr("cpu",t,10),cr("wasm",t,10)}Object.defineProperty(j.versions,"web",{value:fm,enumerable:!0});export{sl as InferenceSession,no as TRACE,Pe as TRACE_FUNC_BEGIN,Ae as TRACE_FUNC_END,ft as Tensor,pl as TrainingSession,gm as default,j as env,cr as registerBackend};
|
|
1801
|
+
/*! Bundled license information:
|
|
1802
|
+
|
|
1803
|
+
onnxruntime-web/dist/ort.bundle.min.mjs:
|
|
1804
|
+
(*!
|
|
1805
|
+
* ONNX Runtime Web v1.20.0
|
|
1806
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1807
|
+
* Licensed under the MIT License.
|
|
1808
|
+
*)
|
|
1809
|
+
|
|
1810
|
+
onnxruntime-web/dist/ort.bundle.min.mjs:
|
|
1811
|
+
(*! Bundled license information:
|
|
1812
|
+
|
|
1813
|
+
long/index.js:
|
|
1814
|
+
(**
|
|
1815
|
+
* @license
|
|
1816
|
+
* Copyright 2009 The Closure Library Authors
|
|
1817
|
+
* Copyright 2020 Daniel Wirtz / The long.js Authors.
|
|
1818
|
+
*
|
|
1819
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1820
|
+
* you may not use this file except in compliance with the License.
|
|
1821
|
+
* You may obtain a copy of the License at
|
|
1822
|
+
*
|
|
1823
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1824
|
+
*
|
|
1825
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1826
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1827
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1828
|
+
* See the License for the specific language governing permissions and
|
|
1829
|
+
* limitations under the License.
|
|
1830
|
+
*
|
|
1831
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
1832
|
+
*)
|
|
1833
|
+
*)
|
|
1834
|
+
*/
|