diff --git "a/dist/ort.webgl.min.mjs" "b/dist/ort.webgl.min.mjs" new file mode 100755--- /dev/null +++ "b/dist/ort.webgl.min.mjs" @@ -0,0 +1,1826 @@ +/*! + * ONNX Runtime Web v1.23.0 + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. + */ +var pd=Object.create;var _n=Object.defineProperty;var hd=Object.getOwnPropertyDescriptor;var md=Object.getOwnPropertyNames;var bd=Object.getPrototypeOf,gd=Object.prototype.hasOwnProperty;var y=(r,t)=>()=>(r&&(t=r(r=0)),t);var O=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),ra=(r,t)=>{for(var n in t)_n(r,n,{get:t[n],enumerable:!0})},oa=(r,t,n,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of md(t))!gd.call(r,o)&&o!==n&&_n(r,o,{get:()=>t[o],enumerable:!(e=hd(t,o))||e.enumerable});return r};var E=(r,t,n)=>(n=r!=null?pd(bd(r)):{},oa(t||!r||!r.__esModule?_n(n,"default",{value:r,enumerable:!0}):n,r)),yd=r=>oa(_n({},"__esModule",{value:!0}),r);var xn,Oe,vn,Td,ia,Ar=y(()=>{xn=new Map,Oe=[],vn=(r,t,n)=>{if(t&&typeof t.init=="function"&&typeof t.createInferenceSessionHandler=="function"){let e=xn.get(r);if(e===void 0)xn.set(r,{backend:t,priority:n});else{if(e.priority>n)return;if(e.priority===n&&e.backend!==t)throw new Error(`cannot register backend "${r}" using priority ${n}`)}if(n>=0){let o=Oe.indexOf(r);o!==-1&&Oe.splice(o,1);for(let i=0;i{let t=xn.get(r);if(!t)return"backend not found.";if(t.initialized)return t.backend;if(t.aborted)return t.error;{let n=!!t.initPromise;try{return n||(t.initPromise=t.backend.init(r)),await t.initPromise,t.initialized=!0,t.backend}catch(e){return n||(t.error=`${e}`,t.aborted=!0),t.error}finally{delete t.initPromise}}},ia=async r=>{let t=r.executionProviders||[],n=t.map(u=>typeof u=="string"?u:u.name),e=n.length===0?Oe:n,o,i=[],a=new Set;for(let u of e){let l=await Td(u);typeof l=="string"?i.push({name:u,err:l}):(o||(o=l),o===l&&a.add(u))}if(!o)throw new Error(`no available backend found. ERR: ${i.map(u=>`[${u.name}] ${u.err}`).join(", ")}`);for(let{name:u,err:l}of i)n.includes(u)&&console.warn(`removing requested execution provider "${u}" from session options because it is not available: ${l}`);let s=t.filter(u=>a.has(typeof u=="string"?u:u.name));return[o,new Proxy(r,{get:(u,l)=>l==="executionProviders"?s:Reflect.get(u,l)})]}});var aa=y(()=>{Ar()});var sa,ua=y(()=>{sa="1.23.0"});var la,ct,Er=y(()=>{ua();la="warning",ct={wasm:{},webgl:{},webgpu:{},versions:{common:sa},set logLevel(r){if(r!==void 0){if(typeof r!="string"||["verbose","info","warning","error","fatal"].indexOf(r)===-1)throw new Error(`Unsupported logging level: ${r}`);la=r}},get logLevel(){return la}};Object.defineProperty(ct,"logLevel",{enumerable:!0})});var K,ca=y(()=>{Er();K=ct});var fa,da,pa=y(()=>{fa=(r,t)=>{let n=typeof document<"u"?document.createElement("canvas"):new OffscreenCanvas(1,1);n.width=r.dims[3],n.height=r.dims[2];let e=n.getContext("2d");if(e!=null){let o,i;t?.tensorLayout!==void 0&&t.tensorLayout==="NHWC"?(o=r.dims[2],i=r.dims[3]):(o=r.dims[3],i=r.dims[2]);let a=t?.format!==void 0?t.format:"RGB",s=t?.norm,u,l;s===void 0||s.mean===void 0?u=[255,255,255,255]:typeof s.mean=="number"?u=[s.mean,s.mean,s.mean,s.mean]:(u=[s.mean[0],s.mean[1],s.mean[2],0],s.mean[3]!==void 0&&(u[3]=s.mean[3])),s===void 0||s.bias===void 0?l=[0,0,0,0]:typeof s.bias=="number"?l=[s.bias,s.bias,s.bias,s.bias]:(l=[s.bias[0],s.bias[1],s.bias[2],0],s.bias[3]!==void 0&&(l[3]=s.bias[3]));let c=i*o,d=0,p=c,m=c*2,g=-1;a==="RGBA"?(d=0,p=c,m=c*2,g=c*3):a==="RGB"?(d=0,p=c,m=c*2):a==="RBG"&&(d=0,m=c,p=c*2);for(let b=0;b{let n=typeof document<"u"?document.createElement("canvas").getContext("2d"):new OffscreenCanvas(1,1).getContext("2d"),e;if(n!=null){let o,i,a;t?.tensorLayout!==void 0&&t.tensorLayout==="NHWC"?(o=r.dims[2],i=r.dims[1],a=r.dims[3]):(o=r.dims[3],i=r.dims[2],a=r.dims[1]);let s=t!==void 0&&t.format!==void 0?t.format:"RGB",u=t?.norm,l,c;u===void 0||u.mean===void 0?l=[255,255,255,255]:typeof u.mean=="number"?l=[u.mean,u.mean,u.mean,u.mean]:(l=[u.mean[0],u.mean[1],u.mean[2],255],u.mean[3]!==void 0&&(l[3]=u.mean[3])),u===void 0||u.bias===void 0?c=[0,0,0,0]:typeof u.bias=="number"?c=[u.bias,u.bias,u.bias,u.bias]:(c=[u.bias[0],u.bias[1],u.bias[2],0],u.bias[3]!==void 0&&(c[3]=u.bias[3]));let d=i*o;if(t!==void 0&&(t.format!==void 0&&a===4&&t.format!=="RGBA"||a===3&&t.format!=="RGB"&&t.format!=="BGR"))throw new Error("Tensor format doesn't match input tensor dims");let p=4,m=0,g=1,b=2,w=3,x=0,A=d,D=d*2,q=-1;s==="RGBA"?(x=0,A=d,D=d*2,q=d*3):s==="RGB"?(x=0,A=d,D=d*2):s==="RBG"&&(x=0,D=d,A=d*2),e=n.createImageData(o,i);for(let F=0;F{wn();Dr=(r,t)=>{if(r===void 0)throw new Error("Image buffer must be defined");if(t.height===void 0||t.width===void 0)throw new Error("Image height and width must be defined");if(t.tensorLayout==="NHWC")throw new Error("NHWC Tensor layout is not supported yet");let{height:n,width:e}=t,o=t.norm??{mean:255,bias:0},i,a;typeof o.mean=="number"?i=[o.mean,o.mean,o.mean,o.mean]:i=[o.mean[0],o.mean[1],o.mean[2],o.mean[3]??255],typeof o.bias=="number"?a=[o.bias,o.bias,o.bias,o.bias]:a=[o.bias[0],o.bias[1],o.bias[2],o.bias[3]??0];let s=t.format!==void 0?t.format:"RGBA",u=t.tensorFormat!==void 0&&t.tensorFormat!==void 0?t.tensorFormat:"RGB",l=n*e,c=u==="RGBA"?new Float32Array(l*4):new Float32Array(l*3),d=4,p=0,m=1,g=2,b=3,w=0,x=l,A=l*2,D=-1;s==="RGB"&&(d=3,p=0,m=1,g=2,b=-1),u==="RGBA"?D=l*3:u==="RBG"?(w=0,A=l,x=l*2):u==="BGR"&&(A=0,x=l,w=l*2);for(let F=0;F{let n=typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement,e=typeof ImageData<"u"&&r instanceof ImageData,o=typeof ImageBitmap<"u"&&r instanceof ImageBitmap,i=typeof r=="string",a,s=t??{},u=()=>{if(typeof document<"u")return document.createElement("canvas");if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(1,1);throw new Error("Canvas is not supported")},l=c=>typeof HTMLCanvasElement<"u"&&c instanceof HTMLCanvasElement||c instanceof OffscreenCanvas?c.getContext("2d"):null;if(n){let c=u();c.width=r.width,c.height=r.height;let d=l(c);if(d!=null){let p=r.height,m=r.width;if(t!==void 0&&t.resizedHeight!==void 0&&t.resizedWidth!==void 0&&(p=t.resizedHeight,m=t.resizedWidth),t!==void 0){if(s=t,t.tensorFormat!==void 0)throw new Error("Image input config format must be RGBA for HTMLImageElement");s.tensorFormat="RGBA",s.height=p,s.width=m}else s.tensorFormat="RGBA",s.height=p,s.width=m;d.drawImage(r,0,0),a=d.getImageData(0,0,m,p).data}else throw new Error("Can not access image data")}else if(e){let c,d;if(t!==void 0&&t.resizedWidth!==void 0&&t.resizedHeight!==void 0?(c=t.resizedHeight,d=t.resizedWidth):(c=r.height,d=r.width),t!==void 0&&(s=t),s.format="RGBA",s.height=c,s.width=d,t!==void 0){let p=u();p.width=d,p.height=c;let m=l(p);if(m!=null)m.putImageData(r,0,0),a=m.getImageData(0,0,d,c).data;else throw new Error("Can not access image data")}else a=r.data}else if(o){if(t===void 0)throw new Error("Please provide image config with format for Imagebitmap");let c=u();c.width=r.width,c.height=r.height;let d=l(c);if(d!=null){let p=r.height,m=r.width;return d.drawImage(r,0,0,m,p),a=d.getImageData(0,0,m,p).data,s.height=p,s.width=m,Dr(a,s)}else throw new Error("Can not access image data")}else{if(i)return new Promise((c,d)=>{let p=u(),m=l(p);if(!r||!m)return d();let g=new Image;g.crossOrigin="Anonymous",g.src=r,g.onload=()=>{p.width=g.width,p.height=g.height,m.drawImage(g,0,0,p.width,p.height);let b=m.getImageData(0,0,p.width,p.height);s.height=p.height,s.width=p.width,c(Dr(b.data,s))}});throw new Error("Input data provided is not supported - aborted tensor creation")}if(a!==void 0)return Dr(a,s);throw new Error("Input data provided is not supported - aborted tensor creation")},ma=(r,t)=>{let{width:n,height:e,download:o,dispose:i}=t,a=[1,e,n,4];return new et({location:"texture",type:"float32",texture:r,dims:a,download:o,dispose:i})},ba=(r,t)=>{let{dataType:n,dims:e,download:o,dispose:i}=t;return new et({location:"gpu-buffer",type:n??"float32",gpuBuffer:r,dims:e,download:o,dispose:i})},ga=(r,t)=>{let{dataType:n,dims:e,download:o,dispose:i}=t;return new et({location:"ml-tensor",type:n??"float32",mlTensor:r,dims:e,download:o,dispose:i})},ya=(r,t,n)=>new et({location:"cpu-pinned",type:r,data:t,dims:n??[t.length]})});var Pe,Qe,_a,xa,va=y(()=>{Pe=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array],["int4",Uint8Array],["uint4",Uint8Array]]),Qe=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]),_a=!1,xa=()=>{if(!_a){_a=!0;let r=typeof BigInt64Array<"u"&&BigInt64Array.from,t=typeof BigUint64Array<"u"&&BigUint64Array.from,n=globalThis.Float16Array,e=typeof n<"u"&&n.from;r&&(Pe.set("int64",BigInt64Array),Qe.set(BigInt64Array,"int64")),t&&(Pe.set("uint64",BigUint64Array),Qe.set(BigUint64Array,"uint64")),e?(Pe.set("float16",n),Qe.set(n,"float16")):Pe.set("float16",Uint16Array)}}});var wa,Ia,Oa=y(()=>{wn();wa=r=>{let t=1;for(let n=0;n{switch(r.location){case"cpu":return new et(r.type,r.data,t);case"cpu-pinned":return new et({location:"cpu-pinned",data:r.data,type:r.type,dims:t});case"texture":return new et({location:"texture",texture:r.texture,type:r.type,dims:t});case"gpu-buffer":return new et({location:"gpu-buffer",gpuBuffer:r.gpuBuffer,type:r.type,dims:t});case"ml-tensor":return new et({location:"ml-tensor",mlTensor:r.mlTensor,type:r.type,dims:t});default:throw new Error(`tensorReshape: tensor location ${r.location} is not supported`)}}});var et,wn=y(()=>{pa();Ta();va();Oa();et=class{constructor(t,n,e){xa();let o,i;if(typeof t=="object"&&"location"in t)switch(this.dataLocation=t.location,o=t.type,i=t.dims,t.location){case"cpu-pinned":{let s=Pe.get(o);if(!s)throw new TypeError(`unsupported type "${o}" to create tensor from pinned buffer`);if(!(t.data instanceof s))throw new TypeError(`buffer should be of type ${s.name}`);this.cpuData=t.data;break}case"texture":{if(o!=="float32")throw new TypeError(`unsupported type "${o}" to create tensor from texture`);this.gpuTextureData=t.texture,this.downloader=t.download,this.disposer=t.dispose;break}case"gpu-buffer":{if(o!=="float32"&&o!=="float16"&&o!=="int32"&&o!=="int64"&&o!=="uint32"&&o!=="uint8"&&o!=="bool"&&o!=="uint4"&&o!=="int4")throw new TypeError(`unsupported type "${o}" to create tensor from gpu buffer`);this.gpuBufferData=t.gpuBuffer,this.downloader=t.download,this.disposer=t.dispose;break}case"ml-tensor":{if(o!=="float32"&&o!=="float16"&&o!=="int32"&&o!=="int64"&&o!=="uint32"&&o!=="uint64"&&o!=="int8"&&o!=="uint8"&&o!=="bool"&&o!=="uint4"&&o!=="int4")throw new TypeError(`unsupported type "${o}" 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 s,u;if(typeof t=="string")if(o=t,u=e,t==="string"){if(!Array.isArray(n))throw new TypeError("A string tensor's data must be a string array.");s=n}else{let l=Pe.get(t);if(l===void 0)throw new TypeError(`Unsupported tensor type: ${t}.`);if(Array.isArray(n)){if(t==="float16"&&l===Uint16Array||t==="uint4"||t==="int4")throw new TypeError(`Creating a ${t} tensor from number array is not supported. Please use ${l.name} as data.`);t==="uint64"||t==="int64"?s=l.from(n,BigInt):s=l.from(n)}else if(n instanceof l)s=n;else if(n instanceof Uint8ClampedArray)if(t==="uint8")s=Uint8Array.from(n);else throw new TypeError("A Uint8ClampedArray tensor's data must be type of uint8");else if(t==="float16"&&n instanceof Uint16Array&&l!==Uint16Array)s=new globalThis.Float16Array(n.buffer,n.byteOffset,n.length);else throw new TypeError(`A ${o} tensor's data must be type of ${l}`)}else if(u=n,Array.isArray(t)){if(t.length===0)throw new TypeError("Tensor type cannot be inferred from an empty array.");let l=typeof t[0];if(l==="string")o="string",s=t;else if(l==="boolean")o="bool",s=Uint8Array.from(t);else throw new TypeError(`Invalid element type of data array: ${l}.`)}else if(t instanceof Uint8ClampedArray)o="uint8",s=Uint8Array.from(t);else{let l=Qe.get(t.constructor);if(l===void 0)throw new TypeError(`Unsupported type for tensor data: ${t.constructor}.`);o=l,s=t}if(u===void 0)u=[s.length];else if(!Array.isArray(u))throw new TypeError("A tensor's dims must be a number array");i=u,this.cpuData=s,this.dataLocation="cpu"}let a=wa(i);if(this.cpuData&&a!==this.cpuData.length&&!((o==="uint4"||o==="int4")&&Math.ceil(a/2)===this.cpuData.length))throw new Error(`Tensor's size(${a}) does not match data length(${this.cpuData.length}).`);this.type=o,this.dims=i,this.size=a}static async fromImage(t,n){return ha(t,n)}static fromTexture(t,n){return ma(t,n)}static fromGpuBuffer(t,n){return ba(t,n)}static fromMLTensor(t,n){return ga(t,n)}static fromPinnedBuffer(t,n,e){return ya(t,n,e)}toDataURL(t){return fa(this,t)}toImageData(t){return da(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 n=await this.downloader();return this.downloader=void 0,this.dataLocation="cpu",this.cpuData=n,t&&this.disposer&&(this.disposer(),this.disposer=void 0),n}finally{this.isDownloading=!1}}default:throw new Error(`cannot get data from location: ${this.dataLocation}`)}}dispose(){if(this.isDownloading)throw new Error("The current tensor is being downloaded.");this.disposer&&(this.disposer(),this.disposer=void 0),this.cpuData=void 0,this.gpuTextureData=void 0,this.gpuBufferData=void 0,this.mlTensorData=void 0,this.downloader=void 0,this.isDownloading=void 0,this.dataLocation="none"}ensureValid(){if(this.dataLocation==="none")throw new Error("The tensor is disposed.")}reshape(t){if(this.ensureValid(),this.downloader||this.disposer)throw new Error("Cannot reshape a tensor that owns GPU resource.");return Ia(this,t)}}});var de,Lr=y(()=>{wn();de=et});var Pa,Sa,In,On,$r=y(()=>{Er();Pa=(r,t)=>{(typeof ct.trace>"u"?!ct.wasm.trace:!ct.trace)||console.timeStamp(`${r}::ORT::${t}`)},Sa=(r,t)=>{let n=new Error().stack?.split(/\r\n|\r|\n/g)||[],e=!1;for(let o=0;o{(typeof ct.trace>"u"?!ct.wasm.trace:!ct.trace)||Sa("BEGIN",r)},On=r=>{(typeof ct.trace>"u"?!ct.wasm.trace:!ct.trace)||Sa("END",r)}});var Pn,Aa=y(()=>{Ar();Lr();$r();Pn=class r{constructor(t){this.handler=t}async run(t,n,e){In();let o={},i={};if(typeof t!="object"||t===null||t instanceof de||Array.isArray(t))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let a=!0;if(typeof n=="object"){if(n===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(n instanceof de)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.");a=!1;for(let l of n){if(typeof l!="string")throw new TypeError("'fetches' must be a string array or an object.");if(this.outputNames.indexOf(l)===-1)throw new RangeError(`'fetches' contains invalid output name: ${l}.`);o[l]=null}if(typeof e=="object"&&e!==null)i=e;else if(typeof e<"u")throw new TypeError("'options' must be an object.")}else{let l=!1,c=Object.getOwnPropertyNames(n);for(let d of this.outputNames)if(c.indexOf(d)!==-1){let p=n[d];(p===null||p instanceof de)&&(l=!0,a=!1,o[d]=p)}if(l){if(typeof e=="object"&&e!==null)i=e;else if(typeof e<"u")throw new TypeError("'options' must be an object.")}else i=n}}else if(typeof n<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let l of this.inputNames)if(typeof t[l]>"u")throw new Error(`input '${l}' is missing in 'feeds'.`);if(a)for(let l of this.outputNames)o[l]=null;let s=await this.handler.run(t,o,i),u={};for(let l in s)if(Object.hasOwnProperty.call(s,l)){let c=s[l];c instanceof de?u[l]=c:u[l]=new de(c.type,c.data,c.dims)}return On(),u}async release(){return this.handler.dispose()}static async create(t,n,e,o){In();let i,a={};if(typeof t=="string"){if(i=t,typeof n=="object"&&n!==null)a=n;else if(typeof n<"u")throw new TypeError("'options' must be an object.")}else if(t instanceof Uint8Array){if(i=t,typeof n=="object"&&n!==null)a=n;else if(typeof n<"u")throw new TypeError("'options' must be an object.")}else if(t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer){let c=t,d=0,p=t.byteLength;if(typeof n=="object"&&n!==null)a=n;else if(typeof n=="number"){if(d=n,!Number.isSafeInteger(d))throw new RangeError("'byteOffset' must be an integer.");if(d<0||d>=c.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${c.byteLength}).`);if(p=t.byteLength-d,typeof e=="number"){if(p=e,!Number.isSafeInteger(p))throw new RangeError("'byteLength' must be an integer.");if(p<=0||d+p>c.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${c.byteLength-d}].`);if(typeof o=="object"&&o!==null)a=o;else if(typeof o<"u")throw new TypeError("'options' must be an object.")}else if(typeof e<"u")throw new TypeError("'byteLength' must be a number.")}else if(typeof n<"u")throw new TypeError("'options' must be an object.");i=new Uint8Array(c,d,p)}else throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");let[s,u]=await ia(a),l=await s.createInferenceSessionHandler(i,u);return On(),new r(l)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}get inputMetadata(){return this.handler.inputMetadata}get outputMetadata(){return this.handler.outputMetadata}}});var _d,Ea=y(()=>{Aa();_d=Pn});var Da=y(()=>{});var La=y(()=>{});var $a=y(()=>{});var Na=y(()=>{});var Nr={};ra(Nr,{InferenceSession:()=>_d,TRACE:()=>Pa,TRACE_FUNC_BEGIN:()=>In,TRACE_FUNC_END:()=>On,Tensor:()=>de,env:()=>K,registerBackend:()=>vn});var me=y(()=>{aa();ca();Ea();Lr();Da();La();$r();$a();Na()});function be(r,t,n,e){if(t===void 0)return vd(r);if(n===void 0)Sn(r,t,1);else if(typeof n=="number"&&e===void 0)Sn(r,t,n);else if(typeof n=="string"&&e===void 0)Sn(r,n,1,t);else if(typeof n=="string"&&typeof e=="number")Sn(r,n,e,t);else throw new TypeError("input is valid")}function vd(r){return{verbose:be.verbose.bind(null,r),info:be.info.bind(null,r),warning:be.warning.bind(null,r),error:be.error.bind(null,r),fatal:be.fatal.bind(null,r)}}function Sn(r,t,n,e){let o=tn[e||""]||tn[""];Ca[r]{"use strict";Fr=class{log(t,n,e){}},Cr=class{log(t,n,e){console.log(`${this.color(t)} ${e?"\x1B[35m"+e+"\x1B[0m ":""}${n}`)}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}`)}}},Ca={verbose:1e3,info:2e3,warning:4e3,error:5e3,fatal:6e3},xd={none:new Fr,console:new Cr},Ra={provider:"console",minimalSeverity:"warning",logDateTime:!0,logSourceLocation:!1},tn={"":Ra};(u=>{function r(l,c){u("verbose",l,c)}u.verbose=r;function t(l,c){u("info",l,c)}u.info=t;function n(l,c){u("warning",l,c)}u.warning=n;function e(l,c){u("error",l,c)}u.error=e;function o(l,c){u("fatal",l,c)}u.fatal=o;function i(l){tn={},a("",l||{})}u.reset=i;function a(l,c){if(l==="*")i(c);else{let d=tn[l]||Ra;tn[l]={provider:c.provider||d.provider,minimalSeverity:c.minimalSeverity||d.minimalSeverity,logDateTime:c.logDateTime===void 0?d.logDateTime:c.logDateTime,logSourceLocation:c.logSourceLocation===void 0?d.logSourceLocation:c.logSourceLocation}}}u.set=a;function s(l){let c={};l.logLevel&&(c.minimalSeverity=l.logLevel),a("",c)}u.setWithEnv=s})(be||={});B=be,En=class{constructor(t,n,e,o,i,a){this.category=t;this.name=n;this.startTime=e;this.endCallback=o;this.timer=i;this.ctx=a}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)}},Dn=class{constructor(t,n,e,o){this.category=t;this.name=n;this.startTime=e;this.endTime=o}},Ln=class{constructor(t,n,e){this._started=!1;this._flushPointer=0;this._started=!1,this._maxNumberEvents=t===void 0?1e4:t,this._flushBatchSize=n===void 0?10:n,this._flushIntervalInMilliseconds=e===void 0?5e3:e}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=An(),this._flushPointer=0}stop(){for(this._started=!1;this._flushPointer{s.then(async c=>{i&&await i.end(),u(c)},async c=>{i&&await i.end(),l(c)})});if(!a&&i){let u=i.end();if(u&&typeof u.then=="function")return new Promise((l,c)=>{u.then(()=>{l(s)},d=>{c(d)})})}return s}begin(t,n,e){if(!this._started)throw new Error("profiler is not started yet");if(e===void 0){let o=An();return this.flush(o),new En(t,n,o,i=>this.endSync(i))}else{let o=e.beginTimer();return new En(t,n,0,async i=>this.end(i),o,e)}}async end(t){let n=await t.checkTimer();this._timingEvents.length=this._flushBatchSize||t-this._flushTime>=this._flushIntervalInMilliseconds){for(let n=this._flushPointer;this._flushPointerperformance.now():Date.now});function Ga(r,t,n){for(let e of n){let o=e[0],i=e[1],a=e[2],s=e[3],u=e[4];if(r.opType===o){for(let l of t)if((l.domain===i||l.domain==="ai.onnx"&&i==="")&&wd(l.version,a))return{opImpl:s,opInit:u}}}throw new TypeError(`cannot resolve operator '${r.opType}' with opsets: ${t.map(e=>`${e.domain||"ai.onnx"} v${e.version}`).join(", ")}`)}function wd(r,t){if(t.endsWith("+")){let n=Number.parseInt(t.substring(0,t.length-1),10);return!isNaN(n)&&n<=r}else if(t.split("-").length===2){let n=t.split("-"),e=Number.parseInt(n[0],10),o=Number.parseInt(n[1],10);return!isNaN(e)&&!isNaN(o)&&e<=r&&r<=o}else return Number.parseInt(t,10)===r}var ka=y(()=>{"use strict"});var Ma=O(Rr=>{"use strict";Rr.__esModule=!0;var Id=function(){function r(t){if(!t)throw new TypeError("Invalid argument; `value` has no value.");this.value=r.EMPTY,t&&r.isGuid(t)&&(this.value=t)}return r.isGuid=function(t){var n=t.toString();return t&&(t instanceof r||r.validator.test(n))},r.create=function(){return new r([r.gen(2),r.gen(1),r.gen(1),r.gen(1),r.gen(3)].join("-"))},r.createEmpty=function(){return new r("emptyguid")},r.parse=function(t){return new r(t)},r.raw=function(){return[r.gen(2),r.gen(1),r.gen(1),r.gen(1),r.gen(3)].join("-")},r.gen=function(t){for(var n="",e=0;e>>=0,(o=0<=r&&r<256)&&(e=za[r],e)?e:(n=k(r,0,!0),o&&(za[r]=n),n)):(r|=0,(o=-128<=r&&r<128)&&(e=Ba[r],e)?e:(n=k(r,r<0?-1:0,!1),o&&(Ba[r]=n),n))}function ht(r,t){if(isNaN(r))return t?pe:vt;if(t){if(r<0)return pe;if(r>=Ha)return Xa}else{if(r<=-ja)return at;if(r+1>=ja)return Ka}return r<0?ht(-r,t).neg():k(r%ze|0,r/ze|0,t)}function k(r,t,n){return new z(r,t,n)}function kr(r,t,n){if(r.length===0)throw Error("empty string");if(typeof t=="number"?(n=t,t=!1):t=!!t,r==="NaN"||r==="Infinity"||r==="+Infinity"||r==="-Infinity")return t?pe:vt;if(n=n||10,n<2||360)throw Error("interior hyphen");if(e===0)return kr(r.substring(1),t,n).neg();for(var o=ht($n(n,8)),i=vt,a=0;a{pt=null;try{pt=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{}z.prototype.__isLong__;Object.defineProperty(z.prototype,"__isLong__",{value:!0});z.isLong=rt;Ba={},za={};z.fromInt=Se;z.fromNumber=ht;z.fromBits=k;$n=Math.pow;z.fromString=kr;z.fromValue=wt;Ua=65536,Od=1<<24,ze=Ua*Ua,Ha=ze*ze,ja=Ha/2,Wa=Se(Od),vt=Se(0);z.ZERO=vt;pe=Se(0,!0);z.UZERO=pe;Be=Se(1);z.ONE=Be;qa=Se(1,!0);z.UONE=qa;Gr=Se(-1);z.NEG_ONE=Gr;Ka=k(-1,2147483647,!1);z.MAX_VALUE=Ka;Xa=k(-1,-1,!0);z.MAX_UNSIGNED_VALUE=Xa;at=k(0,-2147483648,!1);z.MIN_VALUE=at;T=z.prototype;T.toInt=function(){return this.unsigned?this.low>>>0:this.low};T.toNumber=function(){return this.unsigned?(this.high>>>0)*ze+(this.low>>>0):this.high*ze+(this.low>>>0)};T.toString=function(t){if(t=t||10,t<2||36>>0,c=l.toString(t);if(a=u,a.isZero())return c+s;for(;c.length<6;)c="0"+c;s=""+c+s}};T.getHighBits=function(){return this.high};T.getHighBitsUnsigned=function(){return this.high>>>0};T.getLowBits=function(){return this.low};T.getLowBitsUnsigned=function(){return this.low>>>0};T.getNumBitsAbs=function(){if(this.isNegative())return this.eq(at)?64:this.neg().getNumBitsAbs();for(var t=this.high!=0?this.high:this.low,n=31;n>0&&(t&1<=0};T.isOdd=function(){return(this.low&1)===1};T.isEven=function(){return(this.low&1)===0};T.equals=function(t){return rt(t)||(t=wt(t)),this.unsigned!==t.unsigned&&this.high>>>31===1&&t.high>>>31===1?!1:this.high===t.high&&this.low===t.low};T.eq=T.equals;T.notEquals=function(t){return!this.eq(t)};T.neq=T.notEquals;T.ne=T.notEquals;T.lessThan=function(t){return this.comp(t)<0};T.lt=T.lessThan;T.lessThanOrEqual=function(t){return this.comp(t)<=0};T.lte=T.lessThanOrEqual;T.le=T.lessThanOrEqual;T.greaterThan=function(t){return this.comp(t)>0};T.gt=T.greaterThan;T.greaterThanOrEqual=function(t){return this.comp(t)>=0};T.gte=T.greaterThanOrEqual;T.ge=T.greaterThanOrEqual;T.compare=function(t){if(rt(t)||(t=wt(t)),this.eq(t))return 0;var n=this.isNegative(),e=t.isNegative();return n&&!e?-1:!n&&e?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};T.comp=T.compare;T.negate=function(){return!this.unsigned&&this.eq(at)?at:this.not().add(Be)};T.neg=T.negate;T.add=function(t){rt(t)||(t=wt(t));var n=this.high>>>16,e=this.high&65535,o=this.low>>>16,i=this.low&65535,a=t.high>>>16,s=t.high&65535,u=t.low>>>16,l=t.low&65535,c=0,d=0,p=0,m=0;return m+=i+l,p+=m>>>16,m&=65535,p+=o+u,d+=p>>>16,p&=65535,d+=e+s,c+=d>>>16,d&=65535,c+=n+a,c&=65535,k(p<<16|m,c<<16|d,this.unsigned)};T.subtract=function(t){return rt(t)||(t=wt(t)),this.add(t.neg())};T.sub=T.subtract;T.multiply=function(t){if(this.isZero())return this;if(rt(t)||(t=wt(t)),pt){var n=pt.mul(this.low,this.high,t.low,t.high);return k(n,pt.get_high(),this.unsigned)}if(t.isZero())return this.unsigned?pe:vt;if(this.eq(at))return t.isOdd()?at:vt;if(t.eq(at))return this.isOdd()?at:vt;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(Wa)&&t.lt(Wa))return ht(this.toNumber()*t.toNumber(),this.unsigned);var e=this.high>>>16,o=this.high&65535,i=this.low>>>16,a=this.low&65535,s=t.high>>>16,u=t.high&65535,l=t.low>>>16,c=t.low&65535,d=0,p=0,m=0,g=0;return g+=a*c,m+=g>>>16,g&=65535,m+=i*c,p+=m>>>16,m&=65535,m+=a*l,p+=m>>>16,m&=65535,p+=o*c,d+=p>>>16,p&=65535,p+=i*l,d+=p>>>16,p&=65535,p+=a*u,d+=p>>>16,p&=65535,d+=e*c+o*l+i*u+a*s,d&=65535,k(m<<16|g,d<<16|p,this.unsigned)};T.mul=T.multiply;T.divide=function(t){if(rt(t)||(t=wt(t)),t.isZero())throw Error("division by zero");if(pt){if(!this.unsigned&&this.high===-2147483648&&t.low===-1&&t.high===-1)return this;var n=(this.unsigned?pt.div_u:pt.div_s)(this.low,this.high,t.low,t.high);return k(n,pt.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?pe:vt;var e,o,i;if(this.unsigned){if(t.unsigned||(t=t.toUnsigned()),t.gt(this))return pe;if(t.gt(this.shru(1)))return qa;i=pe}else{if(this.eq(at)){if(t.eq(Be)||t.eq(Gr))return at;if(t.eq(at))return Be;var a=this.shr(1);return e=a.div(t).shl(1),e.eq(vt)?t.isNegative()?Be:Gr:(o=this.sub(t.mul(e)),i=e.add(o.div(t)),i)}else if(t.eq(at))return this.unsigned?pe:vt;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();i=vt}for(o=this;o.gte(t);){e=Math.max(1,Math.floor(o.toNumber()/t.toNumber()));for(var s=Math.ceil(Math.log(e)/Math.LN2),u=s<=48?1:$n(2,s-48),l=ht(e),c=l.mul(t);c.isNegative()||c.gt(o);)e-=u,l=ht(e,this.unsigned),c=l.mul(t);l.isZero()&&(l=Be),i=i.add(l),o=o.sub(c)}return i};T.div=T.divide;T.modulo=function(t){if(rt(t)||(t=wt(t)),pt){var n=(this.unsigned?pt.rem_u:pt.rem_s)(this.low,this.high,t.low,t.high);return k(n,pt.get_high(),this.unsigned)}return this.sub(this.div(t).mul(t))};T.mod=T.modulo;T.rem=T.modulo;T.not=function(){return k(~this.low,~this.high,this.unsigned)};T.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32};T.clz=T.countLeadingZeros;T.countTrailingZeros=function(){return this.low?Va(this.low):Va(this.high)+32};T.ctz=T.countTrailingZeros;T.and=function(t){return rt(t)||(t=wt(t)),k(this.low&t.low,this.high&t.high,this.unsigned)};T.or=function(t){return rt(t)||(t=wt(t)),k(this.low|t.low,this.high|t.high,this.unsigned)};T.xor=function(t){return rt(t)||(t=wt(t)),k(this.low^t.low,this.high^t.high,this.unsigned)};T.shiftLeft=function(t){return rt(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?k(this.low<>>32-t,this.unsigned):k(0,this.low<>>t|this.high<<32-t,this.high>>t,this.unsigned):k(this.high>>t-32,this.high>=0?0:-1,this.unsigned)};T.shr=T.shiftRight;T.shiftRightUnsigned=function(t){return rt(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?k(this.low>>>t|this.high<<32-t,this.high>>>t,this.unsigned):t===32?k(this.high,0,this.unsigned):k(this.high>>>t-32,0,this.unsigned)};T.shru=T.shiftRightUnsigned;T.shr_u=T.shiftRightUnsigned;T.rotateLeft=function(t){var n;return rt(t)&&(t=t.toInt()),(t&=63)===0?this:t===32?k(this.high,this.low,this.unsigned):t<32?(n=32-t,k(this.low<>>n,this.high<>>n,this.unsigned)):(t-=32,n=32-t,k(this.high<>>n,this.low<>>n,this.unsigned))};T.rotl=T.rotateLeft;T.rotateRight=function(t){var n;return rt(t)&&(t=t.toInt()),(t&=63)===0?this:t===32?k(this.high,this.low,this.unsigned):t<32?(n=32-t,k(this.high<>>t,this.low<>>t,this.unsigned)):(t-=32,n=32-t,k(this.low<>>t,this.high<>>t,this.unsigned))};T.rotr=T.rotateRight;T.toSigned=function(){return this.unsigned?k(this.low,this.high,!1):this};T.toUnsigned=function(){return this.unsigned?this:k(this.low,this.high,!0)};T.toBytes=function(t){return t?this.toBytesLE():this.toBytesBE()};T.toBytesLE=function(){var t=this.high,n=this.low;return[n&255,n>>>8&255,n>>>16&255,n>>>24,t&255,t>>>8&255,t>>>16&255,t>>>24]};T.toBytesBE=function(){var t=this.high,n=this.low;return[t>>>24,t>>>16&255,t>>>8&255,t&255,n>>>24,n>>>16&255,n>>>8&255,n&255]};z.fromBytes=function(t,n,e){return e?z.fromBytesLE(t,n):z.fromBytesBE(t,n)};z.fromBytesLE=function(t,n){return new z(t[0]|t[1]<<8|t[2]<<16|t[3]<<24,t[4]|t[5]<<8|t[6]<<16|t[7]<<24,n)};z.fromBytesBE=function(t,n){return new z(t[4]<<24|t[5]<<16|t[6]<<8|t[7],t[0]<<24|t[1]<<16|t[2]<<8|t[3],n)};ge=z});var Vr=O(Nn=>{"use strict";Object.defineProperty(Nn,"__esModule",{value:!0});Nn.ArgType=void 0;var Za;(function(r){r[r.INPUT=0]="INPUT",r[r.OUTPUT=1]="OUTPUT"})(Za||(Nn.ArgType=Za={}))});var Ae=O(Et=>{"use strict";Object.defineProperty(Et,"__esModule",{value:!0});Et.SIZE_PREFIX_LENGTH=Et.FILE_IDENTIFIER_LENGTH=Et.SIZEOF_INT=Et.SIZEOF_SHORT=void 0;Et.SIZEOF_SHORT=2;Et.SIZEOF_INT=4;Et.FILE_IDENTIFIER_LENGTH=4;Et.SIZE_PREFIX_LENGTH=4});var Br=O(mt=>{"use strict";Object.defineProperty(mt,"__esModule",{value:!0});mt.isLittleEndian=mt.float64=mt.float32=mt.int32=void 0;mt.int32=new Int32Array(2);mt.float32=new Float32Array(mt.int32.buffer);mt.float64=new Float64Array(mt.int32.buffer);mt.isLittleEndian=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1});var zr=O(Fn=>{"use strict";Object.defineProperty(Fn,"__esModule",{value:!0});Fn.Encoding=void 0;var Ja;(function(r){r[r.UTF8_BYTES=1]="UTF8_BYTES",r[r.UTF16_STRING=2]="UTF16_STRING"})(Ja||(Fn.Encoding=Ja={}))});var jr=O(Cn=>{"use strict";Object.defineProperty(Cn,"__esModule",{value:!0});Cn.ByteBuffer=void 0;var Dt=Ae(),st=Br(),Pd=zr(),Ur=class r{constructor(t){this.bytes_=t,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(t){return new r(new Uint8Array(t))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(t){this.position_=t}capacity(){return this.bytes_.length}readInt8(t){return this.readUint8(t)<<24>>24}readUint8(t){return this.bytes_[t]}readInt16(t){return this.readUint16(t)<<16>>16}readUint16(t){return this.bytes_[t]|this.bytes_[t+1]<<8}readInt32(t){return this.bytes_[t]|this.bytes_[t+1]<<8|this.bytes_[t+2]<<16|this.bytes_[t+3]<<24}readUint32(t){return this.readInt32(t)>>>0}readInt64(t){return BigInt.asIntN(64,BigInt(this.readUint32(t))+(BigInt(this.readUint32(t+4))<>8}writeUint16(t,n){this.bytes_[t]=n,this.bytes_[t+1]=n>>8}writeInt32(t,n){this.bytes_[t]=n,this.bytes_[t+1]=n>>8,this.bytes_[t+2]=n>>16,this.bytes_[t+3]=n>>24}writeUint32(t,n){this.bytes_[t]=n,this.bytes_[t+1]=n>>8,this.bytes_[t+2]=n>>16,this.bytes_[t+3]=n>>24}writeInt64(t,n){this.writeInt32(t,Number(BigInt.asIntN(32,n))),this.writeInt32(t+4,Number(BigInt.asIntN(32,n>>BigInt(32))))}writeUint64(t,n){this.writeUint32(t,Number(BigInt.asUintN(32,n))),this.writeUint32(t+4,Number(BigInt.asUintN(32,n>>BigInt(32))))}writeFloat32(t,n){st.float32[0]=n,this.writeInt32(t,st.int32[0])}writeFloat64(t,n){st.float64[0]=n,this.writeInt32(t,st.int32[st.isLittleEndian?0:1]),this.writeInt32(t+4,st.int32[st.isLittleEndian?1:0])}getBufferIdentifier(){if(this.bytes_.length{"use strict";Object.defineProperty(Rn,"__esModule",{value:!0});Rn.Builder=void 0;var Ya=jr(),ft=Ae(),Wr=class r{constructor(t){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,this.string_maps=null,this.text_encoder=new TextEncoder;let n;t?n=t:n=1024,this.bb=Ya.ByteBuffer.allocate(n),this.space=n}clear(){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,this.string_maps=null}forceDefaults(t){this.force_defaults=t}dataBuffer(){return this.bb}asUint8Array(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())}prep(t,n){t>this.minalign&&(this.minalign=t);let e=~(this.bb.capacity()-this.space+n)+1&t-1;for(;this.space=0&&this.vtable[n]==0;n--);let e=n+1;for(;n>=0;n--)this.addInt16(this.vtable[n]!=0?t-this.vtable[n]:0);let o=2;this.addInt16(t-this.object_start);let i=(e+o)*ft.SIZEOF_SHORT;this.addInt16(i);let a=0,s=this.space;t:for(n=0;n=0;a--)this.writeInt8(i.charCodeAt(a))}this.prep(this.minalign,ft.SIZEOF_INT+o),this.addOffset(t),o&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(t,n){this.finish(t,n,!0)}requiredField(t,n){let e=this.bb.capacity()-t,o=e-this.bb.readInt32(e);if(!(n{"use strict";Object.defineProperty(W,"__esModule",{value:!0});W.ByteBuffer=W.Builder=W.Encoding=W.isLittleEndian=W.float64=W.float32=W.int32=W.SIZE_PREFIX_LENGTH=W.FILE_IDENTIFIER_LENGTH=W.SIZEOF_INT=W.SIZEOF_SHORT=void 0;var Sd=Ae();Object.defineProperty(W,"SIZEOF_SHORT",{enumerable:!0,get:function(){return Sd.SIZEOF_SHORT}});var Ad=Ae();Object.defineProperty(W,"SIZEOF_INT",{enumerable:!0,get:function(){return Ad.SIZEOF_INT}});var Ed=Ae();Object.defineProperty(W,"FILE_IDENTIFIER_LENGTH",{enumerable:!0,get:function(){return Ed.FILE_IDENTIFIER_LENGTH}});var Dd=Ae();Object.defineProperty(W,"SIZE_PREFIX_LENGTH",{enumerable:!0,get:function(){return Dd.SIZE_PREFIX_LENGTH}});var Gn=Br();Object.defineProperty(W,"int32",{enumerable:!0,get:function(){return Gn.int32}});Object.defineProperty(W,"float32",{enumerable:!0,get:function(){return Gn.float32}});Object.defineProperty(W,"float64",{enumerable:!0,get:function(){return Gn.float64}});Object.defineProperty(W,"isLittleEndian",{enumerable:!0,get:function(){return Gn.isLittleEndian}});var Ld=zr();Object.defineProperty(W,"Encoding",{enumerable:!0,get:function(){return Ld.Encoding}});var $d=Qa();Object.defineProperty(W,"Builder",{enumerable:!0,get:function(){return $d.Builder}});var Nd=jr();Object.defineProperty(W,"ByteBuffer",{enumerable:!0,get:function(){return Nd.ByteBuffer}})});var qr=O(Lt=>{"use strict";var Fd=Lt&&Lt.__createBinding||(Object.create?function(r,t,n,e){e===void 0&&(e=n);var o=Object.getOwnPropertyDescriptor(t,n);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(r,e,o)}:function(r,t,n,e){e===void 0&&(e=n),r[e]=t[n]}),Cd=Lt&&Lt.__setModuleDefault||(Object.create?function(r,t){Object.defineProperty(r,"default",{enumerable:!0,value:t})}:function(r,t){r.default=t}),Rd=Lt&&Lt.__importStar||function(r){if(r&&r.__esModule)return r;var t={};if(r!=null)for(var n in r)n!=="default"&&Object.prototype.hasOwnProperty.call(r,n)&&Fd(t,r,n);return Cd(t,r),t};Object.defineProperty(Lt,"__esModule",{value:!0});Lt.ArgTypeAndIndex=void 0;var Gd=Rd(M()),ts=Vr(),Hr=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsArgTypeAndIndex(t,n){return(n||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsArgTypeAndIndex(t,n){return t.setPosition(t.position()+Gd.SIZE_PREFIX_LENGTH),(n||new r).__init(t.readInt32(t.position())+t.position(),t)}argType(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt8(this.bb_pos+t):ts.ArgType.INPUT}index(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint32(this.bb_pos+t):0}static startArgTypeAndIndex(t){t.startObject(2)}static addArgType(t,n){t.addFieldInt8(0,n,ts.ArgType.INPUT)}static addIndex(t,n){t.addFieldInt32(1,n,0)}static endArgTypeAndIndex(t){return t.endObject()}static createArgTypeAndIndex(t,n,e){return r.startArgTypeAndIndex(t),r.addArgType(t,n),r.addIndex(t,e),r.endArgTypeAndIndex(t)}};Lt.ArgTypeAndIndex=Hr});var Kr=O(kn=>{"use strict";Object.defineProperty(kn,"__esModule",{value:!0});kn.AttributeType=void 0;var es;(function(r){r[r.UNDEFINED=0]="UNDEFINED",r[r.FLOAT=1]="FLOAT",r[r.INT=2]="INT",r[r.STRING=3]="STRING",r[r.TENSOR=4]="TENSOR",r[r.GRAPH=5]="GRAPH",r[r.FLOATS=6]="FLOATS",r[r.INTS=7]="INTS",r[r.STRINGS=8]="STRINGS",r[r.TENSORS=9]="TENSORS",r[r.GRAPHS=10]="GRAPHS",r[r.SPARSE_TENSOR=11]="SPARSE_TENSOR",r[r.SPARSE_TENSORS=12]="SPARSE_TENSORS"})(es||(kn.AttributeType=es={}))});var Xr=O(Mn=>{"use strict";Object.defineProperty(Mn,"__esModule",{value:!0});Mn.NodeType=void 0;var ns;(function(r){r[r.Primitive=0]="Primitive",r[r.Fused=1]="Fused"})(ns||(Mn.NodeType=ns={}))});var Jr=O($t=>{"use strict";var kd=$t&&$t.__createBinding||(Object.create?function(r,t,n,e){e===void 0&&(e=n);var o=Object.getOwnPropertyDescriptor(t,n);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(r,e,o)}:function(r,t,n,e){e===void 0&&(e=n),r[e]=t[n]}),Md=$t&&$t.__setModuleDefault||(Object.create?function(r,t){Object.defineProperty(r,"default",{enumerable:!0,value:t})}:function(r,t){r.default=t}),Vd=$t&&$t.__importStar||function(r){if(r&&r.__esModule)return r;var t={};if(r!=null)for(var n in r)n!=="default"&&Object.prototype.hasOwnProperty.call(r,n)&&kd(t,r,n);return Md(t,r),t};Object.defineProperty($t,"__esModule",{value:!0});$t.Node=void 0;var Bd=Vd(M()),zd=Yr(),rs=Xr(),Zr=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsNode(t,n){return(n||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsNode(t,n){return t.setPosition(t.position()+Bd.SIZE_PREFIX_LENGTH),(n||new r).__init(t.readInt32(t.position())+t.position(),t)}name(t){let n=this.bb.__offset(this.bb_pos,4);return n?this.bb.__string(this.bb_pos+n,t):null}docString(t){let n=this.bb.__offset(this.bb_pos,6);return n?this.bb.__string(this.bb_pos+n,t):null}domain(t){let n=this.bb.__offset(this.bb_pos,8);return n?this.bb.__string(this.bb_pos+n,t):null}sinceVersion(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt32(this.bb_pos+t):0}index(){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.readUint32(this.bb_pos+t):0}opType(t){let n=this.bb.__offset(this.bb_pos,14);return n?this.bb.__string(this.bb_pos+n,t):null}type(){let t=this.bb.__offset(this.bb_pos,16);return t?this.bb.readInt32(this.bb_pos+t):rs.NodeType.Primitive}executionProviderType(t){let n=this.bb.__offset(this.bb_pos,18);return n?this.bb.__string(this.bb_pos+n,t):null}inputs(t,n){let e=this.bb.__offset(this.bb_pos,20);return e?this.bb.__string(this.bb.__vector(this.bb_pos+e)+t*4,n):null}inputsLength(){let t=this.bb.__offset(this.bb_pos,20);return t?this.bb.__vector_len(this.bb_pos+t):0}outputs(t,n){let e=this.bb.__offset(this.bb_pos,22);return e?this.bb.__string(this.bb.__vector(this.bb_pos+e)+t*4,n):null}outputsLength(){let t=this.bb.__offset(this.bb_pos,22);return t?this.bb.__vector_len(this.bb_pos+t):0}attributes(t,n){let e=this.bb.__offset(this.bb_pos,24);return e?(n||new zd.Attribute).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+e)+t*4),this.bb):null}attributesLength(){let t=this.bb.__offset(this.bb_pos,24);return t?this.bb.__vector_len(this.bb_pos+t):0}inputArgCounts(t){let n=this.bb.__offset(this.bb_pos,26);return n?this.bb.readInt32(this.bb.__vector(this.bb_pos+n)+t*4):0}inputArgCountsLength(){let t=this.bb.__offset(this.bb_pos,26);return t?this.bb.__vector_len(this.bb_pos+t):0}inputArgCountsArray(){let t=this.bb.__offset(this.bb_pos,26);return t?new Int32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}implicitInputs(t,n){let e=this.bb.__offset(this.bb_pos,28);return e?this.bb.__string(this.bb.__vector(this.bb_pos+e)+t*4,n):null}implicitInputsLength(){let t=this.bb.__offset(this.bb_pos,28);return t?this.bb.__vector_len(this.bb_pos+t):0}static startNode(t){t.startObject(13)}static addName(t,n){t.addFieldOffset(0,n,0)}static addDocString(t,n){t.addFieldOffset(1,n,0)}static addDomain(t,n){t.addFieldOffset(2,n,0)}static addSinceVersion(t,n){t.addFieldInt32(3,n,0)}static addIndex(t,n){t.addFieldInt32(4,n,0)}static addOpType(t,n){t.addFieldOffset(5,n,0)}static addType(t,n){t.addFieldInt32(6,n,rs.NodeType.Primitive)}static addExecutionProviderType(t,n){t.addFieldOffset(7,n,0)}static addInputs(t,n){t.addFieldOffset(8,n,0)}static createInputsVector(t,n){t.startVector(4,n.length,4);for(let e=n.length-1;e>=0;e--)t.addOffset(n[e]);return t.endVector()}static startInputsVector(t,n){t.startVector(4,n,4)}static addOutputs(t,n){t.addFieldOffset(9,n,0)}static createOutputsVector(t,n){t.startVector(4,n.length,4);for(let e=n.length-1;e>=0;e--)t.addOffset(n[e]);return t.endVector()}static startOutputsVector(t,n){t.startVector(4,n,4)}static addAttributes(t,n){t.addFieldOffset(10,n,0)}static createAttributesVector(t,n){t.startVector(4,n.length,4);for(let e=n.length-1;e>=0;e--)t.addOffset(n[e]);return t.endVector()}static startAttributesVector(t,n){t.startVector(4,n,4)}static addInputArgCounts(t,n){t.addFieldOffset(11,n,0)}static createInputArgCountsVector(t,n){t.startVector(4,n.length,4);for(let e=n.length-1;e>=0;e--)t.addInt32(n[e]);return t.endVector()}static startInputArgCountsVector(t,n){t.startVector(4,n,4)}static addImplicitInputs(t,n){t.addFieldOffset(12,n,0)}static createImplicitInputsVector(t,n){t.startVector(4,n.length,4);for(let e=n.length-1;e>=0;e--)t.addOffset(n[e]);return t.endVector()}static startImplicitInputsVector(t,n){t.startVector(4,n,4)}static endNode(t){return t.endObject()}static createNode(t,n,e,o,i,a,s,u,l,c,d,p,m,g){return r.startNode(t),r.addName(t,n),r.addDocString(t,e),r.addDomain(t,o),r.addSinceVersion(t,i),r.addIndex(t,a),r.addOpType(t,s),r.addType(t,u),r.addExecutionProviderType(t,l),r.addInputs(t,c),r.addOutputs(t,d),r.addAttributes(t,p),r.addInputArgCounts(t,m),r.addImplicitInputs(t,g),r.endNode(t)}};$t.Node=Zr});var to=O(Vn=>{"use strict";Object.defineProperty(Vn,"__esModule",{value:!0});Vn.EdgeEnd=void 0;var Qr=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,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 sizeOf(){return 12}static createEdgeEnd(t,n,e,o){return t.prep(4,12),t.writeInt32(o),t.writeInt32(e),t.writeInt32(n),t.offset()}};Vn.EdgeEnd=Qr});var no=O(Nt=>{"use strict";var Ud=Nt&&Nt.__createBinding||(Object.create?function(r,t,n,e){e===void 0&&(e=n);var o=Object.getOwnPropertyDescriptor(t,n);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(r,e,o)}:function(r,t,n,e){e===void 0&&(e=n),r[e]=t[n]}),jd=Nt&&Nt.__setModuleDefault||(Object.create?function(r,t){Object.defineProperty(r,"default",{enumerable:!0,value:t})}:function(r,t){r.default=t}),Wd=Nt&&Nt.__importStar||function(r){if(r&&r.__esModule)return r;var t={};if(r!=null)for(var n in r)n!=="default"&&Object.prototype.hasOwnProperty.call(r,n)&&Ud(t,r,n);return jd(t,r),t};Object.defineProperty(Nt,"__esModule",{value:!0});Nt.NodeEdge=void 0;var Hd=Wd(M()),os=to(),eo=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsNodeEdge(t,n){return(n||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsNodeEdge(t,n){return t.setPosition(t.position()+Hd.SIZE_PREFIX_LENGTH),(n||new r).__init(t.readInt32(t.position())+t.position(),t)}nodeIndex(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readUint32(this.bb_pos+t):0}inputEdges(t,n){let e=this.bb.__offset(this.bb_pos,6);return e?(n||new os.EdgeEnd).__init(this.bb.__vector(this.bb_pos+e)+t*12,this.bb):null}inputEdgesLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}outputEdges(t,n){let e=this.bb.__offset(this.bb_pos,8);return e?(n||new os.EdgeEnd).__init(this.bb.__vector(this.bb_pos+e)+t*12,this.bb):null}outputEdgesLength(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}static startNodeEdge(t){t.startObject(3)}static addNodeIndex(t,n){t.addFieldInt32(0,n,0)}static addInputEdges(t,n){t.addFieldOffset(1,n,0)}static startInputEdgesVector(t,n){t.startVector(12,n,4)}static addOutputEdges(t,n){t.addFieldOffset(2,n,0)}static startOutputEdgesVector(t,n){t.startVector(12,n,4)}static endNodeEdge(t){return t.endObject()}static createNodeEdge(t,n,e,o){return r.startNodeEdge(t),r.addNodeIndex(t,n),r.addInputEdges(t,e),r.addOutputEdges(t,o),r.endNodeEdge(t)}};Nt.NodeEdge=eo});var oo=O(Ft=>{"use strict";var qd=Ft&&Ft.__createBinding||(Object.create?function(r,t,n,e){e===void 0&&(e=n);var o=Object.getOwnPropertyDescriptor(t,n);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(r,e,o)}:function(r,t,n,e){e===void 0&&(e=n),r[e]=t[n]}),Kd=Ft&&Ft.__setModuleDefault||(Object.create?function(r,t){Object.defineProperty(r,"default",{enumerable:!0,value:t})}:function(r,t){r.default=t}),Xd=Ft&&Ft.__importStar||function(r){if(r&&r.__esModule)return r;var t={};if(r!=null)for(var n in r)n!=="default"&&Object.prototype.hasOwnProperty.call(r,n)&&qd(t,r,n);return Kd(t,r),t};Object.defineProperty(Ft,"__esModule",{value:!0});Ft.NodesToOptimizeIndices=void 0;var Zd=Xd(M()),ro=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsNodesToOptimizeIndices(t,n){return(n||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsNodesToOptimizeIndices(t,n){return t.setPosition(t.position()+Zd.SIZE_PREFIX_LENGTH),(n||new r).__init(t.readInt32(t.position())+t.position(),t)}nodeIndices(t){let n=this.bb.__offset(this.bb_pos,4);return n?this.bb.readUint32(this.bb.__vector(this.bb_pos+n)+t*4):0}nodeIndicesLength(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__vector_len(this.bb_pos+t):0}nodeIndicesArray(){let t=this.bb.__offset(this.bb_pos,4);return t?new Uint32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}numInputs(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint32(this.bb_pos+t):0}numOutputs(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readUint32(this.bb_pos+t):0}hasVariadicInput(){let t=this.bb.__offset(this.bb_pos,10);return t?!!this.bb.readInt8(this.bb_pos+t):!1}hasVariadicOutput(){let t=this.bb.__offset(this.bb_pos,12);return t?!!this.bb.readInt8(this.bb_pos+t):!1}numVariadicInputs(){let t=this.bb.__offset(this.bb_pos,14);return t?this.bb.readUint32(this.bb_pos+t):0}numVariadicOutputs(){let t=this.bb.__offset(this.bb_pos,16);return t?this.bb.readUint32(this.bb_pos+t):0}static startNodesToOptimizeIndices(t){t.startObject(7)}static addNodeIndices(t,n){t.addFieldOffset(0,n,0)}static createNodeIndicesVector(t,n){t.startVector(4,n.length,4);for(let e=n.length-1;e>=0;e--)t.addInt32(n[e]);return t.endVector()}static startNodeIndicesVector(t,n){t.startVector(4,n,4)}static addNumInputs(t,n){t.addFieldInt32(1,n,0)}static addNumOutputs(t,n){t.addFieldInt32(2,n,0)}static addHasVariadicInput(t,n){t.addFieldInt8(3,+n,0)}static addHasVariadicOutput(t,n){t.addFieldInt8(4,+n,0)}static addNumVariadicInputs(t,n){t.addFieldInt32(5,n,0)}static addNumVariadicOutputs(t,n){t.addFieldInt32(6,n,0)}static endNodesToOptimizeIndices(t){return t.endObject()}static createNodesToOptimizeIndices(t,n,e,o,i,a,s,u){return r.startNodesToOptimizeIndices(t),r.addNodeIndices(t,n),r.addNumInputs(t,e),r.addNumOutputs(t,o),r.addHasVariadicInput(t,i),r.addHasVariadicOutput(t,a),r.addNumVariadicInputs(t,s),r.addNumVariadicOutputs(t,u),r.endNodesToOptimizeIndices(t)}};Ft.NodesToOptimizeIndices=ro});var ao=O(Ct=>{"use strict";var Jd=Ct&&Ct.__createBinding||(Object.create?function(r,t,n,e){e===void 0&&(e=n);var o=Object.getOwnPropertyDescriptor(t,n);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(r,e,o)}:function(r,t,n,e){e===void 0&&(e=n),r[e]=t[n]}),Yd=Ct&&Ct.__setModuleDefault||(Object.create?function(r,t){Object.defineProperty(r,"default",{enumerable:!0,value:t})}:function(r,t){r.default=t}),Qd=Ct&&Ct.__importStar||function(r){if(r&&r.__esModule)return r;var t={};if(r!=null)for(var n in r)n!=="default"&&Object.prototype.hasOwnProperty.call(r,n)&&Jd(t,r,n);return Yd(t,r),t};Object.defineProperty(Ct,"__esModule",{value:!0});Ct.RuntimeOptimizationRecord=void 0;var tp=Qd(M()),ep=oo(),io=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsRuntimeOptimizationRecord(t,n){return(n||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsRuntimeOptimizationRecord(t,n){return t.setPosition(t.position()+tp.SIZE_PREFIX_LENGTH),(n||new r).__init(t.readInt32(t.position())+t.position(),t)}actionId(t){let n=this.bb.__offset(this.bb_pos,4);return n?this.bb.__string(this.bb_pos+n,t):null}nodesToOptimizeIndices(t){let n=this.bb.__offset(this.bb_pos,6);return n?(t||new ep.NodesToOptimizeIndices).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}producedOpIds(t,n){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__string(this.bb.__vector(this.bb_pos+e)+t*4,n):null}producedOpIdsLength(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}static startRuntimeOptimizationRecord(t){t.startObject(4)}static addActionId(t,n){t.addFieldOffset(0,n,0)}static addNodesToOptimizeIndices(t,n){t.addFieldOffset(1,n,0)}static addProducedOpIds(t,n){t.addFieldOffset(3,n,0)}static createProducedOpIdsVector(t,n){t.startVector(4,n.length,4);for(let e=n.length-1;e>=0;e--)t.addOffset(n[e]);return t.endVector()}static startProducedOpIdsVector(t,n){t.startVector(4,n,4)}static endRuntimeOptimizationRecord(t){return t.endObject()}};Ct.RuntimeOptimizationRecord=io});var uo=O(Rt=>{"use strict";var np=Rt&&Rt.__createBinding||(Object.create?function(r,t,n,e){e===void 0&&(e=n);var o=Object.getOwnPropertyDescriptor(t,n);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(r,e,o)}:function(r,t,n,e){e===void 0&&(e=n),r[e]=t[n]}),rp=Rt&&Rt.__setModuleDefault||(Object.create?function(r,t){Object.defineProperty(r,"default",{enumerable:!0,value:t})}:function(r,t){r.default=t}),op=Rt&&Rt.__importStar||function(r){if(r&&r.__esModule)return r;var t={};if(r!=null)for(var n in r)n!=="default"&&Object.prototype.hasOwnProperty.call(r,n)&&np(t,r,n);return rp(t,r),t};Object.defineProperty(Rt,"__esModule",{value:!0});Rt.RuntimeOptimizationRecordContainerEntry=void 0;var ip=op(M()),ap=ao(),so=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsRuntimeOptimizationRecordContainerEntry(t,n){return(n||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsRuntimeOptimizationRecordContainerEntry(t,n){return t.setPosition(t.position()+ip.SIZE_PREFIX_LENGTH),(n||new r).__init(t.readInt32(t.position())+t.position(),t)}optimizerName(t){let n=this.bb.__offset(this.bb_pos,4);return n?this.bb.__string(this.bb_pos+n,t):null}runtimeOptimizationRecords(t,n){let e=this.bb.__offset(this.bb_pos,6);return e?(n||new ap.RuntimeOptimizationRecord).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+e)+t*4),this.bb):null}runtimeOptimizationRecordsLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}static startRuntimeOptimizationRecordContainerEntry(t){t.startObject(2)}static addOptimizerName(t,n){t.addFieldOffset(0,n,0)}static addRuntimeOptimizationRecords(t,n){t.addFieldOffset(1,n,0)}static createRuntimeOptimizationRecordsVector(t,n){t.startVector(4,n.length,4);for(let e=n.length-1;e>=0;e--)t.addOffset(n[e]);return t.endVector()}static startRuntimeOptimizationRecordsVector(t,n){t.startVector(4,n,4)}static endRuntimeOptimizationRecordContainerEntry(t){let n=t.endObject();return t.requiredField(n,4),n}static createRuntimeOptimizationRecordContainerEntry(t,n,e){return r.startRuntimeOptimizationRecordContainerEntry(t),r.addOptimizerName(t,n),r.addRuntimeOptimizationRecords(t,e),r.endRuntimeOptimizationRecordContainerEntry(t)}};Rt.RuntimeOptimizationRecordContainerEntry=so});var co=O(Gt=>{"use strict";var sp=Gt&&Gt.__createBinding||(Object.create?function(r,t,n,e){e===void 0&&(e=n);var o=Object.getOwnPropertyDescriptor(t,n);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(r,e,o)}:function(r,t,n,e){e===void 0&&(e=n),r[e]=t[n]}),up=Gt&&Gt.__setModuleDefault||(Object.create?function(r,t){Object.defineProperty(r,"default",{enumerable:!0,value:t})}:function(r,t){r.default=t}),lp=Gt&&Gt.__importStar||function(r){if(r&&r.__esModule)return r;var t={};if(r!=null)for(var n in r)n!=="default"&&Object.prototype.hasOwnProperty.call(r,n)&&sp(t,r,n);return up(t,r),t};Object.defineProperty(Gt,"__esModule",{value:!0});Gt.RuntimeOptimizations=void 0;var cp=lp(M()),fp=uo(),lo=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsRuntimeOptimizations(t,n){return(n||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsRuntimeOptimizations(t,n){return t.setPosition(t.position()+cp.SIZE_PREFIX_LENGTH),(n||new r).__init(t.readInt32(t.position())+t.position(),t)}records(t,n){let e=this.bb.__offset(this.bb_pos,4);return e?(n||new fp.RuntimeOptimizationRecordContainerEntry).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+e)+t*4),this.bb):null}recordsLength(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__vector_len(this.bb_pos+t):0}static startRuntimeOptimizations(t){t.startObject(1)}static addRecords(t,n){t.addFieldOffset(0,n,0)}static createRecordsVector(t,n){t.startVector(4,n.length,4);for(let e=n.length-1;e>=0;e--)t.addOffset(n[e]);return t.endVector()}static startRecordsVector(t,n){t.startVector(4,n,4)}static endRuntimeOptimizations(t){return t.endObject()}static createRuntimeOptimizations(t,n){return r.startRuntimeOptimizations(t),r.addRecords(t,n),r.endRuntimeOptimizations(t)}};Gt.RuntimeOptimizations=lo});var en=O(Bn=>{"use strict";Object.defineProperty(Bn,"__esModule",{value:!0});Bn.TensorDataType=void 0;var is;(function(r){r[r.UNDEFINED=0]="UNDEFINED",r[r.FLOAT=1]="FLOAT",r[r.UINT8=2]="UINT8",r[r.INT8=3]="INT8",r[r.UINT16=4]="UINT16",r[r.INT16=5]="INT16",r[r.INT32=6]="INT32",r[r.INT64=7]="INT64",r[r.STRING=8]="STRING",r[r.BOOL=9]="BOOL",r[r.FLOAT16=10]="FLOAT16",r[r.DOUBLE=11]="DOUBLE",r[r.UINT32=12]="UINT32",r[r.UINT64=13]="UINT64",r[r.COMPLEX64=14]="COMPLEX64",r[r.COMPLEX128=15]="COMPLEX128",r[r.BFLOAT16=16]="BFLOAT16",r[r.FLOAT8E4M3FN=17]="FLOAT8E4M3FN",r[r.FLOAT8E4M3FNUZ=18]="FLOAT8E4M3FNUZ",r[r.FLOAT8E5M2=19]="FLOAT8E5M2",r[r.FLOAT8E5M2FNUZ=20]="FLOAT8E5M2FNUZ"})(is||(Bn.TensorDataType=is={}))});var nn=O(kt=>{"use strict";var dp=kt&&kt.__createBinding||(Object.create?function(r,t,n,e){e===void 0&&(e=n);var o=Object.getOwnPropertyDescriptor(t,n);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(r,e,o)}:function(r,t,n,e){e===void 0&&(e=n),r[e]=t[n]}),pp=kt&&kt.__setModuleDefault||(Object.create?function(r,t){Object.defineProperty(r,"default",{enumerable:!0,value:t})}:function(r,t){r.default=t}),hp=kt&&kt.__importStar||function(r){if(r&&r.__esModule)return r;var t={};if(r!=null)for(var n in r)n!=="default"&&Object.prototype.hasOwnProperty.call(r,n)&&dp(t,r,n);return pp(t,r),t};Object.defineProperty(kt,"__esModule",{value:!0});kt.Tensor=void 0;var mp=hp(M()),as=en(),fo=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsTensor(t,n){return(n||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTensor(t,n){return t.setPosition(t.position()+mp.SIZE_PREFIX_LENGTH),(n||new r).__init(t.readInt32(t.position())+t.position(),t)}name(t){let n=this.bb.__offset(this.bb_pos,4);return n?this.bb.__string(this.bb_pos+n,t):null}docString(t){let n=this.bb.__offset(this.bb_pos,6);return n?this.bb.__string(this.bb_pos+n,t):null}dims(t){let n=this.bb.__offset(this.bb_pos,8);return n?this.bb.readInt64(this.bb.__vector(this.bb_pos+n)+t*8):BigInt(0)}dimsLength(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}dataType(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt32(this.bb_pos+t):as.TensorDataType.UNDEFINED}rawData(t){let n=this.bb.__offset(this.bb_pos,12);return n?this.bb.readUint8(this.bb.__vector(this.bb_pos+n)+t):0}rawDataLength(){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}rawDataArray(){let t=this.bb.__offset(this.bb_pos,12);return t?new Uint8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}stringData(t,n){let e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__string(this.bb.__vector(this.bb_pos+e)+t*4,n):null}stringDataLength(){let t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__vector_len(this.bb_pos+t):0}externalDataOffset(){let t=this.bb.__offset(this.bb_pos,16);return t?this.bb.readInt64(this.bb_pos+t):BigInt("-1")}static startTensor(t){t.startObject(7)}static addName(t,n){t.addFieldOffset(0,n,0)}static addDocString(t,n){t.addFieldOffset(1,n,0)}static addDims(t,n){t.addFieldOffset(2,n,0)}static createDimsVector(t,n){t.startVector(8,n.length,8);for(let e=n.length-1;e>=0;e--)t.addInt64(n[e]);return t.endVector()}static startDimsVector(t,n){t.startVector(8,n,8)}static addDataType(t,n){t.addFieldInt32(3,n,as.TensorDataType.UNDEFINED)}static addRawData(t,n){t.addFieldOffset(4,n,0)}static createRawDataVector(t,n){t.startVector(1,n.length,1);for(let e=n.length-1;e>=0;e--)t.addInt8(n[e]);return t.endVector()}static startRawDataVector(t,n){t.startVector(1,n,1)}static addStringData(t,n){t.addFieldOffset(5,n,0)}static createStringDataVector(t,n){t.startVector(4,n.length,4);for(let e=n.length-1;e>=0;e--)t.addOffset(n[e]);return t.endVector()}static startStringDataVector(t,n){t.startVector(4,n,4)}static addExternalDataOffset(t,n){t.addFieldInt64(6,n,BigInt("-1"))}static endTensor(t){return t.endObject()}static createTensor(t,n,e,o,i,a,s,u){return r.startTensor(t),r.addName(t,n),r.addDocString(t,e),r.addDims(t,o),r.addDataType(t,i),r.addRawData(t,a),r.addStringData(t,s),r.addExternalDataOffset(t,u),r.endTensor(t)}};kt.Tensor=fo});var ho=O(Mt=>{"use strict";var bp=Mt&&Mt.__createBinding||(Object.create?function(r,t,n,e){e===void 0&&(e=n);var o=Object.getOwnPropertyDescriptor(t,n);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(r,e,o)}:function(r,t,n,e){e===void 0&&(e=n),r[e]=t[n]}),gp=Mt&&Mt.__setModuleDefault||(Object.create?function(r,t){Object.defineProperty(r,"default",{enumerable:!0,value:t})}:function(r,t){r.default=t}),yp=Mt&&Mt.__importStar||function(r){if(r&&r.__esModule)return r;var t={};if(r!=null)for(var n in r)n!=="default"&&Object.prototype.hasOwnProperty.call(r,n)&&bp(t,r,n);return gp(t,r),t};Object.defineProperty(Mt,"__esModule",{value:!0});Mt.SparseTensor=void 0;var Tp=yp(M()),ss=nn(),po=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsSparseTensor(t,n){return(n||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSparseTensor(t,n){return t.setPosition(t.position()+Tp.SIZE_PREFIX_LENGTH),(n||new r).__init(t.readInt32(t.position())+t.position(),t)}values(t){let n=this.bb.__offset(this.bb_pos,4);return n?(t||new ss.Tensor).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}indices(t){let n=this.bb.__offset(this.bb_pos,6);return n?(t||new ss.Tensor).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}dims(t){let n=this.bb.__offset(this.bb_pos,8);return n?this.bb.readInt64(this.bb.__vector(this.bb_pos+n)+t*8):BigInt(0)}dimsLength(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}static startSparseTensor(t){t.startObject(3)}static addValues(t,n){t.addFieldOffset(0,n,0)}static addIndices(t,n){t.addFieldOffset(1,n,0)}static addDims(t,n){t.addFieldOffset(2,n,0)}static createDimsVector(t,n){t.startVector(8,n.length,8);for(let e=n.length-1;e>=0;e--)t.addInt64(n[e]);return t.endVector()}static startDimsVector(t,n){t.startVector(8,n,8)}static endSparseTensor(t){return t.endObject()}};Mt.SparseTensor=po});var bo=O(Vt=>{"use strict";var _p=Vt&&Vt.__createBinding||(Object.create?function(r,t,n,e){e===void 0&&(e=n);var o=Object.getOwnPropertyDescriptor(t,n);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(r,e,o)}:function(r,t,n,e){e===void 0&&(e=n),r[e]=t[n]}),xp=Vt&&Vt.__setModuleDefault||(Object.create?function(r,t){Object.defineProperty(r,"default",{enumerable:!0,value:t})}:function(r,t){r.default=t}),vp=Vt&&Vt.__importStar||function(r){if(r&&r.__esModule)return r;var t={};if(r!=null)for(var n in r)n!=="default"&&Object.prototype.hasOwnProperty.call(r,n)&&_p(t,r,n);return xp(t,r),t};Object.defineProperty(Vt,"__esModule",{value:!0});Vt.MapType=void 0;var wp=vp(M()),us=en(),Ip=rn(),mo=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsMapType(t,n){return(n||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMapType(t,n){return t.setPosition(t.position()+wp.SIZE_PREFIX_LENGTH),(n||new r).__init(t.readInt32(t.position())+t.position(),t)}keyType(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):us.TensorDataType.UNDEFINED}valueType(t){let n=this.bb.__offset(this.bb_pos,6);return n?(t||new Ip.TypeInfo).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}static startMapType(t){t.startObject(2)}static addKeyType(t,n){t.addFieldInt32(0,n,us.TensorDataType.UNDEFINED)}static addValueType(t,n){t.addFieldOffset(1,n,0)}static endMapType(t){return t.endObject()}};Vt.MapType=mo});var yo=O(Bt=>{"use strict";var Op=Bt&&Bt.__createBinding||(Object.create?function(r,t,n,e){e===void 0&&(e=n);var o=Object.getOwnPropertyDescriptor(t,n);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(r,e,o)}:function(r,t,n,e){e===void 0&&(e=n),r[e]=t[n]}),Pp=Bt&&Bt.__setModuleDefault||(Object.create?function(r,t){Object.defineProperty(r,"default",{enumerable:!0,value:t})}:function(r,t){r.default=t}),Sp=Bt&&Bt.__importStar||function(r){if(r&&r.__esModule)return r;var t={};if(r!=null)for(var n in r)n!=="default"&&Object.prototype.hasOwnProperty.call(r,n)&&Op(t,r,n);return Pp(t,r),t};Object.defineProperty(Bt,"__esModule",{value:!0});Bt.SequenceType=void 0;var Ap=Sp(M()),Ep=rn(),go=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsSequenceType(t,n){return(n||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSequenceType(t,n){return t.setPosition(t.position()+Ap.SIZE_PREFIX_LENGTH),(n||new r).__init(t.readInt32(t.position())+t.position(),t)}elemType(t){let n=this.bb.__offset(this.bb_pos,4);return n?(t||new Ep.TypeInfo).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}static startSequenceType(t){t.startObject(1)}static addElemType(t,n){t.addFieldOffset(0,n,0)}static endSequenceType(t){return t.endObject()}static createSequenceType(t,n){return r.startSequenceType(t),r.addElemType(t,n),r.endSequenceType(t)}};Bt.SequenceType=go});var To=O(zn=>{"use strict";Object.defineProperty(zn,"__esModule",{value:!0});zn.DimensionValueType=void 0;var ls;(function(r){r[r.UNKNOWN=0]="UNKNOWN",r[r.VALUE=1]="VALUE",r[r.PARAM=2]="PARAM"})(ls||(zn.DimensionValueType=ls={}))});var xo=O(zt=>{"use strict";var Dp=zt&&zt.__createBinding||(Object.create?function(r,t,n,e){e===void 0&&(e=n);var o=Object.getOwnPropertyDescriptor(t,n);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(r,e,o)}:function(r,t,n,e){e===void 0&&(e=n),r[e]=t[n]}),Lp=zt&&zt.__setModuleDefault||(Object.create?function(r,t){Object.defineProperty(r,"default",{enumerable:!0,value:t})}:function(r,t){r.default=t}),$p=zt&&zt.__importStar||function(r){if(r&&r.__esModule)return r;var t={};if(r!=null)for(var n in r)n!=="default"&&Object.prototype.hasOwnProperty.call(r,n)&&Dp(t,r,n);return Lp(t,r),t};Object.defineProperty(zt,"__esModule",{value:!0});zt.DimensionValue=void 0;var Np=$p(M()),cs=To(),_o=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsDimensionValue(t,n){return(n||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDimensionValue(t,n){return t.setPosition(t.position()+Np.SIZE_PREFIX_LENGTH),(n||new r).__init(t.readInt32(t.position())+t.position(),t)}dimType(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt8(this.bb_pos+t):cs.DimensionValueType.UNKNOWN}dimValue(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}dimParam(t){let n=this.bb.__offset(this.bb_pos,8);return n?this.bb.__string(this.bb_pos+n,t):null}static startDimensionValue(t){t.startObject(3)}static addDimType(t,n){t.addFieldInt8(0,n,cs.DimensionValueType.UNKNOWN)}static addDimValue(t,n){t.addFieldInt64(1,n,BigInt("0"))}static addDimParam(t,n){t.addFieldOffset(2,n,0)}static endDimensionValue(t){return t.endObject()}static createDimensionValue(t,n,e,o){return r.startDimensionValue(t),r.addDimType(t,n),r.addDimValue(t,e),r.addDimParam(t,o),r.endDimensionValue(t)}};zt.DimensionValue=_o});var wo=O(Ut=>{"use strict";var Fp=Ut&&Ut.__createBinding||(Object.create?function(r,t,n,e){e===void 0&&(e=n);var o=Object.getOwnPropertyDescriptor(t,n);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(r,e,o)}:function(r,t,n,e){e===void 0&&(e=n),r[e]=t[n]}),Cp=Ut&&Ut.__setModuleDefault||(Object.create?function(r,t){Object.defineProperty(r,"default",{enumerable:!0,value:t})}:function(r,t){r.default=t}),Rp=Ut&&Ut.__importStar||function(r){if(r&&r.__esModule)return r;var t={};if(r!=null)for(var n in r)n!=="default"&&Object.prototype.hasOwnProperty.call(r,n)&&Fp(t,r,n);return Cp(t,r),t};Object.defineProperty(Ut,"__esModule",{value:!0});Ut.Dimension=void 0;var Gp=Rp(M()),kp=xo(),vo=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsDimension(t,n){return(n||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDimension(t,n){return t.setPosition(t.position()+Gp.SIZE_PREFIX_LENGTH),(n||new r).__init(t.readInt32(t.position())+t.position(),t)}value(t){let n=this.bb.__offset(this.bb_pos,4);return n?(t||new kp.DimensionValue).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}denotation(t){let n=this.bb.__offset(this.bb_pos,6);return n?this.bb.__string(this.bb_pos+n,t):null}static startDimension(t){t.startObject(2)}static addValue(t,n){t.addFieldOffset(0,n,0)}static addDenotation(t,n){t.addFieldOffset(1,n,0)}static endDimension(t){return t.endObject()}static createDimension(t,n,e){return r.startDimension(t),r.addValue(t,n),r.addDenotation(t,e),r.endDimension(t)}};Ut.Dimension=vo});var Oo=O(jt=>{"use strict";var Mp=jt&&jt.__createBinding||(Object.create?function(r,t,n,e){e===void 0&&(e=n);var o=Object.getOwnPropertyDescriptor(t,n);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(r,e,o)}:function(r,t,n,e){e===void 0&&(e=n),r[e]=t[n]}),Vp=jt&&jt.__setModuleDefault||(Object.create?function(r,t){Object.defineProperty(r,"default",{enumerable:!0,value:t})}:function(r,t){r.default=t}),Bp=jt&&jt.__importStar||function(r){if(r&&r.__esModule)return r;var t={};if(r!=null)for(var n in r)n!=="default"&&Object.prototype.hasOwnProperty.call(r,n)&&Mp(t,r,n);return Vp(t,r),t};Object.defineProperty(jt,"__esModule",{value:!0});jt.Shape=void 0;var zp=Bp(M()),Up=wo(),Io=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsShape(t,n){return(n||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsShape(t,n){return t.setPosition(t.position()+zp.SIZE_PREFIX_LENGTH),(n||new r).__init(t.readInt32(t.position())+t.position(),t)}dim(t,n){let e=this.bb.__offset(this.bb_pos,4);return e?(n||new Up.Dimension).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+e)+t*4),this.bb):null}dimLength(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__vector_len(this.bb_pos+t):0}static startShape(t){t.startObject(1)}static addDim(t,n){t.addFieldOffset(0,n,0)}static createDimVector(t,n){t.startVector(4,n.length,4);for(let e=n.length-1;e>=0;e--)t.addOffset(n[e]);return t.endVector()}static startDimVector(t,n){t.startVector(4,n,4)}static endShape(t){return t.endObject()}static createShape(t,n){return r.startShape(t),r.addDim(t,n),r.endShape(t)}};jt.Shape=Io});var So=O(Wt=>{"use strict";var jp=Wt&&Wt.__createBinding||(Object.create?function(r,t,n,e){e===void 0&&(e=n);var o=Object.getOwnPropertyDescriptor(t,n);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(r,e,o)}:function(r,t,n,e){e===void 0&&(e=n),r[e]=t[n]}),Wp=Wt&&Wt.__setModuleDefault||(Object.create?function(r,t){Object.defineProperty(r,"default",{enumerable:!0,value:t})}:function(r,t){r.default=t}),Hp=Wt&&Wt.__importStar||function(r){if(r&&r.__esModule)return r;var t={};if(r!=null)for(var n in r)n!=="default"&&Object.prototype.hasOwnProperty.call(r,n)&&jp(t,r,n);return Wp(t,r),t};Object.defineProperty(Wt,"__esModule",{value:!0});Wt.TensorTypeAndShape=void 0;var qp=Hp(M()),Kp=Oo(),fs=en(),Po=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsTensorTypeAndShape(t,n){return(n||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTensorTypeAndShape(t,n){return t.setPosition(t.position()+qp.SIZE_PREFIX_LENGTH),(n||new r).__init(t.readInt32(t.position())+t.position(),t)}elemType(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):fs.TensorDataType.UNDEFINED}shape(t){let n=this.bb.__offset(this.bb_pos,6);return n?(t||new Kp.Shape).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}static startTensorTypeAndShape(t){t.startObject(2)}static addElemType(t,n){t.addFieldInt32(0,n,fs.TensorDataType.UNDEFINED)}static addShape(t,n){t.addFieldOffset(1,n,0)}static endTensorTypeAndShape(t){return t.endObject()}};Wt.TensorTypeAndShape=Po});var Ao=O(ye=>{"use strict";Object.defineProperty(ye,"__esModule",{value:!0});ye.unionListToTypeInfoValue=ye.unionToTypeInfoValue=ye.TypeInfoValue=void 0;var ds=bo(),ps=yo(),hs=So(),Un;(function(r){r[r.NONE=0]="NONE",r[r.tensor_type=1]="tensor_type",r[r.sequence_type=2]="sequence_type",r[r.map_type=3]="map_type"})(Un||(ye.TypeInfoValue=Un={}));function Xp(r,t){switch(Un[r]){case"NONE":return null;case"tensor_type":return t(new hs.TensorTypeAndShape);case"sequence_type":return t(new ps.SequenceType);case"map_type":return t(new ds.MapType);default:return null}}ye.unionToTypeInfoValue=Xp;function Zp(r,t,n){switch(Un[r]){case"NONE":return null;case"tensor_type":return t(n,new hs.TensorTypeAndShape);case"sequence_type":return t(n,new ps.SequenceType);case"map_type":return t(n,new ds.MapType);default:return null}}ye.unionListToTypeInfoValue=Zp});var rn=O(Ht=>{"use strict";var Jp=Ht&&Ht.__createBinding||(Object.create?function(r,t,n,e){e===void 0&&(e=n);var o=Object.getOwnPropertyDescriptor(t,n);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(r,e,o)}:function(r,t,n,e){e===void 0&&(e=n),r[e]=t[n]}),Yp=Ht&&Ht.__setModuleDefault||(Object.create?function(r,t){Object.defineProperty(r,"default",{enumerable:!0,value:t})}:function(r,t){r.default=t}),Qp=Ht&&Ht.__importStar||function(r){if(r&&r.__esModule)return r;var t={};if(r!=null)for(var n in r)n!=="default"&&Object.prototype.hasOwnProperty.call(r,n)&&Jp(t,r,n);return Yp(t,r),t};Object.defineProperty(Ht,"__esModule",{value:!0});Ht.TypeInfo=void 0;var th=Qp(M()),ms=Ao(),Eo=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsTypeInfo(t,n){return(n||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTypeInfo(t,n){return t.setPosition(t.position()+th.SIZE_PREFIX_LENGTH),(n||new r).__init(t.readInt32(t.position())+t.position(),t)}denotation(t){let n=this.bb.__offset(this.bb_pos,4);return n?this.bb.__string(this.bb_pos+n,t):null}valueType(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):ms.TypeInfoValue.NONE}value(t){let n=this.bb.__offset(this.bb_pos,8);return n?this.bb.__union(t,this.bb_pos+n):null}static startTypeInfo(t){t.startObject(3)}static addDenotation(t,n){t.addFieldOffset(0,n,0)}static addValueType(t,n){t.addFieldInt8(1,n,ms.TypeInfoValue.NONE)}static addValue(t,n){t.addFieldOffset(2,n,0)}static endTypeInfo(t){return t.endObject()}static createTypeInfo(t,n,e,o){return r.startTypeInfo(t),r.addDenotation(t,n),r.addValueType(t,e),r.addValue(t,o),r.endTypeInfo(t)}};Ht.TypeInfo=Eo});var Lo=O(qt=>{"use strict";var eh=qt&&qt.__createBinding||(Object.create?function(r,t,n,e){e===void 0&&(e=n);var o=Object.getOwnPropertyDescriptor(t,n);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(r,e,o)}:function(r,t,n,e){e===void 0&&(e=n),r[e]=t[n]}),nh=qt&&qt.__setModuleDefault||(Object.create?function(r,t){Object.defineProperty(r,"default",{enumerable:!0,value:t})}:function(r,t){r.default=t}),rh=qt&&qt.__importStar||function(r){if(r&&r.__esModule)return r;var t={};if(r!=null)for(var n in r)n!=="default"&&Object.prototype.hasOwnProperty.call(r,n)&&eh(t,r,n);return nh(t,r),t};Object.defineProperty(qt,"__esModule",{value:!0});qt.ValueInfo=void 0;var oh=rh(M()),ih=rn(),Do=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsValueInfo(t,n){return(n||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsValueInfo(t,n){return t.setPosition(t.position()+oh.SIZE_PREFIX_LENGTH),(n||new r).__init(t.readInt32(t.position())+t.position(),t)}name(t){let n=this.bb.__offset(this.bb_pos,4);return n?this.bb.__string(this.bb_pos+n,t):null}docString(t){let n=this.bb.__offset(this.bb_pos,6);return n?this.bb.__string(this.bb_pos+n,t):null}type(t){let n=this.bb.__offset(this.bb_pos,8);return n?(t||new ih.TypeInfo).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}static startValueInfo(t){t.startObject(3)}static addName(t,n){t.addFieldOffset(0,n,0)}static addDocString(t,n){t.addFieldOffset(1,n,0)}static addType(t,n){t.addFieldOffset(2,n,0)}static endValueInfo(t){return t.endObject()}};qt.ValueInfo=Do});var jn=O(Kt=>{"use strict";var ah=Kt&&Kt.__createBinding||(Object.create?function(r,t,n,e){e===void 0&&(e=n);var o=Object.getOwnPropertyDescriptor(t,n);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(r,e,o)}:function(r,t,n,e){e===void 0&&(e=n),r[e]=t[n]}),sh=Kt&&Kt.__setModuleDefault||(Object.create?function(r,t){Object.defineProperty(r,"default",{enumerable:!0,value:t})}:function(r,t){r.default=t}),uh=Kt&&Kt.__importStar||function(r){if(r&&r.__esModule)return r;var t={};if(r!=null)for(var n in r)n!=="default"&&Object.prototype.hasOwnProperty.call(r,n)&&ah(t,r,n);return sh(t,r),t};Object.defineProperty(Kt,"__esModule",{value:!0});Kt.Graph=void 0;var lh=uh(M()),ch=Jr(),fh=no(),dh=co(),ph=ho(),hh=nn(),mh=Lo(),$o=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsGraph(t,n){return(n||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsGraph(t,n){return t.setPosition(t.position()+lh.SIZE_PREFIX_LENGTH),(n||new r).__init(t.readInt32(t.position())+t.position(),t)}initializers(t,n){let e=this.bb.__offset(this.bb_pos,4);return e?(n||new hh.Tensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+e)+t*4),this.bb):null}initializersLength(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__vector_len(this.bb_pos+t):0}nodeArgs(t,n){let e=this.bb.__offset(this.bb_pos,6);return e?(n||new mh.ValueInfo).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+e)+t*4),this.bb):null}nodeArgsLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}nodes(t,n){let e=this.bb.__offset(this.bb_pos,8);return e?(n||new ch.Node).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+e)+t*4),this.bb):null}nodesLength(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}maxNodeIndex(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readUint32(this.bb_pos+t):0}nodeEdges(t,n){let e=this.bb.__offset(this.bb_pos,12);return e?(n||new fh.NodeEdge).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+e)+t*4),this.bb):null}nodeEdgesLength(){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}inputs(t,n){let e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__string(this.bb.__vector(this.bb_pos+e)+t*4,n):null}inputsLength(){let t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__vector_len(this.bb_pos+t):0}outputs(t,n){let e=this.bb.__offset(this.bb_pos,16);return e?this.bb.__string(this.bb.__vector(this.bb_pos+e)+t*4,n):null}outputsLength(){let t=this.bb.__offset(this.bb_pos,16);return t?this.bb.__vector_len(this.bb_pos+t):0}sparseInitializers(t,n){let e=this.bb.__offset(this.bb_pos,18);return e?(n||new ph.SparseTensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+e)+t*4),this.bb):null}sparseInitializersLength(){let t=this.bb.__offset(this.bb_pos,18);return t?this.bb.__vector_len(this.bb_pos+t):0}runtimeOptimizations(t){let n=this.bb.__offset(this.bb_pos,20);return n?(t||new dh.RuntimeOptimizations).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}static startGraph(t){t.startObject(9)}static addInitializers(t,n){t.addFieldOffset(0,n,0)}static createInitializersVector(t,n){t.startVector(4,n.length,4);for(let e=n.length-1;e>=0;e--)t.addOffset(n[e]);return t.endVector()}static startInitializersVector(t,n){t.startVector(4,n,4)}static addNodeArgs(t,n){t.addFieldOffset(1,n,0)}static createNodeArgsVector(t,n){t.startVector(4,n.length,4);for(let e=n.length-1;e>=0;e--)t.addOffset(n[e]);return t.endVector()}static startNodeArgsVector(t,n){t.startVector(4,n,4)}static addNodes(t,n){t.addFieldOffset(2,n,0)}static createNodesVector(t,n){t.startVector(4,n.length,4);for(let e=n.length-1;e>=0;e--)t.addOffset(n[e]);return t.endVector()}static startNodesVector(t,n){t.startVector(4,n,4)}static addMaxNodeIndex(t,n){t.addFieldInt32(3,n,0)}static addNodeEdges(t,n){t.addFieldOffset(4,n,0)}static createNodeEdgesVector(t,n){t.startVector(4,n.length,4);for(let e=n.length-1;e>=0;e--)t.addOffset(n[e]);return t.endVector()}static startNodeEdgesVector(t,n){t.startVector(4,n,4)}static addInputs(t,n){t.addFieldOffset(5,n,0)}static createInputsVector(t,n){t.startVector(4,n.length,4);for(let e=n.length-1;e>=0;e--)t.addOffset(n[e]);return t.endVector()}static startInputsVector(t,n){t.startVector(4,n,4)}static addOutputs(t,n){t.addFieldOffset(6,n,0)}static createOutputsVector(t,n){t.startVector(4,n.length,4);for(let e=n.length-1;e>=0;e--)t.addOffset(n[e]);return t.endVector()}static startOutputsVector(t,n){t.startVector(4,n,4)}static addSparseInitializers(t,n){t.addFieldOffset(7,n,0)}static createSparseInitializersVector(t,n){t.startVector(4,n.length,4);for(let e=n.length-1;e>=0;e--)t.addOffset(n[e]);return t.endVector()}static startSparseInitializersVector(t,n){t.startVector(4,n,4)}static addRuntimeOptimizations(t,n){t.addFieldOffset(8,n,0)}static endGraph(t){return t.endObject()}};Kt.Graph=$o});var Yr=O(Xt=>{"use strict";var bh=Xt&&Xt.__createBinding||(Object.create?function(r,t,n,e){e===void 0&&(e=n);var o=Object.getOwnPropertyDescriptor(t,n);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(r,e,o)}:function(r,t,n,e){e===void 0&&(e=n),r[e]=t[n]}),gh=Xt&&Xt.__setModuleDefault||(Object.create?function(r,t){Object.defineProperty(r,"default",{enumerable:!0,value:t})}:function(r,t){r.default=t}),yh=Xt&&Xt.__importStar||function(r){if(r&&r.__esModule)return r;var t={};if(r!=null)for(var n in r)n!=="default"&&Object.prototype.hasOwnProperty.call(r,n)&&bh(t,r,n);return gh(t,r),t};Object.defineProperty(Xt,"__esModule",{value:!0});Xt.Attribute=void 0;var Th=yh(M()),bs=Kr(),gs=jn(),ys=nn(),No=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsAttribute(t,n){return(n||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsAttribute(t,n){return t.setPosition(t.position()+Th.SIZE_PREFIX_LENGTH),(n||new r).__init(t.readInt32(t.position())+t.position(),t)}name(t){let n=this.bb.__offset(this.bb_pos,4);return n?this.bb.__string(this.bb_pos+n,t):null}docString(t){let n=this.bb.__offset(this.bb_pos,6);return n?this.bb.__string(this.bb_pos+n,t):null}type(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readInt32(this.bb_pos+t):bs.AttributeType.UNDEFINED}f(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readFloat32(this.bb_pos+t):0}i(){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}s(t){let n=this.bb.__offset(this.bb_pos,14);return n?this.bb.__string(this.bb_pos+n,t):null}t(t){let n=this.bb.__offset(this.bb_pos,16);return n?(t||new ys.Tensor).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}g(t){let n=this.bb.__offset(this.bb_pos,18);return n?(t||new gs.Graph).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}floats(t){let n=this.bb.__offset(this.bb_pos,20);return n?this.bb.readFloat32(this.bb.__vector(this.bb_pos+n)+t*4):0}floatsLength(){let t=this.bb.__offset(this.bb_pos,20);return t?this.bb.__vector_len(this.bb_pos+t):0}floatsArray(){let t=this.bb.__offset(this.bb_pos,20);return t?new Float32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}ints(t){let n=this.bb.__offset(this.bb_pos,22);return n?this.bb.readInt64(this.bb.__vector(this.bb_pos+n)+t*8):BigInt(0)}intsLength(){let t=this.bb.__offset(this.bb_pos,22);return t?this.bb.__vector_len(this.bb_pos+t):0}strings(t,n){let e=this.bb.__offset(this.bb_pos,24);return e?this.bb.__string(this.bb.__vector(this.bb_pos+e)+t*4,n):null}stringsLength(){let t=this.bb.__offset(this.bb_pos,24);return t?this.bb.__vector_len(this.bb_pos+t):0}tensors(t,n){let e=this.bb.__offset(this.bb_pos,26);return e?(n||new ys.Tensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+e)+t*4),this.bb):null}tensorsLength(){let t=this.bb.__offset(this.bb_pos,26);return t?this.bb.__vector_len(this.bb_pos+t):0}graphs(t,n){let e=this.bb.__offset(this.bb_pos,28);return e?(n||new gs.Graph).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+e)+t*4),this.bb):null}graphsLength(){let t=this.bb.__offset(this.bb_pos,28);return t?this.bb.__vector_len(this.bb_pos+t):0}static startAttribute(t){t.startObject(13)}static addName(t,n){t.addFieldOffset(0,n,0)}static addDocString(t,n){t.addFieldOffset(1,n,0)}static addType(t,n){t.addFieldInt32(2,n,bs.AttributeType.UNDEFINED)}static addF(t,n){t.addFieldFloat32(3,n,0)}static addI(t,n){t.addFieldInt64(4,n,BigInt("0"))}static addS(t,n){t.addFieldOffset(5,n,0)}static addT(t,n){t.addFieldOffset(6,n,0)}static addG(t,n){t.addFieldOffset(7,n,0)}static addFloats(t,n){t.addFieldOffset(8,n,0)}static createFloatsVector(t,n){t.startVector(4,n.length,4);for(let e=n.length-1;e>=0;e--)t.addFloat32(n[e]);return t.endVector()}static startFloatsVector(t,n){t.startVector(4,n,4)}static addInts(t,n){t.addFieldOffset(9,n,0)}static createIntsVector(t,n){t.startVector(8,n.length,8);for(let e=n.length-1;e>=0;e--)t.addInt64(n[e]);return t.endVector()}static startIntsVector(t,n){t.startVector(8,n,8)}static addStrings(t,n){t.addFieldOffset(10,n,0)}static createStringsVector(t,n){t.startVector(4,n.length,4);for(let e=n.length-1;e>=0;e--)t.addOffset(n[e]);return t.endVector()}static startStringsVector(t,n){t.startVector(4,n,4)}static addTensors(t,n){t.addFieldOffset(11,n,0)}static createTensorsVector(t,n){t.startVector(4,n.length,4);for(let e=n.length-1;e>=0;e--)t.addOffset(n[e]);return t.endVector()}static startTensorsVector(t,n){t.startVector(4,n,4)}static addGraphs(t,n){t.addFieldOffset(12,n,0)}static createGraphsVector(t,n){t.startVector(4,n.length,4);for(let e=n.length-1;e>=0;e--)t.addOffset(n[e]);return t.endVector()}static startGraphsVector(t,n){t.startVector(4,n,4)}static endAttribute(t){return t.endObject()}};Xt.Attribute=No});var Co=O(Zt=>{"use strict";var _h=Zt&&Zt.__createBinding||(Object.create?function(r,t,n,e){e===void 0&&(e=n);var o=Object.getOwnPropertyDescriptor(t,n);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(r,e,o)}:function(r,t,n,e){e===void 0&&(e=n),r[e]=t[n]}),xh=Zt&&Zt.__setModuleDefault||(Object.create?function(r,t){Object.defineProperty(r,"default",{enumerable:!0,value:t})}:function(r,t){r.default=t}),vh=Zt&&Zt.__importStar||function(r){if(r&&r.__esModule)return r;var t={};if(r!=null)for(var n in r)n!=="default"&&Object.prototype.hasOwnProperty.call(r,n)&&_h(t,r,n);return xh(t,r),t};Object.defineProperty(Zt,"__esModule",{value:!0});Zt.DeprecatedKernelCreateInfos=void 0;var wh=vh(M()),Fo=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsDeprecatedKernelCreateInfos(t,n){return(n||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDeprecatedKernelCreateInfos(t,n){return t.setPosition(t.position()+wh.SIZE_PREFIX_LENGTH),(n||new r).__init(t.readInt32(t.position())+t.position(),t)}nodeIndices(t){let n=this.bb.__offset(this.bb_pos,4);return n?this.bb.readUint32(this.bb.__vector(this.bb_pos+n)+t*4):0}nodeIndicesLength(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__vector_len(this.bb_pos+t):0}nodeIndicesArray(){let t=this.bb.__offset(this.bb_pos,4);return t?new Uint32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}kernelDefHashes(t){let n=this.bb.__offset(this.bb_pos,6);return n?this.bb.readUint64(this.bb.__vector(this.bb_pos+n)+t*8):BigInt(0)}kernelDefHashesLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}static startDeprecatedKernelCreateInfos(t){t.startObject(2)}static addNodeIndices(t,n){t.addFieldOffset(0,n,0)}static createNodeIndicesVector(t,n){t.startVector(4,n.length,4);for(let e=n.length-1;e>=0;e--)t.addInt32(n[e]);return t.endVector()}static startNodeIndicesVector(t,n){t.startVector(4,n,4)}static addKernelDefHashes(t,n){t.addFieldOffset(1,n,0)}static createKernelDefHashesVector(t,n){t.startVector(8,n.length,8);for(let e=n.length-1;e>=0;e--)t.addInt64(n[e]);return t.endVector()}static startKernelDefHashesVector(t,n){t.startVector(8,n,8)}static endDeprecatedKernelCreateInfos(t){return t.endObject()}static createDeprecatedKernelCreateInfos(t,n,e){return r.startDeprecatedKernelCreateInfos(t),r.addNodeIndices(t,n),r.addKernelDefHashes(t,e),r.endDeprecatedKernelCreateInfos(t)}};Zt.DeprecatedKernelCreateInfos=Fo});var Ts=O(Jt=>{"use strict";var Ih=Jt&&Jt.__createBinding||(Object.create?function(r,t,n,e){e===void 0&&(e=n);var o=Object.getOwnPropertyDescriptor(t,n);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(r,e,o)}:function(r,t,n,e){e===void 0&&(e=n),r[e]=t[n]}),Oh=Jt&&Jt.__setModuleDefault||(Object.create?function(r,t){Object.defineProperty(r,"default",{enumerable:!0,value:t})}:function(r,t){r.default=t}),Ph=Jt&&Jt.__importStar||function(r){if(r&&r.__esModule)return r;var t={};if(r!=null)for(var n in r)n!=="default"&&Object.prototype.hasOwnProperty.call(r,n)&&Ih(t,r,n);return Oh(t,r),t};Object.defineProperty(Jt,"__esModule",{value:!0});Jt.DeprecatedNodeIndexAndKernelDefHash=void 0;var Sh=Ph(M()),Ro=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsDeprecatedNodeIndexAndKernelDefHash(t,n){return(n||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDeprecatedNodeIndexAndKernelDefHash(t,n){return t.setPosition(t.position()+Sh.SIZE_PREFIX_LENGTH),(n||new r).__init(t.readInt32(t.position())+t.position(),t)}nodeIndex(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readUint32(this.bb_pos+t):0}kernelDefHash(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint64(this.bb_pos+t):BigInt("0")}static startDeprecatedNodeIndexAndKernelDefHash(t){t.startObject(2)}static addNodeIndex(t,n){t.addFieldInt32(0,n,0)}static addKernelDefHash(t,n){t.addFieldInt64(1,n,BigInt("0"))}static endDeprecatedNodeIndexAndKernelDefHash(t){return t.endObject()}static createDeprecatedNodeIndexAndKernelDefHash(t,n,e){return r.startDeprecatedNodeIndexAndKernelDefHash(t),r.addNodeIndex(t,n),r.addKernelDefHash(t,e),r.endDeprecatedNodeIndexAndKernelDefHash(t)}};Jt.DeprecatedNodeIndexAndKernelDefHash=Ro});var ko=O(Yt=>{"use strict";var Ah=Yt&&Yt.__createBinding||(Object.create?function(r,t,n,e){e===void 0&&(e=n);var o=Object.getOwnPropertyDescriptor(t,n);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(r,e,o)}:function(r,t,n,e){e===void 0&&(e=n),r[e]=t[n]}),Eh=Yt&&Yt.__setModuleDefault||(Object.create?function(r,t){Object.defineProperty(r,"default",{enumerable:!0,value:t})}:function(r,t){r.default=t}),Dh=Yt&&Yt.__importStar||function(r){if(r&&r.__esModule)return r;var t={};if(r!=null)for(var n in r)n!=="default"&&Object.prototype.hasOwnProperty.call(r,n)&&Ah(t,r,n);return Eh(t,r),t};Object.defineProperty(Yt,"__esModule",{value:!0});Yt.DeprecatedSubGraphSessionState=void 0;var Lh=Dh(M()),$h=Mo(),Go=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsDeprecatedSubGraphSessionState(t,n){return(n||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDeprecatedSubGraphSessionState(t,n){return t.setPosition(t.position()+Lh.SIZE_PREFIX_LENGTH),(n||new r).__init(t.readInt32(t.position())+t.position(),t)}graphId(t){let n=this.bb.__offset(this.bb_pos,4);return n?this.bb.__string(this.bb_pos+n,t):null}sessionState(t){let n=this.bb.__offset(this.bb_pos,6);return n?(t||new $h.DeprecatedSessionState).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}static startDeprecatedSubGraphSessionState(t){t.startObject(2)}static addGraphId(t,n){t.addFieldOffset(0,n,0)}static addSessionState(t,n){t.addFieldOffset(1,n,0)}static endDeprecatedSubGraphSessionState(t){let n=t.endObject();return t.requiredField(n,4),n}};Yt.DeprecatedSubGraphSessionState=Go});var Mo=O(Qt=>{"use strict";var Nh=Qt&&Qt.__createBinding||(Object.create?function(r,t,n,e){e===void 0&&(e=n);var o=Object.getOwnPropertyDescriptor(t,n);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(r,e,o)}:function(r,t,n,e){e===void 0&&(e=n),r[e]=t[n]}),Fh=Qt&&Qt.__setModuleDefault||(Object.create?function(r,t){Object.defineProperty(r,"default",{enumerable:!0,value:t})}:function(r,t){r.default=t}),Ch=Qt&&Qt.__importStar||function(r){if(r&&r.__esModule)return r;var t={};if(r!=null)for(var n in r)n!=="default"&&Object.prototype.hasOwnProperty.call(r,n)&&Nh(t,r,n);return Fh(t,r),t};Object.defineProperty(Qt,"__esModule",{value:!0});Qt.DeprecatedSessionState=void 0;var Rh=Ch(M()),Gh=Co(),kh=ko(),Vo=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsDeprecatedSessionState(t,n){return(n||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDeprecatedSessionState(t,n){return t.setPosition(t.position()+Rh.SIZE_PREFIX_LENGTH),(n||new r).__init(t.readInt32(t.position())+t.position(),t)}kernels(t){let n=this.bb.__offset(this.bb_pos,4);return n?(t||new Gh.DeprecatedKernelCreateInfos).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}subGraphSessionStates(t,n){let e=this.bb.__offset(this.bb_pos,6);return e?(n||new kh.DeprecatedSubGraphSessionState).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+e)+t*4),this.bb):null}subGraphSessionStatesLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}static startDeprecatedSessionState(t){t.startObject(2)}static addKernels(t,n){t.addFieldOffset(0,n,0)}static addSubGraphSessionStates(t,n){t.addFieldOffset(1,n,0)}static createSubGraphSessionStatesVector(t,n){t.startVector(4,n.length,4);for(let e=n.length-1;e>=0;e--)t.addOffset(n[e]);return t.endVector()}static startSubGraphSessionStatesVector(t,n){t.startVector(4,n,4)}static endDeprecatedSessionState(t){return t.endObject()}static createDeprecatedSessionState(t,n,e){return r.startDeprecatedSessionState(t),r.addKernels(t,n),r.addSubGraphSessionStates(t,e),r.endDeprecatedSessionState(t)}};Qt.DeprecatedSessionState=Vo});var zo=O(te=>{"use strict";var Mh=te&&te.__createBinding||(Object.create?function(r,t,n,e){e===void 0&&(e=n);var o=Object.getOwnPropertyDescriptor(t,n);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(r,e,o)}:function(r,t,n,e){e===void 0&&(e=n),r[e]=t[n]}),Vh=te&&te.__setModuleDefault||(Object.create?function(r,t){Object.defineProperty(r,"default",{enumerable:!0,value:t})}:function(r,t){r.default=t}),Bh=te&&te.__importStar||function(r){if(r&&r.__esModule)return r;var t={};if(r!=null)for(var n in r)n!=="default"&&Object.prototype.hasOwnProperty.call(r,n)&&Mh(t,r,n);return Vh(t,r),t};Object.defineProperty(te,"__esModule",{value:!0});te.KernelTypeStrArgsEntry=void 0;var zh=Bh(M()),Uh=qr(),Bo=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsKernelTypeStrArgsEntry(t,n){return(n||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsKernelTypeStrArgsEntry(t,n){return t.setPosition(t.position()+zh.SIZE_PREFIX_LENGTH),(n||new r).__init(t.readInt32(t.position())+t.position(),t)}kernelTypeStr(t){let n=this.bb.__offset(this.bb_pos,4);return n?this.bb.__string(this.bb_pos+n,t):null}args(t,n){let e=this.bb.__offset(this.bb_pos,6);return e?(n||new Uh.ArgTypeAndIndex).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+e)+t*4),this.bb):null}argsLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}static startKernelTypeStrArgsEntry(t){t.startObject(2)}static addKernelTypeStr(t,n){t.addFieldOffset(0,n,0)}static addArgs(t,n){t.addFieldOffset(1,n,0)}static createArgsVector(t,n){t.startVector(4,n.length,4);for(let e=n.length-1;e>=0;e--)t.addOffset(n[e]);return t.endVector()}static startArgsVector(t,n){t.startVector(4,n,4)}static endKernelTypeStrArgsEntry(t){let n=t.endObject();return t.requiredField(n,4),n}static createKernelTypeStrArgsEntry(t,n,e){return r.startKernelTypeStrArgsEntry(t),r.addKernelTypeStr(t,n),r.addArgs(t,e),r.endKernelTypeStrArgsEntry(t)}};te.KernelTypeStrArgsEntry=Bo});var jo=O(ee=>{"use strict";var jh=ee&&ee.__createBinding||(Object.create?function(r,t,n,e){e===void 0&&(e=n);var o=Object.getOwnPropertyDescriptor(t,n);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(r,e,o)}:function(r,t,n,e){e===void 0&&(e=n),r[e]=t[n]}),Wh=ee&&ee.__setModuleDefault||(Object.create?function(r,t){Object.defineProperty(r,"default",{enumerable:!0,value:t})}:function(r,t){r.default=t}),Hh=ee&&ee.__importStar||function(r){if(r&&r.__esModule)return r;var t={};if(r!=null)for(var n in r)n!=="default"&&Object.prototype.hasOwnProperty.call(r,n)&&jh(t,r,n);return Wh(t,r),t};Object.defineProperty(ee,"__esModule",{value:!0});ee.OpIdKernelTypeStrArgsEntry=void 0;var qh=Hh(M()),Kh=zo(),Uo=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsOpIdKernelTypeStrArgsEntry(t,n){return(n||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsOpIdKernelTypeStrArgsEntry(t,n){return t.setPosition(t.position()+qh.SIZE_PREFIX_LENGTH),(n||new r).__init(t.readInt32(t.position())+t.position(),t)}opId(t){let n=this.bb.__offset(this.bb_pos,4);return n?this.bb.__string(this.bb_pos+n,t):null}kernelTypeStrArgs(t,n){let e=this.bb.__offset(this.bb_pos,6);return e?(n||new Kh.KernelTypeStrArgsEntry).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+e)+t*4),this.bb):null}kernelTypeStrArgsLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}static startOpIdKernelTypeStrArgsEntry(t){t.startObject(2)}static addOpId(t,n){t.addFieldOffset(0,n,0)}static addKernelTypeStrArgs(t,n){t.addFieldOffset(1,n,0)}static createKernelTypeStrArgsVector(t,n){t.startVector(4,n.length,4);for(let e=n.length-1;e>=0;e--)t.addOffset(n[e]);return t.endVector()}static startKernelTypeStrArgsVector(t,n){t.startVector(4,n,4)}static endOpIdKernelTypeStrArgsEntry(t){let n=t.endObject();return t.requiredField(n,4),n}static createOpIdKernelTypeStrArgsEntry(t,n,e){return r.startOpIdKernelTypeStrArgsEntry(t),r.addOpId(t,n),r.addKernelTypeStrArgs(t,e),r.endOpIdKernelTypeStrArgsEntry(t)}};ee.OpIdKernelTypeStrArgsEntry=Uo});var Ho=O(ne=>{"use strict";var Xh=ne&&ne.__createBinding||(Object.create?function(r,t,n,e){e===void 0&&(e=n);var o=Object.getOwnPropertyDescriptor(t,n);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(r,e,o)}:function(r,t,n,e){e===void 0&&(e=n),r[e]=t[n]}),Zh=ne&&ne.__setModuleDefault||(Object.create?function(r,t){Object.defineProperty(r,"default",{enumerable:!0,value:t})}:function(r,t){r.default=t}),Jh=ne&&ne.__importStar||function(r){if(r&&r.__esModule)return r;var t={};if(r!=null)for(var n in r)n!=="default"&&Object.prototype.hasOwnProperty.call(r,n)&&Xh(t,r,n);return Zh(t,r),t};Object.defineProperty(ne,"__esModule",{value:!0});ne.KernelTypeStrResolver=void 0;var Yh=Jh(M()),Qh=jo(),Wo=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsKernelTypeStrResolver(t,n){return(n||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsKernelTypeStrResolver(t,n){return t.setPosition(t.position()+Yh.SIZE_PREFIX_LENGTH),(n||new r).__init(t.readInt32(t.position())+t.position(),t)}opKernelTypeStrArgs(t,n){let e=this.bb.__offset(this.bb_pos,4);return e?(n||new Qh.OpIdKernelTypeStrArgsEntry).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+e)+t*4),this.bb):null}opKernelTypeStrArgsLength(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__vector_len(this.bb_pos+t):0}static startKernelTypeStrResolver(t){t.startObject(1)}static addOpKernelTypeStrArgs(t,n){t.addFieldOffset(0,n,0)}static createOpKernelTypeStrArgsVector(t,n){t.startVector(4,n.length,4);for(let e=n.length-1;e>=0;e--)t.addOffset(n[e]);return t.endVector()}static startOpKernelTypeStrArgsVector(t,n){t.startVector(4,n,4)}static endKernelTypeStrResolver(t){return t.endObject()}static createKernelTypeStrResolver(t,n){return r.startKernelTypeStrResolver(t),r.addOpKernelTypeStrArgs(t,n),r.endKernelTypeStrResolver(t)}};ne.KernelTypeStrResolver=Wo});var Ko=O(re=>{"use strict";var tm=re&&re.__createBinding||(Object.create?function(r,t,n,e){e===void 0&&(e=n);var o=Object.getOwnPropertyDescriptor(t,n);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(r,e,o)}:function(r,t,n,e){e===void 0&&(e=n),r[e]=t[n]}),em=re&&re.__setModuleDefault||(Object.create?function(r,t){Object.defineProperty(r,"default",{enumerable:!0,value:t})}:function(r,t){r.default=t}),nm=re&&re.__importStar||function(r){if(r&&r.__esModule)return r;var t={};if(r!=null)for(var n in r)n!=="default"&&Object.prototype.hasOwnProperty.call(r,n)&&tm(t,r,n);return em(t,r),t};Object.defineProperty(re,"__esModule",{value:!0});re.OperatorSetId=void 0;var rm=nm(M()),qo=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsOperatorSetId(t,n){return(n||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsOperatorSetId(t,n){return t.setPosition(t.position()+rm.SIZE_PREFIX_LENGTH),(n||new r).__init(t.readInt32(t.position())+t.position(),t)}domain(t){let n=this.bb.__offset(this.bb_pos,4);return n?this.bb.__string(this.bb_pos+n,t):null}version(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}static startOperatorSetId(t){t.startObject(2)}static addDomain(t,n){t.addFieldOffset(0,n,0)}static addVersion(t,n){t.addFieldInt64(1,n,BigInt("0"))}static endOperatorSetId(t){return t.endObject()}static createOperatorSetId(t,n,e){return r.startOperatorSetId(t),r.addDomain(t,n),r.addVersion(t,e),r.endOperatorSetId(t)}};re.OperatorSetId=qo});var Zo=O(oe=>{"use strict";var om=oe&&oe.__createBinding||(Object.create?function(r,t,n,e){e===void 0&&(e=n);var o=Object.getOwnPropertyDescriptor(t,n);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(r,e,o)}:function(r,t,n,e){e===void 0&&(e=n),r[e]=t[n]}),im=oe&&oe.__setModuleDefault||(Object.create?function(r,t){Object.defineProperty(r,"default",{enumerable:!0,value:t})}:function(r,t){r.default=t}),am=oe&&oe.__importStar||function(r){if(r&&r.__esModule)return r;var t={};if(r!=null)for(var n in r)n!=="default"&&Object.prototype.hasOwnProperty.call(r,n)&&om(t,r,n);return im(t,r),t};Object.defineProperty(oe,"__esModule",{value:!0});oe.StringStringEntry=void 0;var sm=am(M()),Xo=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsStringStringEntry(t,n){return(n||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsStringStringEntry(t,n){return t.setPosition(t.position()+sm.SIZE_PREFIX_LENGTH),(n||new r).__init(t.readInt32(t.position())+t.position(),t)}key(t){let n=this.bb.__offset(this.bb_pos,4);return n?this.bb.__string(this.bb_pos+n,t):null}value(t){let n=this.bb.__offset(this.bb_pos,6);return n?this.bb.__string(this.bb_pos+n,t):null}static startStringStringEntry(t){t.startObject(2)}static addKey(t,n){t.addFieldOffset(0,n,0)}static addValue(t,n){t.addFieldOffset(1,n,0)}static endStringStringEntry(t){return t.endObject()}static createStringStringEntry(t,n,e){return r.startStringStringEntry(t),r.addKey(t,n),r.addValue(t,e),r.endStringStringEntry(t)}};oe.StringStringEntry=Xo});var Yo=O(ie=>{"use strict";var um=ie&&ie.__createBinding||(Object.create?function(r,t,n,e){e===void 0&&(e=n);var o=Object.getOwnPropertyDescriptor(t,n);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(r,e,o)}:function(r,t,n,e){e===void 0&&(e=n),r[e]=t[n]}),lm=ie&&ie.__setModuleDefault||(Object.create?function(r,t){Object.defineProperty(r,"default",{enumerable:!0,value:t})}:function(r,t){r.default=t}),cm=ie&&ie.__importStar||function(r){if(r&&r.__esModule)return r;var t={};if(r!=null)for(var n in r)n!=="default"&&Object.prototype.hasOwnProperty.call(r,n)&&um(t,r,n);return lm(t,r),t};Object.defineProperty(ie,"__esModule",{value:!0});ie.Model=void 0;var fm=cm(M()),dm=jn(),pm=Ko(),hm=Zo(),Jo=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsModel(t,n){return(n||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsModel(t,n){return t.setPosition(t.position()+fm.SIZE_PREFIX_LENGTH),(n||new r).__init(t.readInt32(t.position())+t.position(),t)}irVersion(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}opsetImport(t,n){let e=this.bb.__offset(this.bb_pos,6);return e?(n||new pm.OperatorSetId).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+e)+t*4),this.bb):null}opsetImportLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}producerName(t){let n=this.bb.__offset(this.bb_pos,8);return n?this.bb.__string(this.bb_pos+n,t):null}producerVersion(t){let n=this.bb.__offset(this.bb_pos,10);return n?this.bb.__string(this.bb_pos+n,t):null}domain(t){let n=this.bb.__offset(this.bb_pos,12);return n?this.bb.__string(this.bb_pos+n,t):null}modelVersion(){let t=this.bb.__offset(this.bb_pos,14);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}docString(t){let n=this.bb.__offset(this.bb_pos,16);return n?this.bb.__string(this.bb_pos+n,t):null}graph(t){let n=this.bb.__offset(this.bb_pos,18);return n?(t||new dm.Graph).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}graphDocString(t){let n=this.bb.__offset(this.bb_pos,20);return n?this.bb.__string(this.bb_pos+n,t):null}metadataProps(t,n){let e=this.bb.__offset(this.bb_pos,22);return e?(n||new hm.StringStringEntry).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+e)+t*4),this.bb):null}metadataPropsLength(){let t=this.bb.__offset(this.bb_pos,22);return t?this.bb.__vector_len(this.bb_pos+t):0}static startModel(t){t.startObject(10)}static addIrVersion(t,n){t.addFieldInt64(0,n,BigInt("0"))}static addOpsetImport(t,n){t.addFieldOffset(1,n,0)}static createOpsetImportVector(t,n){t.startVector(4,n.length,4);for(let e=n.length-1;e>=0;e--)t.addOffset(n[e]);return t.endVector()}static startOpsetImportVector(t,n){t.startVector(4,n,4)}static addProducerName(t,n){t.addFieldOffset(2,n,0)}static addProducerVersion(t,n){t.addFieldOffset(3,n,0)}static addDomain(t,n){t.addFieldOffset(4,n,0)}static addModelVersion(t,n){t.addFieldInt64(5,n,BigInt("0"))}static addDocString(t,n){t.addFieldOffset(6,n,0)}static addGraph(t,n){t.addFieldOffset(7,n,0)}static addGraphDocString(t,n){t.addFieldOffset(8,n,0)}static addMetadataProps(t,n){t.addFieldOffset(9,n,0)}static createMetadataPropsVector(t,n){t.startVector(4,n.length,4);for(let e=n.length-1;e>=0;e--)t.addOffset(n[e]);return t.endVector()}static startMetadataPropsVector(t,n){t.startVector(4,n,4)}static endModel(t){return t.endObject()}};ie.Model=Jo});var _s=O(ae=>{"use strict";var mm=ae&&ae.__createBinding||(Object.create?function(r,t,n,e){e===void 0&&(e=n);var o=Object.getOwnPropertyDescriptor(t,n);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(r,e,o)}:function(r,t,n,e){e===void 0&&(e=n),r[e]=t[n]}),bm=ae&&ae.__setModuleDefault||(Object.create?function(r,t){Object.defineProperty(r,"default",{enumerable:!0,value:t})}:function(r,t){r.default=t}),gm=ae&&ae.__importStar||function(r){if(r&&r.__esModule)return r;var t={};if(r!=null)for(var n in r)n!=="default"&&Object.prototype.hasOwnProperty.call(r,n)&&mm(t,r,n);return bm(t,r),t};Object.defineProperty(ae,"__esModule",{value:!0});ae.InferenceSession=void 0;var ym=gm(M()),Tm=Ho(),_m=Yo(),Qo=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsInferenceSession(t,n){return(n||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInferenceSession(t,n){return t.setPosition(t.position()+ym.SIZE_PREFIX_LENGTH),(n||new r).__init(t.readInt32(t.position())+t.position(),t)}static bufferHasIdentifier(t){return t.__has_identifier("ORTM")}ortVersion(t){let n=this.bb.__offset(this.bb_pos,4);return n?this.bb.__string(this.bb_pos+n,t):null}model(t){let n=this.bb.__offset(this.bb_pos,6);return n?(t||new _m.Model).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}kernelTypeStrResolver(t){let n=this.bb.__offset(this.bb_pos,10);return n?(t||new Tm.KernelTypeStrResolver).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}static startInferenceSession(t){t.startObject(4)}static addOrtVersion(t,n){t.addFieldOffset(0,n,0)}static addModel(t,n){t.addFieldOffset(1,n,0)}static addKernelTypeStrResolver(t,n){t.addFieldOffset(3,n,0)}static endInferenceSession(t){return t.endObject()}static finishInferenceSessionBuffer(t,n){t.finish(n,"ORTM")}static finishSizePrefixedInferenceSessionBuffer(t,n){t.finish(n,"ORTM",!0)}};ae.InferenceSession=Qo});var xm,vm,Wn,bt,wm,Im,Om,Pm,Sm,Am,Em,Dm,ti,ei,Lm,$m,Nm,Fm,ni,Cm,Rm,Gm,km,Mm,Vm,Bm,zm,Um,jm,Wm,Hm,qm,on,ri,Km,oi,Xm,xs=y(()=>{"use strict";xm=E(Vr()),vm=E(qr()),Wn=E(Yr()),bt=E(Kr()),wm=E(Co()),Im=E(Ts()),Om=E(Mo()),Pm=E(ko()),Sm=E(wo()),Am=E(xo()),Em=E(To()),Dm=E(to()),ti=E(jn()),ei=E(_s()),Lm=E(zo()),$m=E(Ho()),Nm=E(bo()),Fm=E(Yo()),ni=E(Jr()),Cm=E(no()),Rm=E(Xr()),Gm=E(oo()),km=E(jo()),Mm=E(Ko()),Vm=E(ao()),Bm=E(uo()),zm=E(co()),Um=E(yo()),jm=E(Oo()),Wm=E(ho()),Hm=E(Zo()),qm=E(nn()),on=E(en()),ri=E(So()),Km=E(rn()),oi=E(Ao()),Xm=E(Lo())});var an=y(()=>{"use strict";xs()});var ws=O((X_,vs)=>{"use strict";vs.exports=Zm;function Zm(r,t){for(var n=new Array(arguments.length-1),e=0,o=2,i=!0;o{"use strict";var qn=Ps;qn.length=function(t){var n=t.length;if(!n)return 0;for(var e=0;--n%4>1&&t.charAt(n)==="=";)++e;return Math.ceil(t.length*3)/4-e};var Ue=new Array(64),Os=new Array(123);for(It=0;It<64;)Os[Ue[It]=It<26?It+65:It<52?It+71:It<62?It-4:It-59|43]=It++;var It;qn.encode=function(t,n,e){for(var o=null,i=[],a=0,s=0,u;n>2],u=(l&3)<<4,s=1;break;case 1:i[a++]=Ue[u|l>>4],u=(l&15)<<2,s=2;break;case 2:i[a++]=Ue[u|l>>6],i[a++]=Ue[l&63],s=0;break}a>8191&&((o||(o=[])).push(String.fromCharCode.apply(String,i)),a=0)}return s&&(i[a++]=Ue[u],i[a++]=61,s===1&&(i[a++]=61)),o?(a&&o.push(String.fromCharCode.apply(String,i.slice(0,a))),o.join("")):String.fromCharCode.apply(String,i.slice(0,a))};var Is="invalid encoding";qn.decode=function(t,n,e){for(var o=e,i=0,a,s=0;s1)break;if((u=Os[u])===void 0)throw Error(Is);switch(i){case 0:a=u,i=1;break;case 1:n[e++]=a<<2|(u&48)>>4,a=u,i=2;break;case 2:n[e++]=(a&15)<<4|(u&60)>>2,a=u,i=3;break;case 3:n[e++]=(a&3)<<6|u,i=0;break}}if(i===1)throw Error(Is);return e-o};qn.test=function(t){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t)}});var Es=O((J_,As)=>{"use strict";As.exports=Kn;function Kn(){this._listeners={}}Kn.prototype.on=function(t,n,e){return(this._listeners[t]||(this._listeners[t]=[])).push({fn:n,ctx:e||this}),this};Kn.prototype.off=function(t,n){if(t===void 0)this._listeners={};else if(n===void 0)this._listeners[t]=[];else for(var e=this._listeners[t],o=0;o{"use strict";Cs.exports=Ds(Ds);function Ds(r){return typeof Float32Array<"u"?function(){var t=new Float32Array([-0]),n=new Uint8Array(t.buffer),e=n[3]===128;function o(u,l,c){t[0]=u,l[c]=n[0],l[c+1]=n[1],l[c+2]=n[2],l[c+3]=n[3]}function i(u,l,c){t[0]=u,l[c]=n[3],l[c+1]=n[2],l[c+2]=n[1],l[c+3]=n[0]}r.writeFloatLE=e?o:i,r.writeFloatBE=e?i:o;function a(u,l){return n[0]=u[l],n[1]=u[l+1],n[2]=u[l+2],n[3]=u[l+3],t[0]}function s(u,l){return n[3]=u[l],n[2]=u[l+1],n[1]=u[l+2],n[0]=u[l+3],t[0]}r.readFloatLE=e?a:s,r.readFloatBE=e?s:a}():function(){function t(e,o,i,a){var s=o<0?1:0;if(s&&(o=-o),o===0)e(1/o>0?0:2147483648,i,a);else if(isNaN(o))e(2143289344,i,a);else if(o>34028234663852886e22)e((s<<31|2139095040)>>>0,i,a);else if(o<11754943508222875e-54)e((s<<31|Math.round(o/1401298464324817e-60))>>>0,i,a);else{var u=Math.floor(Math.log(o)/Math.LN2),l=Math.round(o*Math.pow(2,-u)*8388608)&8388607;e((s<<31|u+127<<23|l)>>>0,i,a)}}r.writeFloatLE=t.bind(null,Ls),r.writeFloatBE=t.bind(null,$s);function n(e,o,i){var a=e(o,i),s=(a>>31)*2+1,u=a>>>23&255,l=a&8388607;return u===255?l?NaN:s*(1/0):u===0?s*1401298464324817e-60*l:s*Math.pow(2,u-150)*(l+8388608)}r.readFloatLE=n.bind(null,Ns),r.readFloatBE=n.bind(null,Fs)}(),typeof Float64Array<"u"?function(){var t=new Float64Array([-0]),n=new Uint8Array(t.buffer),e=n[7]===128;function o(u,l,c){t[0]=u,l[c]=n[0],l[c+1]=n[1],l[c+2]=n[2],l[c+3]=n[3],l[c+4]=n[4],l[c+5]=n[5],l[c+6]=n[6],l[c+7]=n[7]}function i(u,l,c){t[0]=u,l[c]=n[7],l[c+1]=n[6],l[c+2]=n[5],l[c+3]=n[4],l[c+4]=n[3],l[c+5]=n[2],l[c+6]=n[1],l[c+7]=n[0]}r.writeDoubleLE=e?o:i,r.writeDoubleBE=e?i:o;function a(u,l){return n[0]=u[l],n[1]=u[l+1],n[2]=u[l+2],n[3]=u[l+3],n[4]=u[l+4],n[5]=u[l+5],n[6]=u[l+6],n[7]=u[l+7],t[0]}function s(u,l){return n[7]=u[l],n[6]=u[l+1],n[5]=u[l+2],n[4]=u[l+3],n[3]=u[l+4],n[2]=u[l+5],n[1]=u[l+6],n[0]=u[l+7],t[0]}r.readDoubleLE=e?a:s,r.readDoubleBE=e?s:a}():function(){function t(e,o,i,a,s,u){var l=a<0?1:0;if(l&&(a=-a),a===0)e(0,s,u+o),e(1/a>0?0:2147483648,s,u+i);else if(isNaN(a))e(0,s,u+o),e(2146959360,s,u+i);else if(a>17976931348623157e292)e(0,s,u+o),e((l<<31|2146435072)>>>0,s,u+i);else{var c;if(a<22250738585072014e-324)c=a/5e-324,e(c>>>0,s,u+o),e((l<<31|c/4294967296)>>>0,s,u+i);else{var d=Math.floor(Math.log(a)/Math.LN2);d===1024&&(d=1023),c=a*Math.pow(2,-d),e(c*4503599627370496>>>0,s,u+o),e((l<<31|d+1023<<20|c*1048576&1048575)>>>0,s,u+i)}}}r.writeDoubleLE=t.bind(null,Ls,0,4),r.writeDoubleBE=t.bind(null,$s,4,0);function n(e,o,i,a,s){var u=e(a,s+o),l=e(a,s+i),c=(l>>31)*2+1,d=l>>>20&2047,p=4294967296*(l&1048575)+u;return d===2047?p?NaN:c*(1/0):d===0?c*5e-324*p:c*Math.pow(2,d-1075)*(p+4503599627370496)}r.readDoubleLE=n.bind(null,Ns,0,4),r.readDoubleBE=n.bind(null,Fs,4,0)}(),r}function Ls(r,t,n){t[n]=r&255,t[n+1]=r>>>8&255,t[n+2]=r>>>16&255,t[n+3]=r>>>24}function $s(r,t,n){t[n]=r>>>24,t[n+1]=r>>>16&255,t[n+2]=r>>>8&255,t[n+3]=r&255}function Ns(r,t){return(r[t]|r[t+1]<<8|r[t+2]<<16|r[t+3]<<24)>>>0}function Fs(r,t){return(r[t]<<24|r[t+1]<<16|r[t+2]<<8|r[t+3])>>>0}});var Gs=O((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(r){}return null}});var Ms=O(ks=>{"use strict";var ii=ks;ii.length=function(t){for(var n=0,e=0,o=0;o191&&u<224?a[s++]=(u&31)<<6|t[n++]&63:u>239&&u<365?(u=((u&7)<<18|(t[n++]&63)<<12|(t[n++]&63)<<6|t[n++]&63)-65536,a[s++]=55296+(u>>10),a[s++]=56320+(u&1023)):a[s++]=(u&15)<<12|(t[n++]&63)<<6|t[n++]&63,s>8191&&((i||(i=[])).push(String.fromCharCode.apply(String,a)),s=0);return i?(s&&i.push(String.fromCharCode.apply(String,a.slice(0,s))),i.join("")):String.fromCharCode.apply(String,a.slice(0,s))};ii.write=function(t,n,e){for(var o=e,i,a,s=0;s>6|192,n[e++]=i&63|128):(i&64512)===55296&&((a=t.charCodeAt(s+1))&64512)===56320?(i=65536+((i&1023)<<10)+(a&1023),++s,n[e++]=i>>18|240,n[e++]=i>>12&63|128,n[e++]=i>>6&63|128,n[e++]=i&63|128):(n[e++]=i>>12|224,n[e++]=i>>6&63|128,n[e++]=i&63|128);return e-o}});var Bs=O((tx,Vs)=>{"use strict";Vs.exports=Jm;function Jm(r,t,n){var e=n||8192,o=e>>>1,i=null,a=e;return function(u){if(u<1||u>o)return r(u);a+u>e&&(i=r(e),a=0);var l=t.call(i,a,a+=u);return a&7&&(a=(a|7)+1),l}}});var Us=O((ex,zs)=>{"use strict";zs.exports=Q;var sn=_e();function Q(r,t){this.lo=r>>>0,this.hi=t>>>0}var Ee=Q.zero=new Q(0,0);Ee.toNumber=function(){return 0};Ee.zzEncode=Ee.zzDecode=function(){return this};Ee.length=function(){return 1};var Ym=Q.zeroHash="\0\0\0\0\0\0\0\0";Q.fromNumber=function(t){if(t===0)return Ee;var n=t<0;n&&(t=-t);var e=t>>>0,o=(t-e)/4294967296>>>0;return n&&(o=~o>>>0,e=~e>>>0,++e>4294967295&&(e=0,++o>4294967295&&(o=0))),new Q(e,o)};Q.from=function(t){if(typeof t=="number")return Q.fromNumber(t);if(sn.isString(t))if(sn.Long)t=sn.Long.fromString(t);else return Q.fromNumber(parseInt(t,10));return t.low||t.high?new Q(t.low>>>0,t.high>>>0):Ee};Q.prototype.toNumber=function(t){if(!t&&this.hi>>>31){var n=~this.lo+1>>>0,e=~this.hi>>>0;return n||(e=e+1>>>0),-(n+e*4294967296)}return this.lo+this.hi*4294967296};Q.prototype.toLong=function(t){return sn.Long?new sn.Long(this.lo|0,this.hi|0,!!t):{low:this.lo|0,high:this.hi|0,unsigned:!!t}};var Te=String.prototype.charCodeAt;Q.fromHash=function(t){return t===Ym?Ee:new Q((Te.call(t,0)|Te.call(t,1)<<8|Te.call(t,2)<<16|Te.call(t,3)<<24)>>>0,(Te.call(t,4)|Te.call(t,5)<<8|Te.call(t,6)<<16|Te.call(t,7)<<24)>>>0)};Q.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)};Q.prototype.zzEncode=function(){var t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this};Q.prototype.zzDecode=function(){var t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this};Q.prototype.length=function(){var t=this.lo,n=(this.lo>>>28|this.hi<<4)>>>0,e=this.hi>>>24;return e===0?n===0?t<16384?t<128?1:2:t<2097152?3:4:n<16384?n<128?5:6:n<2097152?7:8:e<128?9:10}});var _e=O(ai=>{"use strict";var P=ai;P.asPromise=ws();P.base64=Ss();P.EventEmitter=Es();P.float=Rs();P.inquire=Gs();P.utf8=Ms();P.pool=Bs();P.LongBits=Us();P.isNode=!!(typeof global<"u"&&global&&global.process&&global.process.versions&&global.process.versions.node);P.global=P.isNode&&global||typeof window<"u"&&window||typeof self<"u"&&self||ai;P.emptyArray=Object.freeze?Object.freeze([]):[];P.emptyObject=Object.freeze?Object.freeze({}):{};P.isInteger=Number.isInteger||function(t){return typeof t=="number"&&isFinite(t)&&Math.floor(t)===t};P.isString=function(t){return typeof t=="string"||t instanceof String};P.isObject=function(t){return t&&typeof t=="object"};P.isset=P.isSet=function(t,n){var e=t[n];return e!=null&&t.hasOwnProperty(n)?typeof e!="object"||(Array.isArray(e)?e.length:Object.keys(e).length)>0:!1};P.Buffer=function(){try{var r=P.inquire("buffer").Buffer;return r.prototype.utf8Write?r:null}catch{return null}}();P._Buffer_from=null;P._Buffer_allocUnsafe=null;P.newBuffer=function(t){return typeof t=="number"?P.Buffer?P._Buffer_allocUnsafe(t):new P.Array(t):P.Buffer?P._Buffer_from(t):typeof Uint8Array>"u"?t:new Uint8Array(t)};P.Array=typeof Uint8Array<"u"?Uint8Array:Array;P.Long=P.global.dcodeIO&&P.global.dcodeIO.Long||P.global.Long||P.inquire("long");P.key2Re=/^true|false|0|1$/;P.key32Re=/^-?(?:0|[1-9][0-9]*)$/;P.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/;P.longToHash=function(t){return t?P.LongBits.from(t).toHash():P.LongBits.zeroHash};P.longFromHash=function(t,n){var e=P.LongBits.fromHash(t);return P.Long?P.Long.fromBits(e.lo,e.hi,n):e.toNumber(!!n)};function js(r,t,n){for(var e=Object.keys(t),o=0;o-1;--i)if(n[o[i]]===1&&this[o[i]]!==void 0&&this[o[i]]!==null)return o[i]}};P.oneOfSetter=function(t){return function(n){for(var e=0;e{"use strict";Xs.exports=R;var gt=_e(),si,Xn=gt.LongBits,Hs=gt.base64,qs=gt.utf8;function un(r,t,n){this.fn=r,this.len=t,this.next=void 0,this.val=n}function li(){}function Qm(r){this.head=r.head,this.tail=r.tail,this.len=r.len,this.next=r.states}function R(){this.len=0,this.head=new un(li,0,0),this.tail=this.head,this.states=null}var Ks=function(){return gt.Buffer?function(){return(R.create=function(){return new si})()}:function(){return new R}};R.create=Ks();R.alloc=function(t){return new gt.Array(t)};gt.Array!==Array&&(R.alloc=gt.pool(R.alloc,gt.Array.prototype.subarray));R.prototype._push=function(t,n,e){return this.tail=this.tail.next=new un(t,n,e),this.len+=n,this};function ci(r,t,n){t[n]=r&255}function tb(r,t,n){for(;r>127;)t[n++]=r&127|128,r>>>=7;t[n]=r}function fi(r,t){this.len=r,this.next=void 0,this.val=t}fi.prototype=Object.create(un.prototype);fi.prototype.fn=tb;R.prototype.uint32=function(t){return this.len+=(this.tail=this.tail.next=new fi((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this};R.prototype.int32=function(t){return t<0?this._push(di,10,Xn.fromNumber(t)):this.uint32(t)};R.prototype.sint32=function(t){return this.uint32((t<<1^t>>31)>>>0)};function di(r,t,n){for(;r.hi;)t[n++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)t[n++]=r.lo&127|128,r.lo=r.lo>>>7;t[n++]=r.lo}R.prototype.uint64=function(t){var n=Xn.from(t);return this._push(di,n.length(),n)};R.prototype.int64=R.prototype.uint64;R.prototype.sint64=function(t){var n=Xn.from(t).zzEncode();return this._push(di,n.length(),n)};R.prototype.bool=function(t){return this._push(ci,1,t?1:0)};function ui(r,t,n){t[n]=r&255,t[n+1]=r>>>8&255,t[n+2]=r>>>16&255,t[n+3]=r>>>24}R.prototype.fixed32=function(t){return this._push(ui,4,t>>>0)};R.prototype.sfixed32=R.prototype.fixed32;R.prototype.fixed64=function(t){var n=Xn.from(t);return this._push(ui,4,n.lo)._push(ui,4,n.hi)};R.prototype.sfixed64=R.prototype.fixed64;R.prototype.float=function(t){return this._push(gt.float.writeFloatLE,4,t)};R.prototype.double=function(t){return this._push(gt.float.writeDoubleLE,8,t)};var eb=gt.Array.prototype.set?function(t,n,e){n.set(t,e)}:function(t,n,e){for(var o=0;o>>0;if(!n)return this._push(ci,1,0);if(gt.isString(t)){var e=R.alloc(n=Hs.length(t));Hs.decode(t,e,0),t=e}return this.uint32(n)._push(eb,n,t)};R.prototype.string=function(t){var n=qs.length(t);return n?this.uint32(n)._push(qs.write,n,t):this._push(ci,1,0)};R.prototype.fork=function(){return this.states=new Qm(this),this.head=this.tail=new un(li,0,0),this.len=0,this};R.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 un(li,0,0),this.len=0),this};R.prototype.ldelim=function(){var t=this.head,n=this.tail,e=this.len;return this.reset().uint32(e),e&&(this.tail.next=t.next,this.tail=n,this.len+=e),this};R.prototype.finish=function(){for(var t=this.head.next,n=this.constructor.alloc(this.len),e=0;t;)t.fn(t.val,n,e),e+=t.len,t=t.next;return n};R._configure=function(r){si=r,R.create=Ks(),si._configure()}});var Ys=O((ox,Js)=>{"use strict";Js.exports=se;var Zs=pi();(se.prototype=Object.create(Zs.prototype)).constructor=se;var xe=_e();function se(){Zs.call(this)}se._configure=function(){se.alloc=xe._Buffer_allocUnsafe,se.writeBytesBuffer=xe.Buffer&&xe.Buffer.prototype instanceof Uint8Array&&xe.Buffer.prototype.set.name==="set"?function(t,n,e){n.set(t,e)}:function(t,n,e){if(t.copy)t.copy(n,e,0,t.length);else for(var o=0;o>>0;return this.uint32(n),n&&this._push(se.writeBytesBuffer,n,t),this};function nb(r,t,n){r.length<40?xe.utf8.write(r,t,n):t.utf8Write?t.utf8Write(r,n):t.write(r,n)}se.prototype.string=function(t){var n=xe.Buffer.byteLength(t);return this.uint32(n),n&&this._push(nb,n,t),this};se._configure()});var bi=O((ix,ru)=>{"use strict";ru.exports=X;var Ot=_e(),mi,eu=Ot.LongBits,rb=Ot.utf8;function Pt(r,t){return RangeError("index out of range: "+r.pos+" + "+(t||1)+" > "+r.len)}function X(r){this.buf=r,this.pos=0,this.len=r.length}var Qs=typeof Uint8Array<"u"?function(t){if(t instanceof Uint8Array||Array.isArray(t))return new X(t);throw Error("illegal buffer")}:function(t){if(Array.isArray(t))return new X(t);throw Error("illegal buffer")},nu=function(){return Ot.Buffer?function(n){return(X.create=function(o){return Ot.Buffer.isBuffer(o)?new mi(o):Qs(o)})(n)}:Qs};X.create=nu();X.prototype._slice=Ot.Array.prototype.subarray||Ot.Array.prototype.slice;X.prototype.uint32=function(){var t=4294967295;return function(){if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,Pt(this,10);return t}}();X.prototype.int32=function(){return this.uint32()|0};X.prototype.sint32=function(){var t=this.uint32();return t>>>1^-(t&1)|0};function hi(){var r=new eu(0,0),t=0;if(this.len-this.pos>4){for(;t<4;++t)if(r.lo=(r.lo|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return r;if(r.lo=(r.lo|(this.buf[this.pos]&127)<<28)>>>0,r.hi=(r.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return r;t=0}else{for(;t<3;++t){if(this.pos>=this.len)throw Pt(this);if(r.lo=(r.lo|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return r}return r.lo=(r.lo|(this.buf[this.pos++]&127)<>>0,r}if(this.len-this.pos>4){for(;t<5;++t)if(r.hi=(r.hi|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return r}else for(;t<5;++t){if(this.pos>=this.len)throw Pt(this);if(r.hi=(r.hi|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return r}throw Error("invalid varint encoding")}X.prototype.bool=function(){return this.uint32()!==0};function Zn(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}X.prototype.fixed32=function(){if(this.pos+4>this.len)throw Pt(this,4);return Zn(this.buf,this.pos+=4)};X.prototype.sfixed32=function(){if(this.pos+4>this.len)throw Pt(this,4);return Zn(this.buf,this.pos+=4)|0};function tu(){if(this.pos+8>this.len)throw Pt(this,8);return new eu(Zn(this.buf,this.pos+=4),Zn(this.buf,this.pos+=4))}X.prototype.float=function(){if(this.pos+4>this.len)throw Pt(this,4);var t=Ot.float.readFloatLE(this.buf,this.pos);return this.pos+=4,t};X.prototype.double=function(){if(this.pos+8>this.len)throw Pt(this,4);var t=Ot.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,t};X.prototype.bytes=function(){var t=this.uint32(),n=this.pos,e=this.pos+t;if(e>this.len)throw Pt(this,t);if(this.pos+=t,Array.isArray(this.buf))return this.buf.slice(n,e);if(n===e){var o=Ot.Buffer;return o?o.alloc(0):new this.buf.constructor(0)}return this._slice.call(this.buf,n,e)};X.prototype.string=function(){var t=this.bytes();return rb.read(t,0,t.length)};X.prototype.skip=function(t){if(typeof t=="number"){if(this.pos+t>this.len)throw Pt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw Pt(this);while(this.buf[this.pos++]&128);return this};X.prototype.skipType=function(r){switch(r){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(r=this.uint32()&7)!==4;)this.skipType(r);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+r+" at offset "+this.pos)}return this};X._configure=function(r){mi=r,X.create=nu(),mi._configure();var t=Ot.Long?"toLong":"toNumber";Ot.merge(X.prototype,{int64:function(){return hi.call(this)[t](!1)},uint64:function(){return hi.call(this)[t](!0)},sint64:function(){return hi.call(this).zzDecode()[t](!1)},fixed64:function(){return tu.call(this)[t](!0)},sfixed64:function(){return tu.call(this)[t](!1)}})}});var su=O((ax,au)=>{"use strict";au.exports=De;var iu=bi();(De.prototype=Object.create(iu.prototype)).constructor=De;var ou=_e();function De(r){iu.call(this,r)}De._configure=function(){ou.Buffer&&(De.prototype._slice=ou.Buffer.prototype.slice)};De.prototype.string=function(){var t=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+t,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+t,this.len))};De._configure()});var lu=O((sx,uu)=>{"use strict";uu.exports=ln;var gi=_e();(ln.prototype=Object.create(gi.EventEmitter.prototype)).constructor=ln;function ln(r,t,n){if(typeof r!="function")throw TypeError("rpcImpl must be a function");gi.EventEmitter.call(this),this.rpcImpl=r,this.requestDelimited=!!t,this.responseDelimited=!!n}ln.prototype.rpcCall=function r(t,n,e,o,i){if(!o)throw TypeError("request must be specified");var a=this;if(!i)return gi.asPromise(r,a,t,n,e,o);if(!a.rpcImpl){setTimeout(function(){i(Error("already ended"))},0);return}try{return a.rpcImpl(t,n[a.requestDelimited?"encodeDelimited":"encode"](o).finish(),function(u,l){if(u)return a.emit("error",u,t),i(u);if(l===null){a.end(!0);return}if(!(l instanceof e))try{l=e[a.responseDelimited?"decodeDelimited":"decode"](l)}catch(c){return a.emit("error",c,t),i(c)}return a.emit("data",l,t),i(null,l)})}catch(s){a.emit("error",s,t),setTimeout(function(){i(s)},0);return}};ln.prototype.end=function(t){return this.rpcImpl&&(t||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}});var fu=O(cu=>{"use strict";var ob=cu;ob.Service=lu()});var pu=O((lx,du)=>{"use strict";du.exports={}});var bu=O(mu=>{"use strict";var ut=mu;ut.build="minimal";ut.Writer=pi();ut.BufferWriter=Ys();ut.Reader=bi();ut.BufferReader=su();ut.util=_e();ut.rpc=fu();ut.roots=pu();ut.configure=hu;function hu(){ut.util._configure(),ut.Writer._configure(ut.BufferWriter),ut.Reader._configure(ut.BufferReader)}hu()});var yu=O((fx,gu)=>{"use strict";gu.exports=bu()});var je=O((dx,Tu)=>{"use strict";var U=yu(),_=U.Reader,Z=U.Writer,h=U.util,f=U.roots.default||(U.roots.default={});f.onnx=function(){var r={};return r.Version=function(){var t={},n=Object.create(t);return n[t[0]="_START_VERSION"]=0,n[t[1]="IR_VERSION_2017_10_10"]=1,n[t[2]="IR_VERSION_2017_10_30"]=2,n[t[3]="IR_VERSION_2017_11_3"]=3,n[t[4]="IR_VERSION_2019_1_22"]=4,n[t[5]="IR_VERSION_2019_3_18"]=5,n[t[6]="IR_VERSION_2019_9_19"]=6,n[t[7]="IR_VERSION_2020_5_8"]=7,n[t[8]="IR_VERSION_2021_7_30"]=8,n[t[9]="IR_VERSION"]=9,n}(),r.AttributeProto=function(){function t(n){if(this.floats=[],this.ints=[],this.strings=[],this.tensors=[],this.graphs=[],this.sparseTensors=[],this.typeProtos=[],n)for(var e=Object.keys(n),o=0;o>>3){case 1:{a.name=e.string();break}case 21:{a.refAttrName=e.string();break}case 13:{a.docString=e.string();break}case 20:{a.type=e.int32();break}case 2:{a.f=e.float();break}case 3:{a.i=e.int64();break}case 4:{a.s=e.bytes();break}case 5:{a.t=f.onnx.TensorProto.decode(e,e.uint32());break}case 6:{a.g=f.onnx.GraphProto.decode(e,e.uint32());break}case 22:{a.sparseTensor=f.onnx.SparseTensorProto.decode(e,e.uint32());break}case 14:{a.tp=f.onnx.TypeProto.decode(e,e.uint32());break}case 7:{if(a.floats&&a.floats.length||(a.floats=[]),(s&7)===2)for(var u=e.uint32()+e.pos;e.pos>>0,e.i.high>>>0).toNumber())),e.s!=null&&(typeof e.s=="string"?h.base64.decode(e.s,o.s=h.newBuffer(h.base64.length(e.s)),0):e.s.length>=0&&(o.s=e.s)),e.t!=null){if(typeof e.t!="object")throw TypeError(".onnx.AttributeProto.t: object expected");o.t=f.onnx.TensorProto.fromObject(e.t)}if(e.g!=null){if(typeof e.g!="object")throw TypeError(".onnx.AttributeProto.g: object expected");o.g=f.onnx.GraphProto.fromObject(e.g)}if(e.sparseTensor!=null){if(typeof e.sparseTensor!="object")throw TypeError(".onnx.AttributeProto.sparseTensor: object expected");o.sparseTensor=f.onnx.SparseTensorProto.fromObject(e.sparseTensor)}if(e.tp!=null){if(typeof e.tp!="object")throw TypeError(".onnx.AttributeProto.tp: object expected");o.tp=f.onnx.TypeProto.fromObject(e.tp)}if(e.floats){if(!Array.isArray(e.floats))throw TypeError(".onnx.AttributeProto.floats: array expected");o.floats=[];for(var i=0;i>>0,e.ints[i].high>>>0).toNumber())}if(e.strings){if(!Array.isArray(e.strings))throw TypeError(".onnx.AttributeProto.strings: array expected");o.strings=[];for(var i=0;i=0&&(o.strings[i]=e.strings[i])}if(e.tensors){if(!Array.isArray(e.tensors))throw TypeError(".onnx.AttributeProto.tensors: array expected");o.tensors=[];for(var i=0;i>>0,e.i.high>>>0).toNumber():e.i),e.s!=null&&e.hasOwnProperty("s")&&(i.s=o.bytes===String?h.base64.encode(e.s,0,e.s.length):o.bytes===Array?Array.prototype.slice.call(e.s):e.s),e.t!=null&&e.hasOwnProperty("t")&&(i.t=f.onnx.TensorProto.toObject(e.t,o)),e.g!=null&&e.hasOwnProperty("g")&&(i.g=f.onnx.GraphProto.toObject(e.g,o)),e.floats&&e.floats.length){i.floats=[];for(var s=0;s>>0,e.ints[s].high>>>0).toNumber():e.ints[s]}if(e.strings&&e.strings.length){i.strings=[];for(var s=0;s>>3){case 1:{a.name=e.string();break}case 2:{a.type=f.onnx.TypeProto.decode(e,e.uint32());break}case 3:{a.docString=e.string();break}default:e.skipType(s&7);break}}return a},t.decodeDelimited=function(e){return e instanceof _||(e=new _(e)),this.decode(e,e.uint32())},t.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.name!=null&&e.hasOwnProperty("name")&&!h.isString(e.name))return"name: string expected";if(e.type!=null&&e.hasOwnProperty("type")){var o=f.onnx.TypeProto.verify(e.type);if(o)return"type."+o}return e.docString!=null&&e.hasOwnProperty("docString")&&!h.isString(e.docString)?"docString: string expected":null},t.fromObject=function(e){if(e instanceof f.onnx.ValueInfoProto)return e;var o=new f.onnx.ValueInfoProto;if(e.name!=null&&(o.name=String(e.name)),e.type!=null){if(typeof e.type!="object")throw TypeError(".onnx.ValueInfoProto.type: object expected");o.type=f.onnx.TypeProto.fromObject(e.type)}return e.docString!=null&&(o.docString=String(e.docString)),o},t.toObject=function(e,o){o||(o={});var i={};return o.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=f.onnx.TypeProto.toObject(e.type,o)),e.docString!=null&&e.hasOwnProperty("docString")&&(i.docString=e.docString),i},t.prototype.toJSON=function(){return this.constructor.toObject(this,U.util.toJSONOptions)},t.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/onnx.ValueInfoProto"},t}(),r.NodeProto=function(){function t(n){if(this.input=[],this.output=[],this.attribute=[],n)for(var e=Object.keys(n),o=0;o>>3){case 1:{a.input&&a.input.length||(a.input=[]),a.input.push(e.string());break}case 2:{a.output&&a.output.length||(a.output=[]),a.output.push(e.string());break}case 3:{a.name=e.string();break}case 4:{a.opType=e.string();break}case 7:{a.domain=e.string();break}case 5:{a.attribute&&a.attribute.length||(a.attribute=[]),a.attribute.push(f.onnx.AttributeProto.decode(e,e.uint32()));break}case 6:{a.docString=e.string();break}default:e.skipType(s&7);break}}return a},t.decodeDelimited=function(e){return e instanceof _||(e=new _(e)),this.decode(e,e.uint32())},t.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 o=0;o>>3){case 1:{a.initialization=f.onnx.GraphProto.decode(e,e.uint32());break}case 2:{a.algorithm=f.onnx.GraphProto.decode(e,e.uint32());break}case 3:{a.initializationBinding&&a.initializationBinding.length||(a.initializationBinding=[]),a.initializationBinding.push(f.onnx.StringStringEntryProto.decode(e,e.uint32()));break}case 4:{a.updateBinding&&a.updateBinding.length||(a.updateBinding=[]),a.updateBinding.push(f.onnx.StringStringEntryProto.decode(e,e.uint32()));break}default:e.skipType(s&7);break}}return a},t.decodeDelimited=function(e){return e instanceof _||(e=new _(e)),this.decode(e,e.uint32())},t.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.initialization!=null&&e.hasOwnProperty("initialization")){var o=f.onnx.GraphProto.verify(e.initialization);if(o)return"initialization."+o}if(e.algorithm!=null&&e.hasOwnProperty("algorithm")){var o=f.onnx.GraphProto.verify(e.algorithm);if(o)return"algorithm."+o}if(e.initializationBinding!=null&&e.hasOwnProperty("initializationBinding")){if(!Array.isArray(e.initializationBinding))return"initializationBinding: array expected";for(var i=0;i>>3){case 1:{a.irVersion=e.int64();break}case 8:{a.opsetImport&&a.opsetImport.length||(a.opsetImport=[]),a.opsetImport.push(f.onnx.OperatorSetIdProto.decode(e,e.uint32()));break}case 2:{a.producerName=e.string();break}case 3:{a.producerVersion=e.string();break}case 4:{a.domain=e.string();break}case 5:{a.modelVersion=e.int64();break}case 6:{a.docString=e.string();break}case 7:{a.graph=f.onnx.GraphProto.decode(e,e.uint32());break}case 14:{a.metadataProps&&a.metadataProps.length||(a.metadataProps=[]),a.metadataProps.push(f.onnx.StringStringEntryProto.decode(e,e.uint32()));break}case 20:{a.trainingInfo&&a.trainingInfo.length||(a.trainingInfo=[]),a.trainingInfo.push(f.onnx.TrainingInfoProto.decode(e,e.uint32()));break}case 25:{a.functions&&a.functions.length||(a.functions=[]),a.functions.push(f.onnx.FunctionProto.decode(e,e.uint32()));break}default:e.skipType(s&7);break}}return a},t.decodeDelimited=function(e){return e instanceof _||(e=new _(e)),this.decode(e,e.uint32())},t.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.irVersion!=null&&e.hasOwnProperty("irVersion")&&!h.isInteger(e.irVersion)&&!(e.irVersion&&h.isInteger(e.irVersion.low)&&h.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 o=0;o>>0,e.irVersion.high>>>0).toNumber())),e.opsetImport){if(!Array.isArray(e.opsetImport))throw TypeError(".onnx.ModelProto.opsetImport: array expected");o.opsetImport=[];for(var i=0;i>>0,e.modelVersion.high>>>0).toNumber())),e.docString!=null&&(o.docString=String(e.docString)),e.graph!=null){if(typeof e.graph!="object")throw TypeError(".onnx.ModelProto.graph: object expected");o.graph=f.onnx.GraphProto.fromObject(e.graph)}if(e.metadataProps){if(!Array.isArray(e.metadataProps))throw TypeError(".onnx.ModelProto.metadataProps: array expected");o.metadataProps=[];for(var i=0;i>>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=o.longs===String?String(e.modelVersion):e.modelVersion:i.modelVersion=o.longs===String?h.Long.prototype.toString.call(e.modelVersion):o.longs===Number?new h.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=f.onnx.GraphProto.toObject(e.graph,o)),e.opsetImport&&e.opsetImport.length){i.opsetImport=[];for(var s=0;s>>3){case 1:{a.key=e.string();break}case 2:{a.value=e.string();break}default:e.skipType(s&7);break}}return a},t.decodeDelimited=function(e){return e instanceof _||(e=new _(e)),this.decode(e,e.uint32())},t.verify=function(e){return typeof e!="object"||e===null?"object expected":e.key!=null&&e.hasOwnProperty("key")&&!h.isString(e.key)?"key: string expected":e.value!=null&&e.hasOwnProperty("value")&&!h.isString(e.value)?"value: string expected":null},t.fromObject=function(e){if(e instanceof f.onnx.StringStringEntryProto)return e;var o=new f.onnx.StringStringEntryProto;return e.key!=null&&(o.key=String(e.key)),e.value!=null&&(o.value=String(e.value)),o},t.toObject=function(e,o){o||(o={});var i={};return o.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},t.prototype.toJSON=function(){return this.constructor.toObject(this,U.util.toJSONOptions)},t.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/onnx.StringStringEntryProto"},t}(),r.TensorAnnotation=function(){function t(n){if(this.quantParameterTensorNames=[],n)for(var e=Object.keys(n),o=0;o>>3){case 1:{a.tensorName=e.string();break}case 2:{a.quantParameterTensorNames&&a.quantParameterTensorNames.length||(a.quantParameterTensorNames=[]),a.quantParameterTensorNames.push(f.onnx.StringStringEntryProto.decode(e,e.uint32()));break}default:e.skipType(s&7);break}}return a},t.decodeDelimited=function(e){return e instanceof _||(e=new _(e)),this.decode(e,e.uint32())},t.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.tensorName!=null&&e.hasOwnProperty("tensorName")&&!h.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 o=0;o>>3){case 1:{a.node&&a.node.length||(a.node=[]),a.node.push(f.onnx.NodeProto.decode(e,e.uint32()));break}case 2:{a.name=e.string();break}case 5:{a.initializer&&a.initializer.length||(a.initializer=[]),a.initializer.push(f.onnx.TensorProto.decode(e,e.uint32()));break}case 15:{a.sparseInitializer&&a.sparseInitializer.length||(a.sparseInitializer=[]),a.sparseInitializer.push(f.onnx.SparseTensorProto.decode(e,e.uint32()));break}case 10:{a.docString=e.string();break}case 11:{a.input&&a.input.length||(a.input=[]),a.input.push(f.onnx.ValueInfoProto.decode(e,e.uint32()));break}case 12:{a.output&&a.output.length||(a.output=[]),a.output.push(f.onnx.ValueInfoProto.decode(e,e.uint32()));break}case 13:{a.valueInfo&&a.valueInfo.length||(a.valueInfo=[]),a.valueInfo.push(f.onnx.ValueInfoProto.decode(e,e.uint32()));break}case 14:{a.quantizationAnnotation&&a.quantizationAnnotation.length||(a.quantizationAnnotation=[]),a.quantizationAnnotation.push(f.onnx.TensorAnnotation.decode(e,e.uint32()));break}default:e.skipType(s&7);break}}return a},t.decodeDelimited=function(e){return e instanceof _||(e=new _(e)),this.decode(e,e.uint32())},t.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 o=0;o>>3){case 1:{if(a.dims&&a.dims.length||(a.dims=[]),(s&7)===2)for(var u=e.uint32()+e.pos;e.pos>>0,e.dims[i].high>>>0).toNumber())}if(e.dataType!=null&&(o.dataType=e.dataType|0),e.segment!=null){if(typeof e.segment!="object")throw TypeError(".onnx.TensorProto.segment: object expected");o.segment=f.onnx.TensorProto.Segment.fromObject(e.segment)}if(e.floatData){if(!Array.isArray(e.floatData))throw TypeError(".onnx.TensorProto.floatData: array expected");o.floatData=[];for(var i=0;i=0&&(o.stringData[i]=e.stringData[i])}if(e.int64Data){if(!Array.isArray(e.int64Data))throw TypeError(".onnx.TensorProto.int64Data: array expected");o.int64Data=[];for(var i=0;i>>0,e.int64Data[i].high>>>0).toNumber())}if(e.name!=null&&(o.name=String(e.name)),e.docString!=null&&(o.docString=String(e.docString)),e.rawData!=null&&(typeof e.rawData=="string"?h.base64.decode(e.rawData,o.rawData=h.newBuffer(h.base64.length(e.rawData)),0):e.rawData.length>=0&&(o.rawData=e.rawData)),e.externalData){if(!Array.isArray(e.externalData))throw TypeError(".onnx.TensorProto.externalData: array expected");o.externalData=[];for(var i=0;i>>0,e.uint64Data[i].high>>>0).toNumber(!0))}return o},t.toObject=function(e,o){o||(o={});var i={};if((o.arrays||o.defaults)&&(i.dims=[],i.floatData=[],i.int32Data=[],i.stringData=[],i.int64Data=[],i.doubleData=[],i.uint64Data=[],i.externalData=[]),o.defaults&&(i.dataType=0,i.segment=null,i.name="",o.bytes===String?i.rawData="":(i.rawData=[],o.bytes!==Array&&(i.rawData=h.newBuffer(i.rawData))),i.docString="",i.dataLocation=o.enums===String?"DEFAULT":0),e.dims&&e.dims.length){i.dims=[];for(var a=0;a>>0,e.dims[a].high>>>0).toNumber():e.dims[a]}if(e.dataType!=null&&e.hasOwnProperty("dataType")&&(i.dataType=e.dataType),e.segment!=null&&e.hasOwnProperty("segment")&&(i.segment=f.onnx.TensorProto.Segment.toObject(e.segment,o)),e.floatData&&e.floatData.length){i.floatData=[];for(var a=0;a>>0,e.int64Data[a].high>>>0).toNumber():e.int64Data[a]}if(e.name!=null&&e.hasOwnProperty("name")&&(i.name=e.name),e.rawData!=null&&e.hasOwnProperty("rawData")&&(i.rawData=o.bytes===String?h.base64.encode(e.rawData,0,e.rawData.length):o.bytes===Array?Array.prototype.slice.call(e.rawData):e.rawData),e.doubleData&&e.doubleData.length){i.doubleData=[];for(var a=0;a>>0,e.uint64Data[a].high>>>0).toNumber(!0):e.uint64Data[a]}if(e.docString!=null&&e.hasOwnProperty("docString")&&(i.docString=e.docString),e.externalData&&e.externalData.length){i.externalData=[];for(var a=0;a>>3){case 1:{s.begin=o.int64();break}case 2:{s.end=o.int64();break}default:o.skipType(u&7);break}}return s},n.decodeDelimited=function(o){return o instanceof _||(o=new _(o)),this.decode(o,o.uint32())},n.verify=function(o){return typeof o!="object"||o===null?"object expected":o.begin!=null&&o.hasOwnProperty("begin")&&!h.isInteger(o.begin)&&!(o.begin&&h.isInteger(o.begin.low)&&h.isInteger(o.begin.high))?"begin: integer|Long expected":o.end!=null&&o.hasOwnProperty("end")&&!h.isInteger(o.end)&&!(o.end&&h.isInteger(o.end.low)&&h.isInteger(o.end.high))?"end: integer|Long expected":null},n.fromObject=function(o){if(o instanceof f.onnx.TensorProto.Segment)return o;var i=new f.onnx.TensorProto.Segment;return o.begin!=null&&(h.Long?(i.begin=h.Long.fromValue(o.begin)).unsigned=!1:typeof o.begin=="string"?i.begin=parseInt(o.begin,10):typeof o.begin=="number"?i.begin=o.begin:typeof o.begin=="object"&&(i.begin=new h.LongBits(o.begin.low>>>0,o.begin.high>>>0).toNumber())),o.end!=null&&(h.Long?(i.end=h.Long.fromValue(o.end)).unsigned=!1:typeof o.end=="string"?i.end=parseInt(o.end,10):typeof o.end=="number"?i.end=o.end:typeof o.end=="object"&&(i.end=new h.LongBits(o.end.low>>>0,o.end.high>>>0).toNumber())),i},n.toObject=function(o,i){i||(i={});var a={};if(i.defaults){if(h.Long){var s=new h.Long(0,0,!1);a.begin=i.longs===String?s.toString():i.longs===Number?s.toNumber():s}else a.begin=i.longs===String?"0":0;if(h.Long){var s=new h.Long(0,0,!1);a.end=i.longs===String?s.toString():i.longs===Number?s.toNumber():s}else a.end=i.longs===String?"0":0}return o.begin!=null&&o.hasOwnProperty("begin")&&(typeof o.begin=="number"?a.begin=i.longs===String?String(o.begin):o.begin:a.begin=i.longs===String?h.Long.prototype.toString.call(o.begin):i.longs===Number?new h.LongBits(o.begin.low>>>0,o.begin.high>>>0).toNumber():o.begin),o.end!=null&&o.hasOwnProperty("end")&&(typeof o.end=="number"?a.end=i.longs===String?String(o.end):o.end:a.end=i.longs===String?h.Long.prototype.toString.call(o.end):i.longs===Number?new h.LongBits(o.end.low>>>0,o.end.high>>>0).toNumber():o.end),a},n.prototype.toJSON=function(){return this.constructor.toObject(this,U.util.toJSONOptions)},n.getTypeUrl=function(o){return o===void 0&&(o="type.googleapis.com"),o+"/onnx.TensorProto.Segment"},n}(),t.DataLocation=function(){var n={},e=Object.create(n);return e[n[0]="DEFAULT"]=0,e[n[1]="EXTERNAL"]=1,e}(),t}(),r.SparseTensorProto=function(){function t(n){if(this.dims=[],n)for(var e=Object.keys(n),o=0;o>>3){case 1:{a.values=f.onnx.TensorProto.decode(e,e.uint32());break}case 2:{a.indices=f.onnx.TensorProto.decode(e,e.uint32());break}case 3:{if(a.dims&&a.dims.length||(a.dims=[]),(s&7)===2)for(var u=e.uint32()+e.pos;e.pos>>0,e.dims[i].high>>>0).toNumber())}return o},t.toObject=function(e,o){o||(o={});var i={};if((o.arrays||o.defaults)&&(i.dims=[]),o.defaults&&(i.values=null,i.indices=null),e.values!=null&&e.hasOwnProperty("values")&&(i.values=f.onnx.TensorProto.toObject(e.values,o)),e.indices!=null&&e.hasOwnProperty("indices")&&(i.indices=f.onnx.TensorProto.toObject(e.indices,o)),e.dims&&e.dims.length){i.dims=[];for(var a=0;a>>0,e.dims[a].high>>>0).toNumber():e.dims[a]}return i},t.prototype.toJSON=function(){return this.constructor.toObject(this,U.util.toJSONOptions)},t.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/onnx.SparseTensorProto"},t}(),r.TensorShapeProto=function(){function t(n){if(this.dim=[],n)for(var e=Object.keys(n),o=0;o>>3){case 1:{a.dim&&a.dim.length||(a.dim=[]),a.dim.push(f.onnx.TensorShapeProto.Dimension.decode(e,e.uint32()));break}default:e.skipType(s&7);break}}return a},t.decodeDelimited=function(e){return e instanceof _||(e=new _(e)),this.decode(e,e.uint32())},t.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 o=0;o>>3){case 1:{u.dimValue=i.int64();break}case 2:{u.dimParam=i.string();break}case 3:{u.denotation=i.string();break}default:i.skipType(l&7);break}}return u},n.decodeDelimited=function(i){return i instanceof _||(i=new _(i)),this.decode(i,i.uint32())},n.verify=function(i){if(typeof i!="object"||i===null)return"object expected";var a={};if(i.dimValue!=null&&i.hasOwnProperty("dimValue")&&(a.value=1,!h.isInteger(i.dimValue)&&!(i.dimValue&&h.isInteger(i.dimValue.low)&&h.isInteger(i.dimValue.high))))return"dimValue: integer|Long expected";if(i.dimParam!=null&&i.hasOwnProperty("dimParam")){if(a.value===1)return"value: multiple values";if(a.value=1,!h.isString(i.dimParam))return"dimParam: string expected"}return i.denotation!=null&&i.hasOwnProperty("denotation")&&!h.isString(i.denotation)?"denotation: string expected":null},n.fromObject=function(i){if(i instanceof f.onnx.TensorShapeProto.Dimension)return i;var a=new f.onnx.TensorShapeProto.Dimension;return i.dimValue!=null&&(h.Long?(a.dimValue=h.Long.fromValue(i.dimValue)).unsigned=!1:typeof i.dimValue=="string"?a.dimValue=parseInt(i.dimValue,10):typeof i.dimValue=="number"?a.dimValue=i.dimValue:typeof i.dimValue=="object"&&(a.dimValue=new h.LongBits(i.dimValue.low>>>0,i.dimValue.high>>>0).toNumber())),i.dimParam!=null&&(a.dimParam=String(i.dimParam)),i.denotation!=null&&(a.denotation=String(i.denotation)),a},n.toObject=function(i,a){a||(a={});var s={};return a.defaults&&(s.denotation=""),i.dimValue!=null&&i.hasOwnProperty("dimValue")&&(typeof i.dimValue=="number"?s.dimValue=a.longs===String?String(i.dimValue):i.dimValue:s.dimValue=a.longs===String?h.Long.prototype.toString.call(i.dimValue):a.longs===Number?new h.LongBits(i.dimValue.low>>>0,i.dimValue.high>>>0).toNumber():i.dimValue,a.oneofs&&(s.value="dimValue")),i.dimParam!=null&&i.hasOwnProperty("dimParam")&&(s.dimParam=i.dimParam,a.oneofs&&(s.value="dimParam")),i.denotation!=null&&i.hasOwnProperty("denotation")&&(s.denotation=i.denotation),s},n.prototype.toJSON=function(){return this.constructor.toObject(this,U.util.toJSONOptions)},n.getTypeUrl=function(i){return i===void 0&&(i="type.googleapis.com"),i+"/onnx.TensorShapeProto.Dimension"},n}(),t}(),r.TypeProto=function(){function t(e){if(e)for(var o=Object.keys(e),i=0;i>>3){case 1:{s.tensorType=f.onnx.TypeProto.Tensor.decode(o,o.uint32());break}case 4:{s.sequenceType=f.onnx.TypeProto.Sequence.decode(o,o.uint32());break}case 5:{s.mapType=f.onnx.TypeProto.Map.decode(o,o.uint32());break}case 9:{s.optionalType=f.onnx.TypeProto.Optional.decode(o,o.uint32());break}case 8:{s.sparseTensorType=f.onnx.TypeProto.SparseTensor.decode(o,o.uint32());break}case 6:{s.denotation=o.string();break}default:o.skipType(u&7);break}}return s},t.decodeDelimited=function(o){return o instanceof _||(o=new _(o)),this.decode(o,o.uint32())},t.verify=function(o){if(typeof o!="object"||o===null)return"object expected";var i={};if(o.tensorType!=null&&o.hasOwnProperty("tensorType")){i.value=1;{var a=f.onnx.TypeProto.Tensor.verify(o.tensorType);if(a)return"tensorType."+a}}if(o.sequenceType!=null&&o.hasOwnProperty("sequenceType")){if(i.value===1)return"value: multiple values";i.value=1;{var a=f.onnx.TypeProto.Sequence.verify(o.sequenceType);if(a)return"sequenceType."+a}}if(o.mapType!=null&&o.hasOwnProperty("mapType")){if(i.value===1)return"value: multiple values";i.value=1;{var a=f.onnx.TypeProto.Map.verify(o.mapType);if(a)return"mapType."+a}}if(o.optionalType!=null&&o.hasOwnProperty("optionalType")){if(i.value===1)return"value: multiple values";i.value=1;{var a=f.onnx.TypeProto.Optional.verify(o.optionalType);if(a)return"optionalType."+a}}if(o.sparseTensorType!=null&&o.hasOwnProperty("sparseTensorType")){if(i.value===1)return"value: multiple values";i.value=1;{var a=f.onnx.TypeProto.SparseTensor.verify(o.sparseTensorType);if(a)return"sparseTensorType."+a}}return o.denotation!=null&&o.hasOwnProperty("denotation")&&!h.isString(o.denotation)?"denotation: string expected":null},t.fromObject=function(o){if(o instanceof f.onnx.TypeProto)return o;var i=new f.onnx.TypeProto;if(o.tensorType!=null){if(typeof o.tensorType!="object")throw TypeError(".onnx.TypeProto.tensorType: object expected");i.tensorType=f.onnx.TypeProto.Tensor.fromObject(o.tensorType)}if(o.sequenceType!=null){if(typeof o.sequenceType!="object")throw TypeError(".onnx.TypeProto.sequenceType: object expected");i.sequenceType=f.onnx.TypeProto.Sequence.fromObject(o.sequenceType)}if(o.mapType!=null){if(typeof o.mapType!="object")throw TypeError(".onnx.TypeProto.mapType: object expected");i.mapType=f.onnx.TypeProto.Map.fromObject(o.mapType)}if(o.optionalType!=null){if(typeof o.optionalType!="object")throw TypeError(".onnx.TypeProto.optionalType: object expected");i.optionalType=f.onnx.TypeProto.Optional.fromObject(o.optionalType)}if(o.sparseTensorType!=null){if(typeof o.sparseTensorType!="object")throw TypeError(".onnx.TypeProto.sparseTensorType: object expected");i.sparseTensorType=f.onnx.TypeProto.SparseTensor.fromObject(o.sparseTensorType)}return o.denotation!=null&&(i.denotation=String(o.denotation)),i},t.toObject=function(o,i){i||(i={});var a={};return i.defaults&&(a.denotation=""),o.tensorType!=null&&o.hasOwnProperty("tensorType")&&(a.tensorType=f.onnx.TypeProto.Tensor.toObject(o.tensorType,i),i.oneofs&&(a.value="tensorType")),o.sequenceType!=null&&o.hasOwnProperty("sequenceType")&&(a.sequenceType=f.onnx.TypeProto.Sequence.toObject(o.sequenceType,i),i.oneofs&&(a.value="sequenceType")),o.mapType!=null&&o.hasOwnProperty("mapType")&&(a.mapType=f.onnx.TypeProto.Map.toObject(o.mapType,i),i.oneofs&&(a.value="mapType")),o.denotation!=null&&o.hasOwnProperty("denotation")&&(a.denotation=o.denotation),o.sparseTensorType!=null&&o.hasOwnProperty("sparseTensorType")&&(a.sparseTensorType=f.onnx.TypeProto.SparseTensor.toObject(o.sparseTensorType,i),i.oneofs&&(a.value="sparseTensorType")),o.optionalType!=null&&o.hasOwnProperty("optionalType")&&(a.optionalType=f.onnx.TypeProto.Optional.toObject(o.optionalType,i),i.oneofs&&(a.value="optionalType")),a},t.prototype.toJSON=function(){return this.constructor.toObject(this,U.util.toJSONOptions)},t.getTypeUrl=function(o){return o===void 0&&(o="type.googleapis.com"),o+"/onnx.TypeProto"},t.Tensor=function(){function e(o){if(o)for(var i=Object.keys(o),a=0;a>>3){case 1:{u.elemType=i.int32();break}case 2:{u.shape=f.onnx.TensorShapeProto.decode(i,i.uint32());break}default:i.skipType(l&7);break}}return u},e.decodeDelimited=function(i){return i instanceof _||(i=new _(i)),this.decode(i,i.uint32())},e.verify=function(i){if(typeof i!="object"||i===null)return"object expected";if(i.elemType!=null&&i.hasOwnProperty("elemType")&&!h.isInteger(i.elemType))return"elemType: integer expected";if(i.shape!=null&&i.hasOwnProperty("shape")){var a=f.onnx.TensorShapeProto.verify(i.shape);if(a)return"shape."+a}return null},e.fromObject=function(i){if(i instanceof f.onnx.TypeProto.Tensor)return i;var a=new f.onnx.TypeProto.Tensor;if(i.elemType!=null&&(a.elemType=i.elemType|0),i.shape!=null){if(typeof i.shape!="object")throw TypeError(".onnx.TypeProto.Tensor.shape: object expected");a.shape=f.onnx.TensorShapeProto.fromObject(i.shape)}return a},e.toObject=function(i,a){a||(a={});var s={};return a.defaults&&(s.elemType=0,s.shape=null),i.elemType!=null&&i.hasOwnProperty("elemType")&&(s.elemType=i.elemType),i.shape!=null&&i.hasOwnProperty("shape")&&(s.shape=f.onnx.TensorShapeProto.toObject(i.shape,a)),s},e.prototype.toJSON=function(){return this.constructor.toObject(this,U.util.toJSONOptions)},e.getTypeUrl=function(i){return i===void 0&&(i="type.googleapis.com"),i+"/onnx.TypeProto.Tensor"},e}(),t.Sequence=function(){function e(o){if(o)for(var i=Object.keys(o),a=0;a>>3){case 1:{u.elemType=f.onnx.TypeProto.decode(i,i.uint32());break}default:i.skipType(l&7);break}}return u},e.decodeDelimited=function(i){return i instanceof _||(i=new _(i)),this.decode(i,i.uint32())},e.verify=function(i){if(typeof i!="object"||i===null)return"object expected";if(i.elemType!=null&&i.hasOwnProperty("elemType")){var a=f.onnx.TypeProto.verify(i.elemType);if(a)return"elemType."+a}return null},e.fromObject=function(i){if(i instanceof f.onnx.TypeProto.Sequence)return i;var a=new f.onnx.TypeProto.Sequence;if(i.elemType!=null){if(typeof i.elemType!="object")throw TypeError(".onnx.TypeProto.Sequence.elemType: object expected");a.elemType=f.onnx.TypeProto.fromObject(i.elemType)}return a},e.toObject=function(i,a){a||(a={});var s={};return a.defaults&&(s.elemType=null),i.elemType!=null&&i.hasOwnProperty("elemType")&&(s.elemType=f.onnx.TypeProto.toObject(i.elemType,a)),s},e.prototype.toJSON=function(){return this.constructor.toObject(this,U.util.toJSONOptions)},e.getTypeUrl=function(i){return i===void 0&&(i="type.googleapis.com"),i+"/onnx.TypeProto.Sequence"},e}(),t.Map=function(){function e(o){if(o)for(var i=Object.keys(o),a=0;a>>3){case 1:{u.keyType=i.int32();break}case 2:{u.valueType=f.onnx.TypeProto.decode(i,i.uint32());break}default:i.skipType(l&7);break}}return u},e.decodeDelimited=function(i){return i instanceof _||(i=new _(i)),this.decode(i,i.uint32())},e.verify=function(i){if(typeof i!="object"||i===null)return"object expected";if(i.keyType!=null&&i.hasOwnProperty("keyType")&&!h.isInteger(i.keyType))return"keyType: integer expected";if(i.valueType!=null&&i.hasOwnProperty("valueType")){var a=f.onnx.TypeProto.verify(i.valueType);if(a)return"valueType."+a}return null},e.fromObject=function(i){if(i instanceof f.onnx.TypeProto.Map)return i;var a=new f.onnx.TypeProto.Map;if(i.keyType!=null&&(a.keyType=i.keyType|0),i.valueType!=null){if(typeof i.valueType!="object")throw TypeError(".onnx.TypeProto.Map.valueType: object expected");a.valueType=f.onnx.TypeProto.fromObject(i.valueType)}return a},e.toObject=function(i,a){a||(a={});var s={};return a.defaults&&(s.keyType=0,s.valueType=null),i.keyType!=null&&i.hasOwnProperty("keyType")&&(s.keyType=i.keyType),i.valueType!=null&&i.hasOwnProperty("valueType")&&(s.valueType=f.onnx.TypeProto.toObject(i.valueType,a)),s},e.prototype.toJSON=function(){return this.constructor.toObject(this,U.util.toJSONOptions)},e.getTypeUrl=function(i){return i===void 0&&(i="type.googleapis.com"),i+"/onnx.TypeProto.Map"},e}(),t.Optional=function(){function e(o){if(o)for(var i=Object.keys(o),a=0;a>>3){case 1:{u.elemType=f.onnx.TypeProto.decode(i,i.uint32());break}default:i.skipType(l&7);break}}return u},e.decodeDelimited=function(i){return i instanceof _||(i=new _(i)),this.decode(i,i.uint32())},e.verify=function(i){if(typeof i!="object"||i===null)return"object expected";if(i.elemType!=null&&i.hasOwnProperty("elemType")){var a=f.onnx.TypeProto.verify(i.elemType);if(a)return"elemType."+a}return null},e.fromObject=function(i){if(i instanceof f.onnx.TypeProto.Optional)return i;var a=new f.onnx.TypeProto.Optional;if(i.elemType!=null){if(typeof i.elemType!="object")throw TypeError(".onnx.TypeProto.Optional.elemType: object expected");a.elemType=f.onnx.TypeProto.fromObject(i.elemType)}return a},e.toObject=function(i,a){a||(a={});var s={};return a.defaults&&(s.elemType=null),i.elemType!=null&&i.hasOwnProperty("elemType")&&(s.elemType=f.onnx.TypeProto.toObject(i.elemType,a)),s},e.prototype.toJSON=function(){return this.constructor.toObject(this,U.util.toJSONOptions)},e.getTypeUrl=function(i){return i===void 0&&(i="type.googleapis.com"),i+"/onnx.TypeProto.Optional"},e}(),t.SparseTensor=function(){function e(o){if(o)for(var i=Object.keys(o),a=0;a>>3){case 1:{u.elemType=i.int32();break}case 2:{u.shape=f.onnx.TensorShapeProto.decode(i,i.uint32());break}default:i.skipType(l&7);break}}return u},e.decodeDelimited=function(i){return i instanceof _||(i=new _(i)),this.decode(i,i.uint32())},e.verify=function(i){if(typeof i!="object"||i===null)return"object expected";if(i.elemType!=null&&i.hasOwnProperty("elemType")&&!h.isInteger(i.elemType))return"elemType: integer expected";if(i.shape!=null&&i.hasOwnProperty("shape")){var a=f.onnx.TensorShapeProto.verify(i.shape);if(a)return"shape."+a}return null},e.fromObject=function(i){if(i instanceof f.onnx.TypeProto.SparseTensor)return i;var a=new f.onnx.TypeProto.SparseTensor;if(i.elemType!=null&&(a.elemType=i.elemType|0),i.shape!=null){if(typeof i.shape!="object")throw TypeError(".onnx.TypeProto.SparseTensor.shape: object expected");a.shape=f.onnx.TensorShapeProto.fromObject(i.shape)}return a},e.toObject=function(i,a){a||(a={});var s={};return a.defaults&&(s.elemType=0,s.shape=null),i.elemType!=null&&i.hasOwnProperty("elemType")&&(s.elemType=i.elemType),i.shape!=null&&i.hasOwnProperty("shape")&&(s.shape=f.onnx.TensorShapeProto.toObject(i.shape,a)),s},e.prototype.toJSON=function(){return this.constructor.toObject(this,U.util.toJSONOptions)},e.getTypeUrl=function(i){return i===void 0&&(i="type.googleapis.com"),i+"/onnx.TypeProto.SparseTensor"},e}(),t}(),r.OperatorSetIdProto=function(){function t(n){if(n)for(var e=Object.keys(n),o=0;o>>3){case 1:{a.domain=e.string();break}case 2:{a.version=e.int64();break}default:e.skipType(s&7);break}}return a},t.decodeDelimited=function(e){return e instanceof _||(e=new _(e)),this.decode(e,e.uint32())},t.verify=function(e){return typeof e!="object"||e===null?"object expected":e.domain!=null&&e.hasOwnProperty("domain")&&!h.isString(e.domain)?"domain: string expected":e.version!=null&&e.hasOwnProperty("version")&&!h.isInteger(e.version)&&!(e.version&&h.isInteger(e.version.low)&&h.isInteger(e.version.high))?"version: integer|Long expected":null},t.fromObject=function(e){if(e instanceof f.onnx.OperatorSetIdProto)return e;var o=new f.onnx.OperatorSetIdProto;return e.domain!=null&&(o.domain=String(e.domain)),e.version!=null&&(h.Long?(o.version=h.Long.fromValue(e.version)).unsigned=!1:typeof e.version=="string"?o.version=parseInt(e.version,10):typeof e.version=="number"?o.version=e.version:typeof e.version=="object"&&(o.version=new h.LongBits(e.version.low>>>0,e.version.high>>>0).toNumber())),o},t.toObject=function(e,o){o||(o={});var i={};if(o.defaults)if(i.domain="",h.Long){var a=new h.Long(0,0,!1);i.version=o.longs===String?a.toString():o.longs===Number?a.toNumber():a}else i.version=o.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=o.longs===String?String(e.version):e.version:i.version=o.longs===String?h.Long.prototype.toString.call(e.version):o.longs===Number?new h.LongBits(e.version.low>>>0,e.version.high>>>0).toNumber():e.version),i},t.prototype.toJSON=function(){return this.constructor.toObject(this,U.util.toJSONOptions)},t.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/onnx.OperatorSetIdProto"},t}(),r.OperatorStatus=function(){var t={},n=Object.create(t);return n[t[0]="EXPERIMENTAL"]=0,n[t[1]="STABLE"]=1,n}(),r.FunctionProto=function(){function t(n){if(this.input=[],this.output=[],this.attribute=[],this.attributeProto=[],this.node=[],this.opsetImport=[],n)for(var e=Object.keys(n),o=0;o>>3){case 1:{a.name=e.string();break}case 4:{a.input&&a.input.length||(a.input=[]),a.input.push(e.string());break}case 5:{a.output&&a.output.length||(a.output=[]),a.output.push(e.string());break}case 6:{a.attribute&&a.attribute.length||(a.attribute=[]),a.attribute.push(e.string());break}case 11:{a.attributeProto&&a.attributeProto.length||(a.attributeProto=[]),a.attributeProto.push(f.onnx.AttributeProto.decode(e,e.uint32()));break}case 7:{a.node&&a.node.length||(a.node=[]),a.node.push(f.onnx.NodeProto.decode(e,e.uint32()));break}case 8:{a.docString=e.string();break}case 9:{a.opsetImport&&a.opsetImport.length||(a.opsetImport=[]),a.opsetImport.push(f.onnx.OperatorSetIdProto.decode(e,e.uint32()));break}case 10:{a.domain=e.string();break}default:e.skipType(s&7);break}}return a},t.decodeDelimited=function(e){return e instanceof _||(e=new _(e)),this.decode(e,e.uint32())},t.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.name!=null&&e.hasOwnProperty("name")&&!h.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 o=0;o{"use strict";Mr();j=E(je());Ce();Le=class{static arraysEqual(t,n){if(t.length!==n.length)return!1;for(let e=0;e1&&c>1)return;s[a-u]=Math.max(l,c)}return s}static index(t,n){let e=new Array(n.length);return r.fillIndex(t,n,e),e}static fillIndex(t,n,e){let o=t.length-n.length;for(let i=0;i=0;A--)l[A]=w%a[A],w=Math.floor(w/a[A]);g||(r.fillIndex(l,t.dims,c),p=t.get(c)),b||(r.fillIndex(l,n.dims,d),m=n.get(d)),u.set(l,e(p,m))}}return u}}static isValidBroadcast(t,n){let e=t.length,o=n.length;if(e>o)return!1;for(let i=1;i<=e;i++)if(t[e-i]!==1&&t[e-i]!==n[o-i])return!1;return!0}static getBroadcastDims(t,n){let e=t.length,o=[];for(let i=0;i1&&s===1&&o.unshift(a)}return o}},Jn=class{static getShapeOfGemmResult(t,n,e,o,i){if(t.length!==2||e.length!==2)throw new Error("shape need to be of size 2");let a,s,u;n?(a=t[1],s=t[0]):(a=t[0],s=t[1]);let l=-1;if(o?(u=e[0],l=1):(u=e[1],l=0),e[l]!==s)throw new Error("dimension mismatch");if(a<=0||u<=0||s<=0)throw new Error("invalid shape specified");if(i&&!ot.isValidBroadcast(i,[a,u]))throw new Error("gemm: invalid bias shape for broadcast");return[a,u,s]}},nt=class r{static tensorDataTypeFromProto(t){switch(t){case j.onnx.TensorProto.DataType.INT8:return"int8";case j.onnx.TensorProto.DataType.UINT8:return"uint8";case j.onnx.TensorProto.DataType.BOOL:return"bool";case j.onnx.TensorProto.DataType.INT16:return"int16";case j.onnx.TensorProto.DataType.UINT16:return"uint16";case j.onnx.TensorProto.DataType.INT32:return"int32";case j.onnx.TensorProto.DataType.UINT32:return"uint32";case j.onnx.TensorProto.DataType.FLOAT:return"float32";case j.onnx.TensorProto.DataType.DOUBLE:return"float64";case j.onnx.TensorProto.DataType.STRING:return"string";case j.onnx.TensorProto.DataType.INT64:return"int32";case j.onnx.TensorProto.DataType.UINT64:return"uint32";default:throw new Error(`unsupported data type: ${j.onnx.TensorProto.DataType[t]}`)}}static tensorDataTypeStringToEnum(t){switch(t){case"int8":return j.onnx.TensorProto.DataType.INT8;case"uint8":return j.onnx.TensorProto.DataType.UINT8;case"bool":return j.onnx.TensorProto.DataType.BOOL;case"int16":return j.onnx.TensorProto.DataType.INT16;case"uint16":return j.onnx.TensorProto.DataType.UINT16;case"int32":return j.onnx.TensorProto.DataType.INT32;case"uint32":return j.onnx.TensorProto.DataType.UINT32;case"float32":return j.onnx.TensorProto.DataType.FLOAT;case"float64":return j.onnx.TensorProto.DataType.DOUBLE;case"string":return j.onnx.TensorProto.DataType.STRING;case"int64":return j.onnx.TensorProto.DataType.INT64;case"uint64":return j.onnx.TensorProto.DataType.UINT64;default:throw new Error(`unsupported data type: ${t}`)}}static tensorDimsFromProto(t){return t.map(n=>ge.isLong(n)?n.toNumber():n)}static tensorValueTypeFromProto(t){return{tensorType:r.tensorDataTypeFromProto(t.elemType),shape:{dims:r.tensorDimsFromProto(t.shape.dim.map(n=>n.dimValue))}}}static tensorDimsFromORTFormat(t){let n=[];for(let e=0;et.length)throw new Error(`invalid dimension of ${n} for sizeFromDimension as Tensor has ${t.length} dimensions.`);return r.getSizeFromDimensionRange(t,n,t.length)}static sizeToDimension(t,n){if(n<0||n>t.length)throw new Error(`invalid dimension of ${n} for sizeToDimension as Tensor has ${t.length} dimensions.`);return r.getSizeFromDimensionRange(t,0,n)}static getSizeFromDimensionRange(t,n,e){let o=1;for(let i=n;i=0;--o)e[o]=e[o+1]*t[o+1];return e}static transpose(t){return t.slice().reverse()}static indicesToOffset(t,n,e){e===void 0&&(e=t.length);let o=0;for(let i=0;i=n)throw new Error("unsupported axis for this operation.");return t<0?t+n:t}static normalizeAxes(t,n){return t.map(e=>this.normalizeAxis(e,n))}static incrementIndex(t,n,e){if(n.length===0||t.length===0)throw new Error("Index incrementing unsupported for scalar Tensor");if(e===void 0)e=n.length;else if(e<=0||e>n.length)throw new Error("Incorrect axis to increment on");for(let o=e-1;o>=0&&(t[o]++,!(t[o]=t.length)throw new Error("the dimension with value zero exceeds the dimension size of the input tensor");o[u]=t[u]}else o[u]=n[u];a*=o[u]}}let s=r.size(t);if(i!==-1){if(s%a!==0)throw new Error(`the input tensor cannot be reshaped to the requested shape. Input shape: [${t}] Output shape: [${n}]`);o[i]=s/a}else if(a!==s)throw new Error("reshapedDims and originalDims don't have matching sizes");return o}static sortBasedOnPerm(t,n){return n?n.map(e=>t[e]):t.slice().reverse()}static padShape(t,n){let e=t.length;return t.map((o,i)=>o+n[i]+n[i+e])}static areEqual(t,n){return t.length!==n.length?!1:t.every((e,o)=>e===n[o])}static validateDimsAndCalcSize(t){if(t.length>6)throw new TypeError("Only rank 0 to 6 is supported for tensor shape.");let n=1;for(let e of t){if(!Number.isInteger(e))throw new TypeError(`Invalid shape: ${e} is not an integer`);if(e<0||e>2147483647)throw new TypeError(`Invalid shape: length ${e} is not allowed`);n*=e}return n}static flattenShape(t,n){n<0&&(n+=t.length);let e=t.reduce((a,s)=>a*s,1),o=t.slice(n).reduce((a,s)=>a*s,1);return[e/o,o]}static squeezeShape(t,n){let e=new Array;n=r.normalizeAxes(n,t.length);for(let o=0;o=0;if(i&&t[o]!==1)throw new Error("squeeze an axis of size different than 1");(n.length===0&&t[o]>1||n.length>0&&!i)&&e.push(t[o])}return e}static unsqueezeShape(t,n){let e=new Array(t.length+n.length);e.fill(0);for(let i=0;i=e.length)throw new Error("'axes' has an out of range axis");if(e[a]!==0)throw new Error("'axes' has a duplicate axis");e[a]=1}let o=0;for(let i=0;i=e.length?e.push(n[s+2]):e[s]=n[s+2];for(let s=0;s=e[s]||a[s+e.length]>=e[s])throw new Error("pads should be smaller than kernel")}}static adjustPadsBasedOnAutoPad(t,n,e,o,i,a){if(a){if(i.length!==2*(t.length-2))throw new Error("length of pads should be twice the length of data dimensions");if(n.length!==t.length-2)throw new Error("length of strides should be the length of data dimensions");if(o.length!==t.length-2)throw new Error("length of kernel shapes should be the length of data dimensions");for(let s=0;s{"use strict";vu=E(Ma());Mr();an();$=E(je());V();Y=class r{constructor(t,n,e,o,i,a=vu.Guid.create()){this.dims=t;this.type=n;this.dataProvider=e;this.asyncDataProvider=o;this.cache=i;this.dataId=a;this.size=I.validateDimsAndCalcSize(t);let s=this.size,u=e===void 0&&o===void 0&&i===void 0;if(i!==void 0&&i.length!==s)throw new RangeError("Input dims doesn't match data length.");if(n==="string"){if(i!==void 0&&(!Array.isArray(i)||!i.every(l=>typeof l=="string")))throw new TypeError("cache should be a string array");u&&(this.cache=new Array(s))}else{if(i!==void 0){let l=wu(n);if(!(i instanceof l))throw new TypeError(`cache should be type ${l.name}`)}if(u){let l=new ArrayBuffer(s*ib(n));this.cache=ab(l,n)}}}get data(){if(this.cache===void 0){let t=this.dataProvider(this.dataId);if(t.length!==this.size)throw new Error("Length of data provided by the Data Provider is inconsistent with the dims of this Tensor.");this.cache=t}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(t){return this.data[I.indicesToOffset(t,this.strides)]}set(t,n){this.data[I.indicesToOffset(t,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=I.computeStrides(this.dims)),this._strides}static fromProto(t){if(!t)throw new Error("cannot construct Value from an empty tensor");let n=nt.tensorDataTypeFromProto(t.dataType),e=nt.tensorDimsFromProto(t.dims),o=new r(e,n);if(n==="string")t.stringData.forEach((i,a)=>{o.data[a]=fn(i)});else if(t.rawData&&typeof t.rawData.byteLength=="number"&&t.rawData.byteLength>0){let i=o.data,a=new DataView(t.rawData.buffer,t.rawData.byteOffset,t.rawData.byteLength),s=_u(t.dataType),u=t.rawData.byteLength/s;if(t.rawData.byteLength%s!==0)throw new Error("invalid buffer length");if(i.length!==u)throw new Error("buffer length mismatch");for(let l=0;l0){let i=o.data,a=new DataView(t.rawDataArray().buffer,t.rawDataArray().byteOffset,t.rawDataLength()),s=_u(t.dataType()),u=t.rawDataLength()/s;if(t.rawDataLength()%s!==0)throw new Error("invalid buffer length");if(i.length!==u)throw new Error("buffer length mismatch");for(let l=0;l{"use strict";sb={version:"",attribute:"attribute",varyingVertex:"varying",varyingFrag:"varying",texture2D:"texture2D",output:"gl_FragColor",outputDeclaration:""},ub={version:"#version 300 es",attribute:"in",varyingVertex:"out",varyingFrag:"in",texture2D:"texture",output:"outputColor",outputDeclaration:"out vec4 outputColor;"}});var C=y(()=>{"use strict"});async function _i(r,t=e=>0,n){return new Promise((e,o)=>{let i=0,a=()=>{if(r()){e();return}i++;let s=t(i);if(n!=null&&i>=n){o();return}setTimeout(a,s)};a()})}function Yn(r){return We(typeof r<"u"&&r.length!==0,()=>"empty string found for sampler name"),"get"+r.charAt(0).toUpperCase()+r.slice(1)}function Su(r){return We(typeof r<"u"&&r.length!==0,()=>"empty string found for sampler name"),"get"+r.charAt(0).toUpperCase()+r.slice(1)+"AtOutCoords"}function He(r,t){let n=JSON.parse(JSON.stringify(r));return n=t,n}function qe(r,t){return t.map(n=>r[n]).join(", ")}function it(r){if(r<=1)return"int";if(r===2)return"ivec2";if(r===3)return"ivec3";if(r===4)return"ivec4";if(r===5)return"ivec5";if(r===6)return"ivec6";throw Error(`GPU for rank ${r} is not yet supported`)}function St(r=6){return["x","y","z","w","u","v"].slice(0,r)}var ue=y(()=>{"use strict";V()});function lb(r,t){return St(t).map(n=>`${r}.${n}`)}function Ke(r,t){return t===1?[r]:lb(r,t)}function le(){return` + float getChannel(vec4 frag, int dim) { + int modCoord = imod(dim, 2); + return modCoord == 0 ? frag.r : frag.g; + } + + float getChannel(vec4 frag, vec2 innerDims) { + vec2 modCoord = mod(innerDims, 2.); + return modCoord.x == 0. ? + (modCoord.y == 0. ? frag.r : frag.g) : + (modCoord.y == 0. ? frag.b : frag.a); + } + `}var Re=y(()=>{"use strict";ue()});function fb(r,t,n){if(r===0)return"false";if(r===1)return`rc > ${t[0]}`;let e="";for(let o=r-2;o= ${t[o-r+2]}`,o= ${r[0]} ? 0. : getA(rc + 1), + 0, 0`;let e="r, c",o="r, cp1",i="rp1, c",a="rp1, cp1",s="";if(n>2)for(let u=0;u= ${e}; + bool cEdge = cp1 >= ${n}; + `}var Au,cb,Eu,Du=y(()=>{"use strict";H();C();ue();Re();Au={name:"pack",inputNames:["A"],inputTypes:[1]},cb=(r,t)=>{let n=S(r.session.backend.glContext.version),e=t.dims,o=e.length,i=t.dims.length,a=it(i),s=Ke("rc",i),u=pb(i,s,e[e.length-2],e[e.length-1]),l;o===0?l=[1,1]:o===1?l=[e[0],1]:l=[e[i-1],e[i-2]];let c=fb(i,l,s),d=db(e,s),p=` + void main() { + ${a} rc = getOutputCoords(); + + if(${c}) { + ${n.output} = vec4(0); + } else { + ${u} + + ${n.output} = vec4(${d}); + } + } + `;return{...Au,hasMain:!0,output:{dims:t.dims,type:t.type,textureType:2},shaderSource:p}},Eu=(r,t)=>({...Au,get:()=>cb(r,t)})});function xi(r){if(r.length===0)return[1,1,1];let t=1;for(let n=0;n1?r[r.length-2]:1,r[r.length-1]]}function $u(r,t){let n=!1;return r.length===0||t.length===0?n=!0:r.length<2||t.length<2?n=r[r.length-1]===t[t.length-1]:n=r[r.length-1]===t[t.length-1]&&r[r.length-2]===t[t.length-2],n}function bb(r){let t=I.computeStrides(r),n=["b","r","c"],e="index";return` + ivec3 inputCoordsFromReshapedOutCoords(int index) { + ${t.map((i,a)=>{let s=`int ${n[a]} = ${e} / ${i}`,u=a===t.length-1?`int ${n[a+1]} = ${e} - ${n[a]} * ${i}`:`index -= ${n[a]} * ${i}`;return`${s}; ${u};`}).join("")} + return ivec3(b, r, c); + } + `}function gb(r){let t=I.computeStrides(r);return` + int getFlattenedIndex(ivec3 coords) { + // reverse y, z order + return coords.x * ${t[0]} + coords.z * ${t[1]} + coords.y; + } +`}var hb,mb,Lu,Nu=y(()=>{"use strict";V();H();C();Re();hb=r=>({name:"Reshape (packed)",inputTypes:[2],inputNames:["A"],cacheHint:`${r}`}),mb=(r,t,n,e)=>{let o=t.dims,i=e,a="";for(let l=0;l<4;l++){let c="";switch(l){case 0:c="outputCoords = rc;";break;case 1:c="outputCoords = ivec3(rc.x, rc.y+1, rc.z);";break;case 2:c="outputCoords = ivec3(rc.x, rc.y, rc.z+1);";break;case 3:c="outputCoords = ivec3(rc.x, rc.y+1, rc.z+1);";break;default:throw new Error}a+=` + ${c} + ${l>0?"if(outputCoords.y < rows && outputCoords.z < cols){":""} + int flattenedIndex = getFlattenedIndex(outputCoords); + + ivec3 inputRC = inputCoordsFromReshapedOutCoords(flattenedIndex); + vec2 innerDims = vec2(float(inputRC.y),float(inputRC.z)); + + result[${l}] = getChannel(getA(inputRC.x, inputRC.y, inputRC.z), innerDims); + + ${l>0?"}":""} + `}let s=S(r.session.backend.glContext.version),u=` + ${bb(o)} + ${gb(i)} + ${le()} + + void main() { + ivec3 rc = getOutputCoords(); + + vec4 result = vec4(0.0); + + ivec3 outputCoords; + int rows = ${i[2]}; + int cols = ${i[1]}; + + ${a} + ${s.output} = result; + } + `;return{...n,output:{dims:i,type:t.type,textureType:2},shaderSource:u,hasMain:!0}},Lu=(r,t,n)=>{let e=hb(n);return{...e,get:()=>mb(r,t,e,n)}}});var vi,Fu=y(()=>{"use strict";H();C();vi=(r,t)=>{let n=t.shape,e=S(r.session.backend.glContext.version),o=` + const float FLOAT_MAX = 1.70141184e38; + const float FLOAT_MIN = 1.17549435e-38; + + bool isNaN(float val) { + return (val < 1.0 || 0.0 < val || val == 0.0) ? false : true; + } + + highp vec4 encodeAsUint8(highp float v) { + if (isNaN(v)) { + return vec4(255, 255, 255, 255); + } + + highp float av = abs(v); + + if(av < FLOAT_MIN) { + return vec4(0.0, 0.0, 0.0, 0.0); + } else if(v > FLOAT_MAX) { + return vec4(0.0, 0.0, 128.0, 127.0) / 255.0; + } else if(v < -FLOAT_MAX) { + return vec4(0.0, 0.0, 128.0, 255.0) / 255.0; + } + + highp vec4 c = vec4(0,0,0,0); + + highp float e = floor(log2(av)); + highp float m = exp2(fract(log2(av))) - 1.0; + + c[2] = floor(128.0 * m); + m -= c[2] / 128.0; + c[1] = floor(32768.0 * m); + m -= c[1] / 32768.0; + c[0] = floor(8388608.0 * m); + + highp float ebias = e + 127.0; + c[3] = floor(ebias / 2.0); + ebias -= c[3] * 2.0; + c[2] += floor(ebias) * 128.0; + + c[3] += 128.0 * step(0.0, -v); + + return c / 255.0; + } + + void main() { + float value = ${e.texture2D}(X,TexCoords).r; + ${e.output} = encodeAsUint8(value); + }`,i={name:"Uint8Encode",inputTypes:[0],inputNames:["X"],output:{dims:n,type:t.tensor.type,textureType:3},shaderSource:o,hasMain:!0};return r.executeProgram(i,[t.tensor])}});function Tb(r,t){if(r===1)return"rc";let n="";for(let e=0;e{"use strict";H();C();ue();Re();Cu={name:"unpack",inputNames:["A"],inputTypes:[2]},yb=(r,t)=>{let n=t.dims.length,e=Ke("rc",n),o=e.slice(-2),i=it(n),a=le(),u=t.dims.length===0?"":Tb(n,e),l=n<=1?"rc":`vec2(${o.join(",")})`,c=S(r.session.backend.glContext.version),d=` + ${a} + void main() { + ${i} rc = getOutputCoords(); + + // Sample the texture with the coords to get the rgba channel value. + vec4 packedInput = getA(${u}); + + ${c.output} = vec4(getChannel(packedInput, ${l}), 0, 0, 0); + } + `;return{...Cu,hasMain:!0,output:{dims:t.dims,type:t.type,textureType:0},shaderSource:d}},Ru=(r,t)=>({...Cu,get:()=>yb(r,t)})});var Qn,dn,tr,pn=y(()=>{"use strict";dt();Qn=class{constructor(t,n=1){if(n===1)this.internalFormat=t.R32F,this.format=t.RED,this.textureType=t.FLOAT,this.channelSize=n;else if(n===4)this.internalFormat=t.RGBA32F,this.format=t.RGBA,this.textureType=t.FLOAT,this.channelSize=n;else throw new Error(`Invalid number of channels: ${n}`)}encode(t,n){let e,o;return t.constructor!==Float32Array&&(B.warning("Encoder","data was not of type Float32; creating new Float32Array"),o=new Float32Array(t)),n*this.channelSize>t.length?(B.warning("Encoder","Source data too small. Allocating larger array"),o=t,e=this.allocate(n*this.channelSize),o.forEach((i,a)=>e[a]=i)):(o=t,e=o),e}allocate(t){return new Float32Array(t*4)}decode(t,n){return this.channelSize===1?t.filter((o,i)=>i%4===0).subarray(0,n):t.subarray(0,n)}},dn=class{constructor(t,n=1,e){if(n!==1&&n!==4)throw new Error(`Invalid number of channels: ${n}`);this.internalFormat=t.RGBA,this.format=t.RGBA,this.channelSize=n,this.textureType=e||t.FLOAT}encode(t,n){let e=t;return this.channelSize===1&&(B.verbose("Encoder","Exploding into a larger array"),e=this.allocate(n),t.forEach((o,i)=>e[i*4]=o)),e}allocate(t){return new Float32Array(t*4)}decode(t,n){return this.channelSize===1?t.filter((o,i)=>i%4===0).subarray(0,n):t.subarray(0,n)}},tr=class{constructor(t,n=1){this.channelSize=4;if(n===1)this.internalFormat=t.ALPHA,this.format=t.ALPHA,this.textureType=t.UNSIGNED_BYTE,this.channelSize=n;else if(n===4)this.internalFormat=t.RGBA,this.format=t.RGBA,this.textureType=t.UNSIGNED_BYTE,this.channelSize=n;else throw new Error(`Invalid number of channels: ${n}`)}encode(t,n){return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}allocate(t){return new Uint8Array(t*this.channelSize)}decode(t,n){if(t instanceof Uint8Array)return t.subarray(0,n);throw new Error(`Invalid array type: ${t.constructor}`)}}});var hn,ku,wi,Mu=y(()=>{"use strict";V();C();hn=(r,t,n)=>{let e=n===0||n===1?1:4,o=n===2,i=n===1||n===2,a=n===4?t.length-1:void 0,s=n===4?t.map((u,l)=>l===t.length-1?u*4:u):void 0;return wi(r,t,e,s,{isPacked:o,reverseWH:i,breakAxis:a})},ku=(r,t,n)=>{let e=hn(r,t,n);return[e.width,e.height]},wi=(r,t,n=1,e,o)=>{let i=!!(o&&o.isPacked),[a,s]=r.computeTextureWH(i&&e||t,o),u=t.length,l=t.slice(0);if(u===0&&(l=[1]),n===1)e=t;else if(i){if(n!==4)throw new Error("a packed texture must be 4-channel");e=t,u>0&&(l[u-1]=Math.ceil(l[u-1]/2)),u>1&&(l[u-2]=Math.ceil(l[u-2]/2))}else if(!e)throw new Error("Unpacked shape is needed when using channels > 1");return{width:a,height:s,channels:n,isPacked:i,shape:l,strides:I.computeStrides(l),unpackedShape:e,reversedWH:o&&o.reverseWH}}});var xb,er,Bu=y(()=>{"use strict";dt();Ce();V();Du();Nu();Fu();Gu();pn();Mu();C();xb=(r,t)=>{let n=t.map(o=>`${o.unpackedShape.join(",")};${o.width}x${o.height}`).join("_"),e=r.name;return r.cacheHint&&(e+="["+r.cacheHint+"]"),e+=":"+n,e},er=class{constructor(t){this.session=t;this.packedTextureDataCache=new Map,this.unpackedTextureDataCache=new Map}calculateTextureWidthAndHeight(t,n){return ku(this.session.layoutStrategy,t,n)}executeProgram(t,n){if(n.lengththis.readTexture(a),async s=>this.readTextureAsync(a),void 0,i),texture:e};return this.setTextureData(a.tensor.dataId,a,t.isPacked),a}getTextureData(t,n=!1){return this.session.isInitializer(t)?this.session.getTextureData(t,n):n?this.packedTextureDataCache.get(t):this.unpackedTextureDataCache.get(t)}setTextureData(t,n,e=!1){this.session.isInitializer(t)?this.session.setTextureData(t,n,e):(e?this.packedTextureDataCache:this.unpackedTextureDataCache).set(t,n)}isTextureLayoutCached(t,n=!1){return!!this.getTextureData(t.dataId,n)}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(vi(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(vi(this,t))}pack(t){return this.executeProgram(Eu(this,t.tensor),[t.tensor])}unpack(t){return this.executeProgram(Ru(this,t.tensor),[t.tensor])}}});var Ii,L,tt=y(()=>{"use strict";Ii=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}},L=r=>new Ii(r)});var zu,Uu,ju,vb,wb,Wu=y(()=>{"use strict";tt();H();C();zu={name:"BatchNormalization",inputNames:["A","Scale","B","Mean","Variance"],inputTypes:[0,0,0,0,0]},Uu=(r,t,n)=>(wb(t),[r.run({...zu,cacheHint:n.cacheKey,get:()=>vb(r,t,n)},t)]),ju=r=>{let t=r.attributes.getFloat("epsilon",1e-5),n=r.attributes.getFloat("momentum",.9),e=r.attributes.getInt("spatial",1);return L({epsilon:t,momentum:n,spatial:e})},vb=(r,t,n)=>{let e=S(r.session.backend.glContext.version),o=t[0].dims.length,[i,a]=r.calculateTextureWidthAndHeight(t[1].dims,0),s=` + float process(int[${o}] indices) { + vec2 position = offsetToCoords(indices[1], ${i}, ${a}); + float scale = getColorAsFloat(${e.texture2D}(Scale, position)); + float mean = getColorAsFloat(${e.texture2D}(Mean, position)); + float variance = getColorAsFloat(${e.texture2D}(Variance, position)); + float b = getColorAsFloat(${e.texture2D}(B, position)); + + return scale * ( (_A(indices) - mean) / sqrt(variance + float(${n.epsilon})) ) + b; + }`;return{...zu,output:{dims:t[0].dims,type:t[0].type,textureType:0},shaderSource:s}},wb=r=>{if(!r||r.length!==5)throw new Error("BatchNormalization requires 5 inputs.");let t=r[0],n=r[1],e=r[2],o=r[3],i=r[4];if(t.dims.length<3||n.dims.length!==1||e.dims.length!==1||o.dims.length!==1||i.dims.length!==1)throw new Error("invalid input shape.");if(n.dims[0]!==t.dims[1]||e.dims[0]!==t.dims[1]||o.dims[0]!==t.dims[1]||i.dims[0]!==t.dims[1])throw new Error("invalid input shape.");if(t.type!=="float32"&&t.type!=="float64"||n.type!=="float32"&&n.type!=="float64"||e.type!=="float32"&&e.type!=="float64"||o.type!=="float32"&&o.type!=="float64"||i.type!=="float32"&&i.type!=="float64")throw new Error("invalid input tensor types.")}});var nr,yt,v,mn,rr,he=y(()=>{"use strict";nr=class{constructor(t,n,e,o){this.glContext=t;this.programInfo=n;this.inputTextureLayouts=e;this.outputTextureLayout=o}},yt=class{constructor(t){this.context=t}},v=class{constructor(t,n){this.routineBody=t;this.dependencies=n}},mn=class{constructor(t,n,e){this.name=t;e?this.dependencies=e:this.dependencies=[],n&&(this.routineBody=n)}addDependency(t){t&&this.dependencies.push(t)}},rr=class{static returnOrderedNodes(t){if(!t||t.length===0)return[];if(t.length===1)return t;let n=new Set,e=new Set,o=new Array;return this.createOrderedNodes(t,n,e,o),o}static createOrderedNodes(t,n,e,o){for(let i=0;i0)for(let a=0;a b); + } + vec4 ${r}(vec4 v1, vec4 v2) { + return vec4( v1.r > v2.r , + v1.g > v2.g, + v1.b > v2.b, + v1.a > v2.a ); + } + `,name:r,type:0}}function Lb(){let r="less_";return{body:` + float ${r}(float a, float b) { + return float(a < b); + } + vec4 ${r}(vec4 v1, vec4 v2) { + return vec4( v1.r < v2.r , + v1.g < v2.g, + v1.b < v2.b, + v1.a < v2.a ); + } + `,name:r,type:0}}function $b(){let r="and_";return{body:` + float ${r}(float a, float b) { + return float( bool(a) && bool(b) ); + } + vec4 ${r}(vec4 v1, vec4 v2) { + bvec4 b1 = bvec4(v1); + bvec4 b2 = bvec4(v2); + return vec4( b1.r && b2.r , + b1.g && b2.g, + b1.b && b2.b, + b1.a && b2.a ); + } + `,name:r,type:0}}function Nb(){let r="or_";return{body:` + float ${r}(float a, float b) { + return float( bool(a) || bool(b) ); + } + vec4 ${r}(vec4 v1, vec4 v2) { + bvec4 b1 = bvec4(v1); + bvec4 b2 = bvec4(v2); + return vec4( b1.r || b2.r , + b1.g || b2.g, + b1.b || b2.b, + b1.a || b2.a ); + } + `,name:r,type:0}}function Fb(){let r="xor_";return{body:` + float ${r}(float a, float b) { + return float( bool(a) ^^ bool(b) ); + } + vec4 ${r}(vec4 v1, vec4 v2) { + bvec4 b1 = bvec4(v1); + bvec4 b2 = bvec4(v2); + return vec4( b1.r ^^ b2.r , + b1.g ^^ b2.g, + b1.b ^^ b2.b, + b1.a ^^ b2.a ); + } + `,name:r,type:0}}function Cb(){return Gb("pow")}function Rb(){let r="prelu_";return{body:` + float ${r}(float a, float b) { + return a < 0.0 ? a * b: a; + } + vec4 ${r}(vec4 v1, vec4 v2) { + return vec4( + v1.r < 0.0 ? v1.r * v2.r: v1.r, + v1.g < 0.0 ? v1.g * v2.g: v1.g, + v1.b < 0.0 ? v1.b * v2.b: v1.b, + v1.a < 0.0 ? v1.a * v2.a: v1.a + ); + } + `,name:r,type:0}}function Gb(r){let t=`${r}_`;return{body:` + float ${t}(float a, float b) { + return ${r}(a, b); + } + vec4 ${t}(vec4 v1, vec4 v2) { + return ${r}(v1, v2); + } + `,name:t,type:0}}var Tt,kb,Hu,qu,Ku,Xu,Zu,Ju,Yu,Qu,tl,el,nl,rl,ol=y(()=>{"use strict";V();he();H();C();Tt=(r,t,n,e=t[0].type,o)=>{let i=r.session.pack?2:0;return{name:n.name,inputNames:["A","B"],inputTypes:[i,i],cacheHint:o,get:()=>kb(r,t,n,e)}},kb=(r,t,n,e=t[0].type)=>{let o=r.session.pack?2:0,i=!I.areEqual(t[0].dims,t[1].dims),a=t[0].dims,s=r.session.pack;if(i){let c=ot.calcShape(t[0].dims,t[1].dims,!1);if(!c)throw new Error("Can't perform binary op on the given tensors");a=c;let d=a.length,p=t[0].dims.length!==0?t[0].dims.length:1,m=t[1].dims.length!==0?t[1].dims.length:1,g=t[0].dims.length!==0?"bcastIndices_A(indices, aindices);":"aindices[0] = 0;",b=t[1].dims.length!==0?"bcastIndices_B(indices, bindices);":"bindices[0] = 0;",w=S(r.session.backend.glContext.version),x=s?` + ${n.body} + void main() { + vec4 a = getAAtOutCoords(); + vec4 b = getBAtOutCoords(); + vec4 result = ${n.name}(a, b); + ${w.output} = result; + }`:` + ${n.body} + float process(int indices[${d}]) { + int aindices[${p}]; + int bindices[${m}]; + ${g} + ${b} + return ${n.name}(_A(aindices), _B(bindices)); + }`;return{name:n.name,inputNames:["A","B"],inputTypes:[o,o],output:{dims:a,type:e,textureType:o},shaderSource:x,hasMain:s}}let u=S(r.session.backend.glContext.version),l=` + ${n.body} + void main() { + vec4 v1 = ${u.texture2D}(A, TexCoords); + vec4 v2 = ${u.texture2D}(B, TexCoords); + vec4 result = ${n.name}(v1, v2); + ${u.output} = result; + } + `;return{name:n.name,inputNames:["A","B"],inputTypes:[o,o],output:{dims:t[0].dims,type:e,textureType:o},shaderSource:l,hasMain:!0}},Hu=(r,t)=>[r.run(Tt(r,t,Ob()),t)],qu=(r,t)=>[r.run(Tt(r,t,$b(),"bool"),t)],Ku=(r,t)=>[r.run(Tt(r,t,Pb()),t)],Xu=(r,t)=>[r.run(Tt(r,t,Eb(),"bool"),t)],Zu=(r,t)=>[r.run(Tt(r,t,Db(),"bool"),t)],Ju=(r,t)=>[r.run(Tt(r,t,Lb(),"bool"),t)],Yu=(r,t)=>[r.run(Tt(r,t,Sb()),t)],Qu=(r,t)=>[r.run(Tt(r,t,Nb(),"bool"),t)],tl=(r,t)=>[r.run(Tt(r,t,Cb()),t)],el=(r,t)=>[r.run(Tt(r,t,Rb()),t)],nl=(r,t)=>[r.run(Tt(r,t,Ab()),t)],rl=(r,t)=>[r.run(Tt(r,t,Fb(),"bool"),t)]});var il,al,Vb,sl=y(()=>{"use strict";V();il=(r,t,n)=>(Vb(t),[r.cast(t[0],n)]),al=r=>nt.tensorDataTypeFromProto(r.attributes.getInt("to")),Vb=r=>{if(!r||r.length!==1)throw new Error("Cast requires 1 input.");if(r[0].type==="string")throw new Error("Invalid input type.")}});var Bb,zb,ul,or,ll=y(()=>{"use strict";H();C();ue();Re();Bb=(r,t)=>({name:"Concat (packed)",inputNames:Array.from({length:r},(n,e)=>`X${e}`),inputTypes:Array(r).fill(2),cacheHint:t}),zb=(r,t,n,e)=>{let o=n[0].dims.slice();if(e>=o.length||e<-1*o.length)throw new Error("axis specified for concat doesn't match input dimensionality");e<0&&(e=o.length+e);let i=o.slice(0);for(let F=1;FF.dims),d=St(a),p=new Array(c.length-1);p[0]=c[0][e];for(let F=1;F= ${p[F-1]}) { + return getChannel( + getX${F}(${or(d,m,xt)}), + vec2(${or(g,m,xt)})); + }`}let x=p.length,A=p[p.length-1];w+=` + return getChannel( + getX${x}(${or(d,m,A)}), + vec2(${or(g,m,A)}));`;let D=S(r.session.backend.glContext.version),q=` + ${l} + float getValue(${d.map(F=>"int "+F)}) { + ${w} + } + + void main() { + ${u} coords = getOutputCoords(); + int lastDim = coords.${d[a-1]}; + coords.${d[a-1]} = coords.${d[a-2]}; + coords.${d[a-2]} = lastDim; + + vec4 result = vec4(getValue(${s}), 0., 0., 0.); + + ${s[a-1]} = ${s[a-1]} + 1; + if (${s[a-1]} < ${i[a-1]}) { + result.g = getValue(${s}); + } + + ${s[a-2]} = ${s[a-2]} + 1; + if (${s[a-2]} < ${i[a-2]}) { + result.a = getValue(${s}); + } + + ${s[a-1]} = ${s[a-1]} - 1; + if (${s[a-2]} < ${i[a-2]} && + ${s[a-1]} < ${i[a-1]}) { + result.b = getValue(${s}); + } + ${D.output} = result; + } + `;return{...t,output:{dims:i,type:n[0].type,textureType:2},shaderSource:q,hasMain:!0}},ul=(r,t,n)=>{let e=Bb(t.length,n.cacheKey);return{...e,get:()=>zb(r,e,t,n.axis)}},or=(r,t,n)=>{let e=r.indexOf(t);return r.map((i,a)=>a===e?`${i} - ${n}`:i).join()}});var cl,Ub,jb,Wb,fl,Hb,qb,Kb,dl,Xb,pl=y(()=>{"use strict";tt();C();ll();cl=(r,t,n)=>(Xb(t),r.session.pack&&t[0].dims.length>1?[r.run(ul(r,t,n),t)]:[r.run(Wb(r,t,n),t)]),Ub=(r,t)=>({name:"Concat",inputNames:Array.from({length:r},(n,e)=>`X${e}`),inputTypes:Array(r).fill(0),cacheHint:t}),jb=(r,t,n,e)=>{let o=n[0].dims.slice();if(e>=o.length||e<-1*o.length)throw new Error("axis specified for concat doesn't match input dimensionality");e<0&&(e=o.length+e);let i=o.slice(0);for(let m=1;m{let e=Ub(t.length,n.cacheKey);return{...e,get:()=>jb(r,e,t,n.axis)}},fl=r=>`int getTextureWhereDataResides(int index) { + ${r.map((n,e)=>`if(index<${n}) {return ${e};} +`).join("")} + }`,Hb=r=>fl(r),qb=(r,t)=>{let n=[`float fetchDataFromCorrectTexture(int textureIndex, int indices[${t}]) {`];for(let e=0;e{let t=["int getSizeInConcatAxisValueFromIndex(int index) {"];for(let n=0;nL({axis:r.attributes.getInt("axis")}),Xb=r=>{if(!r||r.length<1)throw new Error("too few inputs");let t=r[0].type,n=r[0].dims.length;if(t==="string")throw new Error("string tensor is not supported yet");for(let e of r){if(e.type!==t)throw new Error("input tensors should be one type");if(e.dims.length!==n)throw new Error("input tensors should have the same shape")}}});function Zb(){return _t("abs")}function Jb(){return _t("acos")}function Yb(){return _t("asin")}function Qb(){return _t("atan")}function tg(){return _t("ceil")}function eg(){return _t("cos")}function ng(r){let t="elu";return{body:` + const float alpha = float(${r}); + + float ${t}_(float a) { + return a >= 0.0 ? a: (exp(a) - 1.0) * alpha; + } + vec4 ${t}_(vec4 v) { + return vec4(${t}_(v.x), ${t}_(v.y), ${t}_(v.z), ${t}_(v.w)); + } + `,name:t,type:0}}function rg(){return _t("exp")}function og(){return _t("floor")}function Oi(r,t){let n="clip";return{body:` + const float min = float(${r}); + const float max = float(${t}); + + float ${n}_(float a) { + return clamp(a, min, max); + } + vec4 ${n}_(vec4 v) { + return clamp(v, min, max); + } + `,name:n,type:0}}function ig(){let r="indentity";return{body:` + float ${r}_(float a) { + return a; + } + vec4 ${r}_(vec4 v) { + return v; + } + `,name:r,type:0}}function ag(r){let t="leakyRelu";return{body:` + const float alpha = float(${r}); + + float ${t}_(float a) { + return a < 0.0 ? a * alpha : a; + } + vec4 ${t}_(vec4 v) { + return vec4(${t}_(v.x), ${t}_(v.y), ${t}_(v.z), ${t}_(v.w)); + } + `,name:t,type:0}}function sg(){return _t("log")}function ug(){let r="neg";return{body:` + float ${r}_(float a) { + return -a; + } + vec4 ${r}_(vec4 v) { + return -v; + } + `,name:r,type:0}}function lg(){let r="not";return{body:` + float ${r}_(float a) { + return float( ! bool(a) ); + } + bool ${r}_(bool a) { + return !a; + } + vec4 ${r}_(vec4 v) { + return vec4(!bool(v.x), !bool(v.y), !bool(v.z), !bool(v.w)); + } + bvec4 ${r}_(bvec4 v) { + return bvec4(!v.x, !v.y, !v.z, !v.w); + } + `,name:r,type:0}}function cg(){return _t("sin")}function Pi(){let r="relu";return{body:` + float ${r}_(float a) { + return max( a, 0.0 ); + } + vec4 ${r}_(vec4 v) { + return max( v, 0.0 ); + } + `,name:r,type:0}}function Si(){let r="sigmoid";return{body:` + float ${r}_(float a) { + return 1.0 / (1.0 + exp(-a)); + } + vec4 ${r}_(vec4 v) { + return 1.0 / (1.0 + exp(-v)); + } + `,name:r,type:0}}function fg(){return _t("sqrt")}function dg(){return _t("tan")}function pg(){let r="tanh";return{body:` + float ${r}_(float a) { + a = clamp(a, -10., 10.); + a = exp(2.*a); + return (a - 1.) / (a + 1.); + } + vec4 ${r}_(vec4 v) { + v = clamp(v, -10., 10.); + v = exp(2.*v); + return (v - 1.) / (v + 1.); + } + `,name:r,type:0}}function _t(r){return{body:` + float ${r}_(float a) { + return ${r}(a); + } + vec4 ${r}_(vec4 v) { + return ${r}(v); + } + `,name:r,type:0}}var hg,J,hl,ml,bl,gl,Ai,yl,Tl,mg,_l,xl,vl,wl,Il,Ol,Ei,Pl,Sl,Al,El,Dl,Ll,$l,Nl,Fl,Cl,Rl,Di=y(()=>{"use strict";tt();V();he();H();C();hg=(r,t,n,e)=>{let o=r.session.pack?2:0,i=S(r.session.backend.glContext.version);return{...t,output:{dims:n.dims,type:n.type,textureType:o},shaderSource:` + ${e.body} + void main() { + vec4 v = ${i.texture2D}(A, TexCoords); + v = ${e.name}_(v); + ${i.output} = v; + } + `,hasMain:!0}},J=(r,t,n,e)=>{let o=r.session.pack?2:0,i={name:n.name,inputTypes:[o],inputNames:["A"],cacheHint:e};return{...i,get:()=>hg(r,i,t,n)}},hl=(r,t)=>[r.run(J(r,t[0],Zb()),t)],ml=(r,t)=>[r.run(J(r,t[0],Jb()),t)],bl=(r,t)=>[r.run(J(r,t[0],Yb()),t)],gl=(r,t)=>[r.run(J(r,t[0],Qb()),t)],Ai=(r,t,n)=>[r.run(J(r,t[0],Oi(n.min,n.max),n.cacheKey),t)],yl=r=>L({min:r.attributes.getFloat("min",Ne),max:r.attributes.getFloat("max",Fe)}),Tl=(r,t)=>{let n=mg(r,t);return Ai(r,[t[0]],n)},mg=(r,t)=>{if(t.length>=3&&(!r.session.isInitializer(t[1].dataId)||!r.session.isInitializer(t[2].dataId)))throw new Error("dynamic clip attributes are not allowed");let n=t.length>=3?t[1].numberData[0]:Ne,e=t.length>=3?t[2].numberData[0]:Fe;return L({min:n,max:e})},_l=(r,t)=>[r.run(J(r,t[0],tg()),t)],xl=(r,t)=>[r.run(J(r,t[0],eg()),t)],vl=(r,t,n)=>[r.run(J(r,t[0],ng(n.alpha),n.cacheKey),t)],wl=r=>L({alpha:r.attributes.getFloat("alpha",1)}),Il=(r,t)=>[r.run(J(r,t[0],rg()),t)],Ol=(r,t)=>[r.run(J(r,t[0],og()),t)],Ei=(r,t)=>[r.run(J(r,t[0],ig()),t)],Pl=(r,t,n)=>[r.run(J(r,t[0],ag(n.alpha),n.cacheKey),t)],Sl=r=>L({alpha:r.attributes.getFloat("alpha",.01)}),Al=(r,t)=>[r.run(J(r,t[0],sg()),t)],El=(r,t)=>[r.run(J(r,t[0],ug()),t)],Dl=(r,t)=>[r.run(J(r,t[0],lg()),t)],Ll=(r,t)=>[r.run(J(r,t[0],Pi()),t)],$l=(r,t)=>[r.run(J(r,t[0],Si()),t)],Nl=(r,t)=>[r.run(J(r,t[0],cg()),t)],Fl=(r,t)=>[r.run(J(r,t[0],fg()),t)],Cl=(r,t)=>[r.run(J(r,t[0],dg()),t)],Rl=(r,t)=>[r.run(J(r,t[0],pg()),t)]});function ce(r){let t;switch(r.activation){case"Relu":t=Pi();break;case"Sigmoid":t=Si();break;case"Clip":t=Oi(r.clipMin,r.clipMax);break;default:return{activationFunction:"",applyActivation:""}}let n=t.name,e=t.body,o=`value = ${n}_(value);`;return{activationFunction:e,applyActivation:o}}var Xe,Ge=y(()=>{"use strict";V();Di();Xe=r=>{let t=r.getString("activation","");if(t==="Clip"){let[n,e]=r.getFloats("activation_params",[Ne,Fe]);return{activation:t,clipMax:e,clipMin:n,activationCacheKey:`${t}:${n},${e}`}}return{activation:t,activationCacheKey:t}}});var gg,yg,Gl,kl=y(()=>{"use strict";dt();H();C();ir();Ge();gg=(r,t)=>({name:"GroupedConv",inputNames:r?["X","W","Bias"]:["X","W"],inputTypes:r?[0,0,0]:[0,0],cacheHint:t}),yg=(r,t,n,e)=>{let i=t.length>2?"value += getBias(output_channel);":"",a=t[0].dims.slice(),s=t[1].dims.slice(),u=s[0]/e.group;B.verbose("GroupedConv",`autpPad:${e.autoPad}, dilations:${e.dilations}, group:${e.group}, kernelShape:${e.kernelShape}, pads:${e.pads}, strides:${e.strides}`);let l=Ze(a,s,e.dilations,e.pads,e.strides),c=S(r.session.backend.glContext.version),{activationFunction:d,applyActivation:p}=ce(e),m=` + const ivec2 strides = ivec2(${e.strides[0]}, ${e.strides[1]}); + const ivec2 pads = ivec2(${e.pads[0]}, ${e.pads[1]}); + ${d} + void main() { + ivec4 coords = getOutputCoords(); + int batch = coords.x; + int output_channel = coords.y; + ivec2 xRCCorner = coords.zw * strides - pads; + int group_id = output_channel / ${u}; + + float value = 0.0; + for (int wInChannel = 0; wInChannel < ${s[1]}; wInChannel++) { + int input_channel = group_id * ${s[1]} + wInChannel; + for (int wHeight = 0; wHeight < ${s[2]}; wHeight++) { + int xHeight = xRCCorner.x + wHeight * ${e.dilations[0]}; + + if (xHeight < 0 || xHeight >= ${a[2]}) { + continue; + } + + for (int wWidth = 0; wWidth < ${s[3]}; wWidth++) { + int xWidth = xRCCorner.y + wWidth * ${e.dilations[1]}; + if (xWidth < 0 || xWidth >= ${a[3]}) { + continue; + } + + float xVal = getX(batch, input_channel, xWidth, xHeight); + float wVal = getW(output_channel, wInChannel, wWidth, wHeight); + value += xVal*wVal; + } + } + } + ${i} + ${p} + ${c.output} = vec4(value, .0, .0, .0); + } +`;return{...n,output:{dims:l,type:t[0].type,textureType:0},shaderSource:m,hasMain:!0}},Gl=(r,t,n)=>{let e=gg(t.length>2,n.cacheKey);return{...e,get:()=>yg(r,t,e,n)}}});var Tg,_g,Ml,Vl=y(()=>{"use strict";H();C();Re();Tg=r=>({name:"Im2Col (packed)",inputNames:["A"],inputTypes:[2],cacheHint:r}),_g=(r,t,n,e,o,i)=>{let a=n.dims,s=e.dims,u=2,l=3,c=o.length,d=[s[1]*s[2]*s[3],o[2]*o[3]],p=s[2]*s[3],m=le(),g=S(r.session.backend.glContext.version),b="";for(let x=0;x<=1;x++)for(let A=0;A<=1;A++)b+=` + blockIndex = rc.x + ${A}; + pos = rc.y + ${x}; + + if(blockIndex < ${d[1]} && pos < ${d[0]}) { + offsetY = int(blockIndex / (${o[c-1]})) * ${i.strides[0]} - + ${i.pads[0]}; + d0 = offsetY + ${i.dilations[0]} * (imod(pos, ${p}) / ${s[2]}); + + if(d0 < ${a[u]} && d0 >= 0) { + offsetX = imod(blockIndex, ${o[c-1]}) * ${i.strides[1]} - + ${i.pads[1]}; + d1 = offsetX + ${i.dilations[1]} * imod(imod(pos, ${p}), ${s[2]}); + + if(d1 < ${a[l]} && d1 >= 0) { + + ch = int(float(pos)/ ${p}.); + innerDims = vec2(d0, d1); + result[${x*2+A}] = getChannel( + getA(0, ch, int(innerDims.x), + int(innerDims.y)), innerDims); + } + } + } + + `;let w=` + ${m} + + void main() { + ivec2 rc = getOutputCoords(); + vec4 result = vec4(0.0); + int blockIndex, pos, offsetY, d0, offsetX, d1, ch; + vec2 innerDims; + ${b} + ${g.output} = result; + } + `;return{...t,output:{dims:d,type:n.type,textureType:2},shaderSource:w,hasMain:!0}},Ml=(r,t,n,e,o)=>{let i=Tg(o.cacheKey);return{...i,get:()=>_g(r,i,t,n,e,o)}}});function vg(r,t,n){let e=t[0].dims,o=t[1].dims,i=ot.calcShape(e,o,!0);if(!i)throw new Error("Can't use matmul on the given tensors");let a=it(i.length),s=St(),{activationFunction:u,applyActivation:l}=ce(n),c=t.length>2,d=c?"value += getBiasForMatmul();":"",p=c?`${$i(a,s,t[2].dims,i,!1)}`:"",m=i.length,g=e.length,b=o.length,w=e[e.length-1],x=` + ${u} + ${p} + float process(int indices[${m}]) { + int a[${g}]; + int b[${b}]; + bcastMatmulIndices_A(indices, a); + bcastMatmulIndices_B(indices, b); + + float value; + for (int k=0; k<${w}; ++k) { + a[${g-1}] = k; + b[${b-2}] = k; + value += _A(a) * _B(b); + } + ${d} + ${l} + return value; + }`;return{...r,output:{dims:i,type:t[0].type,textureType:0},shaderSource:x}}function Li(r,t){let n=xg(r.length>2,t.activationCacheKey);return{...n,get:()=>vg(n,r,t)}}function $i(r,t,n,e,o){let i="",a=n.length,s=e.length,u=s-a;s<2&&a>0?i="coords":i=n.map((b,w)=>`coords.${t[w+u]}`).join(", ");let c=ot.getBroadcastDims(n,e).map(b=>`coords.${t[b+u]} = 0;`).join(` +`),p=I.size(n)===1,m="vec4(outputValue.xx, outputValue.yy)";return p&&(m="vec4(outputValue.x)"),o?` +vec4 getBiasForMatmul() { + ${r} coords = getOutputCoords(); + ${c} + vec4 outputValue = getBias(${i}); + return ${m}; +}`:` +float getBiasForMatmul() { + ${r} coords = getOutputCoords(); + ${c} + return getBias(coords.x); +}`}var Bl,zl,xg,wg,ar=y(()=>{"use strict";V();C();ue();Ge();Ni();Bl=(r,t,n)=>(wg(t),r.session.pack?[r.run(sr(r,t,n),t)]:[r.run(Li(t,n),t)]),zl=r=>Xe(r.attributes),xg=(r,t)=>({name:"MatMul",inputNames:r?["A","B","Bias"]:["A","B"],inputTypes:r?[0,0,0]:[0,0],cacheHint:t});wg=r=>{if(!r||r.length!==2)throw new Error("MatMul requires 2 inputs.");if(r[0].dims[r[0].dims.length-1]!==r[1].dims[r[1].dims.length-2])throw new Error("shared dimension does not match.");if(r[0].type!=="float32"&&r[0].type!=="float64"||r[1].type!=="float32"&&r[1].type!=="float64")throw new Error("inputs should be float type");if(r[0].type!==r[1].type)throw new Error("inputs types should match")}});function Pg(r,t,n,e){let o=[],i=[],a=n[0].dims,s=n[1].dims,u=a.length,l=s.length,c=e.length,d=c-u,p=c-l;o=a.map((D,q)=>`coords.${t[q+d]}`),o[u-1]="i*2",o.join(", "),i=s.map((D,q)=>`coords.${t[q+p]}`),i[l-2]="i*2",i.join(", ");let m=ot.getBroadcastDims(a,e),g=ot.getBroadcastDims(s,e),b=m.map(D=>`coords.${t[D+d]} = 0;`).join(` +`),w=g.map(D=>`coords.${t[D+p]} = 0;`).join(` +`),x=`int lastDim = coords.${t[c-1]}; + coords.${t[c-1]} = coords.${t[c-2]}; + coords.${t[c-2]} = lastDim;`;return` +vec4 getAAtOutCoordsMatmul(int i) { + ${r} coords = getOutputCoords(); + ${x} + ${b} + vec4 outputValue = getA(${o}); + return outputValue; +} + +vec4 getBAtOutCoordsMatmul(int i) { + ${r} coords = getOutputCoords(); + ${x} + ${w} + vec4 outputValue = getB(${i}); + return outputValue; +}`}function Sg(r,t){let n="";for(let e=0;e{"use strict";V();H();C();ue();Ge();ar();Ig=(r,t)=>({name:"MatMul (packed)",inputNames:r?["A","B","Bias"]:["A","B"],inputTypes:r?[2,2,2]:[2,2],cacheHint:t}),Og=(r,t,n,e)=>{let o=n.length>2,i=o?"value += getBiasForMatmul();":"",a=n[0].dims,s=n[1].dims,u=ot.calcShape(a,s,!0),l=!I.areEqual(n[0].dims,n[1].dims);if(!u)throw new Error("Can't use matmul on the given tensors");let c=a[a.length-1],d=Math.ceil(c/2),p=a.length,m=s.length,g=S(r.session.backend.glContext.version),b=it(u.length),w=u.length,x=St(),{activationFunction:A,applyActivation:D}=ce(e),q=o?`${$i(b,x,n[2].dims,u,!0)}`:"",F=l?`${Pg(b,x,n,u)}`:"",xt=l?"getAAtOutCoordsMatmul(i)":`getA(${Sg(x,p)})`,At=l?"getBAtOutCoordsMatmul(i)":`getB(${Ag(x,m)})`,Ie=l?"":`${b} rc = + getOutputCoords(); int lastDim = rc.${x[w-1]}; rc.${x[w-1]} = + rc.${x[w-2]}; rc.${x[w-2]} = lastDim; + `,Ve=` + ${F} + ${q} + ${A} + void main() { + ${Ie} + + vec4 value = vec4(0); + for (int i = 0; i < ${d}; i++) { + vec4 a = ${xt}; + vec4 b = ${At}; + + value += (a.rrbb * b.rgrg); + value += (a.ggaa * b.baba); + } + ${i} + ${D} + ${g.output} = value; + }`;return{...t,output:{dims:u,type:n[0].type,textureType:2},shaderSource:Ve,hasMain:!0}},sr=(r,t,n)=>{let e=Ig(t.length>2,n.activationCacheKey);return{...e,get:()=>Og(r,e,t,n)}}});var Ul,jl=y(()=>{"use strict";ir();Vl();Ni();Ul=(r,t,n)=>{let e=t[0].dims,o=t[1].dims,i=Ze(e,o,n.dilations,n.pads,n.strides),a=r.run(Ml(r,t[0],t[1],i,n),[t[0]]),s=r.reshapePacked(t[1],[o[0],o[1]*o[2]*o[3]]),u=t.length===3?[s,a,t[2]]:[s,a],l=r.run(sr(r,u,n),u);return r.reshapePacked(l,i)}});var Eg,Dg,Wl,Fi,Ci=y(()=>{"use strict";C();Eg=r=>({name:"Im2Col",inputNames:["X"],inputTypes:[0],cacheHint:r}),Dg=(r,t,n,e,o,i)=>{let a=n.dims,s=e.dims,u=o.length,l=Fi(a,s,o,4),c=` + const int XC = ${a[1]}; + const int XH = ${a[2]}; + const int XW = ${a[3]}; + const int KH = ${i.kernelShape[0]}; + const int KW = ${i.kernelShape[1]}; + const int dilationH = ${i.dilations[0]}; + const int dilationW = ${i.dilations[1]}; + const int strideH = ${i.strides[0]}; + const int strideW = ${i.strides[1]}; + const int padH = ${i.pads[0]}; + const int padW = ${i.pads[1]}; + const int KHKW = KH*KW; + const int XCKHKW = XC * KHKW; + const int outputChannels = 4; + vec4 process(int indices[${u}]) { + int b = indices[0]; // batch size + int oh = indices[1] * strideH - padH; //output height + int ow = indices[2] * strideW - padW; //output width + int p = indices[3] * outputChannels; //patch + vec4 value = vec4(0.0); + for(int i=0; i < outputChannels; ++i) { + if(p < XCKHKW) { + int patchC = p / KHKW; + int patchH = (p - patchC*KHKW) / KW; + int patchW = (p - patchC*KHKW) - patchH * KW; + int xh2 = oh + patchH * dilationH; + int xw2 = ow + patchW * dilationW; + int x[${a.length}]; + x[0] = b; + x[1] = patchC; + x[2] = xh2; + x[3] = xw2; + if(xh2 >= 0 && + xh2 < XH && + xw2 >= 0 && + xw2 < XW) { + value[i] = _X(x); + } + } + ++p; + } + return value; + } + `;return{...t,output:{dims:l,type:n.type,textureType:4},shaderSource:c}},Wl=(r,t,n,e,o)=>{let i=Eg(o.cacheKey);return{...i,get:()=>Dg(r,i,t,n,e,o)}},Fi=(r,t,n,e=4)=>[n[0],n[2],n[3],Math.ceil(r[1]*t[2]*t[3]/e)]});var Lg,$g,Hl,ql=y(()=>{"use strict";V();H();C();Ge();Ci();Lg=(r,t)=>({name:"ConvDotProduct",inputNames:r?["Im2Col","K","B"]:["Im2Col","K"],inputTypes:r?[0,4,0]:[0,4],cacheKey:t.activationCacheKey}),$g=(r,t,n,e,o)=>{let i=n[0].dims,a=n[1].dims,s=[a[0],Math.ceil(i[1]*a[2]*a[3]/4)],u=Fi(i,a,e),[l,c]=r.calculateTextureWidthAndHeight(s,4),d=I.computeStrides(u),[p,m]=r.calculateTextureWidthAndHeight(u,4),g=e.length,b=n.length<3?"0.0":"_B(b)",w=Math.ceil(i[1]*a[2]*a[3]/4),{activationFunction:x,applyActivation:A}=ce(o),D=S(r.session.backend.glContext.version),q=` +${x} +float process(int indices[${g}]) { + int b[1]; + b[0] = indices[1]; + int im2col[4]; + im2col[0] = indices[0]; + im2col[1] = indices[2]; + im2col[2] = indices[3]; + int im2colOffset = im2col[0] * ${d[0]} + im2col[1] * ${d[1]} + im2col[2] * ${d[2]}; + int kernelOffset = indices[1] * ${s[1]}; + float value = ${b}; + for (int i = 0; i < ${w}; ++i) { + vec2 im2colCoords = offsetToCoords(im2colOffset, ${p}, ${m}); + vec2 kernelCoords = offsetToCoords(kernelOffset, ${l}, ${c}); + value += dot(${D.texture2D}(Im2Col, im2colCoords), ${D.texture2D}(K, kernelCoords)); + ++im2colOffset; + ++kernelOffset; + } + ${A} + return value; +}`;return{...t,output:{dims:e,type:n[0].type,textureType:0},shaderSource:q}},Hl=(r,t,n,e)=>{let o=Lg(t.length>2,e);return{...o,get:()=>$g(r,o,t,n,e)}}});var Ze,Ri,Ng,Fg,Cg,Rg,Gi,Gg,ir=y(()=>{"use strict";tt();V();kl();jl();ql();Ge();Ci();ar();Ze=(r,t,n,e,o)=>{let i=r[0],a=r.slice(2),s=a.length,u=t[0],c=t.slice(2).map((g,b)=>g+(g-1)*(n[b]-1)),p=a.map((g,b)=>g+e[b]+e[b+s]).map((g,b)=>Math.floor((g-c[b]+o[b])/o[b]));return[i,u].concat(...p)},Ri=(r,t,n)=>(Gg(t,n),Ng(r,t,n)),Ng=(r,t,n)=>{let e=Rg(n,t),o=r.session.pack,i=e.kernelShape[0]===1&&e.kernelShape[1]===1;return e.group>1?[r.run(Gl(r,t,e),t)]:i&&o?[Fg(r,t,e)]:o&&t[0].dims.length===4&&t[0].dims[0]===1&&!i?[Ul(r,t,e)]:[Cg(r,t,e)]},Fg=(r,t,n)=>{let e=t[0].dims,o=t[1].dims,i=Ze(e,o,n.dilations,n.pads,n.strides),a=r.reshapeUnpacked(t[0],[e[1],e[2]*e[3]]),s=r.reshapeUnpacked(t[1],[o[0],o[1]]),u=t.length>2?[s,a,t[2]]:[s,a],l=r.run(Li(u,n),u);return r.reshapeUnpacked(l,i)},Cg=(r,t,n)=>{let e=t[0].dims,o=t[1].dims,i=Ze(e,o,n.dilations,n.pads,n.strides),a=r.run(Wl(r,t[0],t[1],i,n),[t[0]]),s=t.length===3?[a,t[1],t[2]]:[a,t[1]];return r.run(Hl(r,t,i,n),s)},Rg=(r,t)=>{let n=r.kernelShape.slice();if(r.kernelShape.length===0)for(let i=2;i{let t=r.attributes,n=Xe(t),e=t.getString("auto_pad","NOTSET"),o=t.getInts("dilations",[1,1]),i=t.getInt("group",1),a=t.getInts("kernel_shape",[]),s=t.getInts("pads",[0,0,0,0]),u=t.getInts("strides",[1,1]);return L({autoPad:e,dilations:o,group:i,kernelShape:a,pads:s,strides:u,...n})},Gg=(r,t)=>{if(!r||r.length!==2&&r.length!==3)throw new Error("Conv requires 2 or 3 inputs");if(r[0].dims.length!==4||r[1].dims.length!==4)throw new Error("currently only support 2-dimensional conv");let n=r[0].dims[1],e=r[1].dims[1]*t.group;if(n!==e)throw new Error("FILTER_IN_CHANNEL should be equal to DATA_CHANNEL");if(r.length===3&&(r[2].dims.length!==1||r[1].dims[0]!==r[2].dims[0]))throw new Error("invalid bias");let o=r[0].dims.length-2;if(t.dilations.length!==o)throw new Error(`dilations should be ${o}D`);if(t.strides.length!==o)throw new Error(`strides should be ${o}D`);if(t.pads.length!==o*2)throw new Error(`pads should be ${o*2}D`);if(t.kernelShape.length!==0&&t.kernelShape.length!==r[1].dims.length-2)throw new Error("invalid kernel shape");if(r[0].type!=="float32"||r[1].type!=="float32")throw new Error("Conv input(X,W) should be float tensor");if(r.length===3&&r[2].type!=="float32")throw new Error("Conv input(bias) should be float tensor")}});var kg,Mg,Vg,Kl,Bg,zg,Ug,jg,Wg,Hg,Xl,qg,Zl=y(()=>{"use strict";tt();H();C();Ge();kg=(r,t,n,e,o,i)=>(r-1)*t+n+(e-1)*o+1-i,Mg=(r,t,n,e,o)=>{let i=Math.floor(r/2);t==="SAME_UPPER"?(n[e]=i,n[o]=r-i):t==="SAME_LOWER"&&(n[e]=r-i,n[o]=i)},Vg=(r,t,n,e,o,i,a,s)=>{let u=r.length-2,l=s.length===0;for(let c=0;c(qg(t,n),Bg(r,t,n)),Bg=(r,t,n)=>{let e=Hg(n,t);return[Wg(r,t,e)]},zg=(r,t)=>({name:"ConvTranspose",inputNames:r?["X","W","B"]:["X","W"],inputTypes:r?[0,0,0]:[0,0],cacheHint:t}),Ug=(r,t,n,e)=>{let i=t.length>2?"getB(output_channel)":"0.0",a=t[0].dims,s=t[1].dims,u=s[1],l=s[0]/e.group,c=[t[0].dims[0],t[1].dims[1]*e.group,...e.outputShape],d=S(r.session.backend.glContext.version),{activationFunction:p,applyActivation:m}=ce(e),g=` + const ivec2 strides = ivec2(${e.strides[0]}, ${e.strides[1]}); + const ivec2 pads = ivec2(${e.pads[0]}, ${e.pads[1]}); + ${p} + void main() { + ivec4 coords = getOutputCoords(); + int batch = coords.x; + int output_channel = coords.y; + + ivec2 loc = coords.zw + pads; + + int group_id = output_channel / ${u}; + int wOutChannel = output_channel - group_id * ${u}; + + float value = ${i}; + for (int inChannelOffset = 0; inChannelOffset < ${l}; inChannelOffset++) { + int input_channel = group_id * ${l} + inChannelOffset; + for (int wWOff = 0; wWOff < ${s[2]}; wWOff++) { + for (int wHOff = 0; wHOff < ${s[3]}; wHOff++) { + ivec2 wOff = ivec2(wWOff * ${e.dilations[0]}, wHOff * ${e.dilations[1]}); + ivec2 wLoc = loc - wOff; + ivec2 wLocIn = wLoc / strides; + if ( + wLocIn * strides == wLoc && + wLocIn.x >= 0 && wLocIn.x < ${a[2]} && + wLocIn.y >= 0 && wLocIn.y < ${a[3]} + ) { + float xVal = getX(batch, input_channel, wLocIn.y, wLocIn.x); + float wVal = getW(input_channel, wOutChannel, wHOff, wWOff); + value += xVal * wVal; + } + } + } + } + ${m} + ${d.output} = vec4(value, .0, .0, .0); + } +`;return{...n,output:{dims:c,type:t[0].type,textureType:0},shaderSource:g,hasMain:!0}},jg=(r,t,n)=>{let e=zg(t.length>2,n.cacheKey);return{...e,get:()=>Ug(r,t,e,n)}},Wg=(r,t,n)=>r.run(jg(r,t,n),t),Hg=(r,t)=>{let n=r.kernelShape.slice();if(r.kernelShape.length===0)for(let s=2;s{let t=r.attributes,n=Xe(t),e=t.getString("auto_pad","NOTSET"),o=t.getInts("dilations",[1,1]),i=t.getInt("group",1),a=t.getInts("kernel_shape",[]),s=t.getInts("output_padding",[0,0]),u=t.getInts("output_shape",[]),l=t.getInts("pads",[0,0,0,0]),c=t.getInts("strides",[1,1]);return L({autoPad:e,dilations:o,group:i,kernelShape:a,outputPadding:s,outputShape:u,pads:l,strides:c,...n})},qg=(r,t)=>{if(!r||r.length!==2&&r.length!==3)throw new Error("Conv requires 2 or 3 inputs");if(r[0].dims.length!==4||r[1].dims.length!==4)throw new Error("currently only support 2-dimensional conv");let n=r[0].dims[1],e=r[1].dims[0];if(n!==e)throw new Error("FILTER_IN_CHANNEL should be equal to DATA_CHANNEL");let o=r[1].dims[1]*t.group;if(r.length===3&&(r[2].dims.length!==1||r[2].dims[0]!==o))throw new Error("invalid bias");let i=r[0].dims.length-2;if(t.dilations.length!==i)throw new Error(`dilations should be ${i}D`);if(t.strides.length!==i)throw new Error(`strides should be ${i}D`);if(t.pads.length!==i*2)throw new Error(`pads should be ${i*2}D`);if(t.outputPadding.length!==i)throw new Error(`output_padding should be ${i}D`);if(t.kernelShape.length!==0&&t.kernelShape.length!==r[1].dims.length-2)throw new Error("invalid kernel shape");if(t.outputShape.length!==0&&t.outputShape.length!==r[0].dims.length-2)throw new Error("invalid output shape");if(r[0].type!=="float32"||r[1].type!=="float32")throw new Error("ConvTranspose input(X,W) should be float tensor");if(r.length===3&&r[2].type!=="float32")throw new Error("ConvTranspose input(bias) should be float tensor")}});var Jl,ke,Yl,Kg,Ql,Xg,Zg,Jg,ur=y(()=>{"use strict";tt();V();C();Jl={name:"Transpose",inputNames:["A"],inputTypes:[0]},ke=(r,t,n)=>(Jg(t),[r.run({...Jl,cacheHint:n.cacheKey,get:()=>Kg(r,t[0],n.perm)},t)]),Yl=r=>L({perm:r.attributes.getInts("perm",[])}),Kg=(r,t,n)=>{let e=t.dims;n=Ql(e,n);let o=Xg(e,n),i=e.length,a=` + ${Zg("perm",n,i)} + float process(int indices[${i}]) { + int a[${i}]; + perm(a, indices); + return _A(a); + }`;return{...Jl,output:{dims:o,type:t.type,textureType:0},shaderSource:a}},Ql=(r,t)=>(t&&t.length!==r.length&&(t=[...r.keys()].reverse()),t),Xg=(r,t)=>(t=Ql(r,t),I.sortBasedOnPerm(r,t)),Zg=(r,t,n)=>{let e=[];e.push(`void ${r}(out int a[${n}], int src[${n}]) {`);for(let o=0;o{if(!r||r.length!==1)throw new Error("Transpose requires 1 input.");if(r[0].type!=="float32"&&r[0].type!=="float64")throw new Error("input should be float tensor")}});var tc,ec,Yg,nc=y(()=>{"use strict";ur();tc=(r,t,n)=>{Yg(t);let e=n.blocksize,o=e*e,i=n.mode==="DCR"?[0,3,4,1,5,2]:[0,1,4,2,5,3],a=n.mode==="DCR"?[t[0].dims[0],e,e,t[0].dims[1]/o,t[0].dims[2],t[0].dims[3]]:[t[0].dims[0],t[0].dims[1]/o,e,e,t[0].dims[2],t[0].dims[3]],s=r.reshapeUnpacked(t[0],a),u={perm:i,cacheKey:`${i}`},[l]=ke(r,[s],u),c=[t[0].dims[0],t[0].dims[1]/o,t[0].dims[2]*e,t[0].dims[3]*e];return[r.reshapeUnpacked(l,c)]},ec=r=>{let t=r.attributes.getInt("blocksize");if(t<1)throw new Error(`blocksize must be >= 1, but got : ${t} for DepthToSpace`);let n=r.attributes.getString("mode","DCR");if(n!=="DCR"&&n!=="CRD")throw new Error(`unrecognized mode: ${n} for DepthToSpace`);return{mode:n,blocksize:t}},Yg=r=>{if(r.length!==1)throw new Error(`DepthToSpace expect 1 inputs, but got ${r.length}`);if(r[0].type==="string"||r[0].dims.length!==4)throw new TypeError("DepthToSpace input should be a 4-D numeric tensor")}});var rc,oc,Qg,ic=y(()=>{"use strict";V();rc=(r,t,n)=>{Qg(t,n);let e=I.flattenShape(t[0].dims,n);return[r.reshapeUnpacked(t[0],e)]},oc=r=>r.attributes.getInt("axis",1),Qg=(r,t)=>{if(!r||r.length!==1)throw new Error("Flatten requires 1 input.");let n=r[0].dims.length;if(n===0)throw new Error("scalar tensor is not supported.");if(t<-n||t>n)throw new Error("Invalid axis");if(r[0].type==="string")throw new Error("string tensor is not supported.")}});var ve,bn=y(()=>{"use strict";ve=["float32","float64","int32","int16","int8","uint16","uint32","uint8"]});var ac,sc,ty,ey,ny,ry,uc=y(()=>{"use strict";tt();bn();V();C();ac=(r,t,n)=>(ry(t,n.axis),[r.run(ny(r,t,n),t)]),sc=r=>L({axis:r.attributes.getInt("axis",0)}),ty={name:"Gather",inputNames:["A","B"],inputTypes:[0,0]},ey=(r,t,n,e)=>{let o=n[0].dims.slice(),i=n[1].dims.slice(),a=new Array(o.length+i.length-1);e=I.normalizeAxis(e,o.length);let s=[];for(let p=0;p{let e={...ty,cacheHint:n.cacheKey};return{...e,get:()=>ey(r,e,t,n.axis)}},ry=(r,t)=>{if(!r||r.length!==2)throw new Error("Gather requires 2 inputs.");let n=r[0].dims.length;if(n<1)throw new Error("Invalid input shape.");if(t<-n||t>n-1)throw new Error("Invalid axis.");if(ve.indexOf(r[0].type)===-1)throw new Error("Invaid input type.");if(r[1].type!=="int32"&&r[1].type!=="int16")throw new Error("Invaid input type.")}});var ki,lc,cc,fc,oy,iy,ay,dc=y(()=>{"use strict";tt();V();C();ki=(r,t,n)=>(ay(t,n),[r.run(oy(t,n),t)]),lc=(r,t)=>{let n=r.attributes.getInt("transA",0)!==0,e=r.attributes.getInt("transB",0)!==0,o=r.attributes.getFloat("alpha",1),i=r.attributes.getFloat("beta",1);return L({transA:n,transB:e,alpha:o,beta:i,isOptionalC:t})},cc=r=>lc(r,!1),fc=r=>lc(r,!0),oy=(r,t)=>{let n={name:"Gemm",inputNames:r.length===3?["A","B","C"]:["A","B"],inputTypes:r.length===3?[0,0,0]:[0,0],key:t.cacheKey};return{...n,get:()=>iy(n,r,t)}},iy=(r,t,n)=>{let e=t[0].dims.slice(),o=t[1].dims.slice(),[i,a]=Jn.getShapeOfGemmResult(e,n.transA,o,n.transB,t.length===3?t[2].dims:void 0),s=[i,a];if(!s)throw new Error("Can't use gemm on the given tensors");let u=e[e.length-1],l="";n.transA&&(u=e[0]),n.transA&&n.transB?l="value += _A_T(a) * _B_T(b);":n.transA&&!n.transB?l="value += _A_T(a) * _B(b);":!n.transA&&n.transB?l="value += _A(a) * _B_T(b);":!n.transA&&!n.transB&&(l="value += _A(a) * _B(b);");let c=s.length,d=t.length===3?`int c[${t[2].dims.length}];`:"",p=t.length===3?"bcastIndices_C(indices, c);":"",m=t.length===3?"value += beta * _C(c);":"",g=` + float process(int indices[${c}]) { + int a[${c}]; + int b[${c}]; + ${d} + + copyVec(indices, a); + copyVec(indices, b); + ${p} + + float value = 0.0; + for (int k=0; k<${u}; ++k) { + a[${c-1}] = k; + b[${c-2}] = k; + ${l} + } + + value = value * alpha; + ${m} + return value; + }`;return{...r,output:{dims:s,type:t[0].type,textureType:0},variables:[{name:"alpha",type:"float",data:n.alpha},{name:"beta",type:"float",data:n.beta}],shaderSource:g}},ay=(r,t)=>{if(!r)throw new Error("Input is missing");if(t.isOptionalC&&(r.length<2||r.length>3))throw new Error("Invaid input shape.");if(!t.isOptionalC&&r.length!==3)throw new Error("Gemm requires 3 inputs");if(r.length===3&&r[2].dims.length!==1&&r[2].dims.length!==2)throw new Error("Invalid input shape of C");if(r[0].type!=="float32"&&r[0].type!=="float64"||r[1].type!=="float32"&&r[1].type!=="float64"||r.length===3&&r[2].type!=="float32"&&r[2].type!=="float64")throw new Error("Invalid input type.");if(r[0].type!==r[1].type||r.length===3&&r[0].type!==r[2].type)throw new Error("Input types are mismatched")}});var pc,hc,sy,uy,ly,cy,fy,mc=y(()=>{"use strict";tt();C();pc=(r,t,n)=>(fy(t),[r.run(ly(r,t,n),t)]),hc=r=>{let t=r.attributes.getFloat("scale"),n=r.attributes.getFloats("bias");return L({scale:t,bias:n})},sy={name:"ImageScaler",inputNames:["X"],inputTypes:[0]},uy=(r,t,n,e)=>{let o=n[0].dims.slice(),i=o.length,s=` + ${cy(e.bias.length)} + float process(int indices[${i}]) { + return _X(indices) * scale + getBias(bias, indices[1]); + }`;return{...t,output:{dims:o,type:n[0].type,textureType:0},variables:[{name:"bias",type:"float",arrayLength:e.bias.length,data:e.bias},{name:"scale",type:"float",data:e.scale}],shaderSource:s}},ly=(r,t,n)=>{let e={...sy,cacheHint:n.cacheKey};return{...e,get:()=>uy(r,e,t,n)}},cy=r=>{let t=[`float getBias(float bias[${r}], int channel) {`];for(let n=0;n{if(!r||r.length!==1)throw new Error("ImageScaler requires 1 input.");if(r[0].dims.length!==4)throw new Error("Invalid input shape.");if(r[0].type!=="float32"&&r[0].type!=="float64")throw new Error("Invalid input type.")}});var gc,yc,bc,dy,py,hy,my,by,gy,Tc=y(()=>{"use strict";H();C();gc=(r,t,n)=>{gy(t);let e=r.run(py(t[0]),t);return[r.run(by(r,t[0],n,e.dims),[t[0],e,t[1],t[2]])]},yc=r=>r.attributes.getFloat("epsilon",1e-5),bc={name:"InstanceNormalization_MeanAndVariance",inputNames:["X"],inputTypes:[0]},dy=(r,t)=>{let n=t.dims.slice(),e=n[1],o=n[2]*n[3],i=[n[0],e],a=` + vec4 process(int[2] indices) { + vec4 v = vec4(0.0); + int a[4]; + a[0] = indices[0]; + a[1] = indices[1]; + float temp = 0.0; + for(int a2=0; a2<${n[2]}; a2++) { + a[2] = a2; + for(int a3=0; a3<${n[3]}; a3++) { + a[3] = a3; + float x = _X(a); + temp += x; + } + } + float mean = temp / float(${o}); + temp = 0.0; + for(int a2=0; a2<${n[2]}; a2++) { + a[2] = a2; + for(int a3=0; a3<${n[3]}; a3++) { + a[3] = a3; + float x = _X(a); + temp += (x - mean) * (x - mean); + } + } + v.r = mean; + v.g = temp / float(${o}); + + return v; + }`;return{...r,output:{dims:i,type:t.type,textureType:4},shaderSource:a}},py=r=>({...bc,get:()=>dy(bc,r)}),hy={name:"InstanceNormalization_ComputeOutput",inputNames:["X","MeanAndVariance","Scale","B"],inputTypes:[0,4,0,0]},my=(r,t,n,e,o)=>{let i=S(r.session.backend.glContext.version),[a,s]=r.calculateTextureWidthAndHeight(o,4),[u,l]=[a/4,s],c=` + vec4 get_MeanAndVariance(int[2] mv) { + int offset = indicesToOffset_MeanAndVariance(mv); + vec2 coords = offsetToCoords(offset, ${u}, ${l}); + return ${i.texture2D}(MeanAndVariance, coords); + } + + float process(int[4] indices) { + int mv[2]; + mv[0] = indices[0]; + mv[1] = indices[1]; + vec4 mean_and_variance = get_MeanAndVariance(mv); + float mean = mean_and_variance.r; + float variance = mean_and_variance.g; + + int sb[1]; + sb[0] = indices[1]; + float scale = _Scale(sb); + float b = _B(sb); + + return scale * (_X(indices) - mean) / sqrt(variance + epsilon) + b; + }`;return{...t,output:{dims:n.dims,type:n.type,textureType:0},variables:[{name:"epsilon",type:"float",data:e}],shaderSource:c}},by=(r,t,n,e)=>{let o={...hy,cacheHint:`${n}`};return{...o,get:()=>my(r,o,t,n,e)}},gy=r=>{if(!r||r.length!==3)throw new Error("InstanceNormalization requires 3 inputs.");let t=r[0],n=r[1],e=r[2];if(t.dims.length<3||n.dims.length!==1||e.dims.length!==1)throw new Error("Invalid input shape.");if(n.dims[0]!==t.dims[1]||e.dims[0]!==t.dims[1])throw new Error("Input shapes are mismatched.");if(t.type!=="float32"&&t.type!=="float64"||n.type!=="float32"&&n.type!=="float64"||e.type!=="float32"&&e.type!=="float64")throw new Error("Invalid input type.");if(r[0].dims.length!==4)throw new Error("Only support 4-D input shape.")}});function yy(r,t){let n=r[0].dims[1],e=r[0].dims.length,o=-Math.floor((t.size-1)/2),i=Math.ceil((t.size-1)/2),a=`float(${t.alpha}) / float(${t.size})`,s=`float(${t.bias})`,u=`float(${t.beta})`,l=` + float process(int indices[${e}]) { + int c = indices[1]; + float x = _X(indices); + float square_sum = 0.0; + + for (int i = ${o}; i <= ${i}; i++) { + int idx = c + i; + if (c >= 0 && c < ${n}) { + indices[1] = idx; + float j = _X(indices); + square_sum += j * j; + } + } + return x / pow(${s} + ${a} * square_sum, ${u}); + }`;return{...vc,cacheHint:t.cacheKey,output:{dims:r[0].dims,type:r[0].type,textureType:0},shaderSource:l}}function Ty(r,t){return{...vc,cacheHint:t.cacheKey,get:()=>yy(r,t)}}var _c,xc,vc,_y,wc=y(()=>{"use strict";tt();C();_c=(r,t,n)=>(_y(t),[r.run(Ty(t,n),t)]),xc=r=>{let t=r.attributes.getFloat("alpha",1e-4),n=r.attributes.getFloat("beta",.75),e=r.attributes.getFloat("bias",1),o=r.attributes.getInt("size");return L({alpha:t,beta:n,bias:e,size:o})},vc={name:"LRN",inputNames:["X"],inputTypes:[0]};_y=r=>{if(!r||r.length!==1)throw new Error("LRN requires 1 input.");if(r[0].dims.length!==4)throw new Error('currently only support LRN for input with "NCHW" format');if(r[0].type!=="float32")throw new Error("input should be float type")}});var xy,Mi,Ic,Oc,Pc,vy,wy,Iy,Oy,Py,Sy,Ay,Ey,Sc=y(()=>{"use strict";tt();V();H();C();xy={name:"Pad",inputNames:["A"],inputTypes:[0]},Mi=(r,t,n)=>(Iy(t),[r.run({...xy,cacheHint:n.cacheKey,get:()=>wy(r,t[0],n)},t)]),Ic=r=>{let t=r.attributes.getString("mode","constant"),n=r.attributes.getFloat("value",0),e=r.attributes.getInts("pads");return L({mode:t,value:n,pads:e})},Oc=(r,t,n)=>{Oy(t);let e=vy(r,t,n);return Mi(r,[t[0]],e)},Pc=r=>r.attributes.getString("mode","constant"),vy=(r,t,n)=>{if(!r.session.isInitializer(t[1].dataId)||t.length>=3&&!r.session.isInitializer(t[2].dataId))throw new Error("dynamic pad attributes are not allowed");let e=Array.from(t[1].integerData),o=t.length>=3?t[2].floatData[0]:0;return L({mode:n,pads:e,value:o})},wy=(r,t,n)=>{let e=I.padShape(t.dims.slice(),n.pads),o=e.length,a=` + ${Py(r,t,n)} + float process(int[${o}] indices) { + return padA(indices); + }`;return{name:"Pad",inputNames:["A"],inputTypes:[0],output:{dims:e,type:t.type,textureType:0},shaderSource:a}},Iy=r=>{if(!r||r.length!==1)throw new Error("Pad requires 1 input");if(r[0].type!=="float32"&&r[0].type!=="float64")throw new Error("Invalid input type.")},Oy=r=>{if(!r||r.length!==2&&r.length!==3)throw new Error("Pad requires 2 or 3 inputs");if(r[1].type!=="int32")throw new Error("Invalid input type.");if(r.length>=3&&r[2].type==="string")throw new Error("Invalid input type.")},Py=(r,t,n)=>{let e=S(r.session.backend.glContext.version),[o,i]=r.calculateTextureWidthAndHeight(t.dims,0),a=I.computeStrides(t.dims);switch(n.mode){case"constant":return Sy(e,t.dims,a,o,i,n.pads,n.value);case"reflect":return Ay(e,t.dims,a,o,i,n.pads);case"edge":return Ey(e,t.dims,a,o,i,n.pads);default:throw new Error("Invalid mode")}},Sy=(r,t,n,e,o,i,a)=>{let s=t.length,u="";for(let l=s-1;l>=0;--l)u+=` + k = m[${l}] - ${i[l]}; + if (k < 0) return constant; + if (k >= ${t[l]}) return constant; + offset += k * ${n[l]}; + `;return` + float padA(int m[${s}]) { + const float constant = float(${a}); + int offset = 0; + int k = 0; + ${u} + vec2 coords = offsetToCoords(offset, ${e}, ${o}); + float value = getColorAsFloat(${r.texture2D}(A, coords)); + return value; + } + `},Ay=(r,t,n,e,o,i)=>{let a=t.length,s="";for(let u=a-1;u>=0;--u)s+=` + k = m[${u}] - ${i[u]}; + if (k < 0) { k = -k; } + { + const int _2n_1 = ${2*(t[u]-1)}; + k = int( mod( float(k), float(_2n_1) ) ) ; + if(k >= ${t[u]}) { k = _2n_1 - k; } + } + offset += k * ${n[u]}; + `;return` + float padA(int m[${a}]) { + int offset = 0; + int k = 0; + ${s} + vec2 coords = offsetToCoords(offset, ${e}, ${o}); + float value = getColorAsFloat(${r.texture2D}(A, coords)); + return value; + } + `},Ey=(r,t,n,e,o,i)=>{let a=t.length,s="";for(let u=a-1;u>=0;--u)s+=` + k = m[${u}] - ${i[u]}; + if (k < 0) k = 0; + if (k >= ${t[u]}) k = ${t[u]-1}; + offset += k * ${n[u]}; + `;return` + float padA(int m[${a}]) { + int offset = 0; + int k = 0; + ${s} + vec2 coords = offsetToCoords(offset, ${e}, ${o}); + float value = getColorAsFloat(${r.texture2D}(A, coords)); + return value; + } + `}});var Ec,Dc,Lc,$c,Nc,Fc,Cc,Rc,Gc,Dy,Ac,kc,cr,Mc,lr,Ly,Vc=y(()=>{"use strict";tt();V();C();Ec=(r,t,n)=>{cr(t);let e={name:"AveragePool",inputNames:["X"],inputTypes:[0],cacheHint:n.cacheKey};return[r.run({...e,get:()=>Lc(t,e,!1,n)},t)]},Dc=r=>{let t=r.attributes.getString("auto_pad","NOTSET"),n=r.attributes.getInt("ceil_mode",0),e=r.attributes.getInt("count_include_pad",0)!==0,o=r.attributes.getInts("kernel_shape"),i=r.attributes.getInts("strides",[]),a=r.attributes.getInts("pads",[]);if(n!==0)throw new Error("using ceil() in shape computation is not yet supported for AveragePool");return L({autoPad:t,ceilMode:n,countIncludePad:e,kernelShape:o,strides:i,pads:a})},Lc=(r,t,n,e)=>{let[o,i]=Gc(r,e,n),a=I.size(o.kernelShape),s="value += _X(x);",u="";o.countIncludePad?u+=`value /= float(${a});`:u+=`value /= float(${a} - pad);`;let c=` + ${Mc(r[0].dims,o,s,u,"0.0")} + `;return{...t,output:{dims:i,type:r[0].type,textureType:0},shaderSource:c}},$c=(r,t,n)=>{cr(t);let e={name:"GlobalAveragePool",inputNames:["X"],inputTypes:[0],cacheHint:`${n.countIncludePad}`};return[r.run({...e,get:()=>Lc(t,e,!0,n)},t)]},Nc=r=>{let t=r.attributes.getInt("count_include_pad",0)!==0;return L({autoPad:"",ceilMode:0,countIncludePad:t,kernelShape:[],strides:[],pads:[]})},Fc=(r,t,n)=>{cr(t);let e={name:"MaxPool",inputNames:["X"],inputTypes:[0],cacheHint:n.cacheKey};return[r.run({...e,get:()=>Rc(t,e,!1,n)},t)]},Cc=r=>{let t=r.attributes.getString("auto_pad","NOTSET"),n=r.attributes.getInt("ceil_mode",0),e=r.attributes.getInts("kernel_shape"),o=r.attributes.getInts("strides",[]),i=r.attributes.getInts("pads",[]),a=r.attributes.getInt("storage_order",0),s=r.attributes.getInts("dilations",[]);if(a!==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 L({autoPad:t,ceilMode:n,countIncludePad:!1,kernelShape:e,strides:o,pads:i,storageOrder:a,dilations:s})},Rc=(r,t,n,e)=>{let[o,i]=Gc(r,e,n),l=` + ${Mc(r[0].dims,o,` + value = max(_X(x), value); + `,"","-1e5")} + `;return{...t,output:{dims:i,type:r[0].type,textureType:0},shaderSource:l}},Gc=(r,t,n)=>{let e=r[0].dims.slice(),o=Object.hasOwnProperty.call(t,"dilations"),i=t.kernelShape.slice(),a=t.strides.slice(),s=o?t.dilations.slice():[],u=t.pads.slice();$e.adjustPoolAttributes(n,e,i,a,s,u);let l=$e.computePoolOutputShape(n,e,a,s,i,u,t.autoPad),c=Object.assign({},t);return o?Object.assign(c,{kernelShape:i,strides:a,pads:u,dilations:s,cacheKey:t.cacheKey}):Object.assign(c,{kernelShape:i,strides:a,pads:u,cacheKey:t.cacheKey}),[c,l]},Dy={autoPad:"",ceilMode:0,countIncludePad:!1,kernelShape:[],strides:[],pads:[],storageOrder:0,dilations:[],cacheKey:""},Ac={name:"GlobalMaxPool",inputNames:["X"],inputTypes:[0]},kc=(r,t)=>(cr(t),[r.run({...Ac,get:()=>Rc(t,Ac,!0,Dy)},t)]),cr=r=>{if(!r||r.length!==1)throw new Error("Pool ops requires 1 input.");if(r[0].type!=="float32"&&r[0].type!=="float64")throw new Error("Invalid input type.")},Mc=(r,t,n,e,o)=>{let i=r.length;if(t.kernelShape.length<=2){let a=t.kernelShape[t.kernelShape.length-1],s=t.strides[t.strides.length-1],u=t.pads[t.pads.length/2-1],l=t.pads[t.pads.length-1],c=r[i-1],d="",p="",m="";if(u+l!==0?d=` + for (int i = 0; i < ${a}; i++) { + x[${i} - 1] = indices[${i} - 1] * ${s} - ${u} + i; + if (x[${i} - 1] < 0 || x[${i} - 1] >= ${c}) { + pad++; + continue; + } + ${n} + }`:d=` + for (int i = 0; i < ${a}; i++) { + x[${i} - 1] = indices[${i} - 1] * ${s} - ${u} + i; + ${n} + }`,t.kernelShape.length===2){let b=t.kernelShape[t.kernelShape.length-2],w=t.strides[t.strides.length-2],x=t.pads[t.pads.length/2-2],A=t.pads[t.pads.length-2],D=r[i-2];x+A!==0?p=` + for (int j = 0; j < ${b}; j++) { + x[${i} - 2] = indices[${i} - 2] * ${w} - ${x} + j; + if (x[${i} - 2] < 0 || x[${i} - 2] >= ${D}) { + pad+= ${a}; + continue; + } + `:p=` + for (int j = 0; j < ${b}; j++) { + x[${i} - 2] = indices[${i} - 2] * ${w} - ${x} + j; + `,m=` + } + `}return` + float process(int indices[${i}]) { + int x[${i}]; + copyVec(indices, x); + + float value = ${o}; + int pad = 0; + ${p} + ${d} + ${m} + ${e} + return value; + } + `}else{let a=I.size(t.kernelShape),s=I.computeStrides(t.kernelShape),u=s.length,l=t.pads.length,c=Ly(u),d=lr(r,"inputDims"),p=lr(t.pads,"pads"),m=lr(s,"kernelStrides"),g=lr(t.strides,"strides"),b=t.pads.reduce((A,D)=>A+D),w="";return b?w=` + if (x[j] >= inputDims[j] || x[j] < 0) { + pad++; + isPad = true; + break; + } + } + if (!isPad) { + ${n} + }`:w=` + } + ${n} + `,` + ${c} + float process(int indices[${i}]) { + int x[${i}]; + copyVec(indices, x); + int offset[${u}]; + int pads[${l}]; + int inputDims[${i}]; + int kernelStrides[${u}]; + int strides[${u}]; + ${p} + ${d} + ${g} + ${m} + + float value = ${o}; + int pad = 0; + bool isPad = false; + for (int i = 0; i < ${a}; i++) { + offsetToIndices(i, kernelStrides, offset); + isPad = false; + for (int j = ${i} - ${u}; j < ${i}; j++) { + x[j] = indices[j] * strides[j - ${i} + ${u}] + + offset[j - ${i} + ${u}] - pads[j - 2]; + ${w} + } + ${e} + + return value; + } + `}},lr=(r,t)=>{let n="";for(let e=0;e` + void offsetToIndices(int offset, int[${r}] strides, out int[${r}] indices) { + if (${r} == 0) { + return; + } + for (int i = 0; i < ${r} - 1; ++i) { + indices[i] = offset / strides[i]; + offset -= indices[i] * strides[i]; + } + indices[${r} - 1] = offset; + }`});var Me,we,$y,Ny,Bc,zc,Uc,jc,Wc,Hc,qc,Kc=y(()=>{"use strict";tt();bn();V();C();Me=(r,t,n,e,o)=>{Ny(t);let i={name:e,inputNames:["A"],inputTypes:[0]};return[r.run({...i,cacheHint:n.cacheKey,get:()=>$y(r,t,n,e,o,i)},t)]},we=r=>{let t=r.attributes.getInts("axes",[]),n=r.attributes.getInt("keepdims",1)===1;return L({axes:t,keepDims:n})},$y=(r,t,n,e,o,i)=>{let a=[],s=t[0].dims.length||1,u=[],l=I.normalizeAxes(n.axes,t[0].dims.length),c=o(t,l),d=c[1];for(let g=0;g=0||l.length===0?(n.keepDims&&a.push(1),d=` + for(int j${g} = 0; j${g} < ${t[0].dims[g]}; j${g}++) { + inputIdx[${g}] = j${g}; + ${d} + }`):(u.push(`inputIdx[${g}] = outputIdx[${a.length}];`),a.push(t[0].dims[g]));let m=` + float process(int outputIdx[${a.length||1}]) { + float value; // final result + int inputIdx[${s}]; // addressing input data + ${u.join(` +`)} + ${c[0]} // init ops for reduce max/min + ${d} + ${c[2]} // final computation for reduce mean + return value; + }`;return{...i,output:{dims:a,type:t[0].type,textureType:0},shaderSource:m}},Ny=r=>{if(!r||r.length!==1)throw new Error("Reduce op requires 1 input.");if(ve.indexOf(r[0].type)===-1)throw new Error("Invalid input type.")},Bc=(r,t,n)=>Me(r,t,n,"ReduceSum",()=>["value = 0.0;","value += _A(inputIdx);",""]),zc=(r,t,n)=>Me(r,t,n,"ReduceMean",(o,i)=>{let a=1;for(let s=0;s=0||i.length===0)&&(a*=o[0].dims[s]);return["value = 0.0;","value += _A(inputIdx);",`value /= ${a}.;`]}),Uc=(r,t,n)=>Me(r,t,n,"ReduceMax",(o,i)=>{let a=[];for(let s=0;s=0||i.length===0)&&a.push(`inputIdx[${s}] = 0;`);return[`${a.join(` +`)} +value = _A(inputIdx);`,"value = max(value, _A(inputIdx));",""]}),jc=(r,t,n)=>Me(r,t,n,"ReduceMin",(o,i)=>{let a=[];for(let s=0;s=0||i.length===0)&&a.push(`inputIdx[${s}] = 0;`);return[`${a.join(` +`)} +value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),Wc=(r,t,n)=>Me(r,t,n,"ReduceProd",()=>["value = 1.0;","value *= _A(inputIdx);",""]),Hc=(r,t,n)=>Me(r,t,n,"ReduceLogSum",()=>["value = 0.0;","value += _A(inputIdx);","value = log(value);"]),qc=(r,t,n)=>Me(r,t,n,"ReduceLogSumSquare",()=>["float t; value = 0.0;","t = _A(inputIdx); value += t * t;",""])});var Xc,Zc=y(()=>{"use strict";V();Xc=(r,t)=>{let n=I.calculateReshapedDims(t[0].dims,t[1].integerData);return r.session.pack?[r.reshapePacked(t[0],n)]:[r.reshapeUnpacked(t[0],n)]}});var Jc,Vi,Yc,Qc,gn,Fy,Bi,fr,zi=y(()=>{"use strict";tt();H();C();Jc={name:"Upsample",inputNames:["X"],inputTypes:[0]},Vi=(r,t,n)=>(Bi(t,n),[r.run({...Jc,cacheHint:n.cacheKey,get:()=>Fy(r,t,n)},t)]),Yc=r=>gn(r,7),Qc=r=>gn(r,9),gn=(r,t)=>{let n=t>=10,e=r.attributes.getString("mode","nearest");if(e!=="nearest"&&e!=="linear"&&(t<11||e!=="cubic"))throw new Error(`unrecognized mode: ${e}`);let o=[];t<9&&(o=r.attributes.getFloats("scales"),fr(o,e,n));let i=r.attributes.getFloat("extrapolation_value",0),a=t>10?r.attributes.getString("coordinate_transformation_mode","half_pixel"):"asymmetric";if(["asymmetric","pytorch_half_pixel","tf_half_pixel_for_nn","align_corners","tf_crop_and_resize","half_pixel"].indexOf(a)===-1)throw new Error(`coordinate_transform_mode '${a}' is not supported`);let s=a==="tf_crop_and_resize",u=s,l=e==="nearest"&&t>=11?r.attributes.getString("nearest_mode","round_prefer_floor"):"";if(["round_prefer_floor","round_prefer_ceil","floor","ceil",""].indexOf(l)===-1)throw new Error(`nearest_mode '${l}' is not supported`);let c=r.attributes.getFloat("cubic_coeff_a",-.75),d=r.attributes.getInt("exclude_outside",0)!==0;if(d&&e!=="cubic")throw new Error("exclude_outside can be set to 1 only when mode is CUBIC.");let p=t<11?!0:e==="nearest"&&a==="asymmetric"&&l==="floor",m=0,g=0,b=0;return t>10?r.inputs.length>2?(m=1,g=2,b=3):(g=1,b=2):t===9&&(g=1),L({opset:t,isResize:n,mode:e,scales:o,extrapolationValue:i,coordinateTransformMode:a,useExtrapolation:u,needRoiInput:s,nearestMode:l,cubicCoefficientA:c,excludeOutside:d,useNearest2xOptimization:p,roiInputIdx:m,scalesInputIdx:g,sizesInputIdx:b})},Fy=(r,t,n)=>{let e=S(r.session.backend.glContext.version),[o,i]=r.calculateTextureWidthAndHeight(t[0].dims,0),a=t[0].dims.map((b,w)=>Math.floor(b*n.scales[w])),[s,u]=r.calculateTextureWidthAndHeight(a,0),l=a.length,c=new Array(l),d=new Array(l),p=` + int output_pitches[${l}]; + int input_pitches[${l}]; + `;for(let b=l-1;b>=0;b--)c[b]=b===l-1?1:c[b+1]*a[b+1],d[b]=b===l-1?1:d[b+1]*t[0].dims[b+1],p+=` + output_pitches[${b}] = ${c[b]}; + input_pitches[${b}] = ${d[b]}; + `;let m=` + float getInputFloat(int index) { + vec2 coords = offsetToCoords(index, ${o}, ${i}); + float value = getColorAsFloat(${e.texture2D}(X, coords)); + return value; + } + `,g=n.mode==="nearest"?` + ${m} + float process(int indices[${l}]) { + int input_index = 0; + int output_index = coordsToOffset(TexCoords, ${s}, ${u}); + + ${p} + + int d, m; + for (int dim = 0; dim < ${l}; ++dim) { + d = output_index / output_pitches[dim]; + m = output_index - d * output_pitches[dim]; + output_index = m; + + if (scales[dim] != 1 && d > 0) { + int d2 = d / scales[dim]; + m = d - d2 * scales[dim]; + d = d2; + } + input_index += input_pitches[dim] * d; + } + + return getInputFloat(input_index); + }`:l===4?` + ${m} + float process(int indices[4]) { + int input_index = 0; + int output_index = coordsToOffset(TexCoords, ${s}, ${u}); + + ${p} + + int m; + int index_of_dim0, index_of_dim1, index_of_dim2, index_of_dim3; + index_of_dim0 = output_index / output_pitches[0]; + m = output_index - index_of_dim0 * output_pitches[0]; + index_of_dim1 = m / output_pitches[1]; + m = m - index_of_dim1 * output_pitches[1]; + index_of_dim2 = m / output_pitches[2]; + m = m - index_of_dim2 * output_pitches[2]; + index_of_dim3 = m; + + int index_of_input_dim2, index_of_input_dim3, x_offset, y_offset; + index_of_input_dim2 = index_of_dim2 / scales[2]; + y_offset = index_of_dim2 - index_of_input_dim2 * scales[2]; + index_of_input_dim3 = index_of_dim3 / scales[3]; + x_offset = index_of_dim3 - index_of_input_dim3 * scales[3]; + + input_index = index_of_dim0 * input_pitches[0] + + index_of_dim1 * input_pitches[1] + + index_of_input_dim2 * input_pitches[2] + + index_of_input_dim3; + + float x00 = getInputFloat(input_index); + float x10, x01, x11; + + bool end_of_dim2 = false; + if (index_of_input_dim2 == (${t[0].dims[2]} - 1)) { + // It's the end in dimension 2 + x01 = x00; + end_of_dim2 = true; + } else { + x01 = getInputFloat(input_index + input_pitches[2]); + } + + if (index_of_input_dim3 == (input_pitches[2] - 1)) { + // It's the end in dimension 3 + x10 = x00; + x11 = x01; + } + else { + x10 = getInputFloat(input_index + 1); + x11 = end_of_dim2 ? x10 : getInputFloat(input_index + input_pitches[2] + 1); + } + + float y0 = x00 + float(y_offset) * (x01 - x00) / float(scales[2]); + float y1 = x10 + float(y_offset) * (x11 - x10) / float(scales[2]); + return y0 + float(x_offset) * (y1 - y0) / float(scales[3]); + }`:` + ${m} + float process(int indices[2]) { + int input_index = 0; + int output_index = coordsToOffset(TexCoords, ${s}, ${u}); + + ${p} + + int m; + int index_of_dim0, index_of_dim1; + index_of_dim0 = output_index / output_pitches[0]; + m = output_index - index_of_dim0 * output_pitches[0]; + index_of_dim1 = m; + + int index_of_input_dim0, index_of_input_dim1, x_offset, y_offset; + index_of_input_dim0 = index_of_dim0 / scales[0]; + y_offset = index_of_dim0 - index_of_input_dim0 * scales[0]; + index_of_input_dim1 = index_of_dim1 / scales[1]; + x_offset = index_of_dim1 - index_of_input_dim1 * scales[1]; + + input_index = index_of_input_dim0 * input_pitches[0] + index_of_input_dim1; + + float x00 = getInputFloat(input_index); + float x10, x01, x11; + + bool end_of_dim0 = false; + if (index_of_input_dim0 == (${t[0].dims[0]} - 1)) { + // It's the end in dimension 0 + x01 = x00; + end_of_dim0 = true; + } else { + x01 = getInputFloat(input_index + input_pitches[0]); + } + + if (index_of_input_dim1 == (input_pitches[0] - 1)) { + // It's the end in dimension 1 + x10 = x00; + x11 = x01; + } + else { + x10 = getInputFloat(input_index + 1); + x11 = end_of_dim0 ? x10 : getInputFloat(input_index + input_pitches[0] + 1); + } + + float y0 = x00 + float(y_offset) * (x01 - x00) / float(scales[0]); + float y1 = x10 + float(y_offset) * (x11 - x10) / float(scales[0]); + return y0 + float(x_offset) * (y1 - y0) / float(scales[1]); + }`;return{...Jc,output:{dims:a,type:t[0].type,textureType:0},shaderSource:g,variables:[{name:"scales",type:"int",arrayLength:n.scales.length,data:n.scales.map(b=>Math.ceil(b))}]}},Bi=(r,t)=>{if(!r||t.opset<9&&r.length!==1||t.opset>=9&&t.opset<11&&r.length!==2||t.opset>=11&&r.length<2)throw new Error("invalid inputs.");if(t.scales.length>0&&r[0].dims.length!==t.scales.length)throw new Error("Invalid input shape.");if(r[0].type==="string")throw new Error("Invalid input tensor types.")},fr=(r,t,n)=>{if(n){for(let e of r)if(e<=0)throw new Error("Scale value should be greater than 0.")}else for(let e of r)if(e<1)throw new Error("Scale value should be greater than or equal to 1.");if((t==="linear"||t==="cubic")&&r.length!==2&&(r.length!==4||r[0]!==1||r[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.`)}});var Ui,ji,tf,ef,Cy,Ry,Gy,ky,nf=y(()=>{"use strict";H();C();ue();Re();zi();Ui={name:"Resize",inputNames:["A"],inputTypes:[2]},ji=(r,t,n)=>(Bi(t,n),[r.run({...Ui,cacheHint:n.cacheKey,get:()=>Cy(r,t,n)},t)]),tf=r=>gn(r,10),ef=r=>gn(r,11),Cy=(r,t,n)=>{let e=S(r.session.backend.glContext.version),[o,i]=Ry(t,n);if(o.every(D=>D===1)&&n.coordinateTransformMode!=="tf_crop_and_resize")return{...Ui,output:{dims:i,type:t[0].type,textureType:2},hasMain:!0,shaderSource:`void main() { + vec4 v = ${e.texture2D}(X, TexCoords); + ${e.output} = v; + }`};let s=i.length;if(s<2)throw new Error(`output dimension should be at least 2, but got ${s}`);let u=i[s-2],l=i[s-1],c=t[0].dims;if(s!==c.length)throw new Error(`output dimension should match input ${c.length}, but got ${s}`);let d=c[s-2],p=c[s-1],m=o[s-2],g=o[s-1],b="";if(n.mode!=="linear")throw new Error(`resize (packed) does not support mode: '${n.mode}'`);switch(n.coordinateTransformMode){case"asymmetric":b=` + vec4 getSourceFracIndex(ivec4 coords) { + return vec4(coords) / scaleWHWH; + } + `;break;case"half_pixel":b=` + vec4 getSourceFracIndex(ivec4 coords) { + return (vec4(coords) + 0.5) / scaleWHWH - 0.5; + } + `;break;case"pytorch_half_pixel":b=` + vec4 getSourceFracIndex(ivec4 coords) { + vec4 fcoords = vec4(coords); + return vec4( + ${l}.0 > 1.0 ? (fcoords.x + 0.5) / scaleWHWH.x - 0.5 : 0.0, + ${u}.0 > 1.0 ? (fcoords.y + 0.5) / scaleWHWH.y - 0.5 : 0.0, + ${l}.0 > 1.0 ? (fcoords.z + 0.5) / scaleWHWH.z - 0.5 : 0.0, + ${u}.0 > 1.0 ? (fcoords.w + 0.5) / scaleWHWH.w - 0.5 : 0.0 + ); + } + `;break;case"align_corners":b=` + vec4 getSourceFracIndex(ivec4 coords) { + vec4 resized = vec4(${l}.0 - 1.0, ${u}.0 - 1.0, ${l}.0 - 1.0, + ${u}.0 - 1.0); + vec4 original = vec4(${p}.0 - 1.0, ${d}.0 - 1.0, ${p}.0 - 1.0, + ${d}.0 - 1.0); + vec4 new_scale = original / resized; + return vec4(coords) * new_scale; + } + `;break;default:throw new Error(`resize (packed) does not support coordinateTransformMode: '${n.coordinateTransformMode}'`)}let w=it(s),x=le(),A=` + const vec2 inputWH = vec2(${d}.0, ${p}.0); + const vec4 scaleWHWH = vec4(float(${m}), float(${g}), float(${m}), float(${g})); + ${x} + ${b} + float getAValue(int x10, int r, int c, int d) { + return getChannel(getA(x10, r, c, d), vec2(c, d)); + } + void main() { + ${w} rc = getOutputCoords(); + + int batch = rc[0]; + int depth = rc[1]; + + // retrieve the 4 coordinates that is used in the 4 packed output values. + ivec4 coords = ivec4(rc.wz, rc.w + 1, rc.z + 1); + + // calculate the source index in fraction + vec4 sourceFrac = getSourceFracIndex(coords); + + // get the lower and upper bound of the 4 values that will be packed into one texel. + ivec4 x00 = ivec4(max(sourceFrac.xy, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.xy))); + ivec4 x01 = ivec4(max(sourceFrac.xw, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.xw))); + ivec4 x10 = ivec4(max(sourceFrac.zy, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.zy))); + ivec4 x11 = ivec4(max(sourceFrac.zw, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.zw))); + + bool hasNextRow = rc.w < ${u-1}; + bool hasNextCol = rc.z < ${l-1}; + + // pack x00, x01, x10, x11's top-left corner into one vec4 structure + vec4 topLeft = vec4( + getAValue(batch, depth, x00.x, x00.y), + hasNextCol ? getAValue(batch, depth, x01.x, x01.y) : 0.0, + hasNextRow ? getAValue(batch, depth, x10.x, x10.y) : 0.0, + (hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.x, x11.y) : 0.0); + + // pack x00, x01, x10, x11's top-right corner into one vec4 structure + vec4 topRight = vec4( + getAValue(batch, depth, x00.x, x00.w), + hasNextCol ? getAValue(batch, depth, x01.x, x01.w) : 0.0, + hasNextRow ? getAValue(batch, depth, x10.x, x10.w) : 0.0, + (hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.x, x11.w) : 0.0); + + // pack x00, x01, x10, x11's bottom-left corner into one vec4 structure + vec4 bottomLeft = vec4( + getAValue(batch, depth, x00.z, x00.y), + hasNextCol ? getAValue(batch, depth, x01.z, x01.y) : 0.0, + hasNextRow ? getAValue(batch, depth, x10.z, x10.y) : 0.0, + (hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.z, x11.y) : 0.0); + + // pack x00, x01, x10, x11's bottom-right corner into one vec4 structure + vec4 bottomRight = vec4( + getAValue(batch, depth, x00.z, x00.w), + hasNextCol ? getAValue(batch, depth, x01.z, x01.w) : 0.0, + hasNextRow ? getAValue(batch, depth, x10.z, x10.w) : 0.0, + (hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.z, x11.w) : 0.0); + + // calculate the interpolation fraction on u and v direction + vec4 frac = vec4(sourceFrac) - floor(sourceFrac); + vec4 clampFrac = clamp(frac, vec4(0.0), vec4(1.0)); + + vec4 top = mix(topLeft, topRight, clampFrac.ywyw); + vec4 bottom = mix(bottomLeft, bottomRight, clampFrac.ywyw); + vec4 newValue = mix(top, bottom, clampFrac.xxzz); + + ${e.output} = vec4(newValue); + } + `;return{...Ui,output:{dims:i,type:t[0].type,textureType:2},hasMain:!0,shaderSource:A}},Ry=(r,t)=>{let e=r[0].dims,o=t.scales,i;if(o.length===0){let s=r[t.scalesInputIdx];if(s&&s.size!==0){if(r[t.sizesInputIdx])throw new Error("Only one of scales or sizes must be provided as input.");o=Gy(s,t.mode,t.isResize)}else{let u=r[t.sizesInputIdx];if(!u||u.size===0)throw new Error("Either scales or sizes MUST be provided as input.");i=Array.from(u.integerData),o=ky(i,e,t.mode,t.isResize)}}else if(r[t.sizesInputIdx])throw new Error("Only one of scales or sizes must be provided as input.");let a=i||e.map((s,u)=>Math.floor(s*o[u]));return[o,a]},Gy=(r,t,n)=>{let e=Array.from(r.floatData);return fr(e,t,n),e},ky=(r,t,n,e)=>{let o=t.length,i=new Array(o);for(let a=0,s=o;a{"use strict";Ce();rf=(r,t)=>(My(t),[new Y([t[0].dims.length],"int32",void 0,void 0,new Int32Array(t[0].dims))]),My=r=>{if(!r||r.length!==1)throw new Error("Shape requires 1 input.")}});var Wi,af,sf,uf,Vy,lf,By,zy,cf=y(()=>{"use strict";tt();bn();V();C();Wi={name:"Slice",inputNames:["A"],inputTypes:[0]},af=(r,t,n)=>(Vy(t),[r.run({...Wi,cacheHint:n.cacheKey,get:()=>uf(r,t[0],n)},t)]),sf=r=>{let t=r.attributes.getInts("starts"),n=r.attributes.getInts("ends"),e=r.attributes.getInts("axes",[]);return L({starts:t,ends:n,axes:e})},uf=(r,t,n)=>{let e=n.axes.length===0?t.dims.slice(0).map((d,p)=>p):n.axes,o=I.normalizeAxes(e,t.dims.length),i=n.starts.map((d,p)=>d>t.dims[o[p]]-1?t.dims[o[p]]:I.normalizeAxis(d,t.dims[o[p]])),a=n.ends.map((d,p)=>d>t.dims[o[p]]-1?t.dims[o[p]]:I.normalizeAxis(d,t.dims[o[p]])),s=t.dims.slice(),u=[];for(let d=0;d0&&u.push(`outputIdx[${o[d]}] += ${i[d]};`);let c=` + float process(int outputIdx[${s.length}]) { + ${u.join(` + `)} + return _A(outputIdx); + }`;return{...Wi,output:{dims:s,type:t.type,textureType:0},shaderSource:c}},Vy=r=>{if(!r||r.length!==1)throw new Error("Slice requires 1 input.");if(ve.indexOf(r[0].type)===-1)throw new Error("Invalid input type.")},lf=(r,t)=>{zy(t);let n=By(r,t);return[r.run({...Wi,cacheHint:n.cacheKey,get:()=>uf(r,t[0],n)},[t[0]])]},By=(r,t)=>{if(!r.session.isInitializer(t[1].dataId)||!r.session.isInitializer(t[2].dataId)||t.length>=4&&!r.session.isInitializer(t[3].dataId)||t.length>=5&&!r.session.isInitializer(t[4].dataId))throw new Error("dynamic slice attributes are not allowed");if(t.length>=5&&t[4].integerData.some(a=>a!==1))throw new Error("currently non-1 steps is not supported for Slice");let n=Array.from(t[1].integerData),e=Array.from(t[2].integerData),o=t.length>=4?Array.from(t[3].integerData):[],i=`${o};${n};${e}`;return{starts:n,ends:e,axes:o,cacheKey:i}},zy=r=>{if(!r||r.length<3||r.length>5)throw new Error("Invalid input number.");if(r[1].type!=="int32"||r[1].dims.length!==1)throw new Error("Invalid input type.");if(r[2].type!=="int32"||r[2].dims.length!==1)throw new Error("Invalid input type.");if(r.length>=4&&(r[3].type!=="int32"||r[3].dims.length!==1))throw new Error("Invalid input type.");if(r.length>=5&&(r[4].type!=="int32"||r[4].dims.length!==1))throw new Error("Invalid input type.")}});var ff,df,pf,hf,mf,bf,gf,yf,Uy,jy,Wy,Tf,_f=y(()=>{"use strict";tt();V();H();C();ur();ff={name:"SoftmaxComputeMax",inputNames:["A"],inputTypes:[0]},df={name:"SoftmaxComputeScale",inputNames:["A","Max"],inputTypes:[0,0]},pf={name:"SoftMax",inputNames:["A","Max","Norm"],inputTypes:[0,0,0]},hf=(r,t,n)=>{Tf(t);let e=t[0].dims.slice(),o=I.normalizeAxis(n.axis,e.length),i=I.sizeToDimension(e,o),a=I.sizeFromDimension(e,o);return yf(r,t,n,i,a)},mf=r=>L({axis:r.attributes.getInt("axis",1)}),bf=r=>L({axis:r.attributes.getInt("axis",-1)}),gf=(r,t,n)=>{Tf(t);let e=t[0].dims.slice(),o=I.normalizeAxis(n.axis,e.length),i=e.length,a=o!==i-1,s=[],u=[],l=[],c;a&&(u=Array.from({length:i}).map((g,b)=>b),u[o]=i-1,u[i-1]=o,u.map(g=>s.push(e[g])),c=L({perm:u}),l=ke(r,t,c));let d=a?I.sizeToDimension(s,i-1):I.sizeToDimension(e,i-1),p=a?I.sizeFromDimension(s,i-1):I.sizeFromDimension(e,i-1),m=yf(r,a?l:t,n,d,p);return a?ke(r,m,c):m},yf=(r,t,n,e,o)=>{let i=Uy(r,t[0],e,o,[e]),a=r.run({...ff,cacheHint:n.cacheKey,get:()=>i},t),s=jy(r,t[0],e,o,i.output.dims,[e]),u=r.run({...df,cacheHint:n.cacheKey,get:()=>s},[t[0],a]),l=Wy(r,t[0],e,o,i.output.dims,s.output.dims);return[r.run({...pf,cacheHint:n.cacheKey,get:()=>l},[t[0],a,u])]},Uy=(r,t,n,e,o)=>{let[i,a]=r.calculateTextureWidthAndHeight(t.dims,0),s=o.length;if(n<1||e<1)throw new Error("Logical row count N and feature count D must be greater than or equal to 1");if(o.length!==1)throw new Error("Dimensionality of the output should be 1");if(o[0]!==n)throw new Error("Shape of the output should be equal to logical row count");let u=S(r.session.backend.glContext.version),l=` + float process(int[${s}] indices) { + int logical_row_start_offset = indices[0] * ${e}; + + float max = getColorAsFloat(${u.texture2D}(A, offsetToCoords(logical_row_start_offset, ${i}, + ${a} ))); + for(int i=1; i<${e}; ++i) + { + float current = getColorAsFloat(${u.texture2D}(A, offsetToCoords(logical_row_start_offset + i, + ${i}, ${a}))); + if(current > max) + max = current; + } + + return max; + }`;return{...ff,output:{dims:o,type:t.type,textureType:0},shaderSource:l}},jy=(r,t,n,e,o,i)=>{let[a,s]=r.calculateTextureWidthAndHeight(t.dims,0),u=i.length;if(n<1||e<1)throw new Error("Logical row count N and feature count D must be greater than or equal to 1");if(i.length!==1)throw new Error("Dimensionality of the output should be 1");if(i[0]!==n)throw new Error("Shape of the output should be equal to logical row count");if(o.length!==1)throw new Error("Dimensionality of the intermediate results should be 1");if(o[0]!==n)throw new Error("Shape of the intermediate results should be equal to logical row count");let l=S(r.session.backend.glContext.version),c=` + float process(int[${u}] indices) { + int logical_row_start_offset = indices[0] * ${e}; + + float norm_factor = 0.0; + float max = _Max(indices); + for(int i=0; i<${e}; ++i) + { + norm_factor += exp(getColorAsFloat(${l.texture2D}(A, offsetToCoords(logical_row_start_offset + i, + ${a}, ${s}))) - max); + } + + return norm_factor; + }`;return{...df,output:{dims:i,type:t.type,textureType:0},shaderSource:c}},Wy=(r,t,n,e,o,i)=>{let[a,s]=r.calculateTextureWidthAndHeight(t.dims,0),u=t.dims.length;if(n<1||e<1)throw new Error("Logical row count N and feature count D must be greater than or equal to 1");if(o.length!==1||i.length!==1)throw new Error("Dimensionality of the intermediate results should be 1");if(o[0]!==n||i[0]!==n)throw new Error("Shape of the intermediate results should be equal to logical row count");let l=` + float process(int[${u}] indices) { + + // get offset of current logical tensor index from the 2-D texture coordinates (TexCoords) + int offset = coordsToOffset(TexCoords, ${a}, ${s}); + + //determine the logical row for this index + int logical_row_index[1]; + logical_row_index[0] = offset / ${e}; + + float norm_factor = _Norm(logical_row_index); + + // avoid possible division by 0 + // if norm_facor is 0, all elements are zero + // if so, return 0 + if(norm_factor == 0.0) + return 0.0; + + return exp(_A(indices) - _Max(logical_row_index)) / norm_factor; + }`;return{...pf,output:{dims:t.dims,type:t.type,textureType:0},shaderSource:l}},Tf=r=>{if(!r||r.length!==1)throw new Error("Softmax requires 1 input.");if(r[0].type!=="float32"&&r[0].type!=="float64")throw new Error("Invalid input type")}});var xf,vf,wf,Hy,qy,Ky,If=y(()=>{"use strict";tt();V();C();xf={name:"Split",inputNames:["A"],inputTypes:[0]},vf=(r,t,n)=>{Ky(t);let e=I.normalizeAxis(n.axis,t[0].dims.length),o=Hy(r,t,e,n),i=[];for(let a=0;aqy(r,t[0],n,e,a)},t));return i},wf=r=>{let t=r.attributes.getInt("axis",0),n=r.attributes.getInts("split",[]),e=r.outputs.length;return L({axis:t,split:n,numOutputs:e})},Hy=(r,t,n,e)=>{let[,o]=cn.splitShape(t[0].dims,n,e.split,e.numOutputs);return o.length},qy=(r,t,n,e,o)=>{let[i,a]=cn.splitShape(t.dims,e,n.split,n.numOutputs),s=a[o],u=i[o],c=` + float process(int indices[${u.length}]) { + indices[${e}] += ${s}; + return _A(indices); + } + `;return{...xf,cacheHint:`${n.cacheKey}:${o}`,output:{dims:u,type:t.type,textureType:0},shaderSource:c}},Ky=r=>{if(!r||r.length!==1)throw new Error("Split requires one input.");if(r[0].type!=="int8"&&r[0].type!=="uint8"&&r[0].type!=="int16"&&r[0].type!=="uint16"&&r[0].type!=="int32"&&r[0].type!=="uint32"&&r[0].type!=="float32"&&r[0].type!=="float64"&&r[0].type!=="bool")throw new Error("Invalid input type.")}});var Hi,Of,Pf,Xy,Zy,Sf=y(()=>{"use strict";V();Hi=(r,t,n)=>{Xy(t);let e=I.squeezeShape(t[0].dims,n);return[r.reshapeUnpacked(t[0],e)]},Of=(r,t)=>(Zy(t),Hi(r,[t[0]],Array.from(t[1].integerData))),Pf=r=>r.attributes.getInts("axes"),Xy=r=>{if(!r||r.length!==1)throw new Error("Squeeze requires 1 input.");if(r[0].type==="string")throw new Error("invalid input tensor types.")},Zy=r=>{if(!r||r.length!==2)throw new Error("Squeeze requires 2 inputs.");if(r[1].type!=="int32")throw new Error("Invalid input type.")}});var Af,Jy,Yy,Ef=y(()=>{"use strict";H();C();Af=(r,t)=>{Yy(t);let n={name:"Sum",inputNames:t.map((o,i)=>`X${i}`),inputTypes:new Array(t.length).fill(0)};return[r.run({...n,get:()=>Jy(r,t,n)},t)]},Jy=(r,t,n)=>{let e=S(r.session.backend.glContext.version),o=t[0].dims.slice(),a=` + void main() { + vec4 result = ${t.map((s,u)=>`${e.texture2D}(X${u},TexCoords)`).join(" + ")}; + ${e.output} = result; + } + `;return{...n,output:{dims:o,type:t[0].type,textureType:0},hasMain:!0,shaderSource:a}},Yy=r=>{if(!r||r.length===0)throw new Error("Sum requires inputs.");let t=r[0].dims.length;for(let n=1;n{"use strict";bn();C();Df=(r,t)=>{tT(t);let n={name:"Tile",inputNames:["A"],inputTypes:[0]};return[r.run({...n,get:()=>Qy(r,t,n)},t)]},Qy=(r,t,n)=>{let e=t[0].dims.slice(),o=new Array(e.length),i=[];for(let u=0;u{if(!r||r.length!==2)throw new Error("Tile requires 2 input.");if(r[1].dims.length!==1)throw new Error("The second input shape must 1 dimension.");if(r[1].dims[0]!==r[0].dims.length)throw new Error("Invalid input shape.");if(ve.indexOf(r[0].type)===-1)throw new Error("Invalid input type.");if(r[1].type!=="int32"&&r[1].type!=="int16")throw new Error("Invalid repeat type.")}});var qi,$f,Nf,eT,nT,Ff=y(()=>{"use strict";V();qi=(r,t,n)=>{eT(t);let e=I.unsqueezeShape(t[0].dims,n);return[r.reshapeUnpacked(t[0],e)]},$f=(r,t)=>(nT(t),qi(r,[t[0]],Array.from(t[1].integerData))),Nf=r=>r.attributes.getInts("axes"),eT=r=>{if(!r||r.length!==1)throw new Error("Unsqueeze requires 1 input.");if(r[0].type==="string")throw new Error("invalid input tensor types.")},nT=r=>{if(!r||r.length!==2)throw new Error("Unsqueeze requires 2 inputs.");if(r[1].type!=="int32")throw new Error("Invalid input type.")}});var Cf,Rf=y(()=>{"use strict";Wu();ol();sl();pl();ir();Zl();nc();ic();uc();dc();mc();Tc();wc();ar();Sc();Vc();Kc();Zc();nf();of();cf();_f();If();Sf();Ef();Lf();ur();Di();Ff();zi();Cf=[["Abs","","6+",hl],["Acos","","7+",ml],["Add","","7+",Hu],["And","","7+",qu],["Asin","","7+",bl],["Atan","","7+",gl],["AveragePool","","7+",Ec,Dc],["BatchNormalization","","7+",Uu,ju],["Cast","","6+",il,al],["Ceil","","6+",_l],["Clip","","6-10",Ai,yl],["Clip","","11+",Tl],["Concat","","4+",cl,dl],["Conv","","1+",Ri,Gi],["ConvTranspose","","1+",Kl,Xl],["Cos","","7+",xl],["Div","","7+",Ku],["Dropout","","7+",Ei],["DepthToSpace","","1+",tc,ec],["Equal","","7+",Xu],["Elu","","6+",vl,wl],["Exp","","6+",Il],["Flatten","","1+",rc,oc],["Floor","","6+",Ol],["FusedConv","com.microsoft","1+",Ri,Gi],["Gather","","1+",ac,sc],["Gemm","","7-10",ki,cc],["Gemm","","11+",ki,fc],["GlobalAveragePool","","1+",$c,Nc],["GlobalMaxPool","","1+",kc],["Greater","","7+",Zu],["Identity","","1+",Ei],["ImageScaler","","1+",pc,hc],["InstanceNormalization","","6+",gc,yc],["LeakyRelu","","6+",Pl,Sl],["Less","","7+",Ju],["LRN","","1+",_c,xc],["Log","","6+",Al],["MatMul","","1+",Bl,zl],["MaxPool","","1+",Fc,Cc],["Mul","","7+",Yu],["Neg","","6+",El],["Not","","1+",Dl],["Or","","7+",Qu],["Pad","","2-10",Mi,Ic],["Pad","","11+",Oc,Pc],["Pow","","7+",tl],["PRelu","","7+",el],["ReduceLogSum","","1+",Hc,we],["ReduceMax","","1+",Uc,we],["ReduceMean","","1+",zc,we],["ReduceMin","","1+",jc,we],["ReduceProd","","1+",Wc,we],["ReduceSum","","1-12",Bc,we],["ReduceSumSquare","","1+",qc,we],["Relu","","6+",Ll],["Reshape","","5+",Xc],["Resize","","10",ji,tf],["Resize","","11+",ji,ef],["Shape","","1+",rf],["Sigmoid","","6+",$l],["Sin","","7+",Nl],["Slice","","10+",lf],["Slice","","1-9",af,sf],["Softmax","","1-12",hf,mf],["Softmax","","13+",gf,bf],["Split","","2-12",vf,wf],["Sqrt","","6+",Fl],["Squeeze","","1-12",Hi,Pf],["Squeeze","","13+",Of],["Sub","","7+",nl],["Sum","","6+",Af],["Tan","","7+",Cl],["Tanh","","6+",Rl],["Tile","","6+",Df],["Transpose","","1+",ke,Yl],["Upsample","","7-8",Vi,Yc],["Upsample","","9",Vi,Qc],["Unsqueeze","","1-12",qi,Nf],["Unsqueeze","","13+",$f],["Xor","","7+",rl]]});function kf(r){let t={},n;for(;(n=Gf.exec(r))!==null;){let e=n[3].split(",").map(o=>{let i=o.trim().split(" ");return i&&i.length===2?{type:i[0],name:i[1]}:null}).filter(o=>o!==null);t[n[2]]={params:e,body:n[4]}}for(let e in t){let o=rT.replace("__FUNC__",e),i=new RegExp(o,"gm");for(;(n=i.exec(r))!==null;){let a=n[1],s=n[2],u=n[3].split(","),l=a?`${a} ${s};`:"",c=t[e].body,d="";t[e].params.forEach((m,g)=>{m&&(d+=`${m.type} ${m.name} = ${u[g]}; +`)}),c=`${d} + ${c}`,c=c.replace("return",`${s} = `);let p=` + ${l} + { + ${c} + } + `;r=r.replace(n[0],p)}}return r=r.replace(Gf,""),r}var Gf,rT,Mf=y(()=>{"use strict";Gf=/@inline[\s\n\r]+(\w+)[\s\n\r]+([0-9a-zA-Z_]+)\s*\(([^)]*)\)\s*{(([^}]|[\n\r])*)}/gm,rT="(\\w+)?\\s+([_0-9a-zA-Z]+)\\s+=\\s+__FUNC__\\((.*)\\)\\s*;"});function Je(r,t){let n=[],e=[],o=t!=null&&Array.isArray(t)&&t.length===0,i=t==null||o?null:oT(t,r).sort(),a=0;for(let s=0;ss)&&r[s]===1&&(n.push(r[s]),e.push(s)),i[a]<=s&&a++}r[s]!==1&&(n.push(r[s]),e.push(s))}return{newShape:n,keptDims:e}}function oT(r,t){let n=t.length;return r=r==null?t.map((e,o)=>o):[].concat(r),We(r.every(e=>e>=-n&&e`All values in axis param must be in range [-${n}, ${n}) but got axis ${r}`),We(r.every(iT),()=>`All values in axis param must be integers but got axis ${r}`),r.map(e=>e<0?n+e:e)}function iT(r){return r%1===0}function aT(r){if(r.length===0)return 1;let t=r[0];for(let n=1;n{"use strict";dt();V();dr=class{constructor(t){this.maxTextureSize=t}computeTextureWH(t,n){let e=this.computeTexture(t,n);return n&&n.isPacked&&(e[0]/=2,e[1]/=2),n&&n.reverseWH?[e[1],e[0]]:e}computeTexture(t,n){let e=n&&n.isPacked;if(t.length===0)return e?[2,2]:[1,1];let o=this.maxTextureSize;if(n&&n.breakAxis!==void 0){let s=n.breakAxis>=t.length?1:t.slice(n.breakAxis).reduce((l,c)=>l*c),u=n.breakAxis<=0?1:t.slice(0,n.breakAxis).reduce((l,c)=>l*c);if(s>o||u>o)B.verbose("TextureLayout",`Given width/height preferences were unattainable: shape:${t}, breakAxis:${n.breakAxis}`);else return[s,u]}let i=t.slice(0);e&&(o=o*2,i=i.map((s,u)=>u>=i.length-2?i[u]%2===0?i[u]:i[u]+1:i[u]),i.length===1&&(i=[2,i[0]])),i.length!==2&&(i=Je(i).newShape);let a=aT(i);return i.length<=1&&a<=o?[1,a]:i.length===2&&i[0]<=o&&i[1]<=o?i:i.length===3&&i[0]*i[1]<=o&&i[2]<=o?[i[0]*i[1],i[2]]:i.length===3&&i[0]<=o&&i[1]*i[2]<=o?[i[0],i[1]*i[2]]:i.length===4&&i[0]*i[1]*i[2]<=o&&i[3]<=o?[i[0]*i[1]*i[2],i[3]]:i.length===4&&i[0]<=o&&i[1]*i[2]*i[3]<=o?[i[0],i[1]*i[2]*i[3]]:e?Vf(a/4).map(s=>s*2):Vf(a)}}});var pr,Bf=y(()=>{"use strict";V();he();H();Ki();ue();pr=class extends yt{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 v(` + vec2 ${t}(int offset, int width, int height) { + int t = offset / width; + int s = offset - t*width; + vec2 coords = (vec2(s,t) + vec2(0.5,0.5)) / vec2(width, height); + return coords; + } + `)}}coordsToOffset(){let t="coordsToOffset";return{coordsToOffset:new v(` + int ${t}(vec2 coords, int width, int height) { + float s = coords.s * float(width); + float t = coords.t * float(height); + int offset = int(t) * width + int(s); + return offset; + } + `)}}getOutputSamplingSnippet(){let t=this.context.outputTextureLayout;return t.isPacked?this.getPackedOutputSamplingSnippet(t):this.getUnpackedOutputSamplingSnippet(t)}getPackedOutputSamplingSnippet(t){let n=t.unpackedShape,e=[t.width,t.height],o={},i="getOutputCoords";switch(n.length){case 0:o[i]=this.getOutputScalarCoords();break;case 1:o[i]=this.getOutputPacked1DCoords(n,e);break;case 2:o[i]=this.getOutputPacked2DCoords(n,e);break;case 3:o[i]=this.getOutputPacked3DCoords(n,e);break;default:o[i]=this.getOutputPackedNDCoords(n,e)}let s=` + void setOutput(vec4 val) { + ${S(this.context.glContext.version).output} = val; + } + `,u="floatTextureSetRGBA";return o[u]=new v(s),o}getUnpackedOutputSamplingSnippet(t){let n=t.unpackedShape,e=[t.width,t.height],o={},i="getOutputCoords";switch(n.length){case 0:o[i]=this.getOutputScalarCoords();break;case 1:o[i]=this.getOutputUnpacked1DCoords(n,e);break;case 2:o[i]=this.getOutputUnpacked2DCoords(n,e);break;case 3:o[i]=this.getOutputUnpacked3DCoords(n,e);break;case 4:o[i]=this.getOutputUnpacked4DCoords(n,e);break;case 5:o[i]=this.getOutputUnpacked5DCoords(n,e);break;case 6:o[i]=this.getOutputUnpacked6DCoords(n,e);break;default:throw new Error(`Unsupported output dimensionality: ${n.length}`)}let s=` + void setOutput(float val) { + ${S(this.context.glContext.version).output} = vec4(val, 0, 0, 0); + } + `,u="floatTextureSetR";return o[u]=new v(s),o}getOutputScalarCoords(){return new v(` + int getOutputCoords() { + return 0; + } + `)}getOutputPacked1DCoords(t,n){let e=n,o="";return e[0]===1?(o=` + int getOutputCoords() { + return 2 * int(TexCoords.y * ${e[1]}.0); + } + `,new v(o)):e[1]===1?(o=` + int getOutputCoords() { + return 2 * int(TexCoords.x * ${e[0]}.0); + } + `,new v(o)):(o=` + int getOutputCoords() { + ivec2 resTexRC = ivec2(TexCoords.xy * + vec2(${e[0]}, ${e[1]})); + return 2 * (resTexRC.y * ${e[0]} + resTexRC.x); + } + `,new v(o))}getOutputPacked2DCoords(t,n){let e="";if(Le.arraysEqual(t,n))return e=` + ivec2 getOutputCoords() { + return 2 * ivec2(TexCoords.xy * vec2(${n[0]}, ${n[1]})); + } + `,new v(e);let o=n,i=Math.ceil(t[1]/2);return e=` + ivec2 getOutputCoords() { + ivec2 resTexRC = ivec2(TexCoords.xy * + vec2(${o[0]}, ${o[1]})); + + int index = resTexRC.y * ${o[0]} + resTexRC.x; + + // reverse r and c order for packed texture + int r = imod(index, ${i}) * 2; + int c = 2 * (index / ${i}); + + return ivec2(r, c); + } + `,new v(e)}getOutputPacked3DCoords(t,n){let e=[n[0],n[1]],o=Math.ceil(t[2]/2),i=o*Math.ceil(t[1]/2),a=` + ivec3 getOutputCoords() { + ivec2 resTexRC = ivec2(TexCoords.xy * + vec2(${e[0]}, ${e[1]})); + int index = resTexRC.y * ${e[0]} + resTexRC.x; + + int b = index / ${i}; + index -= b * ${i}; + + // reverse r and c order for packed texture + int r = imod(index, ${o}) * 2; + int c = 2 * (index / ${o}); + + return ivec3(b, r, c); + } + `;return new v(a)}getOutputPackedNDCoords(t,n){let e=[n[0],n[1]],o=Math.ceil(t[t.length-1]/2),i=o*Math.ceil(t[t.length-2]/2),a=i,s="",u="b, r, c";for(let c=2;c=0;--u)i[u]=i[u+1]*t[u+1];let a=["r","c","d"],s=i.map((u,l)=>{let c=`int ${a[l]} = index / ${u}`,d=l===i.length-1?`int ${a[l+1]} = index - ${a[l]} * ${u}`:`index -= ${a[l]} * ${u}`;return`${c}; ${d};`}).join("");return e=` + ivec3 getOutputCoords() { + ivec2 resTexRC = ivec2(TexCoords.xy * + vec2(${n[0]}, ${n[1]})); + int index = resTexRC.y * ${n[0]} + resTexRC.x; + ${s} + return ivec3(r, c, d); + } + `,new v(e)}getOutputUnpacked4DCoords(t,n){let e="",o=t.length,i=null;o<2&&(i=[]),i=new Array(o-1),i[o-2]=t[o-1];for(let u=o-3;u>=0;--u)i[u]=i[u+1]*t[u+1];let a=["r","c","d","d2"],s=i.map((u,l)=>{let c=`int ${a[l]} = index / ${u}`,d=l===i.length-1?`int ${a[l+1]} = index - ${a[l]} * ${u}`:`index -= ${a[l]} * ${u}`;return`${c}; ${d};`}).join("");return e=` + ivec4 getOutputCoords() { + ivec2 resTexRC = ivec2(TexCoords.xy * + vec2(${n[0]}, ${n[1]})); + int index = resTexRC.y * ${n[0]} + resTexRC.x; + ${s} + return ivec4(r, c, d, d2); + } + `,new v(e)}getOutputUnpacked5DCoords(t,n){let e="",o=t.length,i=null;o<2&&(i=[]),i=new Array(o-1),i[o-2]=t[o-1];for(let u=o-3;u>=0;--u)i[u]=i[u+1]*t[u+1];let a=["r","c","d","d2","d3"],s=i.map((u,l)=>{let c=`int ${a[l]} = index / ${u}`,d=l===i.length-1?`int ${a[l+1]} = index - ${a[l]} * ${u}`:`index -= ${a[l]} * ${u}`;return`${c}; ${d};`}).join("");return e=` + ivec5 getOutputCoords() { + ivec2 resTexRC = ivec2(TexCoords.xy * + vec2(${n[0]}, ${n[1]})); + int index = resTexRC.y * ${n[0]} + resTexRC.x; + ${s} + return ivec5(r, c, d, d2, d3); + } + `,new v(e)}getOutputUnpacked6DCoords(t,n){let e="",o=t.length,i=null;o<2&&(i=[]),i=new Array(o-1),i[o-2]=t[o-1];for(let u=o-3;u>=0;--u)i[u]=i[u+1]*t[u+1];let a=["r","c","d","d2","d3","d4"],s=i.map((u,l)=>{let c=`int ${a[l]} = index / ${u}`,d=l===i.length-1?`int ${a[l+1]} = index - ${a[l]} * ${u}`:`index -= ${a[l]} * ${u}`;return`${c}; ${d};`}).join("");return e=` + ivec6 getOutputCoords() { + ivec2 resTexRC = ivec2(TexCoords.xy * + vec2(${n[0]}, ${n[1]})); + int index = resTexRC.y * ${n[0]} + resTexRC.x; + ${s} + return ivec6(r, c, d, d2, d3, d4); + } + `,new v(e)}getCommonUtilFuncs(){let t={},n="uvFromFlat";t[n]=new v(` + vec2 uvFromFlat(int texNumR, int texNumC, int index) { + int texC = index / texNumR; + int texR = index - texC * texNumR; + // TODO: swap texR, texC order in following function so row is corresponding to u and column is corresponding to + // v. + return (vec2(texR, texC) + halfCR) / vec2(texNumR, texNumC); + } + `),n="packedUVfrom1D",t[n]=new v(` + vec2 packedUVfrom1D(int texNumR, int texNumC, int index) { + int texelIndex = index / 2; + int texR = texelIndex / texNumC; + int texC = texelIndex - texR * texNumC; + return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR); + } + `),n="packedUVfrom2D",t[n]=new v(` + vec2 packedUVfrom2D(int texNumR, int texNumC, int texelsInLogicalRow, int row, int col) { + int texelIndex = (row / 2) * texelsInLogicalRow + (col / 2); + int texR = texelIndex / texNumC; + int texC = texelIndex - texR * texNumC; + return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR); + } + `),n="packedUVfrom3D",t[n]=new v(` + vec2 packedUVfrom3D(int texNumR, int texNumC, + int texelsInBatch, int texelsInLogicalRow, int b, + int row, int col) { + int index = b * texelsInBatch + (row / 2) * texelsInLogicalRow + (col / 2); + int texR = index / texNumC; + int texC = index - texR * texNumC; + return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR); + } + `),n="sampleTexture";let e=S(this.context.glContext.version);return t[n]=new v(` + float sampleTexture(sampler2D textureSampler, vec2 uv) { + return ${e.texture2D}(textureSampler, uv).r; + }`),t}getInputsSamplingSnippets(){let t={},n=this.context.outputTextureLayout;return this.context.programInfo.inputNames.forEach((e,o)=>{let i=this.context.inputTextureLayouts[o],a=Yn(e);i.isPacked?t[a]=this.getPackedSamplerFromInput(a,e,i):t[a]=this.getUnpackedSamplerFromInput(a,e,i);let s=Su(e);i.unpackedShape.length<=n.unpackedShape.length&&(i.isPacked?t[s]=this.getPackedSamplerAtOutputCoords(s,i,n,e):t[s]=this.getUnpackedSamplerAtOutputCoords(s,i,n,e))}),t}getPackedSamplerAtOutputCoords(t,n,e,o){let i=n.unpackedShape,a=e.unpackedShape,u=Yn(o),l=i.length,c=a.length,d=ot.getBroadcastDims(i,a),p=it(c),m=c-l,g,b=St();l===0?g="":c<2&&d.length>=1?g="coords = 0;":g=d.map(Ie=>`coords.${b[Ie+m]} = 0;`).join(` +`);let w="";c<2&&l>0?w="coords":w=i.map((Ie,Ve)=>`coords.${b[Ve+m]}`).join(", ");let x="return outputValue;",D=I.size(i)===1,F=I.size(a)===1;if(l===1&&!D&&!F)x=` + return vec4(outputValue.xy, outputValue.xy); + `;else if(D&&!F)c===1?x=` + return vec4(outputValue.x, outputValue.x, 0., 0.); + `:x=` + return vec4(outputValue.x); + `;else if(d.length){let Ie=l-2,Ve=l-1;d.indexOf(Ie)>-1&&d.indexOf(Ve)>-1?x="return vec4(outputValue.x);":d.indexOf(Ie)>-1?x="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":d.indexOf(Ve)>-1&&(x="return vec4(outputValue.xx, outputValue.zz);")}let xt=` + int lastDim = coords.${b[c-1]}; + coords.${b[c-1]} = coords.${b[c-2]}; + coords.${b[c-2]} = lastDim; + `,At=` + vec4 ${t}() { + ${p} coords = getOutputCoords(); + ${xt} + ${g} + vec4 outputValue = ${u}(${w}); + ${x} + } + `;return new v(At,["coordinates.getOutputCoords"])}getUnpackedSamplerAtOutputCoords(t,n,e,o){let i=[e.width,e.height],a=[n.width,n.height],s=n.unpackedShape.length,u=e.unpackedShape.length,l=n.unpackedShape,c=e.unpackedShape,d=Yn(o);if(s===u&&Le.arraysEqual(a,i)){let D=` + float ${t}() { + return sampleTexture(${o}, TexCoords); + } + `;return new v(D,["coordinates.sampleTexture"])}let p=it(u),m=ot.getBroadcastDims(l,c),g=u-s,b,w=St();s===0?b="":u<2&&m.length>=1?b="coords = 0;":b=m.map(D=>`coords.${w[D+g]} = 0;`).join(` +`);let x="";u<2&&s>0?x="coords":x=n.unpackedShape.map((D,q)=>`coords.${w[q+g]}`).join(", ");let A=` + float ${t}() { + ${p} coords = getOutputCoords(); + ${b} + return ${d}(${x}); + } + `;return new v(A,["coordinates.getOutputCoords"])}getPackedSamplerFromInput(t,n,e){switch(e.unpackedShape.length){case 0:return this.getPackedSamplerScalar(t,n);case 1:return this.getPackedSampler1D(t,n,e);case 2:return this.getPackedSampler2D(t,n,e);case 3:return this.getPackedSampler3D(t,n,e);default:return this.getPackedSamplerND(t,n,e)}}getUnpackedSamplerFromInput(t,n,e){let o=e.unpackedShape;switch(o.length){case 0:return this.getUnpackedSamplerScalar(t,n,e);case 1:return this.getUnpackedSampler1D(t,n,e);case 2:return this.getUnpackedSampler2D(t,n,e);case 3:return this.getUnpackedSampler3D(t,n,e);case 4:return this.getUnpackedSampler4D(t,n,e);case 5:return this.getUnpackedSampler5D(t,n,e);case 6:return this.getUnpackedSampler6D(t,n,e);default:throw new Error(`Unsupported dimension ${o.length}-D`)}}getPackedSamplerScalar(t,n){let e=S(this.context.glContext.version),o=` + vec4 ${t}() { + return ${e.texture2D}(${n}, halfCR); + } + `;return new v(o)}getPackedSampler1D(t,n,e){let o=[e.width,e.height],i=[o[1],o[0]],a=S(this.context.glContext.version),u=`vec4 ${t}(int index) { + vec2 uv = packedUVfrom1D( + ${i[0]}, ${i[1]}, index); + return ${a.texture2D}(${n}, uv); + }`;return new v(u,["coordinates.packedUVfrom1D"])}getPackedSampler2D(t,n,e){let o=e.unpackedShape,i=[e.width,e.height],a=S(this.context.glContext.version),s=i[0],u=i[1];if(i!=null&&Le.arraysEqual(o,i)){let m=`vec4 ${t}(int row, int col) { + vec2 uv = (vec2(col, row) + halfCR) / vec2(${u}.0, ${s}.0); + return ${a.texture2D}(${n}, uv); + }`;return new v(m)}let l=i,c=Math.ceil(o[1]/2),p=`vec4 ${t}(int row, int col) { + vec2 uv = packedUVfrom2D(${l[1]}, ${l[0]}, ${c}, row, col); + return ${a.texture2D}(${n}, uv); + }`;return new v(p,["coordinates.packedUVfrom2D"])}getPackedSampler3D(t,n,e){let o=e.unpackedShape,i=[e.width,e.height],a=[i[0],i[1]],s=S(this.context.glContext.version);if(o[0]===1){let g=o.slice(1),b=[1,2],w=He(o,g),x=["b","row","col"],A=JSON.parse(JSON.stringify(e));A.unpackedShape=w;let D=this.getPackedSamplerFromInput(t,n,A),F=`${D.routineBody} + vec4 ${t}(int b, int row, int col) { + return ${t}(${qe(x,b)}); + } `;return new v(F,D.dependencies)}let u=a[0],l=a[1],c=Math.ceil(o[2]/2),d=c*Math.ceil(o[1]/2),m=`vec4 ${t}(int b, int row, int col) { + vec2 uv = packedUVfrom3D( + ${l}, ${u}, ${d}, ${c}, b, row, col); + return ${s.texture2D}(${n}, uv);}`;return new v(m,["coordinates.packedUVfrom3D"])}getPackedSamplerND(t,n,e){let o=e.unpackedShape,i=o.length,a=[e.width,e.height],s=S(this.context.glContext.version),u=[a[0],a[1]],l=u[1],c=u[0],d=Math.ceil(o[i-1]/2),p=d*Math.ceil(o[i-2]/2),m="int b, int row, int col",g=`b * ${p} + (row / 2) * ${d} + (col / 2)`;for(let x=2;x{let o=this.context.inputTextureLayouts[e],a=(o.unpackedShape.length>0?o.unpackedShape:o.shape).length,s=`_${n}`;t[s]=new v(this.getValueFromSingle(n,a,o.width,o.height,!1),[`shapeUtils.indicesToOffset${s}`,"coordinates.offsetToCoords","fragcolor.getColorAsFloat"]),s=s+"_T",t[s]=new v(this.getValueFromSingle(n,a,o.width,o.height,!0),[`shapeUtils.indicesToOffset${s}`,"coordinates.offsetToCoords","fragcolor.getColorAsFloat"])}),t}getValueFromSingle(t,n,e,o,i){let a=`_${t}`;i&&(a=a+"_T");let s=S(this.context.glContext.version);return` + float ${a}(int m[${n}]) { + int offset = indicesToOffset${a}(m); + vec2 coords = offsetToCoords(offset, ${e}, ${o}); + float value = getColorAsFloat(${s.texture2D}(${t}, coords)); + return value; + } + `}getPackedValueFrom(t,n,e,o,i){let a=`_${t}_Pack`;i&&(a=a+"_T");let s=S(this.context.glContext.version);return` + vec4 ${a}(int m[${n}]) { + int offset = indicesToOffset_${t}(m); + vec2 coords = offsetToCoords(offset, ${e}, ${o}); + return ${s.texture2D}(${t}, coords); + } + `}}});var hr,zf=y(()=>{"use strict";he();hr=class r extends yt{constructor(t){super(t)}getFunctions(){return{...this.encodeFloat32(),...this.decodeFloat32()}}getCustomTypes(){return{}}encodeFloat32(){return{encode:new v(`highp vec4 encode(highp float f) { + return vec4(f, 0.0, 0.0, 0.0); + } + `)}}decodeFloat32(){return{decode:new v(`highp float decode(highp vec4 rgba) { + return rgba.r; + } + `)}}encodeUint8(){let t=r.isLittleEndian()?"rgba.rgba=rgba.abgr;":"";return{encode:new v(` + highp vec4 encode(highp float f) { + highp float F = abs(f); + highp float Sign = step(0.0,-f); + highp float Exponent = floor(log2(F)); + highp float Mantissa = (exp2(- Exponent) * F); + Exponent = floor(log2(F) + 127.0) + floor(log2(Mantissa)); + highp vec4 rgba; + rgba[0] = 128.0 * Sign + floor(Exponent*exp2(-1.0)); + rgba[1] = 128.0 * mod(Exponent,2.0) + mod(floor(Mantissa*128.0),128.0); + rgba[2] = floor(mod(floor(Mantissa*exp2(23.0 -8.0)),exp2(8.0))); + rgba[3] = floor(exp2(23.0)*mod(Mantissa,exp2(-15.0))); + ${t} + rgba = rgba / 255.0; // values need to be normalized to [0,1] + return rgba; + } + `)}}decodeUint8(){let t=r.isLittleEndian()?"rgba.rgba=rgba.abgr;":"";return{decode:new v(` + highp float decode(highp vec4 rgba) { + rgba = rgba * 255.0; // values need to be de-normalized from [0,1] to [0,255] + ${t} + highp float Sign = 1.0 - step(128.0,rgba[0])*2.0; + highp float Exponent = 2.0 * mod(rgba[0],128.0) + step(128.0,rgba[1]) - 127.0; + highp float Mantissa = mod(rgba[1],128.0)*65536.0 + rgba[2]*256.0 +rgba[3] + float(0x800000); + highp float Result = Sign * exp2(Exponent) * (Mantissa * exp2(-23.0 )); + return Result; + } + `)}}static isLittleEndian(){let t=new ArrayBuffer(4),n=new Uint32Array(t),e=new Uint8Array(t);if(n[0]=3735928559,e[0]===239)return!0;if(e[0]===222)return!1;throw new Error("unknown endianness")}}});var mr,Uf=y(()=>{"use strict";he();H();mr=class extends yt{constructor(t){super(t)}getFunctions(){return{...this.setFragColor(),...this.getColorAsFloat()}}getCustomTypes(){return{}}setFragColor(){let t=S(this.context.glContext.version);return{setFragColor:new v(` + void setFragColor(float value) { + ${t.output} = encode(value); + } + `,["encoding.encode"])}}getColorAsFloat(){return{getColorAsFloat:new v(` + float getColorAsFloat(vec4 color) { + return decode(color); + } + `,["encoding.decode"])}}}});var br,jf=y(()=>{"use strict";he();br=class r extends yt{constructor(t){super(t)}getFunctions(){return{...this.bcastIndex(),...this.bcastMatmulIndex(),...this.offsetToIndices(),...this.indicesToOffset(),...this.incrementIndices()}}getCustomTypes(){return{}}bcastIndex(){let t=this.context.outputTextureLayout.shape.length,n={};return this.context.programInfo.inputNames.forEach((e,o)=>{let i=this.context.inputTextureLayouts[o].unpackedShape;if(i.length<=t){let a=i.length,s=t-a,u=`bcastIndices_${e}`,l="";for(let d=0;d{let i=this.context.inputTextureLayouts[o].shape;if(!(i.length<2||i.length>t)){let a=i.length,s=t-a,u=`bcastMatmulIndices_${e}`,l="";for(let d=0;d{let o=this.context.inputTextureLayouts[e].shape,i=this.context.inputTextureLayouts[e].strides,a=o.length,s=`indicesToOffset_${n}`;t[s]=new v(r.indexToOffsetSingle(s,a,i)),s=`indicesToOffset_${n}_T`,t[s]=new v(r.indexToOffsetSingle(s,a,i.slice().reverse()))}),t}static indexToOffsetSingle(t,n,e){let o="";for(let i=n-1;i>=0;--i)o+=` + offset += indices[${i}] * ${e[i]}; + `;return` + int ${t}(int indices[${n}]) { + int offset = 0; + ${o} + return offset; + } + `}offsetToIndices(){let t={};return this.context.programInfo.inputNames.forEach((n,e)=>{let o=this.context.inputTextureLayouts[e].shape,i=this.context.inputTextureLayouts[e].strides,a=o.length,s=`offsetToIndices_${n}`;t[s]=new v(r.offsetToIndicesSingle(s,a,i)),s=`offsetToIndices_${n}_T`,t[s]=new v(r.offsetToIndicesSingle(s,a,i.slice().reverse()))}),t}static offsetToIndicesSingle(t,n,e){let o=[];for(let i=0;i{let o=this.context.inputTextureLayouts[e].shape,i=o.length,a=`incrementIndices_${n}`,s="";for(let l=0;l= 0; --i) { + if(i > axis) continue; + indices[i] += 1; + if(indices[i] < shape[i]) { + break; + } + indices[i] = 0; + } + } + `;t[a]=new v(u)}),t}}});var gr,Wf=y(()=>{"use strict";he();gr=class extends yt{constructor(t){super(t)}getCustomTypes(){return{}}getFunctions(){return{...this.binaryVecFunctions(),...this.copyVec(),...this.setVecItem(),...this.getVecItem()}}binaryVecFunctions(){let n=this.context.outputTextureLayout.shape.length,e={add:"+=",sub:"-=",mul:"*=",div:"/="},o={};for(let i in e){let a=`${i}Vec`,s="";for(let l=0;l{"use strict";Bf();zf();Uf();jf();Wf();Xi={encoding:hr,fragcolor:mr,vec:gr,shapeUtils:br,coordinates:pr}});var yr,qf=y(()=>{"use strict";he();Mf();Hf();H();yr=class{constructor(t,n,e,o){this.libs={};this.glslLibRoutineDependencyGraph={};this.context=new nr(t,n,e,o),Object.keys(Xi).forEach(a=>{let s=new Xi[a](this.context);this.libs[a]=s});let i=this.glslLibRoutineDependencyGraph;for(let a in this.libs){let u=this.libs[a].getFunctions();for(let l in u){let c=a+"."+l,d;i[c]?(d=i[c],d.routineBody=u[l].routineBody):(d=new mn(c,u[l].routineBody),i[c]=d);let p=u[l].dependencies;if(p)for(let m=0;m{let o=e.split(".")[1];t.indexOf(o)!==-1&&n.push(this.glslLibRoutineDependencyGraph[e])}),rr.returnOrderedNodes(n)}getUniforms(t,n){let e=[];if(t)for(let o of t)e.push(`uniform sampler2D ${o};`);if(n)for(let o of n)e.push(`uniform ${o.type} ${o.name}${o.arrayLength?`[${o.arrayLength}]`:""};`);return e.join(` +`)}}});var Tr,Kf=y(()=>{"use strict";me();dt();qf();H();Tr=class{constructor(t,n,e){this.profiler=t;this.glContext=n;this.textureLayoutStrategy=e;this.repo=new Map,this.attributesBound=!1}getArtifact(t){return this.repo.get(t)}setArtifact(t,n){this.repo.set(t,n)}run(t,n,e){this.profiler.event("op",`ProgramManager.run ${t.programInfo.name??"unknown kernel"}`,()=>{let o=this.glContext.gl,i=t.program;o.useProgram(i);try{this.bindOutput(e),this.attributesBound||this.bindAttributes(t.attribLocations),this.bindUniforms(t.uniformLocations,t.programInfo.variables??[],n)}catch(a){throw B.error("ProgramManager",t.programInfo.shaderSource),a}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,n,e){return this.profiler.event("backend","ProgramManager.build",()=>{let o=new yr(this.glContext,t,n,e),i=o.preprocess(),a=this.compile(i);return{programInfo:t,program:a,uniformLocations:this.getUniformLocations(a,o.context.programInfo.inputNames,o.context.programInfo.variables),attribLocations:this.getAttribLocations(a)}})}compile(t){if(!this.vertexShader){B.verbose("ProrgramManager","Compiling and caching Vertex shader for the first time");let o=Iu(this.glContext.version);this.vertexShader=this.glContext.compileShader(o,this.glContext.gl.VERTEX_SHADER)}K.debug&&B.verbose("ProrgramManager",`FragShader: +${t} +`);let n=this.glContext.compileShader(t,this.glContext.gl.FRAGMENT_SHADER),e=this.glContext.createProgram(this.vertexShader,n);return this.glContext.deleteShader(n),e}bindOutput(t){let n=t.width,e=t.height;B.verbose("ProrgramManager",`Binding output texture to Framebuffer: w/h=${n}/${e}, shape=${t.shape}, type=${t.tensor.type}`),this.glContext.attachFramebuffer(t.texture,n,e)}bindAttributes(t){let n=t.position,e=t.textureCoord;this.glContext.setVertexAttributes(n,e),this.attributesBound=!0}bindUniforms(t,n,e){let o=this.glContext.gl,i=0;for(let{name:a,type:s,location:u,arrayLength:l}of t){let c=n.find(d=>d.name===a)?.data;if(s!=="sampler2D"&&!c)throw new Error(`variable '${a}' does not have data defined in program info`);switch(s){case"sampler2D":this.bindTexture(e[i],u,i),i++;break;case"float":l?o.uniform1fv(u,c):o.uniform1f(u,c);break;case"int":l?o.uniform1iv(u,c):o.uniform1i(u,c);break;default:throw new Error(`Uniform not implemented: ${s}`)}}}bindTexture(t,n,e){this.glContext.bindTextureToUniform(t.texture,e,n)}getAttribLocations(t){return{position:this.getAttribLocation(t,"position"),textureCoord:this.getAttribLocation(t,"textureCoord")}}getUniformLocations(t,n,e){let o=[];if(n)for(let i of n)o.push({name:i,type:"sampler2D",location:this.getUniformLocation(t,i)});if(e)for(let i of e)o.push({...i,location:this.getUniformLocation(t,i.name)});return o}getUniformLocation(t,n){let o=this.glContext.gl.getUniformLocation(t,n);if(o===null)throw new Error(`Uniform ${n} not found.`);return o}getAttribLocation(t,n){return this.glContext.gl.getAttribLocation(t,n)}}});var _r,Xf=y(()=>{"use strict";dt();pn();_r=class{constructor(t,n,e,o){this.glContext=t;this.layoutStrategy=n;this.profiler=e;this.config=o;this.pendingRead=new Map;o.reuseTextures&&(this.inUseTextures=new Map,this.idleTextures=new Map,this.textureLookup=new Map)}createTextureFromLayout(t,n,e,o){let i=this.toEncoderType(t),a=this.glContext.getEncoder(i,n.channels||1,o);if(n.isPacked&&o===1)throw new Error("not implemented");let s=n.width,u=n.height,l,c;if(this.config.reuseTextures){l=`${s}x${u}_${a.format}_${a.internalFormat}_${a.textureType}`,c=this.inUseTextures.get(l),c||(c=[],this.inUseTextures.set(l,c));let p=this.idleTextures.get(l);if(p&&p.length>0){let m=p.pop();return c.push(m),o===1&&this.glContext.updateTexture(m,s,u,a,this.toTextureData(t,e)),m}}B.verbose("TextureManager",`Creating new texture of size ${n.width}x${n.height}`);let d=this.glContext.allocateTexture(s,u,a,this.toTextureData(t,e));return this.config.reuseTextures&&(c.push(d),this.textureLookup.set(d,l)),d}readTexture(t,n,e){return e||(e=1),this.profiler.event("backend","TextureManager.readTexture",()=>{let o=t.shape.reduce((a,s)=>a*s)*e,i=this.glContext.readTexture(t.texture,t.width,t.height,o,this.toEncoderType(n),e);return this.toTensorData(n,i)})}async readTextureAsync(t,n,e){let o=t.tensor.dataId;if(e||(e=1),this.pendingRead.has(o)){let i=this.pendingRead.get(o);return new Promise(a=>i?.push(a))}return this.profiler.event("backend","TextureManager.readTextureAsync",async()=>{this.pendingRead.set(o,[]);let i=t.shape.reduce((l,c)=>l*c)*e;await this.glContext.createAndWaitForFence();let a=this.glContext.readTexture(t.texture,t.width,t.height,i,this.toEncoderType(n),e),s=this.toTensorData(n,a),u=this.pendingRead.get(o);return this.pendingRead.delete(o),u?.forEach(l=>l(s)),s})}readUint8TextureAsFloat(t){return this.profiler.event("backend","TextureManager.readUint8TextureAsFloat",()=>{let n=t.shape.reduce((o,i)=>o*i),e=this.glContext.readTexture(t.texture,t.width,t.height,n*4,"byte",4);return new Float32Array(e.buffer,e.byteOffset,n)})}releaseTexture(t,n){let e;if(this.config.reuseTextures&&(e=this.textureLookup.get(t.texture),e)){n&&this.textureLookup.delete(e);let o=this.inUseTextures.get(e);if(o){let i=o.indexOf(t.texture);if(i!==-1){o.splice(i,1);let a=this.idleTextures.get(e);a||(a=[],this.idleTextures.set(e,a)),a.push(t.texture)}}}(!e||n)&&(B.verbose("TextureManager",`Deleting texture of size ${t.width}x${t.height}`),this.glContext.deleteTexture(t.texture))}toTensorData(t,n){switch(t){case"int16":return n instanceof Int16Array?n:Int16Array.from(n);case"int32":return n instanceof Int32Array?n:Int32Array.from(n);case"int8":return n instanceof Int8Array?n:Int8Array.from(n);case"uint16":return n instanceof Uint16Array?n:Uint16Array.from(n);case"uint32":return n instanceof Uint32Array?n:Uint32Array.from(n);case"uint8":case"bool":return n instanceof Uint8Array?n:Uint8Array.from(n);case"float32":return n instanceof Float32Array?n:Float32Array.from(n);case"float64":return n instanceof Float64Array?n:Float64Array.from(n);default:throw new Error(`TensorData type ${t} is not supported`)}}toTextureData(t,n){if(n)return n instanceof Float32Array?n:new Float32Array(n)}toEncoderType(t){return"float"}clearActiveTextures(){this.glContext.clearActiveTextures()}}});var xr,Zf=y(()=>{"use strict";dt();ka();Bu();Rf();Kf();Ki();Xf();xr=class{constructor(t,n){this.backend=t;this.context=n;this.layoutStrategy=new dr(t.glContext.maxTextureSize),this.programManager=new Tr(this.context.profiler,t.glContext,this.layoutStrategy),this.textureManager=new _r(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 er(this)}onGraphInitialized(t){let n=t.getValues().filter(e=>e.from===-1&&e.tensor).map(e=>e.tensor.dataId);this.initializers=new Set(n)}isInitializer(t){return this.initializers?this.initializers.has(t):!1}addInitializer(t){this.initializers.add(t)}getTextureData(t,n){return n?this.packedTextureDataCache.get(t):this.unpackedTextureDataCache.get(t)}setTextureData(t,n,e=!1){B.verbose("WebGLSessionHandler","Storing Texture data in cache"),e?this.packedTextureDataCache.set(t,n):this.unpackedTextureDataCache.set(t,n)}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,n,e){let o=Ga(t,n,Cf);return{impl:o.opImpl,context:o.opInit?o.opInit(t,e):t}}}});function sT(r){let t=0;for(;t{"use strict";me();pn();pn();ue();yn=class{constructor(t,n){this.frameBufferBound=!1;this.itemsToPoll=[];this.gl=t,this.version=n,this.getExtensions(),this.vertexbuffer=this.createVertexbuffer(),this.framebuffer=this.createFramebuffer(),this.queryVitalParameters()}allocateTexture(t,n,e,o){let i=this.gl,a=i.createTexture();i.bindTexture(i.TEXTURE_2D,a),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.NEAREST),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE);let s=o?e.encode(o,t*n):null;return i.texImage2D(i.TEXTURE_2D,0,e.internalFormat,t,n,0,e.format,e.textureType,s),this.checkError(),a}updateTexture(t,n,e,o,i){let a=this.gl;a.bindTexture(a.TEXTURE_2D,t);let s=o.encode(i,n*e);a.texSubImage2D(a.TEXTURE_2D,0,0,0,n,e,o.format,o.textureType,s),this.checkError()}attachFramebuffer(t,n,e){let o=this.gl;o.bindTexture(o.TEXTURE_2D,t),o.bindFramebuffer(o.FRAMEBUFFER,this.framebuffer),o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,t,0),this.checkError(),o.viewport(0,0,n,e),o.scissor(0,0,n,e)}readTexture(t,n,e,o,i,a){let s=this.gl;a||(a=1),this.frameBufferBound||this.attachFramebuffer(t,n,e);let u=this.getEncoder(i,a),l=u.allocate(n*e);return s.bindTexture(s.TEXTURE_2D,t),s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,t,0),s.readPixels(0,0,n,e,s.RGBA,u.textureType,l),this.checkError(),u.decode(l,o)}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,n){let e=this.gl;e.vertexAttribPointer(t,3,e.FLOAT,!1,20,0),e.enableVertexAttribArray(t),n!==-1&&(e.vertexAttribPointer(n,2,e.FLOAT,!1,20,12),e.enableVertexAttribArray(n)),this.checkError()}createProgram(t,n){let e=this.gl,o=e.createProgram();return e.attachShader(o,t),e.attachShader(o,n),e.linkProgram(o),o}compileShader(t,n){let e=this.gl,o=e.createShader(n);if(!o)throw new Error(`createShader() returned null with type ${n}`);if(e.shaderSource(o,t),e.compileShader(o),e.getShaderParameter(o,e.COMPILE_STATUS)===!1)throw new Error(`Failed to compile shader: ${e.getShaderInfoLog(o)} +Shader source: +${t}`);return o}deleteShader(t){this.gl.deleteShader(t)}bindTextureToUniform(t,n,e){let o=this.gl;o.activeTexture(o.TEXTURE0+n),this.checkError(),o.bindTexture(o.TEXTURE_2D,t),this.checkError(),o.uniform1i(e,n),this.checkError()}draw(){this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4),this.checkError()}checkError(){if(K.debug){let t=this.gl,n=t.getError(),e="";switch(n){case t.NO_ERROR:return;case t.INVALID_ENUM:e="INVALID_ENUM";break;case t.INVALID_VALUE:e="INVALID_VALUE";break;case t.INVALID_OPERATION:e="INVALID_OPERATION";break;case t.INVALID_FRAMEBUFFER_OPERATION:e="INVALID_FRAMEBUFFER_OPERATION";break;case t.OUT_OF_MEMORY:e="OUT_OF_MEMORY";break;case t.CONTEXT_LOST_WEBGL:e="CONTEXT_LOST_WEBGL";break;default:e=`Unknown WebGL Error: ${n.toString(16)}`}throw new Error(e)}}deleteTexture(t){this.gl.deleteTexture(t)}deleteProgram(t){this.gl.deleteProgram(t)}getEncoder(t,n,e=0){if(this.version===2)return new Qn(this.gl,n);switch(t){case"float":return e===1||this.isRenderFloat32Supported?new dn(this.gl,n):new dn(this.gl,n,this.textureHalfFloatExtension.HALF_FLOAT_OES);case"int":throw new Error("not implemented");case"byte":return new tr(this.gl,n);default:throw new Error(`Invalid dataType: ${t}`)}}clearActiveTextures(){let t=this.gl;for(let n=0;nthis.isTimerResultAvailable(t)),this.getTimerResult(t)}async createAndWaitForFence(){let t=this.createFence(this.gl);return this.pollFence(t)}createFence(t){let n,e=t,o=e.fenceSync(e.SYNC_GPU_COMMANDS_COMPLETE,0);return t.flush(),o===null?n=()=>!0:n=()=>{let i=e.clientWaitSync(o,0,0);return i===e.ALREADY_SIGNALED||i===e.CONDITION_SATISFIED},{query:o,isFencePassed:n}}async pollFence(t){return new Promise(n=>{this.addItemToPoll(()=>t.isFencePassed(),()=>n())})}pollItems(){let t=sT(this.itemsToPoll.map(n=>n.isDoneFn));for(let n=0;n<=t;++n){let{resolveFn:e}=this.itemsToPoll[n];e()}this.itemsToPoll=this.itemsToPoll.slice(t+1)}async addItemToPoll(t,n){this.itemsToPoll.push({isDoneFn:t,resolveFn:n}),!(this.itemsToPoll.length>1)&&await _i(()=>(this.pollItems(),this.itemsToPoll.length===0))}}});function Zi(r){let t;if((!r||r==="webgl2")&&"webgl2"in Ye?t=Ye.webgl2:(!r||r==="webgl")&&"webgl"in Ye&&(t=Ye.webgl),!t)try{let e=lT();t=Yf(e,r)}catch{let o=uT();t=Yf(o,r)}r=r||t.version===1?"webgl":"webgl2";let n=t.gl;return Ye[r]=t,n.isContextLost()?(delete Ye[r],Zi(r)):(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),t)}function Yf(r,t){let n={alpha:!1,depth:!1,antialias:!1,stencil:!1,preserveDrawingBuffer:!1,premultipliedAlpha:!1,failIfMajorPerformanceCaveat:!1},e,o=n;if((!t||t==="webgl2")&&(e=r.getContext("webgl2",o),e))try{return new yn(e,2)}catch(i){B.warning("GlContextFactory",`failed to create WebGLContext using contextId 'webgl2'. Error: ${i}`)}if((!t||t==="webgl")&&(e=r.getContext("webgl",o)||r.getContext("experimental-webgl",o),e))try{return new yn(e,1)}catch(i){B.warning("GlContextFactory",`failed to create WebGLContext using contextId 'webgl' or 'experimental-webgl'. Error: ${i}`)}throw new Error("WebGL is not supported")}function uT(){if(typeof document>"u")throw new TypeError("failed to create canvas: document is not supported");let r=document.createElement("canvas");return r.width=1,r.height=1,r}function lT(){if(typeof OffscreenCanvas>"u")throw new TypeError("failed to create offscreen canvas: OffscreenCanvas is not supported");return new OffscreenCanvas(1,1)}var Ye,Qf=y(()=>{"use strict";dt();Jf();Ye={}});var vr,td=y(()=>{"use strict";me();dt();Zf();Qf();vr=class{get contextId(){return K.webgl.contextId}set contextId(t){K.webgl.contextId=t}get matmulMaxBatchSize(){return K.webgl.matmulMaxBatchSize}set matmulMaxBatchSize(t){K.webgl.matmulMaxBatchSize=t}get textureCacheMode(){return K.webgl.textureCacheMode}set textureCacheMode(t){K.webgl.textureCacheMode=t}get pack(){return K.webgl.pack}set pack(t){K.webgl.pack=t}get async(){return K.webgl.async}set async(t){K.webgl.async=t}initialize(){try{return this.glContext=Zi(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),B.setWithEnv(K),K.webgl.context||Object.defineProperty(K.webgl,"context",{value:this.glContext.gl}),B.verbose("WebGLBackend",`Created WebGLContext: ${typeof this.glContext} with matmulMaxBatchSize: ${this.matmulMaxBatchSize}; textureCacheMode: ${this.textureCacheMode}; pack: ${this.pack}; async: ${this.async}.`),!0}catch(t){return B.warning("WebGLBackend",`Unable to initialize WebGLBackend. ${t}`),!1}}createSessionHandler(t){return new xr(this,t)}dispose(){this.glContext.dispose()}}});async function Ji(r){if(r){let t=typeof r=="string"?[r]:r;for(let n of t){let e=ed.get(n);if(e)return e;let o=await fT(n);if(o)return o}}else return Ji(["webgl"]);throw new Error("no available backend to use")}async function fT(r){let t=cT;if(typeof t[r]<"u"&&dT(t[r])){let n=t[r],e=n.initialize();if(typeof e=="object"&&"then"in e&&(e=await e),e)return ed.set(r,n),n}}function dT(r){let t=r;return"initialize"in t&&typeof t.initialize=="function"&&"createSessionHandler"in t&&typeof t.createSessionHandler=="function"&&"dispose"in t&&typeof t.dispose=="function"}var ed,cT,nd=y(()=>{"use strict";td();ed=new Map,cT={webgl:new vr}});var Yi,wr,rd=y(()=>{"use strict";dt();Yi=class{constructor(t,n){this.op=t;this.node=n}},wr=class{constructor(t,n,e){this.graph=t;this.profiler=e;this.initialize(n)}initialize(t){this.profiler.event("session","ExecutionPlan.initialize",()=>{let n=this.graph.getNodes();if(n.length!==t.length)throw new Error("The size of nodes and OPs do not match.");this._ops=t.map((e,o)=>new Yi(e,n[o])),this.reset(),this._starter=[],this._ops.forEach((e,o)=>{let i=!0;for(let a of e.node.inputs)if(!this._values[a]&&this.graph.getInputIndices().indexOf(a)===-1){i=!1;break}i&&this._starter.push(o)})})}reset(){this._values=this.graph.getValues().map(t=>t.tensor)}async execute(t,n){return this.profiler.event("session","ExecutionPlan.execute",async()=>{this.reset();let e=t.createInferenceHandler(),o=this.graph.getInputIndices();if(n.length!==o.length)throw new Error(`number of input tensors don't match the number of inputs to the model: actual: ${n.length} expected: ${o.length}`);n.forEach((c,d)=>{let p=o[d];this._values[p]=c});let i=this._starter.slice(0),a=this.graph.getValues(),s=this.graph.getNodes(),u=0;for(;uthis._values[w]);if(p.indexOf(void 0)!==-1)throw new Error(`unresolved input detected: op: ${d.node}`);let m=p;B.verbose("ExecPlan",`Running op:${d.node.name} (${m.map((w,x)=>`'${d.node.inputs[x]}': ${w.type}[${w.dims.join(",")}]`).join(", ")})`);let g=await this.profiler.event("node",d.node.name,async()=>d.op.impl(e,m,d.op.context));if(g.length!==d.node.outputs.length)throw new Error("the size of output does not match model definition.");g.forEach((w,x)=>{let A=d.node.outputs[x];if(this._values[A])throw new Error(`output [${A}] already has value: op:${d.node.name}`);this._values[A]=w});let b=new Set;g.forEach((w,x)=>{let A=d.node.outputs[x];for(let D of a[A].to){let q=s[D],F=!0;for(let xt of q.inputs)if(!this._values[xt]){F=!1;break}F&&b.add(D)}}),i.push(...b)}let l=[];for(let c=0;c{"use strict";an();N=E(je());Ce();V();Tn=class r{constructor(t){if(this._attributes=new Map,t!=null){for(let n of t)n instanceof N.onnx.AttributeProto?this._attributes.set(n.name,[r.getValue(n),r.getType(n)]):n instanceof Wn.Attribute&&this._attributes.set(n.name(),[r.getValue(n),r.getType(n)]);if(this._attributes.sizeY.fromProto(i));if(t instanceof Wn.Attribute)return e.map(i=>Y.fromOrtTensor(i))}return n===N.onnx.AttributeProto.AttributeType.STRING&&t instanceof N.onnx.AttributeProto?fn(e):n===N.onnx.AttributeProto.AttributeType.STRINGS&&t instanceof N.onnx.AttributeProto?e.map(fn):e}static getValueNoCheck(t){return t instanceof N.onnx.AttributeProto?this.getValueNoCheckFromOnnxFormat(t):this.getValueNoCheckFromOrtFormat(t)}static getValueNoCheckFromOnnxFormat(t){switch(t.type){case N.onnx.AttributeProto.AttributeType.FLOAT:return t.f;case N.onnx.AttributeProto.AttributeType.INT:return t.i;case N.onnx.AttributeProto.AttributeType.STRING:return t.s;case N.onnx.AttributeProto.AttributeType.TENSOR:return t.t;case N.onnx.AttributeProto.AttributeType.GRAPH:return t.g;case N.onnx.AttributeProto.AttributeType.FLOATS:return t.floats;case N.onnx.AttributeProto.AttributeType.INTS:return t.ints;case N.onnx.AttributeProto.AttributeType.STRINGS:return t.strings;case N.onnx.AttributeProto.AttributeType.TENSORS:return t.tensors;case N.onnx.AttributeProto.AttributeType.GRAPHS:return t.graphs;default:throw new Error(`unsupported attribute type: ${N.onnx.AttributeProto.AttributeType[t.type]}`)}}static getValueNoCheckFromOrtFormat(t){switch(t.type()){case bt.AttributeType.FLOAT:return t.f();case bt.AttributeType.INT:return t.i();case bt.AttributeType.STRING:return t.s();case bt.AttributeType.TENSOR:return t.t();case bt.AttributeType.GRAPH:return t.g();case bt.AttributeType.FLOATS:return t.floatsArray();case bt.AttributeType.INTS:{let n=[];for(let e=0;e{"use strict";od();an();ta=E(je());Ce();V();ea={from:(r,t)=>new Qi(r,t)},fe=class{constructor(t){this._from=void 0,this._to=[],this.tensor=void 0,this.type=void 0,t&&(this.type=nt.tensorValueTypeFromProto(t.type.tensorType))}get from(){return this._from}get to(){return this._to}},Ir=class{constructor(t,n){t instanceof ta.onnx.NodeProto?(this.name=t.name,this.opType=t.opType,this.attributes=new Tn(t.attribute)):t instanceof ni.Node&&(this.name=n??t.name(),this.opType=t.opType(),this.attributes=new Tn(nt.tensorAttributesFromORTFormat(t))),this.inputs=[],this.outputs=[],this.executeNode=!0}},Qi=class{constructor(t,n){if(!t)throw new TypeError("graph is empty");this.buildGraph(t),this.transformGraph(n),this.checkIsAcyclic()}getInputIndices(){return this._allInputIndices}getInputNames(){return this._allInputNames}getOutputIndices(){return this._allOutputIndices}getOutputNames(){return this._allOutputNames}getValues(){return this._allData}getNodes(){return this._nodes}buildGraph(t){if(t instanceof ta.onnx.GraphProto)this.buildGraphFromOnnxFormat(t);else if(t instanceof ti.Graph)this.buildGraphFromOrtFormat(t);else throw new TypeError("Graph type is not supported.")}buildGraphFromOnnxFormat(t){let n=new Map;this._allData=[],this._allInputIndices=[],this._allInputNames=[],this._allOutputIndices=[],this._allOutputNames=[],this._nodes=[];let e=new Map;if(!t.input)throw new Error("missing information in graph: input");let o=[];for(let i of t.input){if(n.has(i.name))throw new Error(`duplicated input name: ${i.name}`);let a=this._allData.push(new fe(i))-1;n.set(i.name,a),o.push(i.name)}if(!t.initializer)throw new Error("missing information in graph: initializer");for(let i of t.initializer){let a=n.get(i.name);if(a===void 0){let s=new fe;s.type={shape:{dims:nt.tensorDimsFromProto(i.dims)},tensorType:nt.tensorDataTypeFromProto(i.dataType)},a=this._allData.push(s)-1,n.set(i.name,a)}this._allData[a]._from=-1,this._allData[a].tensor=Y.fromProto(i)}for(let i=0;i"u"&&(l=this._allData.push(new fe)-1,n.set(u,l)),a.outputs.push(l),this._allData[l]._from!==void 0)throw new Error(`multiple nodes output to one data value: ${l}`);if(this._allData[l]._from=i,s.opType==="Constant"){if(!s.attribute||s.attribute.length!==1||!s.attribute[0].t)throw new Error("missing attributes or missing tensor value in attributes for this Constant operator");if(!s.output||s.output.length!==1)throw new Error("missing output or incorrect number of outputs for this Constant operator");a.outputs.pop(),a.executeNode=!1,this._allData[l]._from=-1,this._allData[l].tensor=Y.fromProto(s.attribute[0].t)}}}for(let i=0;i"u"){if(u===""&&(s.input.length===3||s.input.length===4)&&s.opType==="Resize")continue;throw new Error(`unrecognized input '${u}' for node: ${s.name}`)}a.inputs.push(l),this._allData[l]._to.push(i)}}return!0}buildGraphFromOrtFormat(t){let n=new Map;this._allData=[],this._allInputIndices=[],this._allInputNames=[],this._allOutputIndices=[],this._allOutputNames=[],this._nodes=[];let e=new Map,o=[];for(let i=0;i"u"&&(c=this._allData.push(new fe)-1,n.set(l,c)),a.outputs.push(c),this._allData[c]._from!==void 0)throw new Error(`multiple nodes output to one data value: ${c}`);if(this._allData[c]._from=i,s.opType()==="Constant"){if(s.attributesLength()!==1||!s.attributes(0).t())throw new Error("missing attributes or missing tensor value in attributes for this Constant operator");if(s.outputsLength()!==1)throw new Error("missing output or incorrect number of outputs for this Constant operator");a.outputs.pop(),a.executeNode=!1,this._allData[c]._from=-1,this._allData[c].tensor=Y.fromOrtTensor(s.attributes(0).t())}}}for(let i=0;i"u")throw new Error(`unrecognized input '${l}' for node: ${s.name()}`);a.inputs.push(c),this._allData[c]._to.push(i)}}}checkIsAcyclic(){let t=new Set;this._allInputIndices.forEach(o=>{this._allData[o]._to.forEach(a=>{t.add(a)})});let n=Array.from(t),e=new Array(this._nodes.length).fill("white");for(;n.length>0;){let o=n.pop();e[o]==="gray"?e[o]="black":(n.push(o),e[o]="gray",this._nodes[o].outputs.forEach(i=>{let a=this._allData[i];if(typeof a.tensor<"u")throw new Error("node outputs should not be initialized");if(a._from!==o)throw new Error("from property of the Value object doesn't match index of Node being processed");a._to.forEach(s=>{if(e[s]==="gray")throw new Error("model graph is cyclic");e[s]==="white"&&n.push(s)})}))}}transformGraph(t){this.removeAllIdentityNodes(),this.removeAllDropoutNodes(),this.fuseConvActivationNodes(),t&&t.transformGraph(this),this.finalizeGraph()}finalizeGraph(){let t=0,n=new Array(this._nodes.length,0),e=0;for(let o=0;o{this._allData[i]._from=-2});this._nodes.splice(e,this._nodes.length-e);for(let o=0;o=0)i._to[a]=n[i._to[a]];else throw new Error("Trying to update a removed node")}t=0;for(let o=0;o0){let i=-1;this._allData[o].from!==void 0&&this._allData[o].from!==-1?(i=this._nodes[this._allData[o].from].outputs.indexOf(o+t),i!==-1&&(this._nodes[this._allData[o].from].outputs[i]=o)):(i=this._allInputIndices.indexOf(o+t),i!==-1&&(this._allInputIndices[i]=o)),this._allData[o].to.forEach(a=>{i=this._nodes[a].inputs.indexOf(o+t),i!==-1&&(this._nodes[a].inputs[i]=o)}),this._allData[o].to.length===0&&(i=this._allOutputIndices.indexOf(o+t),i!==-1&&(this._allOutputIndices[i]=o))}}}deleteNode(t){let n=this._nodes[t];if(n.outputs.length>1){for(let s=1;s0)throw new Error("Node deletion with more than one output connected to other nodes is not supported. ")}n.executeNode=!1;let e=n.inputs[0],o=n.outputs[0],i=this._allData[o].to;for(let s=0;s0)for(let s of i){let u=this._nodes[s].inputs.indexOf(o);if(u===-1)throw new Error("The Node object doesn't have the output Value in it's 'inputs' property ");this._nodes[s].inputs[u]=e,this._allData[e].to.push(s)}}removeAllDropoutNodes(){let t=0;for(let n of this._nodes){if(n.opType==="Dropout"){if(n.inputs.length!==1)throw new Error("Dropout nodes should only contain one input. ");if(n.outputs.length!==1&&n.outputs.length!==2)throw new Error("Dropout nodes should contain either 1 or 2 output(s)");if(n.outputs.length===2&&this._allData[n.outputs[1]]._to.length!==0)throw new Error("Dropout nodes's second output should not be referenced by other nodes");this.deleteNode(t)}t++}}removeAllIdentityNodes(){let t=0;for(let n of this._nodes)n.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 n=this._allData[t.outputs[0]]._to;if(n.length===1&&this.isActivation(this._nodes[n[0]])){let e=this._nodes[n[0]];if(e.opType==="Clip")if(e.inputs.length===1)try{t.attributes.set("activation_params","floats",[e.attributes.getFloat("min"),e.attributes.getFloat("max")])}catch{t.attributes.set("activation_params","floats",[Ne,Fe])}else if(e.inputs.length>=3&&this._allData[e.inputs[1]].tensor!==void 0&&this._allData[e.inputs[2]].tensor!==void 0)t.attributes.set("activation_params","floats",[this._allData[e.inputs[1]].tensor.floatData[0],this._allData[e.inputs[2]].tensor.floatData[0]]);else continue;t.attributes.set("activation","string",e.opType),this.deleteNode(n[0])}}}}});var ad,sd,Or,ud=y(()=>{"use strict";ad=E(M());id();an();sd=E(je());V();Or=class{constructor(){}load(t,n,e){let o;if(!e)try{this.loadFromOnnxFormat(t,n);return}catch(i){if(e!==void 0)throw i;o=i}try{this.loadFromOrtFormat(t,n)}catch(i){throw e!==void 0?i:new Error(`Failed to load model as ONNX format: ${o} +as ORT format: ${i}`)}}loadFromOnnxFormat(t,n){let e=sd.onnx.ModelProto.decode(t);if(lt.longToNumber(e.irVersion)<3)throw new Error("only support ONNX model with IR_VERSION>=3");this._opsets=e.opsetImport.map(i=>({domain:i.domain,version:lt.longToNumber(i.version)})),this._graph=ea.from(e.graph,n)}loadFromOrtFormat(t,n){let e=new ad.ByteBuffer(t),o=ei.InferenceSession.getRootAsInferenceSession(e).model();if(lt.longToNumber(o.irVersion())<3)throw new Error("only support ONNX model with IR_VERSION>=3");this._opsets=[];for(let a=0;a{"use strict";nd();rd();dt();ud();Pr=class{constructor(t={}){this._initialized=!1,this.backendHint=t.backendHint,this.profiler=Ln.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,n,e){await this.profiler.event("session","Session.loadModel",async()=>{let o=await Ji(this.backendHint);if(this.sessionHandler=o.createSessionHandler(this.context),this._model=new Or,typeof t=="string"){let i=t.endsWith(".ort");{let s=await(await fetch(t)).arrayBuffer();this.initialize(new Uint8Array(s),i)}}else if(ArrayBuffer.isView(t))this.initialize(t);else{let i=new Uint8Array(t,n||0,e||t.byteLength);this.initialize(i)}})}initialize(t,n){if(this._initialized)throw new Error("already initialized");this.profiler.event("session","Session.initialize",()=>{let e=this.sessionHandler.transformGraph?this.sessionHandler:void 0;this._model.load(t,e,n),this.sessionHandler.onGraphInitialized&&this.sessionHandler.onGraphInitialized(this._model.graph),this.initializeOps(this._model.graph),this._executionPlan=new wr(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 n=this.normalizeAndValidateInputs(t),e=await this._executionPlan.execute(this.sessionHandler,n);return this.createOutput(e)})}normalizeAndValidateInputs(t){let n=this._model.graph.getInputNames();if(Array.isArray(t)){if(t.length!==n.length)throw new Error(`incorrect input array length: expected ${n.length} but got ${t.length}`)}else{if(t.size!==n.length)throw new Error(`incorrect input map size: expected ${n.length} but got ${t.size}`);let e=new Array(t.size),o=0;for(let i=0;i{"use strict";me();Ce();Sr=class{constructor(t){this.session=t;this.inputNames=this.session.inputNames,this.outputNames=this.session.outputNames}get inputMetadata(){throw new Error("Getting model metadata is not supported in webgl backend.")}get outputMetadata(){throw new Error("Getting model metadata is not supported in webgl backend.")}async dispose(){}async run(t,n,e){let o=new Map;for(let s in t)if(Object.hasOwnProperty.call(t,s)){let u=t[s];o.set(s,new Y(u.dims,u.type,void 0,void 0,u.data))}let i=await this.session.run(o),a={};return i.forEach((s,u)=>{a[u]=new de(s.type,s.data,s.dims)}),a}startProfiling(){this.session.startProfiling()}endProfiling(){this.session.endProfiling()}}});var fd={};ra(fd,{onnxjsBackend:()=>pT});var na,pT,dd=y(()=>{"use strict";ld();cd();na=class{async init(){}async createInferenceSessionHandler(t,n){let e=new Pr(n);return typeof t=="string"?await e.loadModel(t):await e.loadModel(t),new Sr(e)}},pT=new na});me();me();me();var Fa="1.23.0";var wS=Nr;{let r=(dd(),yd(fd)).onnxjsBackend;vn("webgl",r,-10)}Object.defineProperty(K.versions,"web",{value:Fa,enumerable:!0});export{_d as InferenceSession,Pa as TRACE,In as TRACE_FUNC_BEGIN,On as TRACE_FUNC_END,de as Tensor,wS as default,K as env,vn as registerBackend}; +/*! Bundled license information: + +long/index.js: + (** + * @license + * Copyright 2009 The Closure Library Authors + * Copyright 2020 Daniel Wirtz / The long.js Authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + *) +*/ +//# sourceMappingURL=ort.webgl.min.mjs.map