!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n=e();for(var r in n)("object"==typeof exports?exports:t)[r]=n[r]}}(window,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=26)}([function(t,e,n){"use strict";var r=this&&this.__read||function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a},o=this&&this.__values||function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.PoolConvUtil=e.ReduceUtil=e.SplitUtil=e.MathUtil=e.ShapeUtil=e.LongUtil=e.ProtoUtil=e.GemmUtil=e.arrayCopyHelper=e.BroadcastUtil=e.MatMulUtil=e.checkInputsShape=void 0;var a=i(n(13)),u=n(9),s=n(1);e.checkInputsShape=function(t){for(var e=[],n=1;n1&&h>1)return;s[u-f]=Math.max(p,h)}return s},t.index=function(e,n){var r=new Array(n.length);return t.fillIndex(e,n,r),r},t.fillIndex=function(t,e,n){for(var r=t.length-e.length,o=0;o=0;_--)c[_]=v%a[_],v=Math.floor(v/a[_]);g||(t.fillIndex(c,e.dims,f),h=e.get(f)),m||(t.fillIndex(c,n.dims,p),y=n.get(p)),l.set(c,r(h,y))}}return l}},t.isValidBroadcast=function(t,e){var n=t.length,r=e.length;if(n>r)return!1;for(var o=1;o<=n;o++)if(1!==t[n-o]&&t[n-o]!==e[r-o])return!1;return!0},t}();e.BroadcastUtil=c,e.arrayCopyHelper=function(t,e,n,r,o){if(r<0||r>=e.length)throw new Error("sourceIndex out of bounds");if(n<0||n>=t.length)throw new Error("targetIndex out of bounds");if(r+o>e.length)throw new Error("source indices to be copied are outside bounds");if(n+o>t.length)throw new Error("target array is too small to hold result");for(var i=0;ie.length)throw new Error("invalid dimension of "+n+" for sizeFromDimension as Tensor has "+e.length+" dimensions.");return t.getSizeFromDimensionRange(e,n,e.length)},t.sizeToDimension=function(e,n){if(n<0||n>e.length)throw new Error("invalid dimension of "+n+" for sizeToDimension as Tensor has "+e.length+" dimensions.");return t.getSizeFromDimensionRange(e,0,n)},t.getSizeFromDimensionRange=function(t,e,n){for(var r=1,o=e;o=0;--r)n[r]=n[r+1]*t[r+1];return n},t.transpose=function(t){return t.slice().reverse()},t.indicesToOffset=function(t,e,n){void 0===n&&(n=t.length);for(var r=0,o=0;o=e)throw new Error("unsupported axis for this operation.");return t<0?t+e:t},t.normalizeAxes=function(t,e){var n=this;return t.map((function(t){return n.normalizeAxis(t,e)}))},t.incrementIndex=function(t,e,n){if(0===e.length||0===t.length)throw new Error("Index incrementing unsupported for scalar Tensor");if(void 0===n)n=e.length;else if(n<=0||n>e.length)throw new Error("Incorrect axis to increment on");for(var r=n-1;r>=0&&(t[r]++,!(t[r]=e.length)throw new Error("the dimension with value zero exceeds the dimension size of the input tensor");o[u]=e[u]}else o[u]=n[u];a*=o[u]}}var s=t.size(e);if(-1!==i){if(s%a!=0)throw new Error("the input tensor cannot be reshaped to the requested shape. Input shape: ["+e+"] Output shape: ["+n+"]");o[i]=s/a}else if(a!==s)throw new Error("reshapedDims and originalDims don't have matching sizes");return o},t.sortBasedOnPerm=function(t,e){return e?e.map((function(e){return t[e]})):t.slice().reverse()},t.padShape=function(t,e){var n=t.length;return t.map((function(t,r){return t+e[r]+e[r+n]}))},t.areEqual=function(t,e){return t.length===e.length&&t.every((function(t,n){return t===e[n]}))},t.validateDimsAndCalcSize=function(t){var e,n;if(t.length>6)throw new TypeError("Only rank 0 to 6 is supported for tensor shape.");var r=1;try{for(var i=o(t),a=i.next();!a.done;a=i.next()){var u=a.value;if(!Number.isInteger(u))throw new TypeError("Invalid shape: "+u+" is not an integer");if(u<0||u>2147483647)throw new TypeError("Invalid shape: length "+u+" is not allowed");r*=u}}catch(t){e={error:t}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}return r},t.flattenShape=function(t,e){e<0&&(e+=t.length);var n=t.reduce((function(t,e){return t*e}),1),r=t.slice(e).reduce((function(t,e){return t*e}),1);return[n/r,r]},t.squeezeShape=function(e,n){var r=new Array;n=t.normalizeAxes(n,e.length);for(var o=0;o=0;if(i&&1!==e[o])throw new Error("squeeze an axis of size different than 1");(0===n.length&&e[o]>1||n.length>0&&!i)&&r.push(e[o])}return r},t.unsqueezeShape=function(e,n){var r=new Array(e.length+n.length);r.fill(0);for(var o=0;o=r.length)throw new Error("'axes' has an out of range axis");if(0!==r[i])throw new Error("'axes' has a duplicate axis");r[i]=1}var a=0;for(o=0;o=e.length)throw new Error("sourceIndex out of bounds");if(n<0||n>=t.length)throw new Error("targetIndex out of bounds");if(r+o>e.length)throw new Error("source indices to be copied are outside bounds");if(n+o>t.length)throw new Error("target array is too small to hold result");for(var i=0;i=e.length)throw new Error("sourceIndex out of bounds");if(n<0||n>=t.length)throw new Error("targetIndex out of bounds");if(r+o>e.length)throw new Error("source indices to be copied are outside bounds");if(n+o>t.length)throw new Error("target array is too small to hold result");for(var a=0;a=e.length)throw new Error("sourceIndex out of bounds");if(n<0||n>=t.length)throw new Error("targetIndex out of bounds");if(r+o>e.length)throw new Error("source indices to be copied are outside bounds");if(n+o>t.length)throw new Error("target array is too small to hold result");for(var a=0;a=e.length)throw new Error("sourceIndex out of bounds");if(n<0||n>=t.length)throw new Error("targetIndex out of bounds");if(r+o>e.length)throw new Error("source indices to be copied are outside bounds");if(n+o>t.length)throw new Error("target array is too small to hold result");for(var i=0;i=n.length)return a(e[i]);for(var l=n[o],c=l>=r.length?1:d.size(r.slice(l+1)),f=0;f=n.length?n.push(e[i+2]):n[i]=e[i+2];for(i=0;i=n[i]||o[i+n.length]>=n[i])throw new Error("pads should be smaller than kernel")}},t.adjustPadsBasedOnAutoPad=function(e,n,r,o,i,a){if(a){if(i.length!==2*(e.length-2))throw new Error("length of pads should be twice the length of data dimensions");if(n.length!==e.length-2)throw new Error("length of strides should be the length of data dimensions");if(o.length!==e.length-2)throw new Error("length of kernel shapes should be the length of data dimensions");for(var u=0;u0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]0){var i=o.data,l=new DataView(n.rawData.buffer,n.rawData.byteOffset,n.rawData.byteLength),c=function(t){switch(t){case u.onnx.TensorProto.DataType.UINT8:case u.onnx.TensorProto.DataType.INT8:case u.onnx.TensorProto.DataType.BOOL:return 1;case u.onnx.TensorProto.DataType.UINT16:case u.onnx.TensorProto.DataType.INT16:return 2;case u.onnx.TensorProto.DataType.FLOAT:case u.onnx.TensorProto.DataType.INT32:case u.onnx.TensorProto.DataType.UINT32:return 4;case u.onnx.TensorProto.DataType.INT64:case u.onnx.TensorProto.DataType.DOUBLE:case u.onnx.TensorProto.DataType.UINT64:return 8;default:throw new Error("cannot calculate sizeof() on type "+u.onnx.TensorProto.DataType[t])}}(n.dataType),h=n.rawData.byteLength/c;if(n.rawData.byteLength%c!=0)throw new Error("invalid buffer length");if(i.length!==h)throw new Error("buffer length mismatch");for(var d=0;d=this._flushBatchSize||t-this._flushTime>=this._flushIntervalInMilliseconds){for(var n=this._flushPointer;this._flushPointer0?(f.Logger.verbose("WebAssembly-Workers","User has requested "+t+" Workers."),!function(){if("undefined"!=typeof window&&void 0!==window.Worker)return!0;return!1}()?(f.Logger.error("WebAssembly-Workers","Environment does not support usage of Workers. Will not spawn workers."),l=0):(f.Logger.verbose("WebAssembly-Workers","Environment supports usage of Workers. Will spawn "+t+" Workers"),l=t)):(f.Logger.verbose("WebAssembly-Workers","User has disabled usage of Workers. Will not spawn workers."),l=0);var m=new Array(l);s=new Array(l),c=new Array(l);for(var v=function(t){var e=new Promise((function(e,r){var o=n(105).default();s[t]=o,c[t]=[],o.onerror=function(e){f.Logger.error("WebAssembly-Workers","worker-"+t+" ERR: "+e),h||r()},o.onmessage=function(n){if(!(n&&n.data&&n.data.type))throw new Error("missing message type from worker");if("init-success"===n.data.type)e();else{if("ccall"!==n.data.type)throw new Error("unknown message type from worker: "+n.data.type);var r=n.data.perfData;c[t].shift()(n.data.buffer,r)}}}));m[t]=e},b=0;b=l)throw new Error("invalid worker ID "+t+". should be in range [0, "+l+")");var i=[],a=e.calculateOffsets(i,r),u=new ArrayBuffer(a);e.ccallSerialize(new Uint8Array(u),i,r);var f=p.now();return s[t].postMessage({type:"ccall",func:n,buffer:u},[u]),new Promise((function(n,o){c[t].push((function(t,o){o.startTimeWorker=o.startTime,o.endTimeWorker=o.endTime,o.startTime=f,o.endTime=p.now(),e.ccallDeserialize(new Uint8Array(t),i,r),n(o)}))}))},e}(p.WasmBinding);e.WasmBinding=y},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.TopologicalSortGlslRoutines=e.GlslLibRoutineNode=e.GlslLibRoutine=e.GlslLib=e.GlslContext=e.FunctionType=void 0,function(t){t[t.ValueBased=0]="ValueBased",t[t.Positional=1]="Positional"}(e.FunctionType||(e.FunctionType={}));var r=function(t,e){this.glContext=t,this.programInfo=e};e.GlslContext=r;var o=function(t){this.context=t};e.GlslLib=o;var i=function(t,e){this.routineBody=t,this.dependencies=e};e.GlslLibRoutine=i;var a=function(){function t(t,e,n){this.name=t,this.dependencies=n||[],e&&(this.routineBody=e)}return t.prototype.addDependency=function(t){t&&this.dependencies.push(t)},t}();e.GlslLibRoutineNode=a;var u=function(){function t(){}return t.returnOrderedNodes=function(t){if(!t||0===t.length)return[];if(1===t.length)return t;var e=new Set,n=new Set,r=new Array;return this.createOrderedNodes(t,e,n,r),r},t.createOrderedNodes=function(t,e,n,r){for(var o=0;o0)for(var i=0;i0)},r.Buffer=function(){try{var t=r.inquire("buffer").Buffer;return t.prototype.utf8Write?t:null}catch(t){return null}}(),r._Buffer_from=null,r._Buffer_allocUnsafe=null,r.newBuffer=function(t){return"number"==typeof t?r.Buffer?r._Buffer_allocUnsafe(t):new r.Array(t):r.Buffer?r._Buffer_from(t):"undefined"==typeof Uint8Array?t:new Uint8Array(t)},r.Array="undefined"!=typeof Uint8Array?Uint8Array:Array,r.Long=r.global.dcodeIO&&r.global.dcodeIO.Long||r.global.Long||r.inquire("long"),r.key2Re=/^true|false|0|1$/,r.key32Re=/^-?(?:0|[1-9][0-9]*)$/,r.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,r.longToHash=function(t){return t?r.LongBits.from(t).toHash():r.LongBits.zeroHash},r.longFromHash=function(t,e){var n=r.LongBits.fromHash(t);return r.Long?r.Long.fromBits(n.lo,n.hi,e):n.toNumber(Boolean(e))},r.merge=o,r.lcFirst=function(t){return t.charAt(0).toLowerCase()+t.substring(1)},r.newError=i,r.ProtocolError=i("ProtocolError"),r.oneOfGetter=function(t){for(var e={},n=0;n-1;--n)if(1===e[t[n]]&&void 0!==this[t[n]]&&null!==this[t[n]])return t[n]}},r.oneOfSetter=function(t){return function(e){for(var n=0;n>>3){case 1:r.name=t.string();break;case 21:r.refAttrName=t.string();break;case 13:r.docString=t.string();break;case 20:r.type=t.int32();break;case 2:r.f=t.float();break;case 3:r.i=t.int64();break;case 4:r.s=t.bytes();break;case 5:r.t=u.onnx.TensorProto.decode(t,t.uint32());break;case 6:r.g=u.onnx.GraphProto.decode(t,t.uint32());break;case 7:if(r.floats&&r.floats.length||(r.floats=[]),2==(7&i))for(var a=t.uint32()+t.pos;t.pos>>0,t.i.high>>>0).toNumber())),null!=t.s&&("string"==typeof t.s?a.base64.decode(t.s,e.s=a.newBuffer(a.base64.length(t.s)),0):t.s.length&&(e.s=t.s)),null!=t.t){if("object"!=typeof t.t)throw TypeError(".onnx.AttributeProto.t: object expected");e.t=u.onnx.TensorProto.fromObject(t.t)}if(null!=t.g){if("object"!=typeof t.g)throw TypeError(".onnx.AttributeProto.g: object expected");e.g=u.onnx.GraphProto.fromObject(t.g)}if(t.floats){if(!Array.isArray(t.floats))throw TypeError(".onnx.AttributeProto.floats: array expected");e.floats=[];for(var n=0;n>>0,t.ints[n].high>>>0).toNumber())}if(t.strings){if(!Array.isArray(t.strings))throw TypeError(".onnx.AttributeProto.strings: array expected");e.strings=[];for(n=0;n>>0,t.i.high>>>0).toNumber():t.i),null!=t.s&&t.hasOwnProperty("s")&&(n.s=e.bytes===String?a.base64.encode(t.s,0,t.s.length):e.bytes===Array?Array.prototype.slice.call(t.s):t.s),null!=t.t&&t.hasOwnProperty("t")&&(n.t=u.onnx.TensorProto.toObject(t.t,e)),null!=t.g&&t.hasOwnProperty("g")&&(n.g=u.onnx.GraphProto.toObject(t.g,e)),t.floats&&t.floats.length){n.floats=[];for(var o=0;o>>0,t.ints[o].high>>>0).toNumber():t.ints[o]}if(t.strings&&t.strings.length){n.strings=[];for(o=0;o>>3){case 1:r.name=t.string();break;case 2:r.type=u.onnx.TypeProto.decode(t,t.uint32());break;case 3:r.docString=t.string();break;default:t.skipType(7&i)}}return r},t.decodeDelimited=function(t){return t instanceof o||(t=new o(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.name&&t.hasOwnProperty("name")&&!a.isString(t.name))return"name: string expected";if(null!=t.type&&t.hasOwnProperty("type")){var e=u.onnx.TypeProto.verify(t.type);if(e)return"type."+e}return null!=t.docString&&t.hasOwnProperty("docString")&&!a.isString(t.docString)?"docString: string expected":null},t.fromObject=function(t){if(t instanceof u.onnx.ValueInfoProto)return t;var e=new u.onnx.ValueInfoProto;if(null!=t.name&&(e.name=String(t.name)),null!=t.type){if("object"!=typeof t.type)throw TypeError(".onnx.ValueInfoProto.type: object expected");e.type=u.onnx.TypeProto.fromObject(t.type)}return null!=t.docString&&(e.docString=String(t.docString)),e},t.toObject=function(t,e){e||(e={});var n={};return e.defaults&&(n.name="",n.type=null,n.docString=""),null!=t.name&&t.hasOwnProperty("name")&&(n.name=t.name),null!=t.type&&t.hasOwnProperty("type")&&(n.type=u.onnx.TypeProto.toObject(t.type,e)),null!=t.docString&&t.hasOwnProperty("docString")&&(n.docString=t.docString),n},t.prototype.toJSON=function(){return this.constructor.toObject(this,r.util.toJSONOptions)},t}(),n.NodeProto=function(){function t(t){if(this.input=[],this.output=[],this.attribute=[],t)for(var e=Object.keys(t),n=0;n>>3){case 1:r.input&&r.input.length||(r.input=[]),r.input.push(t.string());break;case 2:r.output&&r.output.length||(r.output=[]),r.output.push(t.string());break;case 3:r.name=t.string();break;case 4:r.opType=t.string();break;case 7:r.domain=t.string();break;case 5:r.attribute&&r.attribute.length||(r.attribute=[]),r.attribute.push(u.onnx.AttributeProto.decode(t,t.uint32()));break;case 6:r.docString=t.string();break;default:t.skipType(7&i)}}return r},t.decodeDelimited=function(t){return t instanceof o||(t=new o(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.input&&t.hasOwnProperty("input")){if(!Array.isArray(t.input))return"input: array expected";for(var e=0;e>>3){case 1:r.irVersion=t.int64();break;case 8:r.opsetImport&&r.opsetImport.length||(r.opsetImport=[]),r.opsetImport.push(u.onnx.OperatorSetIdProto.decode(t,t.uint32()));break;case 2:r.producerName=t.string();break;case 3:r.producerVersion=t.string();break;case 4:r.domain=t.string();break;case 5:r.modelVersion=t.int64();break;case 6:r.docString=t.string();break;case 7:r.graph=u.onnx.GraphProto.decode(t,t.uint32());break;case 14:r.metadataProps&&r.metadataProps.length||(r.metadataProps=[]),r.metadataProps.push(u.onnx.StringStringEntryProto.decode(t,t.uint32()));break;default:t.skipType(7&i)}}return r},t.decodeDelimited=function(t){return t instanceof o||(t=new o(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.irVersion&&t.hasOwnProperty("irVersion")&&!(a.isInteger(t.irVersion)||t.irVersion&&a.isInteger(t.irVersion.low)&&a.isInteger(t.irVersion.high)))return"irVersion: integer|Long expected";if(null!=t.opsetImport&&t.hasOwnProperty("opsetImport")){if(!Array.isArray(t.opsetImport))return"opsetImport: array expected";for(var e=0;e>>0,t.irVersion.high>>>0).toNumber())),t.opsetImport){if(!Array.isArray(t.opsetImport))throw TypeError(".onnx.ModelProto.opsetImport: array expected");e.opsetImport=[];for(var n=0;n>>0,t.modelVersion.high>>>0).toNumber())),null!=t.docString&&(e.docString=String(t.docString)),null!=t.graph){if("object"!=typeof t.graph)throw TypeError(".onnx.ModelProto.graph: object expected");e.graph=u.onnx.GraphProto.fromObject(t.graph)}if(t.metadataProps){if(!Array.isArray(t.metadataProps))throw TypeError(".onnx.ModelProto.metadataProps: array expected");e.metadataProps=[];for(n=0;n>>0,t.irVersion.high>>>0).toNumber():t.irVersion),null!=t.producerName&&t.hasOwnProperty("producerName")&&(n.producerName=t.producerName),null!=t.producerVersion&&t.hasOwnProperty("producerVersion")&&(n.producerVersion=t.producerVersion),null!=t.domain&&t.hasOwnProperty("domain")&&(n.domain=t.domain),null!=t.modelVersion&&t.hasOwnProperty("modelVersion")&&("number"==typeof t.modelVersion?n.modelVersion=e.longs===String?String(t.modelVersion):t.modelVersion:n.modelVersion=e.longs===String?a.Long.prototype.toString.call(t.modelVersion):e.longs===Number?new a.LongBits(t.modelVersion.low>>>0,t.modelVersion.high>>>0).toNumber():t.modelVersion),null!=t.docString&&t.hasOwnProperty("docString")&&(n.docString=t.docString),null!=t.graph&&t.hasOwnProperty("graph")&&(n.graph=u.onnx.GraphProto.toObject(t.graph,e)),t.opsetImport&&t.opsetImport.length){n.opsetImport=[];for(var o=0;o>>3){case 1:r.key=t.string();break;case 2:r.value=t.string();break;default:t.skipType(7&i)}}return r},t.decodeDelimited=function(t){return t instanceof o||(t=new o(t)),this.decode(t,t.uint32())},t.verify=function(t){return"object"!=typeof t||null===t?"object expected":null!=t.key&&t.hasOwnProperty("key")&&!a.isString(t.key)?"key: string expected":null!=t.value&&t.hasOwnProperty("value")&&!a.isString(t.value)?"value: string expected":null},t.fromObject=function(t){if(t instanceof u.onnx.StringStringEntryProto)return t;var e=new u.onnx.StringStringEntryProto;return null!=t.key&&(e.key=String(t.key)),null!=t.value&&(e.value=String(t.value)),e},t.toObject=function(t,e){e||(e={});var n={};return e.defaults&&(n.key="",n.value=""),null!=t.key&&t.hasOwnProperty("key")&&(n.key=t.key),null!=t.value&&t.hasOwnProperty("value")&&(n.value=t.value),n},t.prototype.toJSON=function(){return this.constructor.toObject(this,r.util.toJSONOptions)},t}(),n.TensorAnnotation=function(){function t(t){if(this.quantParameterTensorNames=[],t)for(var e=Object.keys(t),n=0;n>>3){case 1:r.tensorName=t.string();break;case 2:r.quantParameterTensorNames&&r.quantParameterTensorNames.length||(r.quantParameterTensorNames=[]),r.quantParameterTensorNames.push(u.onnx.StringStringEntryProto.decode(t,t.uint32()));break;default:t.skipType(7&i)}}return r},t.decodeDelimited=function(t){return t instanceof o||(t=new o(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.tensorName&&t.hasOwnProperty("tensorName")&&!a.isString(t.tensorName))return"tensorName: string expected";if(null!=t.quantParameterTensorNames&&t.hasOwnProperty("quantParameterTensorNames")){if(!Array.isArray(t.quantParameterTensorNames))return"quantParameterTensorNames: array expected";for(var e=0;e>>3){case 1:r.node&&r.node.length||(r.node=[]),r.node.push(u.onnx.NodeProto.decode(t,t.uint32()));break;case 2:r.name=t.string();break;case 5:r.initializer&&r.initializer.length||(r.initializer=[]),r.initializer.push(u.onnx.TensorProto.decode(t,t.uint32()));break;case 10:r.docString=t.string();break;case 11:r.input&&r.input.length||(r.input=[]),r.input.push(u.onnx.ValueInfoProto.decode(t,t.uint32()));break;case 12:r.output&&r.output.length||(r.output=[]),r.output.push(u.onnx.ValueInfoProto.decode(t,t.uint32()));break;case 13:r.valueInfo&&r.valueInfo.length||(r.valueInfo=[]),r.valueInfo.push(u.onnx.ValueInfoProto.decode(t,t.uint32()));break;case 14:r.quantizationAnnotation&&r.quantizationAnnotation.length||(r.quantizationAnnotation=[]),r.quantizationAnnotation.push(u.onnx.TensorAnnotation.decode(t,t.uint32()));break;default:t.skipType(7&i)}}return r},t.decodeDelimited=function(t){return t instanceof o||(t=new o(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.node&&t.hasOwnProperty("node")){if(!Array.isArray(t.node))return"node: array expected";for(var e=0;e>>3){case 1:if(r.dims&&r.dims.length||(r.dims=[]),2==(7&i))for(var a=t.uint32()+t.pos;t.pos>>0,t.dims[n].high>>>0).toNumber())}if(null!=t.dataType&&(e.dataType=0|t.dataType),null!=t.segment){if("object"!=typeof t.segment)throw TypeError(".onnx.TensorProto.segment: object expected");e.segment=u.onnx.TensorProto.Segment.fromObject(t.segment)}if(t.floatData){if(!Array.isArray(t.floatData))throw TypeError(".onnx.TensorProto.floatData: array expected");e.floatData=[];for(n=0;n>>0,t.int64Data[n].high>>>0).toNumber())}if(null!=t.name&&(e.name=String(t.name)),null!=t.docString&&(e.docString=String(t.docString)),null!=t.rawData&&("string"==typeof t.rawData?a.base64.decode(t.rawData,e.rawData=a.newBuffer(a.base64.length(t.rawData)),0):t.rawData.length&&(e.rawData=t.rawData)),t.externalData){if(!Array.isArray(t.externalData))throw TypeError(".onnx.TensorProto.externalData: array expected");e.externalData=[];for(n=0;n>>0,t.uint64Data[n].high>>>0).toNumber(!0))}return e},t.toObject=function(t,e){e||(e={});var n={};if((e.arrays||e.defaults)&&(n.dims=[],n.floatData=[],n.int32Data=[],n.stringData=[],n.int64Data=[],n.doubleData=[],n.uint64Data=[],n.externalData=[]),e.defaults&&(n.dataType=0,n.segment=null,n.name="",e.bytes===String?n.rawData="":(n.rawData=[],e.bytes!==Array&&(n.rawData=a.newBuffer(n.rawData))),n.docString="",n.dataLocation=e.enums===String?"DEFAULT":0),t.dims&&t.dims.length){n.dims=[];for(var r=0;r>>0,t.dims[r].high>>>0).toNumber():t.dims[r]}if(null!=t.dataType&&t.hasOwnProperty("dataType")&&(n.dataType=t.dataType),null!=t.segment&&t.hasOwnProperty("segment")&&(n.segment=u.onnx.TensorProto.Segment.toObject(t.segment,e)),t.floatData&&t.floatData.length){n.floatData=[];for(r=0;r>>0,t.int64Data[r].high>>>0).toNumber():t.int64Data[r]}if(null!=t.name&&t.hasOwnProperty("name")&&(n.name=t.name),null!=t.rawData&&t.hasOwnProperty("rawData")&&(n.rawData=e.bytes===String?a.base64.encode(t.rawData,0,t.rawData.length):e.bytes===Array?Array.prototype.slice.call(t.rawData):t.rawData),t.doubleData&&t.doubleData.length){n.doubleData=[];for(r=0;r>>0,t.uint64Data[r].high>>>0).toNumber(!0):t.uint64Data[r]}if(null!=t.docString&&t.hasOwnProperty("docString")&&(n.docString=t.docString),t.externalData&&t.externalData.length){n.externalData=[];for(r=0;r>>3){case 1:r.begin=t.int64();break;case 2:r.end=t.int64();break;default:t.skipType(7&i)}}return r},t.decodeDelimited=function(t){return t instanceof o||(t=new o(t)),this.decode(t,t.uint32())},t.verify=function(t){return"object"!=typeof t||null===t?"object expected":null!=t.begin&&t.hasOwnProperty("begin")&&!(a.isInteger(t.begin)||t.begin&&a.isInteger(t.begin.low)&&a.isInteger(t.begin.high))?"begin: integer|Long expected":null!=t.end&&t.hasOwnProperty("end")&&!(a.isInteger(t.end)||t.end&&a.isInteger(t.end.low)&&a.isInteger(t.end.high))?"end: integer|Long expected":null},t.fromObject=function(t){if(t instanceof u.onnx.TensorProto.Segment)return t;var e=new u.onnx.TensorProto.Segment;return null!=t.begin&&(a.Long?(e.begin=a.Long.fromValue(t.begin)).unsigned=!1:"string"==typeof t.begin?e.begin=parseInt(t.begin,10):"number"==typeof t.begin?e.begin=t.begin:"object"==typeof t.begin&&(e.begin=new a.LongBits(t.begin.low>>>0,t.begin.high>>>0).toNumber())),null!=t.end&&(a.Long?(e.end=a.Long.fromValue(t.end)).unsigned=!1:"string"==typeof t.end?e.end=parseInt(t.end,10):"number"==typeof t.end?e.end=t.end:"object"==typeof t.end&&(e.end=new a.LongBits(t.end.low>>>0,t.end.high>>>0).toNumber())),e},t.toObject=function(t,e){e||(e={});var n={};if(e.defaults){if(a.Long){var r=new a.Long(0,0,!1);n.begin=e.longs===String?r.toString():e.longs===Number?r.toNumber():r}else n.begin=e.longs===String?"0":0;if(a.Long){r=new a.Long(0,0,!1);n.end=e.longs===String?r.toString():e.longs===Number?r.toNumber():r}else n.end=e.longs===String?"0":0}return null!=t.begin&&t.hasOwnProperty("begin")&&("number"==typeof t.begin?n.begin=e.longs===String?String(t.begin):t.begin:n.begin=e.longs===String?a.Long.prototype.toString.call(t.begin):e.longs===Number?new a.LongBits(t.begin.low>>>0,t.begin.high>>>0).toNumber():t.begin),null!=t.end&&t.hasOwnProperty("end")&&("number"==typeof t.end?n.end=e.longs===String?String(t.end):t.end:n.end=e.longs===String?a.Long.prototype.toString.call(t.end):e.longs===Number?new a.LongBits(t.end.low>>>0,t.end.high>>>0).toNumber():t.end),n},t.prototype.toJSON=function(){return this.constructor.toObject(this,r.util.toJSONOptions)},t}(),t.DataLocation=function(){var t={},e=Object.create(t);return e[t[0]="DEFAULT"]=0,e[t[1]="EXTERNAL"]=1,e}(),t}(),n.TensorShapeProto=function(){function t(t){if(this.dim=[],t)for(var e=Object.keys(t),n=0;n>>3){case 1:r.dim&&r.dim.length||(r.dim=[]),r.dim.push(u.onnx.TensorShapeProto.Dimension.decode(t,t.uint32()));break;default:t.skipType(7&i)}}return r},t.decodeDelimited=function(t){return t instanceof o||(t=new o(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.dim&&t.hasOwnProperty("dim")){if(!Array.isArray(t.dim))return"dim: array expected";for(var e=0;e>>3){case 1:r.dimValue=t.int64();break;case 2:r.dimParam=t.string();break;case 3:r.denotation=t.string();break;default:t.skipType(7&i)}}return r},t.decodeDelimited=function(t){return t instanceof o||(t=new o(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";var e={};if(null!=t.dimValue&&t.hasOwnProperty("dimValue")&&(e.value=1,!(a.isInteger(t.dimValue)||t.dimValue&&a.isInteger(t.dimValue.low)&&a.isInteger(t.dimValue.high))))return"dimValue: integer|Long expected";if(null!=t.dimParam&&t.hasOwnProperty("dimParam")){if(1===e.value)return"value: multiple values";if(e.value=1,!a.isString(t.dimParam))return"dimParam: string expected"}return null!=t.denotation&&t.hasOwnProperty("denotation")&&!a.isString(t.denotation)?"denotation: string expected":null},t.fromObject=function(t){if(t instanceof u.onnx.TensorShapeProto.Dimension)return t;var e=new u.onnx.TensorShapeProto.Dimension;return null!=t.dimValue&&(a.Long?(e.dimValue=a.Long.fromValue(t.dimValue)).unsigned=!1:"string"==typeof t.dimValue?e.dimValue=parseInt(t.dimValue,10):"number"==typeof t.dimValue?e.dimValue=t.dimValue:"object"==typeof t.dimValue&&(e.dimValue=new a.LongBits(t.dimValue.low>>>0,t.dimValue.high>>>0).toNumber())),null!=t.dimParam&&(e.dimParam=String(t.dimParam)),null!=t.denotation&&(e.denotation=String(t.denotation)),e},t.toObject=function(t,e){e||(e={});var n={};return e.defaults&&(n.denotation=""),null!=t.dimValue&&t.hasOwnProperty("dimValue")&&("number"==typeof t.dimValue?n.dimValue=e.longs===String?String(t.dimValue):t.dimValue:n.dimValue=e.longs===String?a.Long.prototype.toString.call(t.dimValue):e.longs===Number?new a.LongBits(t.dimValue.low>>>0,t.dimValue.high>>>0).toNumber():t.dimValue,e.oneofs&&(n.value="dimValue")),null!=t.dimParam&&t.hasOwnProperty("dimParam")&&(n.dimParam=t.dimParam,e.oneofs&&(n.value="dimParam")),null!=t.denotation&&t.hasOwnProperty("denotation")&&(n.denotation=t.denotation),n},t.prototype.toJSON=function(){return this.constructor.toObject(this,r.util.toJSONOptions)},t}(),t}(),n.TypeProto=function(){function t(t){if(t)for(var e=Object.keys(t),n=0;n>>3){case 1:r.tensorType=u.onnx.TypeProto.Tensor.decode(t,t.uint32());break;case 6:r.denotation=t.string();break;default:t.skipType(7&i)}}return r},t.decodeDelimited=function(t){return t instanceof o||(t=new o(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.tensorType&&t.hasOwnProperty("tensorType")){var e=u.onnx.TypeProto.Tensor.verify(t.tensorType);if(e)return"tensorType."+e}return null!=t.denotation&&t.hasOwnProperty("denotation")&&!a.isString(t.denotation)?"denotation: string expected":null},t.fromObject=function(t){if(t instanceof u.onnx.TypeProto)return t;var e=new u.onnx.TypeProto;if(null!=t.tensorType){if("object"!=typeof t.tensorType)throw TypeError(".onnx.TypeProto.tensorType: object expected");e.tensorType=u.onnx.TypeProto.Tensor.fromObject(t.tensorType)}return null!=t.denotation&&(e.denotation=String(t.denotation)),e},t.toObject=function(t,e){e||(e={});var n={};return e.defaults&&(n.denotation=""),null!=t.tensorType&&t.hasOwnProperty("tensorType")&&(n.tensorType=u.onnx.TypeProto.Tensor.toObject(t.tensorType,e),e.oneofs&&(n.value="tensorType")),null!=t.denotation&&t.hasOwnProperty("denotation")&&(n.denotation=t.denotation),n},t.prototype.toJSON=function(){return this.constructor.toObject(this,r.util.toJSONOptions)},t.Tensor=function(){function t(t){if(t)for(var e=Object.keys(t),n=0;n>>3){case 1:r.elemType=t.int32();break;case 2:r.shape=u.onnx.TensorShapeProto.decode(t,t.uint32());break;default:t.skipType(7&i)}}return r},t.decodeDelimited=function(t){return t instanceof o||(t=new o(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.elemType&&t.hasOwnProperty("elemType")&&!a.isInteger(t.elemType))return"elemType: integer expected";if(null!=t.shape&&t.hasOwnProperty("shape")){var e=u.onnx.TensorShapeProto.verify(t.shape);if(e)return"shape."+e}return null},t.fromObject=function(t){if(t instanceof u.onnx.TypeProto.Tensor)return t;var e=new u.onnx.TypeProto.Tensor;if(null!=t.elemType&&(e.elemType=0|t.elemType),null!=t.shape){if("object"!=typeof t.shape)throw TypeError(".onnx.TypeProto.Tensor.shape: object expected");e.shape=u.onnx.TensorShapeProto.fromObject(t.shape)}return e},t.toObject=function(t,e){e||(e={});var n={};return e.defaults&&(n.elemType=0,n.shape=null),null!=t.elemType&&t.hasOwnProperty("elemType")&&(n.elemType=t.elemType),null!=t.shape&&t.hasOwnProperty("shape")&&(n.shape=u.onnx.TensorShapeProto.toObject(t.shape,e)),n},t.prototype.toJSON=function(){return this.constructor.toObject(this,r.util.toJSONOptions)},t}(),t}(),n.OperatorSetIdProto=function(){function t(t){if(t)for(var e=Object.keys(t),n=0;n>>3){case 1:r.domain=t.string();break;case 2:r.version=t.int64();break;default:t.skipType(7&i)}}return r},t.decodeDelimited=function(t){return t instanceof o||(t=new o(t)),this.decode(t,t.uint32())},t.verify=function(t){return"object"!=typeof t||null===t?"object expected":null!=t.domain&&t.hasOwnProperty("domain")&&!a.isString(t.domain)?"domain: string expected":null!=t.version&&t.hasOwnProperty("version")&&!(a.isInteger(t.version)||t.version&&a.isInteger(t.version.low)&&a.isInteger(t.version.high))?"version: integer|Long expected":null},t.fromObject=function(t){if(t instanceof u.onnx.OperatorSetIdProto)return t;var e=new u.onnx.OperatorSetIdProto;return null!=t.domain&&(e.domain=String(t.domain)),null!=t.version&&(a.Long?(e.version=a.Long.fromValue(t.version)).unsigned=!1:"string"==typeof t.version?e.version=parseInt(t.version,10):"number"==typeof t.version?e.version=t.version:"object"==typeof t.version&&(e.version=new a.LongBits(t.version.low>>>0,t.version.high>>>0).toNumber())),e},t.toObject=function(t,e){e||(e={});var n={};if(e.defaults)if(n.domain="",a.Long){var r=new a.Long(0,0,!1);n.version=e.longs===String?r.toString():e.longs===Number?r.toNumber():r}else n.version=e.longs===String?"0":0;return null!=t.domain&&t.hasOwnProperty("domain")&&(n.domain=t.domain),null!=t.version&&t.hasOwnProperty("version")&&("number"==typeof t.version?n.version=e.longs===String?String(t.version):t.version:n.version=e.longs===String?a.Long.prototype.toString.call(t.version):e.longs===Number?new a.LongBits(t.version.low>>>0,t.version.high>>>0).toNumber():t.version),n},t.prototype.toJSON=function(){return this.constructor.toObject(this,r.util.toJSONOptions)},t}(),n}(),t.exports=u},function(t,e,n){"use strict";var r,o=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0}),e.reshape=e.WebGLReshape=void 0;var i=n(37),a=n(0),u=n(50),s=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.run=function(t,e){var n=a.ShapeUtil.calculateReshapedDims(e[0].dims,e[1].integerData);return[l(t,e[0],n)]},e}(i.Reshape);function l(t,e,n){var r=t.getOrCreateTextureData(e),o=n;4===r.channels&&(o=u.getPackedShape(n));var i={channels:r.channels,height:r.height,width:r.width,shape:0!==o.length?o:[1],strides:a.ShapeUtil.computeStrides(o),unpackedShape:n};return t.createSharedTextureData(i,e.type,r.texture,e.dataId).tensor}e.WebGLReshape=s,e.reshape=l},function(t,e,n){"use strict";var r=this&&this.__values||function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};function o(t,e){if(e.endsWith("+")){var n=Number.parseInt(e.substring(0,e.length-1),10);return!isNaN(n)&&n<=t}if(2===e.split("-").length){var r=e.split("-"),o=(n=Number.parseInt(r[0],10),Number.parseInt(r[1],10));return!isNaN(n)&&!isNaN(o)&&n<=t&&t<=o}return Number.parseInt(e,10)===t}Object.defineProperty(e,"__esModule",{value:!0}),e.resolveOperator=void 0,e.resolveOperator=function(t,e,n){var i,a,u,s;try{for(var l=r(n),c=l.next();!c.done;c=l.next()){var f=c.value,p=f[0],h=f[1],d=f[2],y=f[3];if(t.opType===p)try{for(var g=(u=void 0,r(e)),m=g.next();!m.done;m=g.next()){var v=m.value;if((v.domain===h||"ai.onnx"===v.domain&&""===h)&&o(v.version,d))return y(t)}}catch(t){u={error:t}}finally{try{m&&!m.done&&(s=g.return)&&s.call(g)}finally{if(u)throw u.error}}}}catch(t){i={error:t}}finally{try{c&&!c.done&&(a=l.return)&&a.call(l)}finally{if(i)throw i.error}}throw new TypeError("cannot resolve operator '"+t.opType+"' with opsets: "+e.map((function(t){return(t.domain||"ai.onnx")+" v"+t.version})).join(", "))}},function(t,e,n){"use strict";(function(t){ /*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh * @license MIT */ var r=n(59),o=n(60),i=n(61);function a(){return s.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function u(t,e){if(a()=a())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a().toString(16)+" bytes");return 0|t}function d(t,e){if(s.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var n=t.length;if(0===n)return 0;for(var r=!1;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return U(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return G(t).length;default:if(r)return U(t).length;e=(""+e).toLowerCase(),r=!0}}function y(t,e,n){var r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return E(this,e,n);case"utf8":case"utf-8":return P(this,e,n);case"ascii":return A(this,e,n);case"latin1":case"binary":return D(this,e,n);case"base64":return S(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function g(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function m(t,e,n,r,o){if(0===t.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=o?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(o)return-1;n=t.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof e&&(e=s.from(e,r)),s.isBuffer(e))return 0===e.length?-1:v(t,e,n,r,o);if("number"==typeof e)return e&=255,s.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):v(t,[e],n,r,o);throw new TypeError("val must be string, number or Buffer")}function v(t,e,n,r,o){var i,a=1,u=t.length,s=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;a=2,u/=2,s/=2,n/=2}function l(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){var c=-1;for(i=n;iu&&(n=u-s),i=n;i>=0;i--){for(var f=!0,p=0;po&&(r=o):r=o;var i=e.length;if(i%2!=0)throw new TypeError("Invalid hex string");r>i/2&&(r=i/2);for(var a=0;a>8,o=n%256,i.push(o),i.push(r);return i}(e,t.length-n),t,n,r)}function S(t,e,n){return 0===e&&n===t.length?r.fromByteArray(t):r.fromByteArray(t.slice(e,n))}function P(t,e,n){n=Math.min(t.length,n);for(var r=[],o=e;o239?4:l>223?3:l>191?2:1;if(o+f<=n)switch(f){case 1:l<128&&(c=l);break;case 2:128==(192&(i=t[o+1]))&&(s=(31&l)<<6|63&i)>127&&(c=s);break;case 3:i=t[o+1],a=t[o+2],128==(192&i)&&128==(192&a)&&(s=(15&l)<<12|(63&i)<<6|63&a)>2047&&(s<55296||s>57343)&&(c=s);break;case 4:i=t[o+1],a=t[o+2],u=t[o+3],128==(192&i)&&128==(192&a)&&128==(192&u)&&(s=(15&l)<<18|(63&i)<<12|(63&a)<<6|63&u)>65535&&s<1114112&&(c=s)}null===c?(c=65533,f=1):c>65535&&(c-=65536,r.push(c>>>10&1023|55296),c=56320|1023&c),r.push(c),o+=f}return function(t){var e=t.length;if(e<=4096)return String.fromCharCode.apply(String,t);var n="",r=0;for(;r0&&(t=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(t+=" ... ")),""},s.prototype.compare=function(t,e,n,r,o){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),e<0||n>t.length||r<0||o>this.length)throw new RangeError("out of range index");if(r>=o&&e>=n)return 0;if(r>=o)return-1;if(e>=n)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(r>>>=0),a=(n>>>=0)-(e>>>=0),u=Math.min(i,a),l=this.slice(r,o),c=t.slice(e,n),f=0;fo)&&(n=o),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i=!1;;)switch(r){case"hex":return b(this,t,e,n);case"utf8":case"utf-8":return _(this,t,e,n);case"ascii":return w(this,t,e,n);case"latin1":case"binary":return x(this,t,e,n);case"base64":return T(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O(this,t,e,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function A(t,e,n){var r="";n=Math.min(t.length,n);for(var o=e;or)&&(n=r);for(var o="",i=e;in)throw new RangeError("Trying to access beyond buffer length")}function M(t,e,n,r,o,i){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function j(t,e,n,r){e<0&&(e=65535+e+1);for(var o=0,i=Math.min(t.length-n,2);o>>8*(r?o:1-o)}function k(t,e,n,r){e<0&&(e=4294967295+e+1);for(var o=0,i=Math.min(t.length-n,4);o>>8*(r?o:3-o)&255}function C(t,e,n,r,o,i){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function R(t,e,n,r,i){return i||C(t,0,n,4),o.write(t,e,n,r,23,4),n+4}function N(t,e,n,r,i){return i||C(t,0,n,8),o.write(t,e,n,r,52,8),n+8}s.prototype.slice=function(t,e){var n,r=this.length;if((t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e0&&(o*=256);)r+=this[t+--e]*o;return r},s.prototype.readUInt8=function(t,e){return e||L(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return e||L(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return e||L(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return e||L(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return e||L(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,n){t|=0,e|=0,n||L(t,e,this.length);for(var r=this[t],o=1,i=0;++i=(o*=128)&&(r-=Math.pow(2,8*e)),r},s.prototype.readIntBE=function(t,e,n){t|=0,e|=0,n||L(t,e,this.length);for(var r=e,o=1,i=this[t+--r];r>0&&(o*=256);)i+=this[t+--r]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},s.prototype.readInt8=function(t,e){return e||L(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){e||L(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},s.prototype.readInt16BE=function(t,e){e||L(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},s.prototype.readInt32LE=function(t,e){return e||L(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return e||L(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return e||L(t,4,this.length),o.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return e||L(t,4,this.length),o.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return e||L(t,8,this.length),o.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return e||L(t,8,this.length),o.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,n,r){(t=+t,e|=0,n|=0,r)||M(this,t,e,n,Math.pow(2,8*n)-1,0);var o=1,i=0;for(this[e]=255&t;++i=0&&(i*=256);)this[e+o]=t/i&255;return e+n},s.prototype.writeUInt8=function(t,e,n){return t=+t,e|=0,n||M(this,t,e,1,255,0),s.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,n){return t=+t,e|=0,n||M(this,t,e,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):j(this,t,e,!0),e+2},s.prototype.writeUInt16BE=function(t,e,n){return t=+t,e|=0,n||M(this,t,e,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):j(this,t,e,!1),e+2},s.prototype.writeUInt32LE=function(t,e,n){return t=+t,e|=0,n||M(this,t,e,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):k(this,t,e,!0),e+4},s.prototype.writeUInt32BE=function(t,e,n){return t=+t,e|=0,n||M(this,t,e,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):k(this,t,e,!1),e+4},s.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e|=0,!r){var o=Math.pow(2,8*n-1);M(this,t,e,n,o-1,-o)}var i=0,a=1,u=0;for(this[e]=255&t;++i>0)-u&255;return e+n},s.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e|=0,!r){var o=Math.pow(2,8*n-1);M(this,t,e,n,o-1,-o)}var i=n-1,a=1,u=0;for(this[e+i]=255&t;--i>=0&&(a*=256);)t<0&&0===u&&0!==this[e+i+1]&&(u=1),this[e+i]=(t/a>>0)-u&255;return e+n},s.prototype.writeInt8=function(t,e,n){return t=+t,e|=0,n||M(this,t,e,1,127,-128),s.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,n){return t=+t,e|=0,n||M(this,t,e,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):j(this,t,e,!0),e+2},s.prototype.writeInt16BE=function(t,e,n){return t=+t,e|=0,n||M(this,t,e,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):j(this,t,e,!1),e+2},s.prototype.writeInt32LE=function(t,e,n){return t=+t,e|=0,n||M(this,t,e,4,2147483647,-2147483648),s.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):k(this,t,e,!0),e+4},s.prototype.writeInt32BE=function(t,e,n){return t=+t,e|=0,n||M(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):k(this,t,e,!1),e+4},s.prototype.writeFloatLE=function(t,e,n){return R(this,t,e,!0,n)},s.prototype.writeFloatBE=function(t,e,n){return R(this,t,e,!1,n)},s.prototype.writeDoubleLE=function(t,e,n){return N(this,t,e,!0,n)},s.prototype.writeDoubleBE=function(t,e,n){return N(this,t,e,!1,n)},s.prototype.copy=function(t,e,n,r){if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e=0;--o)t[o+e]=this[o+n];else if(i<1e3||!s.TYPED_ARRAY_SUPPORT)for(o=0;o>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(i=e;i55295&&n<57344){if(!o){if(n>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===r){(e-=3)>-1&&i.push(239,191,189);continue}o=n;continue}if(n<56320){(e-=3)>-1&&i.push(239,191,189),o=n;continue}n=65536+(o-55296<<10|n-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,n<128){if((e-=1)<0)break;i.push(n)}else if(n<2048){if((e-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function G(t){return r.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(B,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function z(t,e,n,r){for(var o=0;o=e.length||o>=t.length);++o)e[o+n]=t[o];return o}}).call(this,n(8))},function(t,e){t.exports=r;var n=null;try{n=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(t){}function r(t,e,n){this.low=0|t,this.high=0|e,this.unsigned=!!n}function o(t){return!0===(t&&t.__isLong__)}r.prototype.__isLong__,Object.defineProperty(r.prototype,"__isLong__",{value:!0}),r.isLong=o;var i={},a={};function u(t,e){var n,r,o;return e?(o=0<=(t>>>=0)&&t<256)&&(r=a[t])?r:(n=l(t,(0|t)<0?-1:0,!0),o&&(a[t]=n),n):(o=-128<=(t|=0)&&t<128)&&(r=i[t])?r:(n=l(t,t<0?-1:0,!1),o&&(i[t]=n),n)}function s(t,e){if(isNaN(t))return e?v:m;if(e){if(t<0)return v;if(t>=d)return T}else{if(t<=-y)return O;if(t+1>=y)return x}return t<0?s(-t,e).neg():l(t%h|0,t/h|0,e)}function l(t,e,n){return new r(t,e,n)}r.fromInt=u,r.fromNumber=s,r.fromBits=l;var c=Math.pow;function f(t,e,n){if(0===t.length)throw Error("empty string");if("NaN"===t||"Infinity"===t||"+Infinity"===t||"-Infinity"===t)return m;if("number"==typeof e?(n=e,e=!1):e=!!e,(n=n||10)<2||360)throw Error("interior hyphen");if(0===r)return f(t.substring(1),e,n).neg();for(var o=s(c(n,8)),i=m,a=0;a>>0:this.low},S.toNumber=function(){return this.unsigned?(this.high>>>0)*h+(this.low>>>0):this.high*h+(this.low>>>0)},S.toString=function(t){if((t=t||10)<2||36>>0).toString(t);if((i=u).isZero())return l+a;for(;l.length<6;)l="0"+l;a=""+l+a}},S.getHighBits=function(){return this.high},S.getHighBitsUnsigned=function(){return this.high>>>0},S.getLowBits=function(){return this.low},S.getLowBitsUnsigned=function(){return this.low>>>0},S.getNumBitsAbs=function(){if(this.isNegative())return this.eq(O)?64:this.neg().getNumBitsAbs();for(var t=0!=this.high?this.high:this.low,e=31;e>0&&0==(t&1<=0},S.isOdd=function(){return 1==(1&this.low)},S.isEven=function(){return 0==(1&this.low)},S.equals=function(t){return o(t)||(t=p(t)),(this.unsigned===t.unsigned||this.high>>>31!=1||t.high>>>31!=1)&&(this.high===t.high&&this.low===t.low)},S.eq=S.equals,S.notEquals=function(t){return!this.eq(t)},S.neq=S.notEquals,S.ne=S.notEquals,S.lessThan=function(t){return this.comp(t)<0},S.lt=S.lessThan,S.lessThanOrEqual=function(t){return this.comp(t)<=0},S.lte=S.lessThanOrEqual,S.le=S.lessThanOrEqual,S.greaterThan=function(t){return this.comp(t)>0},S.gt=S.greaterThan,S.greaterThanOrEqual=function(t){return this.comp(t)>=0},S.gte=S.greaterThanOrEqual,S.ge=S.greaterThanOrEqual,S.compare=function(t){if(o(t)||(t=p(t)),this.eq(t))return 0;var e=this.isNegative(),n=t.isNegative();return e&&!n?-1:!e&&n?1:this.unsigned?t.high>>>0>this.high>>>0||t.high===this.high&&t.low>>>0>this.low>>>0?-1:1:this.sub(t).isNegative()?-1:1},S.comp=S.compare,S.negate=function(){return!this.unsigned&&this.eq(O)?O:this.not().add(b)},S.neg=S.negate,S.add=function(t){o(t)||(t=p(t));var e=this.high>>>16,n=65535&this.high,r=this.low>>>16,i=65535&this.low,a=t.high>>>16,u=65535&t.high,s=t.low>>>16,c=0,f=0,h=0,d=0;return h+=(d+=i+(65535&t.low))>>>16,f+=(h+=r+s)>>>16,c+=(f+=n+u)>>>16,c+=e+a,l((h&=65535)<<16|(d&=65535),(c&=65535)<<16|(f&=65535),this.unsigned)},S.subtract=function(t){return o(t)||(t=p(t)),this.add(t.neg())},S.sub=S.subtract,S.multiply=function(t){if(this.isZero())return m;if(o(t)||(t=p(t)),n)return l(n.mul(this.low,this.high,t.low,t.high),n.get_high(),this.unsigned);if(t.isZero())return m;if(this.eq(O))return t.isOdd()?O:m;if(t.eq(O))return this.isOdd()?O:m;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(g)&&t.lt(g))return s(this.toNumber()*t.toNumber(),this.unsigned);var e=this.high>>>16,r=65535&this.high,i=this.low>>>16,a=65535&this.low,u=t.high>>>16,c=65535&t.high,f=t.low>>>16,h=65535&t.low,d=0,y=0,v=0,b=0;return v+=(b+=a*h)>>>16,y+=(v+=i*h)>>>16,v&=65535,y+=(v+=a*f)>>>16,d+=(y+=r*h)>>>16,y&=65535,d+=(y+=i*f)>>>16,y&=65535,d+=(y+=a*c)>>>16,d+=e*h+r*f+i*c+a*u,l((v&=65535)<<16|(b&=65535),(d&=65535)<<16|(y&=65535),this.unsigned)},S.mul=S.multiply,S.divide=function(t){if(o(t)||(t=p(t)),t.isZero())throw Error("division by zero");var e,r,i;if(n)return this.unsigned||-2147483648!==this.high||-1!==t.low||-1!==t.high?l((this.unsigned?n.div_u:n.div_s)(this.low,this.high,t.low,t.high),n.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?v:m;if(this.unsigned){if(t.unsigned||(t=t.toUnsigned()),t.gt(this))return v;if(t.gt(this.shru(1)))return _;i=v}else{if(this.eq(O))return t.eq(b)||t.eq(w)?O:t.eq(O)?b:(e=this.shr(1).div(t).shl(1)).eq(m)?t.isNegative()?b:w:(r=this.sub(t.mul(e)),i=e.add(r.div(t)));if(t.eq(O))return this.unsigned?v:m;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=m}for(r=this;r.gte(t);){e=Math.max(1,Math.floor(r.toNumber()/t.toNumber()));for(var a=Math.ceil(Math.log(e)/Math.LN2),u=a<=48?1:c(2,a-48),f=s(e),h=f.mul(t);h.isNegative()||h.gt(r);)h=(f=s(e-=u,this.unsigned)).mul(t);f.isZero()&&(f=b),i=i.add(f),r=r.sub(h)}return i},S.div=S.divide,S.modulo=function(t){return o(t)||(t=p(t)),n?l((this.unsigned?n.rem_u:n.rem_s)(this.low,this.high,t.low,t.high),n.get_high(),this.unsigned):this.sub(this.div(t).mul(t))},S.mod=S.modulo,S.rem=S.modulo,S.not=function(){return l(~this.low,~this.high,this.unsigned)},S.and=function(t){return o(t)||(t=p(t)),l(this.low&t.low,this.high&t.high,this.unsigned)},S.or=function(t){return o(t)||(t=p(t)),l(this.low|t.low,this.high|t.high,this.unsigned)},S.xor=function(t){return o(t)||(t=p(t)),l(this.low^t.low,this.high^t.high,this.unsigned)},S.shiftLeft=function(t){return o(t)&&(t=t.toInt()),0==(t&=63)?this:t<32?l(this.low<>>32-t,this.unsigned):l(0,this.low<>>t|this.high<<32-t,this.high>>t,this.unsigned):l(this.high>>t-32,this.high>=0?0:-1,this.unsigned)},S.shr=S.shiftRight,S.shiftRightUnsigned=function(t){if(o(t)&&(t=t.toInt()),0===(t&=63))return this;var e=this.high;return t<32?l(this.low>>>t|e<<32-t,e>>>t,this.unsigned):l(32===t?e:e>>>t-32,0,this.unsigned)},S.shru=S.shiftRightUnsigned,S.shr_u=S.shiftRightUnsigned,S.toSigned=function(){return this.unsigned?l(this.low,this.high,!1):this},S.toUnsigned=function(){return this.unsigned?this:l(this.low,this.high,!0)},S.toBytes=function(t){return t?this.toBytesLE():this.toBytesBE()},S.toBytesLE=function(){var t=this.high,e=this.low;return[255&e,e>>>8&255,e>>>16&255,e>>>24,255&t,t>>>8&255,t>>>16&255,t>>>24]},S.toBytesBE=function(){var t=this.high,e=this.low;return[t>>>24,t>>>16&255,t>>>8&255,255&t,e>>>24,e>>>16&255,e>>>8&255,255&e]},r.fromBytes=function(t,e,n){return n?r.fromBytesLE(t,e):r.fromBytesBE(t,e)},r.fromBytesLE=function(t,e){return new r(t[0]|t[1]<<8|t[2]<<16|t[3]<<24,t[4]|t[5]<<8|t[6]<<16|t[7]<<24,e)},r.fromBytesBE=function(t,e){return new r(t[4]<<24|t[5]<<16|t[6]<<8|t[7],t[0]<<24|t[1]<<16|t[2]<<8|t[3],e)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.BatchNormalization=void 0;var r=function(){function t(){}return t.prototype.initialize=function(t){this.epsilon=t.getFloat("epsilon",1e-5),this.momentum=t.getFloat("momentum",.9),this.spatial=t.getInt("spatial",1)},t.prototype.checkInputs=function(t){return!(!t||5!==t.length)&&this.checkInputTypes(t)},t.prototype.checkInputTypes=function(t){var e=t[0],n=t[1],r=t[2],o=t[3],i=t[4];return!(e.dims.length<3||1!==n.dims.length||1!==r.dims.length||1!==o.dims.length||1!==i.dims.length)&&(n.dims[0]===e.dims[1]&&r.dims[0]===e.dims[1]&&o.dims[0]===e.dims[1]&&i.dims[0]===e.dims[1]&&!("float32"!==e.type&&"float64"!==e.type||"float32"!==n.type&&"float64"!==n.type||"float32"!==r.type&&"float64"!==r.type||"float32"!==o.type&&"float64"!==o.type||"float32"!==i.type&&"float64"!==i.type))},t}();e.BatchNormalization=r},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.BinaryOp=void 0;var r=function(){function t(t,e,n){this.typeConstraint=t,this.opType=e,this.resultType=n}return t.prototype.initialize=function(t){},t.prototype.checkInputs=function(t){return!(!t||2!==t.length)&&this.checkInputTypes(t)},t.prototype.checkInputTypes=function(t){return-1!==this.typeConstraint.indexOf(t[0].type)&&t[0].type===t[1].type},t}();e.BinaryOp=r},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Conv=void 0;var r=function(){function t(){}return t.prototype.initialize=function(t){this.autoPad=t.getString("auto_pad","NOTSET"),this.dilations=t.getInts("dilations",[1,1]),this.group=t.getInt("group",1),this.kernelShape=t.getInts("kernel_shape",[]),this.pads=t.getInts("pads",[0,0,0,0]),this.strides=t.getInts("strides",[1,1])},t.prototype.checkInputs=function(t){if(!t||2!==t.length&&3!==t.length)return!1;if(4!==t[0].dims.length||4!==t[1].dims.length)return!1;if(t[0].dims[1]!==t[1].dims[1]*this.group)return!1;if(3===t.length&&(1!==t[2].dims.length||t[1].dims[0]!==t[2].dims[0]))return!1;var e=t[0].dims.length-2;return this.dilations.length===e&&(this.strides.length===e&&(this.pads.length===2*e&&((0===this.kernelShape.length||this.kernelShape.length===t[1].dims.length-2)&&this.checkInputTypes(t))))},t.prototype.checkInputTypes=function(t){return"float32"===t[0].type&&"float32"===t[1].type&&(3!==t.length||"float32"===t[2].type)},t}();e.Conv=r},function(t,e,n){"use strict";var r,o=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),i=this&&this.__read||function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a};Object.defineProperty(e,"__esModule",{value:!0}),e.matMul2d=e.matMul=e.CpuMatMul=void 0;var a=n(18),u=n(1),s=n(0),l=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.run=function(t,e){return[c(e[0],e[1])]},e}(a.MatMul);function c(t,e){var n=i(s.MatMulUtil.preprocessInputShapes(t.dims,e.dims),2),r=n[0],o=n[1],a=[r[r.length-2],o[o.length-1]],l=s.BroadcastUtil.calcShape(r,o,!0);if(!l)throw new Error("input dimensions do not match the requirement");for(var c=s.ShapeUtil.size(l)/(a[0]*a[1]),p=new u.Tensor(l,"float64"===t.type||"float64"===e.type?"float64":"float32"),h=0,d=new Array(l.length),y=new Array(t.dims.length),g=new Array(e.dims.length),m=0;m=0;b--)d[b]=v%l[b],v=Math.floor(v/l[b]);s.BroadcastUtil.fillIndex(d,t.dims,y),s.BroadcastUtil.fillIndex(d,e.dims,g);var _=y.length<=2?0:s.ShapeUtil.indicesToOffset(y,t.strides,l.length-2),w=g.length<=2?0:s.ShapeUtil.indicesToOffset(g,e.strides,l.length-2);f(t.floatData.subarray(_),e.floatData.subarray(w),p.floatData.subarray(h),!1,!1,1,0,a[0],a[1],r[r.length-1]),h+=a[0]*a[1]}return p}function f(t,e,n,r,o,i,a,u,s,l){return r&&o?function(t,e,n,r,o,i,a,u){for(var s=0,l=0,c=0,f=0;f3))&&(!(!this.isOptionalC&&3!==t.length)&&((3!==t.length||1===t[2].dims.length||2===t[2].dims.length)&&this.checkInputTypes(t))))},t.prototype.checkInputTypes=function(t){return!("float32"!==t[0].type&&"float64"!==t[0].type||"float32"!==t[1].type&&"float64"!==t[1].type||3===t.length&&"float32"!==t[2].type&&"float64"!==t[2].type)&&(t[0].type===t[1].type&&(3!==t.length||t[0].type===t[2].type))},t}();e.Gemm=r},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.InstanceNormalization=void 0;var r=function(){function t(){}return t.prototype.initialize=function(t){this.epsilon=t.getFloat("epsilon",1e-5)},t.prototype.checkInputs=function(t){return!(!t||3!==t.length)&&this.checkInputTypes(t)},t.prototype.checkInputTypes=function(t){var e=t[0],n=t[1],r=t[2];return!(e.dims.length<3||1!==n.dims.length||1!==r.dims.length)&&(n.dims[0]===e.dims[1]&&r.dims[0]===e.dims[1]&&!("float32"!==e.type&&"float64"!==e.type||"float32"!==n.type&&"float64"!==n.type||"float32"!==r.type&&"float64"!==r.type))},t}();e.InstanceNormalization=r},function(t,e,n){"use strict";var r,o=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0}),e.GlobalMaxPool=e.MaxPool=e.GlobalAveragePool=e.AveragePool=void 0;var i=function(){function t(){}return t.prototype.checkInputs=function(t){return!(!t||1!==t.length)&&this.checkInputTypes(t)},t.prototype.checkInputTypes=function(t){return"float32"===t[0].type||"float64"===t[0].type},t}(),a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.initialize=function(t){if(this.autoPad=t.getString("auto_pad","NOTSET"),this.kernelShape=t.getInts("kernel_shape"),this.strides=t.getInts("strides",[]),this.pads=t.getInts("pads",[]),this.countIncludePad=0!==t.getInt("count_include_pad",0),this.ceilMode=t.getInt("ceil_mode",0),0!==this.ceilMode)throw new Error("using ceil() in shape computation is not yet supported for AveragePool")},e}(i);e.AveragePool=a;var u=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.initialize=function(t){this.countIncludePad=0!==t.getInt("count_include_pad",0)},e}(i);e.GlobalAveragePool=u;var s=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.initialize=function(t){if(this.autoPad=t.getString("auto_pad","NOTSET"),this.kernelShape=t.getInts("kernel_shape"),this.strides=t.getInts("strides",[]),this.pads=t.getInts("pads",[]),this.ceilMode=t.getInt("ceil_mode",0),this.storageOrder=t.getInt("storage_order",0),0!==this.storageOrder)throw new Error("column major storage order is not yet supported for MaxPool");if(0!==this.ceilMode)throw new Error("using ceil() in shape computation is not yet supported for MaxPool")},e}(i);e.MaxPool=s;var l=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.initialize=function(t){},e}(i);e.GlobalMaxPool=l},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Softmax=void 0;var r=function(){function t(){}return t.prototype.initialize=function(t){this.axis=t.getInt("axis",1)},t.prototype.checkInputs=function(t){return!(!t||1!==t.length)&&this.checkInputTypes(t)},t.prototype.checkInputTypes=function(t){return"float32"===t[0].type||"float64"===t[0].type},t}();e.Softmax=r},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Sum=void 0;var r=function(){function t(){}return t.prototype.initialize=function(t){},t.prototype.checkInputs=function(t){if(!t||0===t.length)return!1;for(var e=t[0].dims.length,n=1;n1)for(var n=1;n=0?t:t*e}))}],["Pad","","2-10",function(){return new _.CpuPad}],["Reciprocal","","6+",function(){return new L.CpuUnaryOp(a.FLOAT_TYPES,I.reciprocal)}],["ReduceLogSum","","1+",function(){return new x.CpuReduceLogSum}],["ReduceMax","","1+",function(){return new x.CpuReduceMax}],["ReduceMean","","1+",function(){return new x.CpuReduceMean}],["ReduceMin","","1+",function(){return new x.CpuReduceMin}],["ReduceProd","","1+",function(){return new x.CpuReduceProd}],["ReduceSum","","1+",function(){return new x.CpuReduceSum}],["ReduceSumSquare","","1+",function(){return new x.CpuReduceSumSquare}],["Relu","","6+",function(){return new L.CpuUnaryOp(a.FLOAT_TYPES,I.relu)}],["Reshape","","5+",function(){return new T.CpuReshape}],["Sigmoid","","6+",function(){return new L.CpuUnaryOp(a.FLOAT_TYPES,I.sigmoid)}],["Sign","","9+",function(){return new L.CpuUnaryOp(a.NUMBER_TYPES,I.sign)}],["Sin","","7+",function(){return new L.CpuUnaryOp(a.FLOAT_TYPES,I.sin)}],["Sinh","","9+",function(){return new L.CpuUnaryOp(a.FLOAT_TYPES,I.sinh)}],["Slice","","10+",function(){return new O.CpuSliceV10}],["Slice","","1-9",function(){return new O.CpuSlice}],["Softmax","","1+",function(){return new S.CpuSoftmax}],["Sqrt","","6+",function(){return new L.CpuUnaryOp(a.FLOAT_TYPES,I.sqrt)}],["Squeeze","","1+",function(){return new P.CpuSqueeze}],["Sub","","7+",function(){return new l.CpuBinaryOp(a.NUMBER_TYPES,(function(t,e){return t-e}))}],["Sum","","6+",function(){return new A.CpuSum}],["Tan","","7+",function(){return new L.CpuUnaryOp(a.FLOAT_TYPES,I.tan)}],["Tanh","","6+",function(){return new L.CpuUnaryOp(a.FLOAT_TYPES,I.tanh)}],["Tile","","6+",function(){return new D.CpuTile}],["Transpose","","1+",function(){return new E.CpuTranspose}],["Unsqueeze","","1+",function(){return new M.CpuUnsqueeze}],["Upsample","","7-8",function(){return new j.CpuUpsample}],["Xor","","7+",function(){return new l.CpuBinaryOp(["bool"],(function(t,e){return t^e}))}]]},function(t,e,n){"use strict";t.exports=f;var r,o=n(6),i=o.LongBits,a=o.base64,u=o.utf8;function s(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}function l(){}function c(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}function f(){this.len=0,this.head=new s(l,0,0),this.tail=this.head,this.states=null}var p=function(){return o.Buffer?function(){return(f.create=function(){return new r})()}:function(){return new f}};function h(t,e,n){e[n]=255&t}function d(t,e){this.len=t,this.next=void 0,this.val=e}function y(t,e,n){for(;t.hi;)e[n++]=127&t.lo|128,t.lo=(t.lo>>>7|t.hi<<25)>>>0,t.hi>>>=7;for(;t.lo>127;)e[n++]=127&t.lo|128,t.lo=t.lo>>>7;e[n++]=t.lo}function g(t,e,n){e[n]=255&t,e[n+1]=t>>>8&255,e[n+2]=t>>>16&255,e[n+3]=t>>>24}f.create=p(),f.alloc=function(t){return new o.Array(t)},o.Array!==Array&&(f.alloc=o.pool(f.alloc,o.Array.prototype.subarray)),f.prototype._push=function(t,e,n){return this.tail=this.tail.next=new s(t,e,n),this.len+=e,this},d.prototype=Object.create(s.prototype),d.prototype.fn=function(t,e,n){for(;t>127;)e[n++]=127&t|128,t>>>=7;e[n]=t},f.prototype.uint32=function(t){return this.len+=(this.tail=this.tail.next=new d((t>>>=0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this},f.prototype.int32=function(t){return t<0?this._push(y,10,i.fromNumber(t)):this.uint32(t)},f.prototype.sint32=function(t){return this.uint32((t<<1^t>>31)>>>0)},f.prototype.uint64=function(t){var e=i.from(t);return this._push(y,e.length(),e)},f.prototype.int64=f.prototype.uint64,f.prototype.sint64=function(t){var e=i.from(t).zzEncode();return this._push(y,e.length(),e)},f.prototype.bool=function(t){return this._push(h,1,t?1:0)},f.prototype.fixed32=function(t){return this._push(g,4,t>>>0)},f.prototype.sfixed32=f.prototype.fixed32,f.prototype.fixed64=function(t){var e=i.from(t);return this._push(g,4,e.lo)._push(g,4,e.hi)},f.prototype.sfixed64=f.prototype.fixed64,f.prototype.float=function(t){return this._push(o.float.writeFloatLE,4,t)},f.prototype.double=function(t){return this._push(o.float.writeDoubleLE,8,t)};var m=o.Array.prototype.set?function(t,e,n){e.set(t,n)}:function(t,e,n){for(var r=0;r>>0;if(!e)return this._push(h,1,0);if(o.isString(t)){var n=f.alloc(e=a.length(t));a.decode(t,n,0),t=n}return this.uint32(e)._push(m,e,t)},f.prototype.string=function(t){var e=u.length(t);return e?this.uint32(e)._push(u.write,e,t):this._push(h,1,0)},f.prototype.fork=function(){return this.states=new c(this),this.head=this.tail=new s(l,0,0),this.len=0,this},f.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 s(l,0,0),this.len=0),this},f.prototype.ldelim=function(){var t=this.head,e=this.tail,n=this.len;return this.reset().uint32(n),n&&(this.tail.next=t.next,this.tail=e,this.len+=n),this},f.prototype.finish=function(){for(var t=this.head.next,e=this.constructor.alloc(this.len),n=0;t;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e},f._configure=function(t){r=t,f.create=p(),r._configure()}},function(t,e,n){"use strict";t.exports=s;var r,o=n(6),i=o.LongBits,a=o.utf8;function u(t,e){return RangeError("index out of range: "+t.pos+" + "+(e||1)+" > "+t.len)}function s(t){this.buf=t,this.pos=0,this.len=t.length}var l,c="undefined"!=typeof Uint8Array?function(t){if(t instanceof Uint8Array||Array.isArray(t))return new s(t);throw Error("illegal buffer")}:function(t){if(Array.isArray(t))return new s(t);throw Error("illegal buffer")},f=function(){return o.Buffer?function(t){return(s.create=function(t){return o.Buffer.isBuffer(t)?new r(t):c(t)})(t)}:c};function p(){var t=new i(0,0),e=0;if(!(this.len-this.pos>4)){for(;e<3;++e){if(this.pos>=this.len)throw u(this);if(t.lo=(t.lo|(127&this.buf[this.pos])<<7*e)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(127&this.buf[this.pos++])<<7*e)>>>0,t}for(;e<4;++e)if(t.lo=(t.lo|(127&this.buf[this.pos])<<7*e)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(127&this.buf[this.pos])<<28)>>>0,t.hi=(t.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return t;if(e=0,this.len-this.pos>4){for(;e<5;++e)if(t.hi=(t.hi|(127&this.buf[this.pos])<<7*e+3)>>>0,this.buf[this.pos++]<128)return t}else for(;e<5;++e){if(this.pos>=this.len)throw u(this);if(t.hi=(t.hi|(127&this.buf[this.pos])<<7*e+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}function h(t,e){return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0}function d(){if(this.pos+8>this.len)throw u(this,8);return new i(h(this.buf,this.pos+=4),h(this.buf,this.pos+=4))}s.create=f(),s.prototype._slice=o.Array.prototype.subarray||o.Array.prototype.slice,s.prototype.uint32=(l=4294967295,function(){if(l=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return l;if(l=(l|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return l;if(l=(l|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return l;if(l=(l|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return l;if(l=(l|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return l;if((this.pos+=5)>this.len)throw this.pos=this.len,u(this,10);return l}),s.prototype.int32=function(){return 0|this.uint32()},s.prototype.sint32=function(){var t=this.uint32();return t>>>1^-(1&t)|0},s.prototype.bool=function(){return 0!==this.uint32()},s.prototype.fixed32=function(){if(this.pos+4>this.len)throw u(this,4);return h(this.buf,this.pos+=4)},s.prototype.sfixed32=function(){if(this.pos+4>this.len)throw u(this,4);return 0|h(this.buf,this.pos+=4)},s.prototype.float=function(){if(this.pos+4>this.len)throw u(this,4);var t=o.float.readFloatLE(this.buf,this.pos);return this.pos+=4,t},s.prototype.double=function(){if(this.pos+8>this.len)throw u(this,4);var t=o.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,t},s.prototype.bytes=function(){var t=this.uint32(),e=this.pos,n=this.pos+t;if(n>this.len)throw u(this,t);return this.pos+=t,Array.isArray(this.buf)?this.buf.slice(e,n):e===n?new this.buf.constructor(0):this._slice.call(this.buf,e,n)},s.prototype.string=function(){var t=this.bytes();return a.read(t,0,t.length)},s.prototype.skip=function(t){if("number"==typeof t){if(this.pos+t>this.len)throw u(this,t);this.pos+=t}else do{if(this.pos>=this.len)throw u(this)}while(128&this.buf[this.pos++]);return this},s.prototype.skipType=function(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!=(t=7&this.uint32());)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+t+" at offset "+this.pos)}return this},s._configure=function(t){r=t,s.create=f(),r._configure();var e=o.Long?"toLong":"toNumber";o.merge(s.prototype,{int64:function(){return p.call(this)[e](!1)},uint64:function(){return p.call(this)[e](!0)},sint64:function(){return p.call(this).zzDecode()[e](!1)},fixed64:function(){return d.call(this)[e](!0)},sfixed64:function(){return d.call(this)[e](!1)}})}},function(t,e,n){"use strict";var r=this&&this.__values||function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(e,"__esModule",{value:!0}),e.Concat=void 0;var o=function(){function t(){}return t.prototype.initialize=function(t){this.axis=t.getInt("axis")},t.prototype.checkInputs=function(t){return!(!t||t.length<1)&&this.checkInputTypes(t)},t.prototype.checkInputTypes=function(t){var e,n,o=t[0].type,i=t[0].dims.length;if("string"===o)return!1;try{for(var a=r(t),u=a.next();!u.done;u=a.next()){var s=u.value;if(s.type!==o)return!1;if(s.dims.length!==i)return!1}}catch(t){e={error:t}}finally{try{u&&!u.done&&(n=a.return)&&n.call(a)}finally{if(e)throw e.error}}return!0},t}();e.Concat=o},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Dropout=void 0;var r=function(){function t(){}return t.prototype.initialize=function(t){this.ratio=t.getFloat("ratio",.5),this.testMode=!0},t.prototype.checkInputs=function(t){return!(!t||1!==t.length)&&this.checkInputTypes(t)},t.prototype.checkInputTypes=function(t){return"float32"===t[0].type||"float64"===t[0].type},t}();e.Dropout=r},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Flatten=void 0;var r=function(){function t(){}return t.prototype.initialize=function(t){this.axis=t.getInt("axis",1)},t.prototype.checkInputs=function(t){if(!t||1!==t.length)return!1;var e=t[0].dims.length;return 0!==e&&(!(this.axis<-e||this.axis>e)&&this.checkInputTypes(t))},t.prototype.checkInputTypes=function(t){return"string"!==t[0].type},t}();e.Flatten=r},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Gather=void 0;var r=n(7),o=function(){function t(){}return t.prototype.initialize=function(t){this.axis=t.getInt("axis",0)},t.prototype.checkInputs=function(t){if(!t||2!==t.length)return!1;var e=t[0].dims.length;return!(e<1)&&(!(this.axis<-e||this.axis>e-1)&&this.checkInputTypes(t))},t.prototype.checkInputTypes=function(t){return-1!==r.NUMBER_TYPES.indexOf(t[0].type)&&("int32"===t[1].type||"int16"===t[1].type)},t}();e.Gather=o},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ImageScaler=void 0;var r=function(){function t(){}return t.prototype.initialize=function(t){this.scale=t.getFloat("scale"),this.bias=t.getFloats("bias")},t.prototype.checkInputs=function(t){return!(!t||1!==t.length)&&(4===t[0].dims.length&&this.checkInputTypes(t))},t.prototype.checkInputTypes=function(t){return"float32"===t[0].type||"float64"===t[0].type},t}();e.ImageScaler=r},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Pad=void 0;var r=function(){function t(){}return t.prototype.initialize=function(t){this.mode=t.getString("mode","constant"),this.value=t.getFloat("value",0),this.pads=t.getInts("pads")},t.prototype.checkInputs=function(t){return!(!t||1!==t.length)&&this.checkInputTypes(t)},t.prototype.checkInputTypes=function(t){return"float32"===t[0].type||"float64"===t[0].type},t}();e.Pad=r},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ReduceBase=void 0;var r=n(7),o=function(){function t(){}return t.prototype.initialize=function(t){this.axes=t.getInts("axes",[]),this.keepDims=1===t.getInt("keepdims",1)},t.prototype.checkInputs=function(t){return!(!t||1!==t.length)&&this.checkInputTypes(t)},t.prototype.checkInputTypes=function(t){return-1!==r.NUMBER_TYPES.indexOf(t[0].type)},t}();e.ReduceBase=o},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Reshape=void 0;var r=function(){function t(){}return t.prototype.initialize=function(t){},t.prototype.checkInputs=function(t){return!(!t||2!==t.length||1!==t[1].dims.length)&&this.checkInputTypes(t)},t.prototype.checkInputTypes=function(t){return("float32"===t[0].type||"float64"===t[0].type)&&"int32"===t[1].type},t}();e.Reshape=r},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SliceV10=e.Slice=void 0;var r=function(){function t(){}return t.prototype.initialize=function(t){this.starts=t.getInts("starts"),this.ends=t.getInts("ends"),this.axes=t.getInts("axes",[])},t.prototype.checkInputs=function(t){return!(!t||1!==t.length)&&this.checkInputTypes(t)},t.prototype.checkInputTypes=function(t){return"float32"===t[0].type||"float64"===t[0].type},t}();e.Slice=r;var o=function(){function t(){}return t.prototype.initialize=function(t){},t.prototype.checkInputs=function(t){return!(!t||t.length<3||t.length>5)&&this.checkInputTypes(t)},t.prototype.checkInputTypes=function(t){return"int32"===t[1].type&&1===t[1].dims.length&&("int32"===t[2].type&&1===t[2].dims.length&&((!(t.length>=4)||"int32"===t[3].type&&1===t[3].dims.length)&&(!(t.length>=5)||"int32"===t[4].type&&1===t[4].dims.length)))},t}();e.SliceV10=o},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Squeeze=void 0;var r=function(){function t(){}return t.prototype.initialize=function(t){this.axes=t.getInts("axes")},t.prototype.checkInputs=function(t){return!(!t||1!==t.length)&&this.checkInputTypes(t)},t.prototype.checkInputTypes=function(t){return"string"!==t[0].type},t}();e.Squeeze=r},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Tile=void 0;var r=n(7),o=function(){function t(){}return t.prototype.initialize=function(t){},t.prototype.checkInputs=function(t){return!(!t||2!==t.length)&&(1===t[1].dims.length&&(t[1].dims[0]===t[0].dims.length&&this.checkInputTypes(t)))},t.prototype.checkInputTypes=function(t){return-1!==r.NUMBER_TYPES.indexOf(t[0].type)&&("int32"===t[1].type||"int16"===t[1].type)},t}();e.Tile=o},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Transpose=void 0;var r=function(){function t(){}return t.prototype.initialize=function(t){this.perm=t.getInts("perm",[])},t.prototype.checkInputs=function(t){return!(!t||1!==t.length)&&this.checkInputTypes(t)},t.prototype.checkInputTypes=function(t){return"float32"===t[0].type||"float64"===t[0].type},t}();e.Transpose=r},function(t,e,n){"use strict";var r,o=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0}),e.tanh=e.tan=e.sqrt=e.sinh=e.sin=e.sign=e.sigmoid=e.relu=e.reciprocal=e.not=e.neg=e.log=e.leakyRelu=e.leakyReluInitializer=e.isNan=e.floor=e.exp=e.elu=e.eluInitializer=e.cosh=e.cos=e.clip=e.clipInitializer=e.ceil=e.atanh=e.atan=e.asinh=e.asin=e.acosh=e.acos=e.abs=e.unaryOp=e.CpuUnaryOp=void 0;var i=n(43),a=n(1),u=function(t){function e(e,n,r,o){var i=t.call(this,e,o)||this;return i.func=n,i.attributesInitializer=r,i}return o(e,t),e.prototype.initialize=function(t){this.attributesInitializer&&(this.attributes=this.attributesInitializer(t))},e.prototype.run=function(t,e){return[s(e[0],this.func,this.attributes,this.resultType)]},e}(i.UnaryOp);function s(t,e,n,r){var o=new a.Tensor(t.dims,r||t.type);return e(t.data,o.data,n),o}e.CpuUnaryOp=u,e.unaryOp=s,e.abs=function(t,e){for(var n=0;no?o:a}},e.cos=function(t,e){for(var n=0;n=0?i:r*(Math.exp(i)-1)}},e.exp=function(t,e){for(var n=0;n=0?i:r*i}},e.log=function(t,e){for(var n=0;n0?1:t[n]<0?-1:0},e.sin=function(t,e){for(var n=0;n-1&&r<=c)for(;++n3?"WebKit":/\bOpera\b/.test(B)&&(/\bOPR\b/.test(e)?"Blink":"Presto"))||/\b(?:Midori|Nook|Safari)\b/i.test(e)&&!/^(?:Trident|EdgeHTML)$/.test(N)&&"WebKit"||!N&&/\bMSIE\b/i.test(e)&&("Mac OS"==G?"Tasman":"Trident")||"WebKit"==N&&/\bPlayStation\b(?! Vita\b)/i.test(B)&&"NetFront")&&(N=[u]),"IE"==B&&(u=(/; *(?:XBLWP|ZuneWP)(\d+)/i.exec(e)||0)[1])?(B+=" Mobile",G="Windows Phone "+(/\+$/.test(u)?u:u+".x"),j.unshift("desktop mode")):/\bWPDesktop\b/i.test(e)?(B="IE Mobile",G="Windows Phone 8.x",j.unshift("desktop mode"),R||(R=(/\brv:([\d.]+)/.exec(e)||0)[1])):"IE"!=B&&"Trident"==N&&(u=/\brv:([\d.]+)/.exec(e))&&(B&&j.push("identifying as "+B+(R?" "+R:"")),B="IE",R=u[1]),C){if(c="global",p=null!=(l=n)?typeof l[c]:"number",/^(?:boolean|number|string|undefined)$/.test(p)||"object"==p&&!l[c])v(u=n.runtime)==y?(B="Adobe AIR",G=u.flash.system.Capabilities.os):v(u=n.phantom)==O?(B="PhantomJS",R=(u=u.version||null)&&u.major+"."+u.minor+"."+u.patch):"number"==typeof E.documentMode&&(u=/\bTrident\/(\d+)/i.exec(e))?(R=[R,E.documentMode],(u=+u[1]+4)!=R[1]&&(j.push("IE "+R[1]+" mode"),N&&(N[1]=""),R[1]=u),R="IE"==B?String(R[1].toFixed(1)):R[0]):"number"==typeof E.documentMode&&/^(?:Chrome|Firefox)\b/.test(B)&&(j.push("masking as "+B+" "+R),B="IE",R="11.0",N=["Trident"],G="Windows");else if(S&&(M=(u=S.lang.System).getProperty("os.arch"),G=G||u.getProperty("os.name")+" "+u.getProperty("os.version")),P){try{R=n.require("ringo/engine").version.join("."),B="RingoJS"}catch(t){(u=n.system)&&u.global.system==n.system&&(B="Narwhal",G||(G=u[0].os||null))}B||(B="Rhino")}else"object"==typeof n.process&&!n.process.browser&&(u=n.process)&&("object"==typeof u.versions&&("string"==typeof u.versions.electron?(j.push("Node "+u.versions.node),B="Electron",R=u.versions.electron):"string"==typeof u.versions.nw&&(j.push("Chromium "+R,"Node "+u.versions.node),B="NW.js",R=u.versions.nw)),B||(B="Node.js",M=u.arch,G=u.platform,R=(R=/[\d.]+/.exec(u.version))?R[0]:null));G=G&&g(G)}if(R&&(u=/(?:[ab]|dp|pre|[ab]\d+pre)(?:\d+\+?)?$/i.exec(R)||/(?:alpha|beta)(?: ?\d)?/i.exec(e+";"+(C&&o.appMinorVersion))||/\bMinefield\b/i.test(e)&&"a")&&(k=/b/i.test(u)?"beta":"alpha",R=R.replace(RegExp(u+"\\+?$"),"")+("beta"==k?D:A)+(/\d+\+?/.exec(u)||"")),"Fennec"==B||"Firefox"==B&&/\b(?:Android|Firefox OS|KaiOS)\b/.test(G))B="Firefox Mobile";else if("Maxthon"==B&&R)R=R.replace(/\.[\d.]+/,".x");else if(/\bXbox\b/i.test(F))"Xbox 360"==F&&(G=null),"Xbox 360"==F&&/\bIEMobile\b/.test(e)&&j.unshift("mobile mode");else if(!/^(?:Chrome|IE|Opera)$/.test(B)&&(!B||F||/Browser|Mobi/.test(B))||"Windows CE"!=G&&!/Mobi/i.test(e))if("IE"==B&&C)try{null===n.external&&j.unshift("platform preview")}catch(t){j.unshift("embedded")}else(/\bBlackBerry\b/.test(F)||/\bBB10\b/.test(e))&&(u=(RegExp(F.replace(/ +/g," *")+"/([.\\d]+)","i").exec(e)||0)[1]||R)?(G=((u=[u,/BB10/.test(e)])[1]?(F=null,U="BlackBerry"):"Device Software")+" "+u[0],R=null):this!=m&&"Wii"!=F&&(C&&I||/Opera/.test(B)&&/\b(?:MSIE|Firefox)\b/i.test(e)||"Firefox"==B&&/\bOS X (?:\d+\.){2,}/.test(G)||"IE"==B&&(G&&!/^Win/.test(G)&&R>5.5||/\bWindows XP\b/.test(G)&&R>8||8==R&&!/\bTrident\b/.test(e)))&&!f.test(u=t.call(m,e.replace(f,"")+";"))&&u.name&&(u="ing as "+u.name+((u=u.version)?" "+u:""),f.test(B)?(/\bIE\b/.test(u)&&"Mac OS"==G&&(G=null),u="identify"+u):(u="mask"+u,B=L?g(L.replace(/([a-z])([A-Z])/g,"$1 $2")):"Opera",/\bIE\b/.test(u)&&(G=null),C||(R=null)),N=["Presto"],j.push(u));else B+=" Mobile";(u=(/\bAppleWebKit\/([\d.]+\+?)/i.exec(e)||0)[1])&&(u=[parseFloat(u.replace(/\.(\d)$/,".0$1")),u],"Safari"==B&&"+"==u[1].slice(-1)?(B="WebKit Nightly",k="alpha",R=u[1].slice(0,-1)):R!=u[1]&&R!=(u[2]=(/\bSafari\/([\d.]+\+?)/i.exec(e)||0)[1])||(R=null),u[1]=(/\b(?:Headless)?Chrome\/([\d.]+)/i.exec(e)||0)[1],537.36==u[0]&&537.36==u[2]&&parseFloat(u[1])>=28&&"WebKit"==N&&(N=["Blink"]),C&&(h||u[1])?(N&&(N[1]="like Chrome"),u=u[1]||((u=u[0])<530?1:u<532?2:u<532.05?3:u<533?4:u<534.03?5:u<534.07?6:u<534.1?7:u<534.13?8:u<534.16?9:u<534.24?10:u<534.3?11:u<535.01?12:u<535.02?"13+":u<535.07?15:u<535.11?16:u<535.19?17:u<536.05?18:u<536.1?19:u<537.01?20:u<537.11?"21+":u<537.13?23:u<537.18?24:u<537.24?25:u<537.36?26:"Blink"!=N?"27":"28")):(N&&(N[1]="like Safari"),u=(u=u[0])<400?1:u<500?2:u<526?3:u<533?4:u<534?"4+":u<535?5:u<537?6:u<538?7:u<601?8:u<602?9:u<604?10:u<606?11:u<608?12:"12"),N&&(N[1]+=" "+(u+="number"==typeof u?".x":/[.+]/.test(u)?"":"+")),"Safari"==B&&(!R||parseInt(R)>45)?R=u:"Chrome"==B&&/\bHeadlessChrome/i.test(e)&&j.unshift("headless")),"Opera"==B&&(u=/\bzbov|zvav$/.exec(G))?(B+=" ",j.unshift("desktop mode"),"zvav"==u?(B+="Mini",R=null):B+="Mobile",G=G.replace(RegExp(" *"+u+"$"),"")):"Safari"==B&&/\bChrome\b/.exec(N&&N[1])?(j.unshift("desktop mode"),B="Chrome Mobile",R=null,/\bOS X\b/.test(G)?(U="Apple",G="iOS 4.3+"):G=null):/\bSRWare Iron\b/.test(B)&&!R&&(R=W("Chrome")),R&&0==R.indexOf(u=/[\d.]+$/.exec(G))&&e.indexOf("/"+u+"-")>-1&&(G=w(G.replace(u,""))),G&&-1!=G.indexOf(B)&&!RegExp(B+" OS").test(G)&&(G=G.replace(RegExp(" *"+b(B)+" *"),"")),N&&!/\b(?:Avant|Nook)\b/.test(B)&&(/Browser|Lunascape|Maxthon/.test(B)||"Safari"!=B&&/^iOS/.test(G)&&/\bSafari\b/.test(N[1])||/^(?:Adobe|Arora|Breach|Midori|Opera|Phantom|Rekonq|Rock|Samsung Internet|Sleipnir|SRWare Iron|Vivaldi|Web)/.test(B)&&N[1])&&(u=N[N.length-1])&&j.push(u),j.length&&(j=["("+j.join("; ")+")"]),U&&F&&F.indexOf(U)<0&&j.push("on "+U),F&&j.push((/^on /.test(j[j.length-1])?"":"on ")+F),G&&(u=/ ([\d.+]+)$/.exec(G),s=u&&"/"==G.charAt(G.length-u[0].length-1),G={architecture:32,family:u&&!s?G.replace(u[0],""):G,version:u?u[1]:null,toString:function(){var t=this.version;return this.family+(t&&!s?" "+t:"")+(64==this.architecture?" 64-bit":"")}}),(u=/\b(?:AMD|IA|Win|WOW|x86_|x)64\b/i.exec(M))&&!/\bi686\b/i.test(M)?(G&&(G.architecture=64,G.family=G.family.replace(RegExp(" *"+u),"")),B&&(/\bWOW64\b/i.test(e)||C&&/\w(?:86|32)$/.test(o.cpuClass||o.platform)&&!/\bWin64; x64\b/i.test(e))&&j.unshift("32-bit")):G&&/^OS X/.test(G.family)&&"Chrome"==B&&parseFloat(R)>=39&&(G.architecture=64),e||(e=null);var V={};return V.description=e,V.layout=N&&N[0],V.manufacturer=U,V.name=B,V.prerelease=k,V.product=F,V.ua=e,V.version=B&&R,V.os=G||{architecture:null,family:null,version:null,toString:function(){return"null"}},V.parse=t,V.toString=function(){return this.description||""},V.version&&j.unshift(R),V.name&&j.unshift(B),G&&B&&(G!=String(G).split(" ")[0]||G!=B.split(" ")[0]&&!F)&&j.push(F?"("+G+")":"on "+G),j.length&&(V.description=j.join(" ")),V}();a.platform=x,void 0===(o=function(){return x}.call(e,n,e,t))||(t.exports=o)}).call(this)}).call(this,n(102)(t),n(8))},function(t,e,n){(function(t){function n(t,e){for(var n=0,r=t.length-1;r>=0;r--){var o=t[r];"."===o?t.splice(r,1):".."===o?(t.splice(r,1),n++):n&&(t.splice(r,1),n--)}if(e)for(;n--;n)t.unshift("..");return t}function r(t,e){if(t.filter)return t.filter(e);for(var n=[],r=0;r=-1&&!o;i--){var a=i>=0?arguments[i]:t.cwd();if("string"!=typeof a)throw new TypeError("Arguments to path.resolve must be strings");a&&(e=a+"/"+e,o="/"===a.charAt(0))}return(o?"/":"")+(e=n(r(e.split("/"),(function(t){return!!t})),!o).join("/"))||"."},e.normalize=function(t){var i=e.isAbsolute(t),a="/"===o(t,-1);return(t=n(r(t.split("/"),(function(t){return!!t})),!i).join("/"))||i||(t="."),t&&a&&(t+="/"),(i?"/":"")+t},e.isAbsolute=function(t){return"/"===t.charAt(0)},e.join=function(){var t=Array.prototype.slice.call(arguments,0);return e.normalize(r(t,(function(t,e){if("string"!=typeof t)throw new TypeError("Arguments to path.join must be strings");return t})).join("/"))},e.relative=function(t,n){function r(t){for(var e=0;e=0&&""===t[n];n--);return e>n?[]:t.slice(e,n-e+1)}t=e.resolve(t).substr(1),n=e.resolve(n).substr(1);for(var o=r(t.split("/")),i=r(n.split("/")),a=Math.min(o.length,i.length),u=a,s=0;s=1;--i)if(47===(e=t.charCodeAt(i))){if(!o){r=i;break}}else o=!1;return-1===r?n?"/":".":n&&1===r?"/":t.slice(0,r)},e.basename=function(t,e){var n=function(t){"string"!=typeof t&&(t+="");var e,n=0,r=-1,o=!0;for(e=t.length-1;e>=0;--e)if(47===t.charCodeAt(e)){if(!o){n=e+1;break}}else-1===r&&(o=!1,r=e+1);return-1===r?"":t.slice(n,r)}(t);return e&&n.substr(-1*e.length)===e&&(n=n.substr(0,n.length-e.length)),n},e.extname=function(t){"string"!=typeof t&&(t+="");for(var e=-1,n=0,r=-1,o=!0,i=0,a=t.length-1;a>=0;--a){var u=t.charCodeAt(a);if(47!==u)-1===r&&(o=!1,r=a+1),46===u?-1===e?e=a:1!==i&&(i=1):-1!==e&&(i=-1);else if(!o){n=a+1;break}}return-1===e||-1===r||0===i||1===i&&e===r-1&&e===n+1?"":t.slice(e,r)};var o="b"==="ab".substr(-1)?function(t,e,n){return t.substr(e,n)}:function(t,e,n){return e<0&&(e=t.length+e),t.substr(e,n)}}).call(this,n(24))},function(t,e){},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Clip=void 0;var r=function(){function t(){}return t.prototype.initialize=function(t){this.min=t.getFloat("min",-34028234663852886e22),this.max=t.getFloat("max",34028234663852886e22)},t.prototype.checkInputs=function(t){return!(!t||1!==t.length)&&this.checkInputTypes(t)},t.prototype.checkInputTypes=function(t){return"float32"===t[0].type||"float64"===t[0].type},t}();e.Clip=r},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getPackedShape=void 0,e.getPackedShape=function(t){var e=t.length;return t.slice(0,e-1).concat(t[e-1]/4)}},function(t,e,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n),Object.defineProperty(t,r,{enumerable:!0,get:function(){return e[n]}})}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),o=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),i=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.hasOwnProperty.call(t,n)&&r(e,t,n);return o(e,t),e},a=this&&this.__read||function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a},u=this&&this.__spread||function(){for(var t=[],e=0;e=e.dims[n])throw new RangeError("Input index array dims don't match the tensor dims.")}));var i=this.internalTensor.get(o);return"bool"===this.type?1===i:i},t.prototype.set=function(t,e){for(var n=this,r=[],o=2;o=n.dims[e])throw new RangeError("Input index array dims don't match the tensor dims.")})),"boolean"==typeof t?this.internalTensor.set(i,t?1:0):this.internalTensor.set(i,t)},t}();e.Tensor=c},function(t,e,n){"use strict";var r=this&&this.__values||function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(e,"__esModule",{value:!0}),e.validateIndices=e.matchElementType=e.toInternalTensor=e.fromInternalTensor=void 0;var o=n(1),i=n(51);e.fromInternalTensor=function(t){switch(t.type){case"bool":return new i.Tensor(new Uint8Array(t.integerData),"bool",t.dims);case"float32":return new i.Tensor(t.floatData,"float32",t.dims);case"float64":return new i.Tensor(new Float32Array(t.floatData),"float32",t.dims);case"string":return new i.Tensor(t.stringData,"string",t.dims);case"int8":return new i.Tensor(new Int32Array(t.integerData),"int32",t.dims);case"int32":return new i.Tensor(t.integerData,"int32",t.dims);default:throw new TypeError("Tensor type is not supported. ")}},e.toInternalTensor=function(t){return new o.Tensor(t.dims,t.type,void 0,void 0,t.data)},e.matchElementType=function(t,e){switch(typeof e){case"string":if("string"!==t)throw new TypeError("The new element type doesn't match the tensor data type.");break;case"number":if("float32"!==t&&"int32"!==t)throw new TypeError("The new element type doesn't match the tensor data type.");if("float32"===t&&Number.isInteger(e))throw new TypeError("The new element type doesn't match the tensor data type.");if("int32"===t&&!Number.isInteger(e))throw new TypeError("The new element type doesn't match the tensor data type.");break;case"boolean":if("bool"!==t)throw new TypeError("The new element type doesn't match the tensor data type.");break;default:throw new TypeError("The new element type is not supported.")}},e.validateIndices=function(t){var e,n;if(t.length<0||t.length>6)throw new RangeError("Only rank 0 to 6 is supported for tensor shape.");try{for(var o=r(t),i=o.next();!i.done;i=o.next()){var a=i.value;if(!Number.isInteger(a))throw new TypeError("Invalid index: "+a+" is not an integer");if(a<0||a>2147483647)throw new TypeError("Invalid index: length "+a+" is not allowed")}}catch(t){e={error:t}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(e)throw e.error}}}},function(t,e,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n),Object.defineProperty(t,r,{enumerable:!0,get:function(){return e[n]}})}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),o=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||e.hasOwnProperty(n)||r(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),e.ENV=e.backend=void 0;var i=n(54),a=n(101),u=n(119),s=n(168);o(n(169),e),o(n(170),e),o(n(171),e),o(n(172),e),e.backend={cpu:new i.CpuBackend,wasm:new a.WasmBackend,webgl:new u.WebGLBackend},e.ENV=s.envImpl},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CpuBackend=void 0;var r=n(55),o=function(){function t(){}return t.prototype.initialize=function(){return!0},t.prototype.createSessionHandler=function(t){return new r.CpuSessionHandler(this,t)},t.prototype.dispose=function(){},t}();e.CpuBackend=o},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CpuSessionHandler=void 0;var r=n(11),o=n(56),i=n(27),a=function(){function t(t,e){this.backend=t,this.context=e}return t.prototype.createInferenceHandler=function(){return new o.CpuInferenceHandler(this,this.context.profiler)},t.prototype.dispose=function(){},t.prototype.resolve=function(t,e){var n=r.resolveOperator(t,e,i.CPU_OP_RESOLVE_RULES);return n.initialize(t.attributes),n},t}();e.CpuSessionHandler=a},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CpuInferenceHandler=void 0;var r=function(){function t(t,e){this.session=t,this.profiler=e}return t.prototype.dispose=function(){},t}();e.CpuInferenceHandler=r},function(t,e,n){"use strict";var r,o=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0}),e.argMax=e.CpuArgMax=void 0;var i=n(58),a=n(1),u=n(0),s=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.run=function(t,e){return[l(e[0],this.axis,this.keepDims)]},e}(i.ArgMax);function l(t,e,n){var r=t.dims?t.dims.length:1;e=u.ShapeUtil.normalizeAxis(e,r);for(var o=u.ReduceUtil.calcReduceShape(t.dims,[e],!0),i=t.data,s=new Int32Array(u.ShapeUtil.size(o)),l=u.ShapeUtil.sizeFromDimension(t.dims,e+1),c=u.ShapeUtil.computeStrides(o),f=u.ShapeUtil.computeStrides(t.dims),p=new Array(t.dims.length),h=0;hg&&(g=b,m=v)}s[h]=m}return new a.Tensor(n?o:u.ReduceUtil.calcReduceShape(t.dims,[e],n),"int32",void 0,void 0,s)}e.CpuArgMax=s,e.argMax=l},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ArgMax=void 0;var r=n(7),o=function(){function t(){}return t.prototype.initialize=function(t){this.axis=t.getInt("axis",0),this.keepDims=1===t.getInt("keepdims",1)},t.prototype.checkInputs=function(t){return!(!t||1!==t.length)&&this.checkInputTypes(t)},t.prototype.checkInputTypes=function(t){return-1!==r.NUMBER_TYPES.indexOf(t[0].type)},t}();e.ArgMax=o},function(t,e,n){"use strict";e.byteLength=function(t){var e=l(t),n=e[0],r=e[1];return 3*(n+r)/4-r},e.toByteArray=function(t){var e,n,r=l(t),a=r[0],u=r[1],s=new i(function(t,e,n){return 3*(e+n)/4-n}(0,a,u)),c=0,f=u>0?a-4:a;for(n=0;n>16&255,s[c++]=e>>8&255,s[c++]=255&e;2===u&&(e=o[t.charCodeAt(n)]<<2|o[t.charCodeAt(n+1)]>>4,s[c++]=255&e);1===u&&(e=o[t.charCodeAt(n)]<<10|o[t.charCodeAt(n+1)]<<4|o[t.charCodeAt(n+2)]>>2,s[c++]=e>>8&255,s[c++]=255&e);return s},e.fromByteArray=function(t){for(var e,n=t.length,o=n%3,i=[],a=0,u=n-o;au?u:a+16383));1===o?(e=t[n-1],i.push(r[e>>2]+r[e<<4&63]+"==")):2===o&&(e=(t[n-2]<<8)+t[n-1],i.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"="));return i.join("")};for(var r=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=0,s=a.length;u0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}function c(t,e,n){for(var o,i,a=[],u=e;u>18&63]+r[i>>12&63]+r[i>>6&63]+r[63&i]);return a.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},function(t,e){e.read=function(t,e,n,r,o){var i,a,u=8*o-r-1,s=(1<>1,c=-7,f=n?o-1:0,p=n?-1:1,h=t[e+f];for(f+=p,i=h&(1<<-c)-1,h>>=-c,c+=u;c>0;i=256*i+t[e+f],f+=p,c-=8);for(a=i&(1<<-c)-1,i>>=-c,c+=r;c>0;a=256*a+t[e+f],f+=p,c-=8);if(0===i)i=1-l;else{if(i===s)return a?NaN:1/0*(h?-1:1);a+=Math.pow(2,r),i-=l}return(h?-1:1)*a*Math.pow(2,i-r)},e.write=function(t,e,n,r,o,i){var a,u,s,l=8*i-o-1,c=(1<>1,p=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,h=r?0:i-1,d=r?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(u=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(s=Math.pow(2,-a))<1&&(a--,s*=2),(e+=a+f>=1?p/s:p*Math.pow(2,1-f))*s>=2&&(a++,s/=2),a+f>=c?(u=0,a=c):a+f>=1?(u=(e*s-1)*Math.pow(2,o),a+=f):(u=e*Math.pow(2,f-1)*Math.pow(2,o),a=0));o>=8;t[n+h]=255&u,h+=d,u/=256,o-=8);for(a=a<0;t[n+h]=255&a,h+=d,a/=256,l-=8);t[n+h-d]|=128*y}},function(t,e){var n={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},function(t,e,n){"use strict";t.exports=n(63)},function(t,e,n){"use strict";var r=e;function o(){r.util._configure(),r.Writer._configure(r.BufferWriter),r.Reader._configure(r.BufferReader)}r.build="minimal",r.Writer=n(28),r.BufferWriter=n(72),r.Reader=n(29),r.BufferReader=n(73),r.util=n(6),r.rpc=n(74),r.roots=n(76),r.configure=o,o()},function(t,e,n){"use strict";t.exports=function(t,e){var n=new Array(arguments.length-1),r=0,o=2,i=!0;for(;o1&&"="===t.charAt(e);)++n;return Math.ceil(3*t.length)/4-n};for(var o=new Array(64),i=new Array(123),a=0;a<64;)i[o[a]=a<26?a+65:a<52?a+71:a<62?a-4:a-59|43]=a++;r.encode=function(t,e,n){for(var r,i=null,a=[],u=0,s=0;e>2],r=(3&l)<<4,s=1;break;case 1:a[u++]=o[r|l>>4],r=(15&l)<<2,s=2;break;case 2:a[u++]=o[r|l>>6],a[u++]=o[63&l],s=0}u>8191&&((i||(i=[])).push(String.fromCharCode.apply(String,a)),u=0)}return s&&(a[u++]=o[r],a[u++]=61,1===s&&(a[u++]=61)),i?(u&&i.push(String.fromCharCode.apply(String,a.slice(0,u))),i.join("")):String.fromCharCode.apply(String,a.slice(0,u))};r.decode=function(t,e,n){for(var r,o=n,a=0,u=0;u1)break;if(void 0===(s=i[s]))throw Error("invalid encoding");switch(a){case 0:r=s,a=1;break;case 1:e[n++]=r<<2|(48&s)>>4,r=s,a=2;break;case 2:e[n++]=(15&r)<<4|(60&s)>>2,r=s,a=3;break;case 3:e[n++]=(3&r)<<6|s,a=0}}if(1===a)throw Error("invalid encoding");return n-o},r.test=function(t){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t)}},function(t,e,n){"use strict";function r(){this._listeners={}}t.exports=r,r.prototype.on=function(t,e,n){return(this._listeners[t]||(this._listeners[t]=[])).push({fn:e,ctx:n||this}),this},r.prototype.off=function(t,e){if(void 0===t)this._listeners={};else if(void 0===e)this._listeners[t]=[];else for(var n=this._listeners[t],r=0;r0?0:2147483648,n,r);else if(isNaN(e))t(2143289344,n,r);else if(e>34028234663852886e22)t((o<<31|2139095040)>>>0,n,r);else if(e<11754943508222875e-54)t((o<<31|Math.round(e/1401298464324817e-60))>>>0,n,r);else{var i=Math.floor(Math.log(e)/Math.LN2);t((o<<31|i+127<<23|8388607&Math.round(e*Math.pow(2,-i)*8388608))>>>0,n,r)}}function n(t,e,n){var r=t(e,n),o=2*(r>>31)+1,i=r>>>23&255,a=8388607&r;return 255===i?a?NaN:o*(1/0):0===i?1401298464324817e-60*o*a:o*Math.pow(2,i-150)*(a+8388608)}t.writeFloatLE=e.bind(null,o),t.writeFloatBE=e.bind(null,i),t.readFloatLE=n.bind(null,a),t.readFloatBE=n.bind(null,u)}(),"undefined"!=typeof Float64Array?function(){var e=new Float64Array([-0]),n=new Uint8Array(e.buffer),r=128===n[7];function o(t,r,o){e[0]=t,r[o]=n[0],r[o+1]=n[1],r[o+2]=n[2],r[o+3]=n[3],r[o+4]=n[4],r[o+5]=n[5],r[o+6]=n[6],r[o+7]=n[7]}function i(t,r,o){e[0]=t,r[o]=n[7],r[o+1]=n[6],r[o+2]=n[5],r[o+3]=n[4],r[o+4]=n[3],r[o+5]=n[2],r[o+6]=n[1],r[o+7]=n[0]}function a(t,r){return n[0]=t[r],n[1]=t[r+1],n[2]=t[r+2],n[3]=t[r+3],n[4]=t[r+4],n[5]=t[r+5],n[6]=t[r+6],n[7]=t[r+7],e[0]}function u(t,r){return n[7]=t[r],n[6]=t[r+1],n[5]=t[r+2],n[4]=t[r+3],n[3]=t[r+4],n[2]=t[r+5],n[1]=t[r+6],n[0]=t[r+7],e[0]}t.writeDoubleLE=r?o:i,t.writeDoubleBE=r?i:o,t.readDoubleLE=r?a:u,t.readDoubleBE=r?u:a}():function(){function e(t,e,n,r,o,i){var a=r<0?1:0;if(a&&(r=-r),0===r)t(0,o,i+e),t(1/r>0?0:2147483648,o,i+n);else if(isNaN(r))t(0,o,i+e),t(2146959360,o,i+n);else if(r>17976931348623157e292)t(0,o,i+e),t((a<<31|2146435072)>>>0,o,i+n);else{var u;if(r<22250738585072014e-324)t((u=r/5e-324)>>>0,o,i+e),t((a<<31|u/4294967296)>>>0,o,i+n);else{var s=Math.floor(Math.log(r)/Math.LN2);1024===s&&(s=1023),t(4503599627370496*(u=r*Math.pow(2,-s))>>>0,o,i+e),t((a<<31|s+1023<<20|1048576*u&1048575)>>>0,o,i+n)}}}function n(t,e,n,r,o){var i=t(r,o+e),a=t(r,o+n),u=2*(a>>31)+1,s=a>>>20&2047,l=4294967296*(1048575&a)+i;return 2047===s?l?NaN:u*(1/0):0===s?5e-324*u*l:u*Math.pow(2,s-1075)*(l+4503599627370496)}t.writeDoubleLE=e.bind(null,o,0,4),t.writeDoubleBE=e.bind(null,i,4,0),t.readDoubleLE=n.bind(null,a,0,4),t.readDoubleBE=n.bind(null,u,4,0)}(),t}function o(t,e,n){e[n]=255&t,e[n+1]=t>>>8&255,e[n+2]=t>>>16&255,e[n+3]=t>>>24}function i(t,e,n){e[n]=t>>>24,e[n+1]=t>>>16&255,e[n+2]=t>>>8&255,e[n+3]=255&t}function a(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24)>>>0}function u(t,e){return(t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3])>>>0}t.exports=r(r)},function(module,exports,__webpack_require__){"use strict";function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(t){}return null}module.exports=inquire},function(t,e,n){"use strict";var r=e;r.length=function(t){for(var e=0,n=0,r=0;r191&&r<224?i[a++]=(31&r)<<6|63&t[e++]:r>239&&r<365?(r=((7&r)<<18|(63&t[e++])<<12|(63&t[e++])<<6|63&t[e++])-65536,i[a++]=55296+(r>>10),i[a++]=56320+(1023&r)):i[a++]=(15&r)<<12|(63&t[e++])<<6|63&t[e++],a>8191&&((o||(o=[])).push(String.fromCharCode.apply(String,i)),a=0);return o?(a&&o.push(String.fromCharCode.apply(String,i.slice(0,a))),o.join("")):String.fromCharCode.apply(String,i.slice(0,a))},r.write=function(t,e,n){for(var r,o,i=n,a=0;a>6|192,e[n++]=63&r|128):55296==(64512&r)&&56320==(64512&(o=t.charCodeAt(a+1)))?(r=65536+((1023&r)<<10)+(1023&o),++a,e[n++]=r>>18|240,e[n++]=r>>12&63|128,e[n++]=r>>6&63|128,e[n++]=63&r|128):(e[n++]=r>>12|224,e[n++]=r>>6&63|128,e[n++]=63&r|128);return n-i}},function(t,e,n){"use strict";t.exports=function(t,e,n){var r=n||8192,o=r>>>1,i=null,a=r;return function(n){if(n<1||n>o)return t(n);a+n>r&&(i=t(r),a=0);var u=e.call(i,a,a+=n);return 7&a&&(a=1+(7|a)),u}}},function(t,e,n){"use strict";t.exports=o;var r=n(6);function o(t,e){this.lo=t>>>0,this.hi=e>>>0}var i=o.zero=new o(0,0);i.toNumber=function(){return 0},i.zzEncode=i.zzDecode=function(){return this},i.length=function(){return 1};var a=o.zeroHash="\0\0\0\0\0\0\0\0";o.fromNumber=function(t){if(0===t)return i;var e=t<0;e&&(t=-t);var n=t>>>0,r=(t-n)/4294967296>>>0;return e&&(r=~r>>>0,n=~n>>>0,++n>4294967295&&(n=0,++r>4294967295&&(r=0))),new o(n,r)},o.from=function(t){if("number"==typeof t)return o.fromNumber(t);if(r.isString(t)){if(!r.Long)return o.fromNumber(parseInt(t,10));t=r.Long.fromString(t)}return t.low||t.high?new o(t.low>>>0,t.high>>>0):i},o.prototype.toNumber=function(t){if(!t&&this.hi>>>31){var e=1+~this.lo>>>0,n=~this.hi>>>0;return e||(n=n+1>>>0),-(e+4294967296*n)}return this.lo+4294967296*this.hi},o.prototype.toLong=function(t){return r.Long?new r.Long(0|this.lo,0|this.hi,Boolean(t)):{low:0|this.lo,high:0|this.hi,unsigned:Boolean(t)}};var u=String.prototype.charCodeAt;o.fromHash=function(t){return t===a?i:new o((u.call(t,0)|u.call(t,1)<<8|u.call(t,2)<<16|u.call(t,3)<<24)>>>0,(u.call(t,4)|u.call(t,5)<<8|u.call(t,6)<<16|u.call(t,7)<<24)>>>0)},o.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},o.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},o.prototype.zzDecode=function(){var t=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this},o.prototype.length=function(){var t=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return 0===n?0===e?t<16384?t<128?1:2:t<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:n<128?9:10}},function(t,e,n){"use strict";t.exports=i;var r=n(28);(i.prototype=Object.create(r.prototype)).constructor=i;var o=n(6);function i(){r.call(this)}function a(t,e,n){t.length<40?o.utf8.write(t,e,n):e.utf8Write?e.utf8Write(t,n):e.write(t,n)}i._configure=function(){i.alloc=o._Buffer_allocUnsafe,i.writeBytesBuffer=o.Buffer&&o.Buffer.prototype instanceof Uint8Array&&"set"===o.Buffer.prototype.set.name?function(t,e,n){e.set(t,n)}:function(t,e,n){if(t.copy)t.copy(e,n,0,t.length);else for(var r=0;r>>0;return this.uint32(e),e&&this._push(i.writeBytesBuffer,e,t),this},i.prototype.string=function(t){var e=o.Buffer.byteLength(t);return this.uint32(e),e&&this._push(a,e,t),this},i._configure()},function(t,e,n){"use strict";t.exports=i;var r=n(29);(i.prototype=Object.create(r.prototype)).constructor=i;var o=n(6);function i(t){r.call(this,t)}i._configure=function(){o.Buffer&&(i.prototype._slice=o.Buffer.prototype.slice)},i.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))},i._configure()},function(t,e,n){"use strict";e.Service=n(75)},function(t,e,n){"use strict";t.exports=o;var r=n(6);function o(t,e,n){if("function"!=typeof t)throw TypeError("rpcImpl must be a function");r.EventEmitter.call(this),this.rpcImpl=t,this.requestDelimited=Boolean(e),this.responseDelimited=Boolean(n)}(o.prototype=Object.create(r.EventEmitter.prototype)).constructor=o,o.prototype.rpcCall=function t(e,n,o,i,a){if(!i)throw TypeError("request must be specified");var u=this;if(!a)return r.asPromise(t,u,e,n,o,i);if(u.rpcImpl)try{return u.rpcImpl(e,n[u.requestDelimited?"encodeDelimited":"encode"](i).finish(),(function(t,n){if(t)return u.emit("error",t,e),a(t);if(null!==n){if(!(n instanceof o))try{n=o[u.responseDelimited?"decodeDelimited":"decode"](n)}catch(t){return u.emit("error",t,e),a(t)}return u.emit("data",n,e),a(null,n)}u.end(!0)}))}catch(t){return u.emit("error",t,e),void setTimeout((function(){a(t)}),0)}else setTimeout((function(){a(Error("already ended"))}),0)},o.prototype.end=function(t){return this.rpcImpl&&(t||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}},function(t,e,n){"use strict";t.exports={}},function(t,e,n){"use strict";var r,o=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0}),e.batchNormalization=e.CpuBatchNormalization=void 0;var i=n(14),a=n(1),u=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.run=function(t,e){return[s(e[0],e[1],e[2],e[3],e[4],this.epsilon,this.momentum,this.spatial)]},e}(i.BatchNormalization);function s(t,e,n,r,o,i,u,s){for(var l=t.dims,c=l[0],f=l[1],p=1,h=2;h=r.length||e<-1*r.length)throw new Error("axis specified for concat doesn't match input dimensionality");e<0&&(e=r.length+e);for(var o=r[e],i=new Array(r.length),a=1;a=e;a--)h*=i[a];for(var d=0,y=0;y=e;a--)m*=g.dims[a];for(var v=g.numberData,b=c.ShapeUtil.size(g.dims),_=d,w=(a=0,0);a=0&&P=0&&A0)&&!(r=i.next()).done;)a.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a};Object.defineProperty(e,"__esModule",{value:!0}),e.gemm=e.CpuGemm=void 0;var l=n(19),c=n(1),f=u(n(0)),p=n(17),h=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.run=function(t,e){return[d(e[0],e[1],this.alpha,this.beta,this.transA,this.transB,3===e.length?e[2]:void 0)]},e}(l.Gemm);function d(t,e,n,r,o,i,a){var u=s(f.GemmUtil.getShapeOfGemmResult(t.dims,o,e.dims,i,null==a?void 0:a.dims),3),l=u[0],h=u[1],d=u[2],y=new c.Tensor([l,h],t.type);if(a&&f.BroadcastUtil.calc(y,a,(function(t,e){return e}),!0)!==y)throw new Error("tensor C is not broadcastable to [M,N]");return p.matMul2d(t.floatData,e.floatData,y.floatData,o,i,n,r,l,h,d),y}e.CpuGemm=h,e.gemm=d},function(t,e,n){"use strict";var r,o=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),i=this&&this.__read||function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a};Object.defineProperty(e,"__esModule",{value:!0}),e.imageScaler=e.CpuImageScaler=void 0;var a=n(34),u=n(1),s=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.run=function(t,e){return[l(e[0],this.bias,this.scale)]},e}(a.ImageScaler);function l(t,e,n){for(var r=i(t.dims,4),o=r[0],a=r[1],s=r[2],l=r[3],c=new u.Tensor([o,a,s,l],t.type),f=t.floatData,p=c.floatData,h=0;h0)&&!(r=i.next()).done;)a.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a},a=this&&this.__spread||function(){for(var t=[],e=0;e=e.dims[E]||T[E]<0){P++,A=!0;break}S=A?S:c(S,e.get(T))}S=f(S,r?h:h-P),v.set(w,S)}return v}e.CpuGlobalMaxPool=f,e.averagePool=p,e.globalAveragePool=h,e.maxPool=d,e.globalMaxPool=y,e.pool=g},function(t,e,n){"use strict";var r,o=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0}),e.reduceProd=e.reduceMean=e.reduceMin=e.reduceMax=e.reduceLogSum=e.reduceSumSquare=e.reduceSum=e.CpuReduceProd=e.CpuReduceMean=e.CpuReduceMin=e.CpuReduceMax=e.CpuReduceLogSum=e.CpuReduceSumSquare=e.CpuReduceSum=void 0;var i=n(36),a=n(0),u=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.run=function(t,e){return[d(e[0],a.ShapeUtil.normalizeAxes(this.axes,e[0].dims.length),this.keepDims)]},e}(i.ReduceBase);e.CpuReduceSum=u;var s=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.run=function(t,e){return[y(e[0],a.ShapeUtil.normalizeAxes(this.axes,e[0].dims.length),this.keepDims)]},e}(i.ReduceBase);e.CpuReduceSumSquare=s;var l=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.run=function(t,e){return[g(e[0],a.ShapeUtil.normalizeAxes(this.axes,e[0].dims.length),this.keepDims)]},e}(i.ReduceBase);e.CpuReduceLogSum=l;var c=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.run=function(t,e){return[m(e[0],a.ShapeUtil.normalizeAxes(this.axes,e[0].dims.length),this.keepDims)]},e}(i.ReduceBase);e.CpuReduceMax=c;var f=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.run=function(t,e){return[v(e[0],a.ShapeUtil.normalizeAxes(this.axes,e[0].dims.length),this.keepDims)]},e}(i.ReduceBase);e.CpuReduceMin=f;var p=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.run=function(t,e){return[b(e[0],a.ShapeUtil.normalizeAxes(this.axes,e[0].dims.length),this.keepDims)]},e}(i.ReduceBase);e.CpuReduceMean=p;var h=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.run=function(t,e){return[_(e[0],a.ShapeUtil.normalizeAxes(this.axes,e[0].dims.length),this.keepDims)]},e}(i.ReduceBase);function d(t,e,n){return a.ReduceUtil.calcReduce(t,e,n,(function(t){return t}),(function(t,e){return t+e}))}function y(t,e,n){return a.ReduceUtil.calcReduce(t,e,n,(function(t){return t*t}),(function(t,e){return t+e}))}function g(t,e,n){for(var r=a.ReduceUtil.calcReduce(t,e,n,(function(t){return t}),(function(t,e){return t+e})),o=r.floatData.length,i=0;i=5&&e[4].integerData.some((function(t){return 1!==t})))throw new Error("currently non-1 steps is not supported for Slice");var n=Array.from(e[1].integerData),r=Array.from(e[2].integerData),o=e.length>=4?Array.from(e[3].integerData):[];return[c(e[0],n,r,o)]},e}(i.SliceV10);function c(t,e,n,r){0===r.length&&(r=t.dims.map((function(t,e){return e}))),r=u.ShapeUtil.normalizeAxes(r,t.dims.length),e=e.map((function(e,n){return e>t.dims[r[n]]-1?t.dims[r[n]]:u.ShapeUtil.normalizeAxis(e,t.dims[r[n]])})),n=n.map((function(e,n){return e>t.dims[r[n]]-1?t.dims[r[n]]:u.ShapeUtil.normalizeAxis(e,t.dims[r[n]])}));var o=[],i=[];r.forEach((function(t,r){o[t]=n[r]-e[r],i[t]=e[r]}));for(var s=0;sh&&(h=a[p+d]);var y=0;for(d=0;d=0;--i){var w=o[i];_&&w===i?v*=n[w]:(_=!1,b*=n[w],++m)}return 1===b?(f=v,p=g,h=y,u.arrayCopyHelper(p,h,0,0,f)):1===v?function(t,e,n,r,o,i){for(var a=new Array(t).fill(0),s=0,l=0;l=0;l--)u[l]=u[l+1]*n[l+1];var c=new Array(i);c.fill(0),c[i-1]=-1;for(var f=0,p=0;f=0;h--){if(++c[h]0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]this.numBytesAllocated&&this.expandMemory(l),t.ccallSerialize(r.HEAPU8.subarray(this.ptr8,this.ptr8+l),s,i);var c=e.now();this.func(n,this.ptr8);var f=e.now();t.ccallDeserialize(r.HEAPU8.subarray(this.ptr8,this.ptr8+l),s,i);var p=e.now();return{startTime:u,endTime:p,startTimeFunc:c,endTimeFunc:f}},t.prototype.ccallRaw=function(t,n){if(!o)throw new Error("wasm not initialized. please ensure 'init()' is called.");var i=e.now(),a=n.byteLength;a>this.numBytesAllocated&&this.expandMemory(a),r.HEAPU8.subarray(this.ptr8,this.ptr8+a).set(n);var u=e.now();this.func(t,this.ptr8);var s=e.now();return n.set(r.HEAPU8.subarray(this.ptr8,this.ptr8+a)),{startTime:i,endTime:e.now(),startTimeFunc:u,endTimeFunc:s}},t.prototype.func=function(t,e){(0,r[t])(e)},t.calculateOffsets=function(t,e){for(var n=4+4*e.length,r=0;r>2;if(o[a+1]=f,"out"!==c&&0!==f)switch(l){case"bool":t[f]=!0===s?1:0;break;case"int32":r[p]=s;break;case"float32":i[p]=s;break;case"boolptr":var h=s;t.subarray(f,f+h.length).set(s);break;case"int32ptr":var d=s;r.subarray(p,p+d.length).set(d);break;case"float32ptr":var y=s;i.subarray(p,p+y.length).set(y);break;default:throw new Error("not supported parameter type: "+l)}}},t.ccallDeserialize=function(t,e,n){for(var r=new Float32Array(t.buffer,t.byteOffset),o=new Uint8Array(t.buffer,t.byteOffset),i=0;i>2;if("out"===l||"inout"===l)switch(s){case"float32ptr":var p=u;p.set(r.subarray(f,f+p.length));break;case"boolptr":var h=u;h.set(o.subarray(c,c+h.length));break;default:throw new Error("not supported parameter type: "+s)}}},t.prototype.expandMemory=function(t){if(0!==this.ptr8&&r._free(this.ptr8),this.numBytesAllocated=2*t,this.ptr8=r._malloc(this.numBytesAllocated),0===this.ptr8)throw new Error("Unable to allocate requested amount of memory. Failing.")},t.prototype.dispose=function(){if(!o)throw new Error("wasm not initialized. please ensure 'init()' is called.");0!==this.ptr8&&r._free(this.ptr8)},t}();e.WasmBinding=a,e.now="undefined"!=typeof performance&&performance.now?function(){return performance.now()}:Date.now},function(t,e,n){(function(e,r,o){var i,a=(i=(i="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0)||e,function(t){t=void 0!==(t=t||{})?t:{};var e,a={};for(e in t)t.hasOwnProperty(e)&&(a[e]=t[e]);var u=[],s=!1,l=!1,c=!1,f=!1;s="object"==typeof window,l="function"==typeof importScripts,c="object"==typeof r&&"object"==typeof r.versions&&"string"==typeof r.versions.node,f=!s&&!c&&!l;var p,h,d,y,g="";function m(e){return t.locateFile?t.locateFile(e,g):g+e}c?(g=l?n(47).dirname(g)+"/":o+"/",p=function(t,e){return d||(d=n(48)),y||(y=n(47)),t=y.normalize(t),d.readFileSync(t,e?null:"utf8")},h=function(t){var e=p(t,!0);return e.buffer||(e=new Uint8Array(e)),S(e.buffer),e},r.argv.length>1&&r.argv[1].replace(/\\/g,"/"),u=r.argv.slice(2),r.on("uncaughtException",(function(t){if(!(t instanceof Lt))throw t})),r.on("unhandledRejection",et),t.inspect=function(){return"[Emscripten Module object]"}):f?("undefined"!=typeof read&&(p=function(t){return read(t)}),h=function(t){var e;return"function"==typeof readbuffer?new Uint8Array(readbuffer(t)):(S("object"==typeof(e=read(t,"binary"))),e)},"undefined"!=typeof scriptArgs?u=scriptArgs:void 0!==arguments&&(u=arguments),"undefined"!=typeof print&&("undefined"==typeof console&&(console={}),console.log=print,console.warn=console.error="undefined"!=typeof printErr?printErr:print)):(s||l)&&(l?g=self.location.href:document.currentScript&&(g=document.currentScript.src),i&&(g=i),g=0!==g.indexOf("blob:")?g.substr(0,g.lastIndexOf("/")+1):"",p=function(t){var e=new XMLHttpRequest;return e.open("GET",t,!1),e.send(null),e.responseText},l&&(h=function(t){var e=new XMLHttpRequest;return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)}));var v=t.print||console.log.bind(console),b=t.printErr||console.warn.bind(console);for(e in a)a.hasOwnProperty(e)&&(t[e]=a[e]);a=null,t.arguments&&(u=t.arguments),t.thisProgram&&t.thisProgram,t.quit&&t.quit;var _,w,x=function(t){};t.wasmBinary&&(_=t.wasmBinary),t.noExitRuntime&&t.noExitRuntime,"object"!=typeof WebAssembly&&b("no native wasm support detected");var T=new WebAssembly.Table({initial:31,maximum:31,element:"anyfunc"}),O=!1;function S(t,e){t||et("Assertion failed: "+e)}var P="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function A(t,e,n){for(var r=e+n,o=e;t[o]&&!(o>=r);)++o;if(o-e>16&&t.subarray&&P)return P.decode(t.subarray(e,o));for(var i="";e>10,56320|1023&l)}}else i+=String.fromCharCode((31&a)<<6|u)}else i+=String.fromCharCode(a)}return i}function D(t,e){return t?A(I,t,e):""}"undefined"!=typeof TextDecoder&&new TextDecoder("utf-16le");var E,I,L,M=65536;function j(t,e){return t%e>0&&(t+=e-t%e),t}function k(e){E=e,t.HEAP8=new Int8Array(e),t.HEAP16=new Int16Array(e),t.HEAP32=L=new Int32Array(e),t.HEAPU8=I=new Uint8Array(e),t.HEAPU16=new Uint16Array(e),t.HEAPU32=new Uint32Array(e),t.HEAPF32=new Float32Array(e),t.HEAPF64=new Float64Array(e)}var C=5248800,R=5760,N=t.INITIAL_MEMORY||16777216;function B(e){for(;e.length>0;){var n=e.shift();if("function"!=typeof n){var r=n.func;"number"==typeof r?void 0===n.arg?t.dynCall_v(r):t.dynCall_vi(r,n.arg):r(void 0===n.arg?null:n.arg)}else n()}}(w=t.wasmMemory?t.wasmMemory:new WebAssembly.Memory({initial:N/M}))&&(E=w.buffer),N=E.byteLength,k(E),L[R>>2]=C;var F=[],U=[],G=[],z=[],W=[];function V(){if(t.preRun)for("function"==typeof t.preRun&&(t.preRun=[t.preRun]);t.preRun.length;)X(t.preRun.shift());B(F)}function q(){B(U)}function H(){B(G)}function Y(){if(t.postRun)for("function"==typeof t.postRun&&(t.postRun=[t.postRun]);t.postRun.length;)K(t.postRun.shift());B(W)}function X(t){F.unshift(t)}function K(t){W.unshift(t)}Math.abs,Math.ceil,Math.floor,Math.min;var J=0,$=null,Z=null;function Q(e){J++,t.monitorRunDependencies&&t.monitorRunDependencies(J)}function tt(e){if(J--,t.monitorRunDependencies&&t.monitorRunDependencies(J),0==J&&(null!==$&&(clearInterval($),$=null),Z)){var n=Z;Z=null,n()}}function et(e){throw t.onAbort&&t.onAbort(e),v(e+=""),b(e),O=!0,e="abort("+e+"). Build with -s ASSERTIONS=1 for more info.",new WebAssembly.RuntimeError(e)}t.preloadedImages={},t.preloadedAudios={};var nt="data:application/octet-stream;base64,";function rt(t){return String.prototype.startsWith?t.startsWith(nt):0===t.indexOf(nt)}var ot="onnx-wasm.wasm";function it(){try{if(_)return new Uint8Array(_);if(h)return h(ot);throw"both async and sync fetching of the wasm failed"}catch(t){et(t)}}function at(){return _||!s&&!l||"function"!=typeof fetch?new Promise((function(t,e){t(it())})):fetch(ot,{credentials:"same-origin"}).then((function(t){if(!t.ok)throw"failed to load wasm binary file at '"+ot+"'";return t.arrayBuffer()})).catch((function(){return it()}))}function ut(){var e={env:St,wasi_snapshot_preview1:St};function n(e,n){var r=e.exports;t.asm=r,tt()}function r(t){n(t.instance)}function o(t){return at().then((function(t){return WebAssembly.instantiate(t,e)})).then(t,(function(t){b("failed to asynchronously prepare wasm: "+t),et(t)}))}if(Q(),t.instantiateWasm)try{return t.instantiateWasm(e,n)}catch(t){return b("Module.instantiateWasm callback failed with error: "+t),!1}return function(){if(_||"function"!=typeof WebAssembly.instantiateStreaming||rt(ot)||"function"!=typeof fetch)return o(r);fetch(ot,{credentials:"same-origin"}).then((function(t){return WebAssembly.instantiateStreaming(t,e).then(r,(function(t){b("wasm streaming compile failed: "+t),b("falling back to ArrayBuffer instantiation"),o(r)}))}))}(),{}}function st(t,e,n,r){et("Assertion failed: "+D(t)+", at: "+[e?D(e):"unknown filename",n,r?D(r):"unknown function"])}function lt(t){return Et(t)}rt(ot)||(ot=m(ot)),U.push({func:function(){Dt()}});var ct={};function ft(){return ft.uncaught_exceptions>0}function pt(t,e,n){throw ct[t]={ptr:t,adjusted:[t],type:e,destructor:n,refcount:0,caught:!1,rethrown:!1},"uncaught_exception"in ft?ft.uncaught_exceptions++:ft.uncaught_exceptions=1,t}function ht(){et()}function dt(){return I.length}function yt(){return 5760}function gt(t,e,n){I.copyWithin(t,e,e+n)}function mt(t){try{return w.grow(t-E.byteLength+65535>>16),k(w.buffer),1}catch(t){}}function vt(t){var e=dt();if(t>2147418112)return!1;for(var n=1;n<=4;n*=2){var r=e*(1+.2/n);if(r=Math.min(r,t+100663296),mt(Math.min(2147418112,j(Math.max(16777216,t,r),65536))))return!0}return!1}var bt={mappings:{},buffers:[null,[],[]],printChar:function(t,e){var n=bt.buffers[t];0===e||10===e?((1===t?v:b)(A(n,0)),n.length=0):n.push(e)},varargs:void 0,get:function(){return bt.varargs+=4,L[bt.varargs-4>>2]},getStr:function(t){return D(t)},get64:function(t,e){return t}};function _t(t){return 0}function wt(t,e,n,r,o){}function xt(){void 0!==It&&It(0);var t=bt.buffers;t[1].length&&bt.printChar(1,10),t[2].length&&bt.printChar(2,10)}function Tt(t,e,n,r){for(var o=0,i=0;i>2],u=L[e+(8*i+4)>>2],s=0;s>2]=o,0}function Ot(t){x(0|t)}z.push(xt);var St={__assert_fail:st,__cxa_allocate_exception:lt,__cxa_throw:pt,abort:ht,emscripten_get_sbrk_ptr:yt,emscripten_memcpy_big:gt,emscripten_resize_heap:vt,fd_close:_t,fd_seek:wt,fd_write:Tt,memory:w,setTempRet0:Ot,table:T},Pt=ut();t.asm=Pt;var At,Dt=t.___wasm_call_ctors=function(){return(Dt=t.___wasm_call_ctors=t.asm.__wasm_call_ctors).apply(null,arguments)},Et=(t._batch_normalization_f32=function(){return(t._batch_normalization_f32=t.asm.batch_normalization_f32).apply(null,arguments)},t._add_f32=function(){return(t._add_f32=t.asm.add_f32).apply(null,arguments)},t._sub_f32=function(){return(t._sub_f32=t.asm.sub_f32).apply(null,arguments)},t._mul_f32=function(){return(t._mul_f32=t.asm.mul_f32).apply(null,arguments)},t._div_f32=function(){return(t._div_f32=t.asm.div_f32).apply(null,arguments)},t._prelu_f32=function(){return(t._prelu_f32=t.asm.prelu_f32).apply(null,arguments)},t._xor_u8=function(){return(t._xor_u8=t.asm.xor_u8).apply(null,arguments)},t._or_u8=function(){return(t._or_u8=t.asm.or_u8).apply(null,arguments)},t._and_u8=function(){return(t._and_u8=t.asm.and_u8).apply(null,arguments)},t._clip_f32=function(){return(t._clip_f32=t.asm.clip_f32).apply(null,arguments)},t._conv_f32=function(){return(t._conv_f32=t.asm.conv_f32).apply(null,arguments)},t._gemm_f32=function(){return(t._gemm_f32=t.asm.gemm_f32).apply(null,arguments)},t._free=function(){return(t._free=t.asm.free).apply(null,arguments)},t._malloc=function(){return(Et=t._malloc=t.asm.malloc).apply(null,arguments)}),It=(t._instance_normalization_f32=function(){return(t._instance_normalization_f32=t.asm.instance_normalization_f32).apply(null,arguments)},t._matmul_f32=function(){return(t._matmul_f32=t.asm.matmul_f32).apply(null,arguments)},t._average_pool_f32=function(){return(t._average_pool_f32=t.asm.average_pool_f32).apply(null,arguments)},t._max_pool_f32=function(){return(t._max_pool_f32=t.asm.max_pool_f32).apply(null,arguments)},t._softmax_f32=function(){return(t._softmax_f32=t.asm.softmax_f32).apply(null,arguments)},t._sum_f32=function(){return(t._sum_f32=t.asm.sum_f32).apply(null,arguments)},t.___errno_location=function(){return(t.___errno_location=t.asm.__errno_location).apply(null,arguments)},t._fflush=function(){return(It=t._fflush=t.asm.fflush).apply(null,arguments)});function Lt(t){this.name="ExitStatus",this.message="Program terminated with exit("+t+")",this.status=t}function Mt(e){function n(){At||(At=!0,t.calledRun=!0,O||(q(),H(),t.onRuntimeInitialized&&t.onRuntimeInitialized(),Y()))}e=e||u,J>0||(V(),J>0||(t.setStatus?(t.setStatus("Running..."),setTimeout((function(){setTimeout((function(){t.setStatus("")}),1),n()}),1)):n()))}if(t._setThrew=function(){return(t._setThrew=t.asm.setThrew).apply(null,arguments)},t.stackSave=function(){return(t.stackSave=t.asm.stackSave).apply(null,arguments)},t.stackAlloc=function(){return(t.stackAlloc=t.asm.stackAlloc).apply(null,arguments)},t.stackRestore=function(){return(t.stackRestore=t.asm.stackRestore).apply(null,arguments)},t.__growWasmMemory=function(){return(t.__growWasmMemory=t.asm.__growWasmMemory).apply(null,arguments)},t.dynCall_ii=function(){return(t.dynCall_ii=t.asm.dynCall_ii).apply(null,arguments)},t.dynCall_iiii=function(){return(t.dynCall_iiii=t.asm.dynCall_iiii).apply(null,arguments)},t.dynCall_jiji=function(){return(t.dynCall_jiji=t.asm.dynCall_jiji).apply(null,arguments)},t.dynCall_iidiiii=function(){return(t.dynCall_iidiiii=t.asm.dynCall_iidiiii).apply(null,arguments)},t.dynCall_vii=function(){return(t.dynCall_vii=t.asm.dynCall_vii).apply(null,arguments)},t.dynCall_vi=function(){return(t.dynCall_vi=t.asm.dynCall_vi).apply(null,arguments)},t.dynCall_viiiiii=function(){return(t.dynCall_viiiiii=t.asm.dynCall_viiiiii).apply(null,arguments)},t.dynCall_viiiii=function(){return(t.dynCall_viiiii=t.asm.dynCall_viiiii).apply(null,arguments)},t.dynCall_viiii=function(){return(t.dynCall_viiii=t.asm.dynCall_viiii).apply(null,arguments)},t.asm=Pt,t.then=function(e){if(At)e(t);else{var n=t.onRuntimeInitialized;t.onRuntimeInitialized=function(){n&&n(),e(t)}}return t},Z=function t(){At||Mt(),At||(Z=t)},t.run=Mt,t.preInit)for("function"==typeof t.preInit&&(t.preInit=[t.preInit]);t.preInit.length>0;)t.preInit.pop()();return Mt(),t});t.exports=a}).call(this,"/index.js",n(24),"/")},function(t,e,n){"use strict";n.r(e),e.default=function(){return new Worker(n.p+"onnx-worker.js")}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.WasmSessionHandler=void 0;var r=n(11),o=n(27),i=n(107),a=n(108),u=function(){function t(t,e,n){this.backend=t,this.context=e,this.opResolveRules=n?a.WASM_OP_RESOLVE_RULES.concat(o.CPU_OP_RESOLVE_RULES):a.WASM_OP_RESOLVE_RULES}return t.prototype.createInferenceHandler=function(){return new i.WasmInferenceHandler(this,this.context.profiler)},t.prototype.dispose=function(){},t.prototype.resolve=function(t,e){var n=r.resolveOperator(t,e,this.opResolveRules);return n.initialize(t.attributes),n},t}();e.WasmSessionHandler=u},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.WasmInferenceHandler=void 0;var r=function(){function t(t,e){this.session=t,this.profiler=e}return t.prototype.dispose=function(){},t}();e.WasmInferenceHandler=r},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.WASM_OP_RESOLVE_RULES=void 0;var r=n(109),o=n(110),i=n(111),a=n(112),u=n(113),s=n(114),l=n(115),c=n(116),f=n(117),p=n(118);e.WASM_OP_RESOLVE_RULES=[["Add","","7+",function(){return new o.WasmBinaryOp(["float32"],"Add")}],["And","","7+",function(){return new o.WasmBinaryOp(["bool"],"And")}],["AveragePool","","7-10",function(){return new c.WasmAveragePool}],["BatchNormalization","","7+",function(){return new r.WasmBatchNormalization}],["Clip","","6-10",function(){return new i.WasmClip}],["Conv","","1+",function(){return new a.WasmConv}],["Div","","7+",function(){return new o.WasmBinaryOp(["float32"],"Div")}],["Gemm","","7-10",function(){return new u.WasmGemm(!1)}],["Gemm","","11+",function(){return new u.WasmGemm(!0)}],["GlobalAveragePool","","1+",function(){return new c.WasmGlobalAveragePool}],["GlobalMaxPool","","1+",function(){return new c.WasmGlobalMaxPool}],["InstanceNormalization","","6+",function(){return new s.WasmInstanceNormalization}],["MatMul","","1+",function(){return new l.WasmMatMul}],["MaxPool","","1-9",function(){return new c.WasmMaxPool}],["Mul","","7+",function(){return new o.WasmBinaryOp(["float32"],"Mul")}],["Or","","7+",function(){return new o.WasmBinaryOp(["bool"],"Or")}],["PRelu","","7+",function(){return new o.WasmBinaryOp(["float32"],"PRelu")}],["Softmax","","1+",function(){return new f.WasmSoftmax}],["Sub","","7+",function(){return new o.WasmBinaryOp(["float32"],"Sub")}],["Sum","","6+",function(){return new p.WasmSum}],["Xor","","7+",function(){return new o.WasmBinaryOp(["bool"],"Xor")}]]},function(t,e,n){"use strict";var r,o=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0}),e.WasmBatchNormalization=void 0;var i=n(14),a=n(1),u=n(4),s=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.run=function(t,e){for(var n=e[0],r=e[1],o=e[2],i=e[3],s=e[4],l=1,c=2;c0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]0?_[x]:null,"float32ptr"],[this.dilations,"int32ptr"],[this.group,"int32"],[this.pads,"int32ptr"],[this.strides,"int32ptr"])):(v[x]=n.floatData.subarray(x*h),b[x]=u.floatData.subarray(x*g),r&&(_[x]=r.floatData.subarray(x*p[0])),c.WasmBinding.getInstance().ccall("_conv_f32",[t.floatData,"float32ptr"],[t.dims,"int32ptr"],[v[x],"float32ptr"],[d,"int32ptr"],[b[x],"float32ptr","out"],[m,"int32ptr"],[_.length>0?_[x]:null,"float32ptr"],[this.dilations,"int32ptr"],[this.group,"int32"],[this.pads,"int32ptr"],[this.strides,"int32ptr"]));return[4,Promise.all(w)];case 2:return a.sent(),[2,[u]]}}))}))},e.prototype.checkInputTypes=function(t){return"float32"===t[0].type&&"float32"===t[1].type&&(3!==t.length||"float32"===t[2].type)},e}(u.Conv);e.WasmConv=f},function(t,e,n){"use strict";var r,o=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),i=this&&this.__read||function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a};Object.defineProperty(e,"__esModule",{value:!0}),e.WasmGemm=void 0;var a=n(19),u=n(1),s=n(0),l=n(4),c=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.run=function(t,e){var n=e[0],r=e[1],o=e[2],a=i(s.GemmUtil.getShapeOfGemmResult(n.dims,this.transA,r.dims,this.transB,null==o?void 0:o.dims),2),c=a[0],f=a[1],p=new u.Tensor([c,f],n.type);if(o&&!s.BroadcastUtil.calc(p,o,(function(t,e){return e}),!0))throw new Error("c is not broadcastable to the shape of the result of the Gemm operator");return l.WasmBinding.getInstance().ccall("_gemm_f32",[this.transA,"bool"],[this.transB,"bool"],[this.transA?n.dims[1]:n.dims[0],"int32"],[this.transB?r.dims[0]:r.dims[1],"int32"],[this.transA?n.dims[0]:n.dims[1],"int32"],[this.alpha,"float32"],[n.floatData,"float32ptr"],[r.floatData,"float32ptr"],[this.beta,"float32"],[p.floatData,"float32ptr","inout"]),[p]},e.prototype.checkInputTypes=function(t){return"float32"===t[0].type&&"float32"===t[1].type&&"float32"===t[2].type&&(t[0].type===t[1].type&&t[0].type===t[2].type)},e}(a.Gemm);e.WasmGemm=c},function(t,e,n){"use strict";var r,o=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0}),e.WasmInstanceNormalization=void 0;var i=n(20),a=n(1),u=n(4),s=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.run=function(t,e){for(var n=e[0],r=e[1],o=e[2],i=1,s=2;s0)&&!(r=i.next()).done;)a.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a};Object.defineProperty(e,"__esModule",{value:!0}),e.WasmMatMul=void 0;var a=n(18),u=n(1),s=n(0),l=n(4),c=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.run=function(t,e){var n=i(s.MatMulUtil.preprocessInputShapes(e[0].dims,e[1].dims),2),r=n[0],o=n[1],a=s.BroadcastUtil.calcShape(r,o,!0);if(!a)throw new Error("input dimensions do not match the requirement");var c=s.ShapeUtil.size(a),f=new Float32Array(c);l.WasmBinding.getInstance().ccall("_matmul_f32",[e[0].floatData,"float32ptr"],[e[0].dims,"int32ptr"],[e[0].dims.length,"int32"],[e[1].floatData,"float32ptr"],[e[1].dims,"int32ptr"],[e[1].dims.length,"int32"],[f,"float32ptr","out"],[f.length,"int32"],[a,"int32ptr"],[a.length,"int32"]),s.MatMulUtil.postprocessOutputShape(a,e[0].dims.length,e[1].dims.length);var p=new u.Tensor(a,e[0].type);return p.floatData.set(f),[p]},e.prototype.checkInputTypes=function(t){return"float32"===t[0].type&&"float32"===t[1].type&&t[0].type===t[1].type},e}(a.MatMul);e.WasmMatMul=c},function(t,e,n){"use strict";var r,o=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),i=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function u(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}s((r=r.apply(t,e||[])).next())}))},a=this&&this.__generator||function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]0)&&!(r=i.next()).done;)a.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a},a=this&&this.__spread||function(){for(var t=[],e=0;e0)&&!(r=i.next()).done;)a.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a};Object.defineProperty(e,"__esModule",{value:!0}),e.WebGLInferenceHandler=void 0;var i=n(3),a=n(1),u=n(0),s=n(122),l=n(50),c=function(){function t(t){this.session=t,this.textureDataCache=new Map}return t.prototype.run=function(t,e){var n=this.session.programManager.getArtifact(t);if(!n){var r=t.createProgramInfo(this,e);n=this.session.programManager.build(r),this.session.programManager.setArtifact(t,n)}var o=t.createRunData(this,n.programInfo,e);return this.session.programManager.run(n,o),[o.outputTextureData.tensor]},t.prototype.getOrCreateTextureData=function(t,e){var n=this.getTextureData(t.dataId);return n?i.Logger.verbose("InferenceHandler","Retrieving TextureData from cache: ["+t.dims+"]"):(i.Logger.verbose("InferenceHandler","Creating new TextureData for dims: ["+t.dims+"]"),e||(e=this.createTextureLayoutFromShape(t.dims.slice())),n=this.createTextureData(e,t.type,t.numberData,t,1)),n},t.prototype.createTextureDataFromLayout=function(t,e){return this.createTextureData(t,e)},t.prototype.createTextureDataFromLayoutBindTensor=function(t,e,n,r){return this.createTextureData(t,e,n,r,1)},t.prototype.createTextureData=function(t,e,n,r,o){i.Logger.verbose("InferenceHandler","Creating TextureData: layout:["+JSON.stringify(t)+"]");var a=this.session.textureManager.createTextureFromLayout(e,t,n,o);return this.createTextureDataFromTexture(t,e,a,r)},t.prototype.createSharedTextureData=function(t,e,n,r){return this.createTextureDataFromTexture(t,e,n,void 0,r)},t.prototype.createTextureDataFromTexture=function(t,e,n,o,i){var u=this,s=r(r({},t),{tensor:o||new a.Tensor(t.unpackedShape,e,(function(t){return u.readTexture(s)}),void 0,void 0,i),texture:n});return this.setTextureData(s.tensor.dataId,s),s},t.prototype.getTextureData=function(t){return this.session.isInitializer(t)?this.session.getTextureData(t):this.textureDataCache.get(t)},t.prototype.setTextureData=function(t,e){this.session.isInitializer(t)?this.session.setTextureData(t,e):this.textureDataCache.set(t,e)},t.prototype.getOrCreateTextureLayout=function(t,e,n){void 0===e&&(e=1);var r=this.getTextureData(t.dataId);return r||this.createTextureLayoutFromShape(1===e?t.dims.slice():l.getPackedShape(t.dims.slice()),e,n)},t.prototype.createTextureLayoutFromShape=function(t,e,n,r){void 0===e&&(e=1);var i=o(this.session.layoutStrategy.computeTextureWH(t,r),2),a=i[0],s=i[1],l=t;if(0===t.length&&(l=[1]),1===e)n=t;else if(!n)throw new Error("Unpacked shape is needed when using channels > 1");return{width:a,height:s,channels:e||1,shape:l,strides:u.ShapeUtil.computeStrides(l),unpackedShape:n}},t.prototype.dispose=function(){var t=this;this.session.textureManager.clearActiveTextures(),this.textureDataCache.forEach((function(e){return t.session.textureManager.releaseTexture(e)})),this.textureDataCache=new Map},t.prototype.readTexture=function(t){if(!this.session.backend.glContext.isFloat32DownloadSupported){var e=(new s.WebGLUint8Encode).runInternal(this,t);return this.session.textureManager.readUint8TextureAsFloat(e)}return this.session.textureManager.readTexture(t,t.tensor.type,t.channels)},t}();e.WebGLInferenceHandler=c},function(t,e,n){"use strict";var r=this&&this.__read||function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a};Object.defineProperty(e,"__esModule",{value:!0}),e.WebGLUint8Encode=void 0;var o=n(0),i=n(2),a=function(){function t(){}return t.prototype.runInternal=function(t,e){var n=e.shape,a=r(t.session.layoutStrategy.computeTextureWH(e.shape),2),u={width:a[0],height:a[1],channels:4,shape:n,strides:o.ShapeUtil.computeStrides(n),unpackedShape:n},s=i.getGlsl(t.session.backend.glContext.version),l={inputLayouts:[e],outputLayout:u,samplers:["X"],shaderSource:"\n const float FLOAT_MAX = 1.70141184e38;\n const float FLOAT_MIN = 1.17549435e-38;\n\n bool isNaN(float val) {\n return (val < 1.0 || 0.0 < val || val == 0.0) ? false : true;\n }\n\n highp vec4 encodeAsUint8(highp float v) {\n if (isNaN(v)) {\n return vec4(255, 255, 255, 255);\n }\n\n highp float av = abs(v);\n\n if(av < FLOAT_MIN) {\n return vec4(0.0, 0.0, 0.0, 0.0);\n } else if(v > FLOAT_MAX) {\n return vec4(0.0, 0.0, 128.0, 127.0) / 255.0;\n } else if(v < -FLOAT_MAX) {\n return vec4(0.0, 0.0, 128.0, 255.0) / 255.0;\n }\n\n highp vec4 c = vec4(0,0,0,0);\n\n highp float e = floor(log2(av));\n highp float m = exp2(fract(log2(av))) - 1.0;\n\n c[2] = floor(128.0 * m);\n m -= c[2] / 128.0;\n c[1] = floor(32768.0 * m);\n m -= c[1] / 32768.0;\n c[0] = floor(8388608.0 * m);\n\n highp float ebias = e + 127.0;\n c[3] = floor(ebias / 2.0);\n ebias -= c[3] * 2.0;\n c[2] += floor(ebias) * 128.0;\n\n c[3] += 128.0 * step(0.0, -v);\n\n return c / 255.0;\n }\n\n void main() {\n float value = "+s.texture2D+"(X,TexCoords).r;\n "+s.output+" = encodeAsUint8(value);\n }",hasMain:!0},c=t.session.programManager.build(l),f=t.session.backend.glContext.getEncoder("byte",4),p=t.session.backend.glContext.allocateTexture(u.width,u.height,f),h={inputTextureDatas:[e],outputTextureData:t.createSharedTextureData(u,"uint8",p,{}),uniformData:{}};return t.session.programManager.run(c,h),h.outputTextureData},t}();e.WebGLUint8Encode=a},function(t,e,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n),Object.defineProperty(t,r,{enumerable:!0,get:function(){return e[n]}})}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),o=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),i=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.hasOwnProperty.call(t,n)&&r(e,t,n);return o(e,t),e};Object.defineProperty(e,"__esModule",{value:!0}),e.WEBGL_OP_RESOLVE_RULES=void 0;var a=n(7),u=n(124),s=i(n(125)),l=n(126),c=n(127),f=n(128),p=n(129),h=n(130),d=n(132),y=n(133),g=n(134),m=n(135),v=n(136),b=n(137),_=n(139),w=n(140),x=n(141),T=i(n(142)),O=n(10),S=n(143),P=n(144),A=n(145),D=n(147),E=n(148),I=n(149),L=n(150),M=i(n(151)),j=n(152),k=n(153);e.WEBGL_OP_RESOLVE_RULES=[["Abs","","6+",function(){return new M.WebGLUnaryOp(a.NUMBER_TYPES,M.glslAbs())}],["Acos","","7+",function(){return new M.WebGLUnaryOp(a.FLOAT_TYPES,M.glslAcos())}],["Add","","7+",function(){return new s.WebGLBinaryOp(a.NUMBER_TYPES,s.glslAdd())}],["And","","7+",function(){return new s.WebGLBinaryOp(["bool"],s.glslAnd())}],["Asin","","7+",function(){return new M.WebGLUnaryOp(a.FLOAT_TYPES,M.glslAsin())}],["Atan","","7+",function(){return new M.WebGLUnaryOp(a.FLOAT_TYPES,M.glslAtan())}],["AveragePool","","7-10",function(){return new x.WebGLAveragePool}],["BatchNormalization","","7+",function(){return new u.WebGLBatchNormalization}],["Ceil","","6+",function(){return new M.WebGLUnaryOp(a.FLOAT_TYPES,M.glslCeil())}],["Clip","","6-10",function(){return new l.WebGLClip}],["Concat","","4+",function(){return new c.WebGLConcat}],["Conv","","1+",function(){return new f.WebGLConv}],["Cos","","7+",function(){return new M.WebGLUnaryOp(a.FLOAT_TYPES,M.glslCos())}],["Div","","7+",function(){return new s.WebGLBinaryOp(a.NUMBER_TYPES,s.glslDiv())}],["Dropout","","7+",function(){return new p.WebGLDropout}],["Equal","","7+",function(){return new s.WebGLBinaryOp(a.NUMBER_TYPES,s.glslEqual(),void 0,"bool")}],["Elu","","6+",function(){return new h.WebGLElu}],["Exp","","6+",function(){return new M.WebGLUnaryOp(a.FLOAT_TYPES,M.glslExp())}],["Flatten","","1+",function(){return new d.WebGLFlatten}],["Floor","","6+",function(){return new M.WebGLUnaryOp(a.FLOAT_TYPES,M.glslFloor())}],["Gather","","1+",function(){return new y.WebGLGather}],["Gemm","","7-10",function(){return new g.WebGLGemm(!1)}],["Gemm","","11+",function(){return new g.WebGLGemm(!0)}],["GlobalAveragePool","","1+",function(){return new x.WebGLGlobalAveragePool}],["GlobalMaxPool","","1+",function(){return new x.WebGLGlobalMaxPool}],["Greater","","7+",function(){return new s.WebGLBinaryOp(a.NUMBER_TYPES,s.glslGreater(),void 0,"bool")}],["Identity","","1+",function(){return new M.WebGLUnaryOp(a.NUMBER_TYPES,M.glslIdentity())}],["ImageScaler","","1+",function(){return new m.WebGLImageScaler}],["InstanceNormalization","","6+",function(){return new v.WebGLInstanceNormalization}],["LeakyRelu","","6+",function(){return new b.WebGLLeakyRelu}],["Less","","7+",function(){return new s.WebGLBinaryOp(a.NUMBER_TYPES,s.glslLess(),void 0,"bool")}],["Log","","6+",function(){return new M.WebGLUnaryOp(a.FLOAT_TYPES,M.glslLog())}],["MatMul","","1+",function(){return new _.WebGLMatMul}],["MaxPool","","1-9",function(){return new x.WebGLMaxPool}],["Mul","","7+",function(){return new s.WebGLBinaryOp(a.NUMBER_TYPES,s.glslMul())}],["Neg","","6+",function(){return new M.WebGLUnaryOp(a.NUMBER_TYPES,M.glslNeg())}],["Not","","1+",function(){return new M.WebGLUnaryOp(["bool"],M.glslNot())}],["Or","","7+",function(){return new s.WebGLBinaryOp(["bool"],s.glslOr())}],["Pad","","2-10",function(){return new w.WebGLPad}],["Pow","","7+",function(){return new s.WebGLBinaryOp(a.FLOAT_TYPES,s.glslPow())}],["PRelu","","7+",function(){return new s.WebGLBinaryOp(a.FLOAT_TYPES,s.glslPRelu())}],["ReduceLogSum","","1+",function(){return new T.WebGLReduceLogSum}],["ReduceMax","","1+",function(){return new T.WebGLReduceMax}],["ReduceMean","","1+",function(){return new T.WebGLReduceMean}],["ReduceMin","","1+",function(){return new T.WebGLReduceMin}],["ReduceProd","","1+",function(){return new T.WebGLReduceProd}],["ReduceSum","","1+",function(){return new T.WebGLReduceSum}],["ReduceSumSquare","","1+",function(){return new T.WebGLReduceSumSquare}],["Relu","","6+",function(){return new M.WebGLUnaryOp(a.FLOAT_TYPES,M.glslRelu())}],["Reshape","","5+",function(){return new O.WebGLReshape}],["Sigmoid","","6+",function(){return new M.WebGLUnaryOp(a.FLOAT_TYPES,M.glslSigmoid())}],["Sin","","7+",function(){return new M.WebGLUnaryOp(a.FLOAT_TYPES,M.glslSin())}],["Slice","","10+",function(){return new S.WebGLSliceV10}],["Slice","","1-9",function(){return new S.WebGLSlice}],["Softmax","","1+",function(){return new P.WebGLSoftmax}],["Split","","2+",function(t){return new A.WebGLSplit(t.outputs.length)}],["Sqrt","","6+",function(){return new M.WebGLUnaryOp(a.FLOAT_TYPES,M.glslSqrt())}],["Squeeze","","1+",function(){return new D.WebGLSqueeze}],["Sub","","7+",function(){return new s.WebGLBinaryOp(a.NUMBER_TYPES,s.glslSub())}],["Sum","","6+",function(){return new E.WebGLSum}],["Tan","","7+",function(){return new M.WebGLUnaryOp(a.FLOAT_TYPES,M.glslTan())}],["Tanh","","6+",function(){return new M.WebGLUnaryOp(a.FLOAT_TYPES,M.glslTanh())}],["Tile","","6+",function(){return new I.WebGLTile}],["Transpose","","1+",function(){return new L.WebGLTranspose}],["Upsample","","7-8",function(){return new k.WebGLUpsample}],["Unsqueeze","","1+",function(){return new j.WebGLUnsqueeze}],["Xor","","7+",function(){return new s.WebGLBinaryOp(["bool"],s.glslXor())}]]},function(t,e,n){"use strict";var r,o=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0}),e.WebGLBatchNormalization=void 0;var i=n(14),a=n(2),u=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.run=function(t,e){return t.run(this,e)},e.prototype.createProgramInfo=function(t,e){var n=e.map((function(e){return t.getOrCreateTextureLayout(e)})),r=e[0].dims.slice(),o=r.length,i=n[1],u=a.getGlsl(t.session.backend.glContext.version),s="\n float process(int["+o+"] indices) {\n vec2 position = offsetToCoords(indices[1], "+i.width+", "+i.height+");\n float scale = getColorAsFloat("+u.texture2D+"(Scale, position));\n float mean = getColorAsFloat("+u.texture2D+"(Mean, position));\n float variance = getColorAsFloat("+u.texture2D+"(Variance, position));\n float b = getColorAsFloat("+u.texture2D+"(B, position));\n\n return scale * ( (_A(indices) - mean) / sqrt(variance + float("+this.epsilon+")) ) + b;\n }";return{inputLayouts:n,outputLayout:t.createTextureLayoutFromShape(r),samplers:["A","Scale","B","Mean","Variance"],shaderSource:s}},e.prototype.createRunData=function(t,e,n){var r=[t.getOrCreateTextureData(n[0],e.inputLayouts[0])];n.slice(1).forEach((function(e){return r.push(t.getOrCreateTextureData(e))}));var o=t.createTextureDataFromLayout(e.outputLayout,r[0].tensor.type);return{inputTextureDatas:r,outputTextureData:o,uniformData:{}}},e}(i.BatchNormalization);e.WebGLBatchNormalization=u},function(t,e,n){"use strict";var r,o=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0}),e.glslPRelu=e.glslPow=e.glslXor=e.glslOr=e.glslAnd=e.glslLess=e.glslGreater=e.glslEqual=e.glslSub=e.glslMul=e.glslDiv=e.glslAdd=e.WebGLBinaryOp=void 0;var i=n(15),a=n(0),u=n(5),s=n(2),l=function(t){function e(e,n,r,o){var i=t.call(this,e,r,o)||this;return i.glslFunc=n,i}return o(e,t),e.prototype.run=function(t,e){return t.run(this,e)},e.prototype.createProgramInfo=function(t,e){var n=e.map((function(e){return t.getOrCreateTextureLayout(e)}));if(!a.ShapeUtil.areEqual(e[0].dims,e[1].dims)){var r=a.BroadcastUtil.calcShape(e[0].dims,e[1].dims,!1);if(!r)throw new Error("Can't perform binary op on the given tensors");var o=r.length,i=0!==e[0].dims.length?e[0].dims.length:1,u=0!==e[1].dims.length?e[1].dims.length:1,l=0!==e[0].dims.length?"bcastIndices_A(indices, aindices);":"aindices[0] = 0;",c=0!==e[1].dims.length?"bcastIndices_B(indices, bindices);":"bindices[0] = 0;",f="\n "+this.glslFunc.body+"\n float process(int indices["+o+"]) {\n int aindices["+i+"];\n int bindices["+u+"];\n "+l+"\n "+c+"\n return "+this.glslFunc.name+"(_A(aindices), _B(bindices));\n }";return{inputLayouts:n,outputLayout:t.createTextureLayoutFromShape(r),samplers:["A","B"],shaderSource:f}}var p=s.getGlsl(t.session.backend.glContext.version),h="\n "+this.glslFunc.body+"\n void main() {\n vec4 v1 = "+p.texture2D+"(A, TexCoords);\n vec4 v2 = "+p.texture2D+"(B, TexCoords);\n vec4 result = "+this.glslFunc.name+"(v1, v2);\n "+p.output+" = result;\n }\n ";return{hasMain:!0,inputLayouts:n,outputLayout:t.createTextureLayoutFromShape(e[0].dims),samplers:["A","B"],shaderSource:h}},e.prototype.createRunData=function(t,e,n){return{inputTextureDatas:n.map((function(n,r){return t.getOrCreateTextureData(n,e.inputLayouts[r])})),outputTextureData:t.createTextureDataFromLayout(e.outputLayout,this.resultType?this.resultType:n[0].type),uniformData:{}}},e}(i.BinaryOp);e.WebGLBinaryOp=l,e.glslAdd=function(){return{body:"\n float add_(float a, float b) {\n return a + b;\n }\n vec4 add_(vec4 v1, vec4 v2) {\n return v1 + v2;\n }\n ",name:"add_",type:u.FunctionType.ValueBased}},e.glslDiv=function(){return{body:"\n float div_(float a, float b) {\n return a / b;\n }\n vec4 div_(vec4 v1, vec4 v2) {\n return v1 / v2;\n }\n ",name:"div_",type:u.FunctionType.ValueBased}},e.glslMul=function(){return{body:"\n float mul_(float a, float b) {\n return a * b;\n }\n vec4 mul_(vec4 v1, vec4 v2) {\n return v1 * v2;\n }\n ",name:"mul_",type:u.FunctionType.ValueBased}},e.glslSub=function(){return{body:"\n float sub_(float a, float b) {\n return a - b;\n }\n vec4 sub_(vec4 v1, vec4 v2) {\n return v1 - v2;\n }\n ",name:"sub_",type:u.FunctionType.ValueBased}},e.glslEqual=function(){return{body:"\n float equal_(float a, float b) {\n return float(a == b);\n }\n vec4 equal_(vec4 v1, vec4 v2) {\n return vec4( v1 == v2 );\n }\n ",name:"equal_",type:u.FunctionType.ValueBased}},e.glslGreater=function(){var t="greater_";return{body:"\n float greater_(float a, float b) {\n return float(a > b);\n }\n vec4 greater_(vec4 v1, vec4 v2) {\n return vec4( v1.r > v2.r ,\n v1.g > v2.g,\n v1.b > v2.b,\n v1.a > v2.a );\n }\n ",name:t,type:u.FunctionType.ValueBased}},e.glslLess=function(){return{body:"\n float less_(float a, float b) {\n return float(a < b);\n }\n vec4 less_(vec4 v1, vec4 v2) {\n return vec4( v1.r < v2.r ,\n v1.g < v2.g,\n v1.b < v2.b,\n v1.a < v2.a );\n }\n ",name:"less_",type:u.FunctionType.ValueBased}},e.glslAnd=function(){return{body:"\n float and_(float a, float b) {\n return float( bool(a) && bool(b) );\n }\n vec4 and_(vec4 v1, vec4 v2) {\n bvec4 b1 = bvec4(v1);\n bvec4 b2 = bvec4(v2);\n return vec4( b1.r && b2.r ,\n b1.g && b2.g,\n b1.b && b2.b,\n b1.a && b2.a );\n }\n ",name:"and_",type:u.FunctionType.ValueBased}},e.glslOr=function(){return{body:"\n float or_(float a, float b) {\n return float( bool(a) || bool(b) );\n }\n vec4 or_(vec4 v1, vec4 v2) {\n bvec4 b1 = bvec4(v1);\n bvec4 b2 = bvec4(v2);\n return vec4( b1.r || b2.r ,\n b1.g || b2.g,\n b1.b || b2.b,\n b1.a || b2.a );\n }\n ",name:"or_",type:u.FunctionType.ValueBased}},e.glslXor=function(){return{body:"\n float xor_(float a, float b) {\n return float( bool(a) ^^ bool(b) );\n }\n vec4 xor_(vec4 v1, vec4 v2) {\n bvec4 b1 = bvec4(v1);\n bvec4 b2 = bvec4(v2);\n return vec4( b1.r ^^ b2.r ,\n b1.g ^^ b2.g,\n b1.b ^^ b2.b,\n b1.a ^^ b2.a );\n }\n ",name:"xor_",type:u.FunctionType.ValueBased}},e.glslPow=function(){return function(t){var e=t+"_";return{body:"\n float "+e+"(float a, float b) {\n return "+t+"(a, b);\n }\n vec4 "+e+"(vec4 v1, vec4 v2) {\n return "+t+"(v1, v2);\n }\n ",name:e,type:u.FunctionType.ValueBased}}("pow")},e.glslPRelu=function(){return{body:"\n float prelu_(float a, float b) {\n return a < 0.0 ? a * b: a;\n }\n vec4 prelu_(vec4 v1, vec4 v2) {\n return vec4(\n v1.r < 0.0 ? v1.r * v2.r: v1.r,\n v1.g < 0.0 ? v1.g * v2.g: v1.g,\n v1.b < 0.0 ? v1.b * v2.b: v1.b,\n v1.a < 0.0 ? v1.a * v2.a: v1.a\n );\n }\n ",name:"prelu_",type:u.FunctionType.ValueBased}}},function(t,e,n){"use strict";var r,o=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0}),e.WebGLClip=void 0;var i=n(49),a=n(2),u=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.run=function(t,e){return t.run(this,e)},e.prototype.createProgramInfo=function(t,e){var n=e[0].dims.slice(),r=a.getGlsl(t.session.backend.glContext.version),o="\n const float min = float("+this.min+");\n const float max = float("+this.max+");\n void main() {\n float v = "+r.texture2D+"(A, TexCoords).r;\n "+r.output+" = vec4(clamp(v, min, max));\n }\n ";return{inputLayouts:[t.getOrCreateTextureLayout(e[0])],outputLayout:t.createTextureLayoutFromShape(n),samplers:["A"],shaderSource:o,hasMain:!0}},e.prototype.createRunData=function(t,e,n){var r=[t.getOrCreateTextureData(n[0],e.inputLayouts[0])];return{inputTextureDatas:r,outputTextureData:t.createTextureDataFromLayout(e.outputLayout,r[0].tensor.type),uniformData:{}}},e}(i.Clip);e.WebGLClip=u},function(t,e,n){"use strict";var r,o=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0}),e.WebGLConcat=void 0;var i=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.run=function(t,e){return t.run(this,e)},e.prototype.createProgramInfo=function(t,e){var n=e[0].dims.slice();if(this.axis>=n.length||this.axis<-1*n.length)throw new Error("axis specified for concat doesn't match input dimensionality");this.axis<0&&(this.axis=n.length+this.axis);for(var r=n.slice(0),o=1;o0)&&!(r=i.next()).done;)a.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a},a=this&&this.__spread||function(){for(var t=[],e=0;e=3?r[2]:void 0,a=t.getTextureData(o.dataId);if(!a){u.Logger.verbose("Conv","Did not find the adjustedKernel texture in the cache. Creating rew.");var s=e.prepKernelForDotProduct(o.dims.slice(),this.group,4,o.floatData);a=t.createTextureDataFromLayoutBindTensor(n[1].inputLayouts[1],o.type,s,o)}var l={inputTextureDatas:[t.getOrCreateTextureData(r[0])],outputTextureData:t.createTextureDataFromLayout(n[0].outputLayout,r[0].type),uniformData:{}},c=[l.outputTextureData,a];return i&&c.push(t.getOrCreateTextureData(i)),[l,{inputTextureDatas:c,outputTextureData:t.createTextureDataFromLayout(n[1].outputLayout,r[0].type),uniformData:{},draw:function(t,e){for(var n=t.gl,r=e.programInfo.params.sharedDim,o=e.programInfo.params.sharedDimReadSize,i=e.uniformLocations.find((function(t){return"sharedDimOffset"===t.name})).location,a=!1,s=0;s= 0 &&\n xh2 < XH &&\n xw2 >= 0 &&\n xw2 < XW) {\n v[i] = _X(x);\n }\n }\n ++p;\n }\n return v;\n }\n ";return{inputLayouts:[t.createTextureLayoutFromShape(o)],outputLayout:s,samplers:["X"],shaderSource:l}},e.prototype.createDotProductProgramInfo=function(t,e,n,r){var o,i=n[0].dims.slice(),a=n[1].dims.slice(),u=[a[0],Math.ceil(i[1]*a[2]*a[3]/4)],s=t.createTextureLayoutFromShape(u,4,[u[0],4*u[1]],{breakAxis:1}),l=r.length,f=[e,s];3===n.length&&(o=t.createTextureLayoutFromShape(n[2].dims.slice()),f.push(o));var p=t.createTextureLayoutFromShape(r),h=n.length<3?"0.0":"_B(b)",d=e.shape[3],y=t.session.backend.glContext.isBlendSupported&&t.session.backend.matmulMaxBatchSize?this.calcSharedDimReadSize(t.session.backend.matmulMaxBatchSize,d):d,g=["Im2Col","K"];3===n.length&&g.push("B");var m=c.getGlsl(t.session.backend.glContext.version),v="\n float process(int indices["+l+"]) {\n int b[1];\n b[0] = indices[1];\n int im2col["+e.shape.length+"];\n im2col[0] = indices[0];\n im2col[1] = indices[2];\n im2col[2] = indices[3];\n int im2colOffset = im2col[0] * "+e.strides[0]+" + im2col[1] * "+e.strides[1]+" + im2col[2] * "+e.strides[2]+" + sharedDimOffset;\n int kernelOffset = indices[1] * "+s.strides[0]+" + sharedDimOffset;\n float sum = sharedDimOffset == 0 ? "+h+" : 0.0;\n for (int i = 0; i < "+y+"; ++i) {\n vec2 im2colCoords = offsetToCoords(im2colOffset, "+e.width+", "+e.height+");\n vec2 kernelCoords = offsetToCoords(kernelOffset, "+s.width+", "+s.height+");\n sum += dot("+m.texture2D+"(Im2Col, im2colCoords), "+m.texture2D+"(K, kernelCoords));\n ++im2colOffset;\n ++kernelOffset;\n }\n return sum;\n }";return{inputLayouts:3===n.length?[e,s,o]:[e,s],outputLayout:p,shaderSource:v,samplers:g,variables:[{name:"sharedDimOffset",type:"int"}],params:{sharedDim:d,sharedDimReadSize:y}}},e.prepKernelForDotProduct=function(t,e,n,r){if(1===e&&(1===n||t[2]*t[3]%n==0))return r;for(var o=t[0],i=t[1]*t[2]*t[3],a=Math.ceil(i*e/n)*n,u=new Float32Array(o*a),s=0;s= 0.0 ? v: (exp(v) - 1.0) * "+this.alpha.toExponential()+"); /* float number format */\n }\n ";return{inputLayouts:[t.getOrCreateTextureLayout(e[0])],outputLayout:t.createTextureLayoutFromShape(n),samplers:["A"],shaderSource:o,hasMain:!0}},e.prototype.createRunData=function(t,e,n){var r=[t.getOrCreateTextureData(n[0],e.inputLayouts[0])];return{inputTextureDatas:r,outputTextureData:t.createTextureDataFromLayout(e.outputLayout,r[0].tensor.type),uniformData:{}}},e}(i.Elu);e.WebGLElu=u},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Elu=void 0;var r=function(){function t(){}return t.prototype.initialize=function(t){this.alpha=t.getFloat("alpha",1)},t.prototype.checkInputs=function(t){return!(!t||1!==t.length)&&this.checkInputTypes(t)},t.prototype.checkInputTypes=function(t){return"float32"===t[0].type||"float64"===t[0].type},t}();e.Elu=r},function(t,e,n){"use strict";var r,o=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0}),e.WebGLFlatten=void 0;var i=n(32),a=n(0),u=n(10),s=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.run=function(t,e){var n=a.ShapeUtil.flattenShape(e[0].dims,this.axis);return[u.reshape(t,e[0],n)]},e}(i.Flatten);e.WebGLFlatten=s},function(t,e,n){"use strict";var r,o=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0}),e.WebGLGather=void 0;var i=n(33),a=n(0),u=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.run=function(t,e){return t.run(this,e)},e.prototype.createProgramInfo=function(t,e){var n=e[0].dims.slice(),r=e[1].dims.slice(),o=new Array(n.length+r.length-1);if(0===o.length)throw Error("A scalar tensor output has not been supported");for(var i=a.ShapeUtil.normalizeAxis(this.axis,n.length),u=[],s=0;s0)&&!(r=i.next()).done;)a.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a};Object.defineProperty(e,"__esModule",{value:!0}),e.WebGLGemm=void 0;var a=n(19),u=n(0),s=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.run=function(t,e){return t.run(this,e)},e.prototype.createProgramInfo=function(t,e){var n=e[0].dims.slice(),r=e[1].dims.slice(),o=i(u.GemmUtil.getShapeOfGemmResult(n,this.transA,r,this.transB,3===e.length?e[2].dims:void 0),2),a=[o[0],o[1]];if(!a)throw new Error("Can't use gemm on the given tensors");var s=n[n.length-1],l="";this.transA&&(s=n[0]),this.transA&&this.transB?l="value += _A_T(a) * _B_T(b);":this.transA&&!this.transB?l="value += _A_T(a) * _B(b);":!this.transA&&this.transB?l="value += _A(a) * _B_T(b);":this.transA||this.transB||(l="value += _A(a) * _B(b);");var c=a.length,f="\n float process(int indices["+c+"]) {\n int a["+c+"];\n int b["+c+"];\n "+(3===e.length?"int c["+e[2].dims.length+"];":"")+"\n\n copyVec(indices, a);\n copyVec(indices, b);\n "+(3===e.length?"bcastIndices_C(indices, c);":"")+"\n\n float value = 0.0;\n for (int k=0; k<"+s+"; ++k) {\n a["+(c-1)+"] = k;\n b["+(c-2)+"] = k;\n "+l+"\n }\n\n value = value * alpha;\n "+(3===e.length?"value += beta * _C(c);":"")+"\n return value;\n }";return{inputLayouts:e.map((function(e){return t.getOrCreateTextureLayout(e)})),outputLayout:t.createTextureLayoutFromShape(a),samplers:3===e.length?["A","B","C"]:["A","B"],variables:[{name:"alpha",type:"float"},{name:"beta",type:"float"}],shaderSource:f}},e.prototype.createRunData=function(t,e,n){var r=n.map((function(n,r){return t.getOrCreateTextureData(n,e.inputLayouts[r])}));return{inputTextureDatas:r,outputTextureData:t.createTextureDataFromLayout(e.outputLayout,r[0].tensor.type),uniformData:{alpha:this.alpha,beta:this.beta}}},e}(a.Gemm);e.WebGLGemm=s},function(t,e,n){"use strict";var r,o=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0}),e.WebGLImageScaler=void 0;var i=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.run=function(t,e){return t.run(this,e)},e.prototype.createProgramInfo=function(t,e){var n=e[0].dims.slice(),r=n.length,o="\n "+this.createGetBiasMethod(this.bias.length)+"\n float process(int indices["+r+"]) {\n return _X(indices) * scale + getBias(bias, indices[1]);\n }";return{inputLayouts:[t.getOrCreateTextureLayout(e[0])],outputLayout:t.createTextureLayoutFromShape(n),samplers:["X"],variables:[{name:"bias",type:"float",arrayLength:this.bias.length},{name:"scale",type:"float"}],shaderSource:o}},e.prototype.createRunData=function(t,e,n){var r=[t.getOrCreateTextureData(n[0],e.inputLayouts[0])];return{inputTextureDatas:r,outputTextureData:t.createTextureDataFromLayout(e.outputLayout,r[0].tensor.type),uniformData:{bias:this.bias,scale:this.scale}}},e.prototype.createGetBiasMethod=function(t){for(var e=["float getBias(float bias["+t+"], int channel) {"],n=0;n=0;--c)l+="\n k = m["+c+"] - "+a[c]+";\n if (k < 0) return constant;\n if (k >= "+n[c]+") return constant;\n offset += k * "+r[c]+";\n ";return"\n float pad"+e+"(int m["+s+"]) {\n const float constant = float("+u+");\n int offset = 0;\n int k = 0;\n "+l+"\n vec2 coords = offsetToCoords(offset, "+o+", "+i+");\n float value = getColorAsFloat("+t.texture2D+"("+e+", coords));\n return value;\n }\n "}(t,e,n.shape,n.strides,n.width,n.height,o,i);case"reflect":return function(t,e,n,r,o,i,a){for(var u=n.length,s="",l=u-1;l>=0;--l)s+="\n k = m["+l+"] - "+a[l]+";\n if (k < 0) { k = -k; }\n {\n const int _2n_1 = "+2*(n[l]-1)+";\n k = int( mod( float(k), float(_2n_1) ) ) ;\n if(k >= "+n[l]+") { k = _2n_1 - k; }\n }\n offset += k * "+r[l]+";\n ";return"\n float pad"+e+"(int m["+u+"]) {\n int offset = 0;\n int k = 0;\n "+s+"\n vec2 coords = offsetToCoords(offset, "+o+", "+i+");\n float value = getColorAsFloat("+t.texture2D+"("+e+", coords));\n return value;\n }\n "}(t,e,n.shape,n.strides,n.width,n.height,o);case"edge":return function(t,e,n,r,o,i,a){for(var u=n.length,s="",l=u-1;l>=0;--l)s+="\n k = m["+l+"] - "+a[l]+";\n if (k < 0) k = 0;\n if (k >= "+n[l]+") k = "+(n[l]-1)+";\n offset += k * "+r[l]+";\n ";return"\n float pad"+e+"(int m["+u+"]) {\n int offset = 0;\n int k = 0;\n "+s+"\n vec2 coords = offsetToCoords(offset, "+o+", "+i+");\n float value = getColorAsFloat("+t.texture2D+"("+e+", coords));\n return value;\n }\n "}(t,e,n.shape,n.strides,n.width,n.height,o);default:throw new Error("Invalid mode")}}e.WebGLPad=s,e.getPadFunction=l},function(t,e,n){"use strict";var r,o=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0}),e.offsetToIndices=e.copyArray=e.GeneratePoolingCode=e.WebGLMaxPool=e.WebGLGlobalMaxPool=e.WebGLAveragePool=e.WebGLGlobalAveragePool=void 0;var i=n(21),a=n(0),u=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.run=function(t,e){return t.run(this,e)},e.prototype.createProgramInfo=function(t,e){return l(t,e,!0,this.kernelShape,this.autoPad,this.strides,this.pads,this.countIncludePad)},e.prototype.createRunData=function(t,e,n){var r=[t.getOrCreateTextureData(n[0],e.inputLayouts[0])];return{inputTextureDatas:r,outputTextureData:t.createTextureDataFromLayout(e.outputLayout,r[0].tensor.type),uniformData:{}}},e}(i.GlobalAveragePool);e.WebGLGlobalAveragePool=u;var s=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.run=function(t,e){return t.run(this,e)},e.prototype.createProgramInfo=function(t,e){return l(t,e,!1,this.kernelShape,this.autoPad,this.strides,this.pads,this.countIncludePad)},e.prototype.createRunData=function(t,e,n){var r=[t.getOrCreateTextureData(n[0],e.inputLayouts[0])];return{inputTextureDatas:r,outputTextureData:t.createTextureDataFromLayout(e.outputLayout,r[0].tensor.type),uniformData:{}}},e}(i.AveragePool);function l(t,e,n,r,o,i,u,s){void 0===r&&(r=[]),void 0===o&&(o=""),void 0===i&&(i=[]),void 0===u&&(u=[]);var l=e[0].dims.slice();a.PoolConvUtil.adjustPoolAttributes(n,l,r,i,u);var c=a.PoolConvUtil.computePoolOutputShape(n,l,i,r,u,o),f=a.ShapeUtil.size(r),p="";p+=s?"value /= float("+f+");":"value /= float("+f+" - pad);";var d=t.getOrCreateTextureLayout(e[0]),y="\n "+h(d,r,u,i,"value += _X(x);",p,"0.0")+"\n ";return{inputLayouts:[d],outputLayout:t.createTextureLayoutFromShape(c),samplers:["X"],shaderSource:y}}e.WebGLAveragePool=s;var c=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.run=function(t,e){return t.run(this,e)},e.prototype.createProgramInfo=function(t,e){return p(t,e,!0,this.kernelShape,this.autoPad,this.strides,this.pads)},e.prototype.createRunData=function(t,e,n){var r=[t.getOrCreateTextureData(n[0])];return{inputTextureDatas:r,outputTextureData:t.createTextureDataFromLayout(e.outputLayout,r[0].tensor.type),uniformData:{}}},e}(i.GlobalMaxPool);e.WebGLGlobalMaxPool=c;var f=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.run=function(t,e){return t.run(this,e)},e.prototype.createProgramInfo=function(t,e){return p(t,e,!1,this.kernelShape,this.autoPad,this.strides,this.pads)},e.prototype.createRunData=function(t,e,n){var r=[t.getOrCreateTextureData(n[0])];return{inputTextureDatas:r,outputTextureData:t.createTextureDataFromLayout(e.outputLayout,r[0].tensor.type),uniformData:{}}},e}(i.MaxPool);function p(t,e,n,r,o,i,u){void 0===r&&(r=[]),void 0===o&&(o=""),void 0===i&&(i=[]),void 0===u&&(u=[]);var s=e[0].dims.slice();a.PoolConvUtil.adjustPoolAttributes(n,s,r,i,u);var l=a.PoolConvUtil.computePoolOutputShape(n,s,i,r,u,o),c=t.createTextureLayoutFromShape(s),f="\n "+h(c,r,u,i,"\n value = max(_X(x), value);\n ","","-1e5")+"\n ";return{inputLayouts:[c],outputLayout:t.createTextureLayoutFromShape(l),samplers:["X"],shaderSource:f}}function h(t,e,n,r,o,i,u){var s=t.shape,l=t.shape.length;if(e.length<=2){var c=e[e.length-1],f=r[r.length-1],p=n[n.length/2-1],h=n[n.length-1],g=s[l-1],m="",v="",b="";if(m=p+h!==0?"\n for (int i = 0; i < "+c+"; i++) {\n x["+l+" - 1] = indices["+l+" - 1] * "+f+" - "+p+" + i;\n if (x["+l+" - 1] < 0 || x["+l+" - 1] >= "+g+") {\n pad++;\n continue;\n }\n "+o+"\n }":"\n for (int i = 0; i < "+c+"; i++) {\n x["+l+" - 1] = indices["+l+" - 1] * "+f+" - "+p+" + i;\n "+o+"\n }",2===e.length){var _=e[e.length-2],w=r[r.length-2],x=n[n.length/2-2],T=n[n.length-2],O=s[l-2];v=x+T!==0?"\n for (int j = 0; j < "+_+"; j++) {\n x["+l+" - 2] = indices["+l+" - 2] * "+w+" - "+x+" + j;\n if (x["+l+" - 2] < 0 || x["+l+" - 2] >= "+O+") {\n pad+= "+c+";\n continue;\n }\n ":"\n for (int j = 0; j < "+_+"; j++) {\n x["+l+" - 2] = indices["+l+" - 2] * "+w+" - "+x+" + j;\n ",b="\n }\n "}return"\n float process(int indices["+l+"]) {\n int x["+l+"];\n copyVec(indices, x);\n\n float value = "+u+";\n int pad = 0;\n "+v+"\n "+m+"\n "+b+"\n "+i+"\n return value;\n }\n "}var S=a.ShapeUtil.size(e),P=a.ShapeUtil.computeStrides(e),A=P.length,D=n.length,E=y(A),I=d(s,"inputDims"),L=d(n,"pads"),M=d(P,"kernelStrides");return"\n "+E+"\n float process(int indices["+l+"]) {\n int x["+l+"];\n copyVec(indices, x);\n int offset["+A+"];\n int pads["+D+"];\n int inputDims["+l+"];\n int kernelStrides["+A+"];\n int strides["+A+"];\n "+L+"\n "+I+"\n "+d(r,"strides")+"\n "+M+"\n\n float value = "+u+";\n int pad = 0;\n bool isPad = false;\n for (int i = 0; i < "+S+"; i++) {\n offsetToIndices(i, kernelStrides, offset);\n isPad = false;\n for (int j = "+l+" - "+A+"; j < "+l+"; j++) {\n x[j] = indices[j] * strides[j - "+l+" + "+A+"]\n + offset[j - "+l+" + "+A+"] - pads[j - 2];\n "+(n.reduce((function(t,e){return t+e}))?"\n if (x[j] >= inputDims[j] || x[j] < 0) {\n pad++;\n isPad = true;\n break;\n }\n }\n if (!isPad) {\n "+o+"\n }":"\n }\n "+o)+"\n }\n "+i+"\n\n return value;\n }"}function d(t,e){for(var n="",r=0;r=0||0===i.length?(this.keepDims&&n.push(1),s="\n for(int j"+l+" = 0; j"+l+" < "+e[0].dims[l]+"; j"+l+"++) {\n inputIdx["+l+"] = j"+l+";\n "+s+"\n }\n "):(o.push("inputIdx["+l+"] = outputIdx["+n.length+"];"),n.push(e[0].dims[l]));var c="\n float process(int outputIdx["+(n.length||1)+"]) {\n float value; // final result\n int inputIdx["+r+"]; // addressing input data\n "+o.join("\n")+"\n "+u[0]+" // init ops for reduce max/min\n "+s+"\n "+u[2]+" // final computation for reduce mean\n return value;\n }";return{inputLayouts:e.map((function(e){return t.getOrCreateTextureLayout(e)})),outputLayout:t.createTextureLayoutFromShape(n),samplers:["A"],shaderSource:c}},e.prototype.createRunData=function(t,e,n){var r=n.map((function(n,r){return t.getOrCreateTextureData(n,e.inputLayouts[r])}));return{inputTextureDatas:r,outputTextureData:t.createTextureDataFromLayout(e.outputLayout,r[0].tensor.type),uniformData:{}}},e}(i.ReduceBase),s=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.getOps=function(t){return["value = 0.0;","value += _A(inputIdx);",""]},e}(u);e.WebGLReduceSum=s;var l=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.getOps=function(t,e){for(var n=1,r=0;r=0||0===e.length)&&(n*=t[0].dims[r]);return["value = 0.0;","value += _A(inputIdx);","value /= "+n+".;"]},e}(u);e.WebGLReduceMean=l;var c=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.getOps=function(t,e){for(var n=[],r=0;r=0||0===e.length)&&n.push("inputIdx["+r+"] = 0;");return[n.join("\n")+"\nvalue = _A(inputIdx);","value = max(value, _A(inputIdx));",""]},e}(u);e.WebGLReduceMax=c;var f=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.getOps=function(t,e){for(var n=[],r=0;r=0||0===e.length)&&n.push("inputIdx["+r+"] = 0;");return[n.join("\n")+"\nvalue = _A(inputIdx);","value = min(value, _A(inputIdx));",""]},e}(u);e.WebGLReduceMin=f;var p=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.getOps=function(t){return["value = 1.0;","value *= _A(inputIdx);",""]},e}(u);e.WebGLReduceProd=p;var h=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.getOps=function(t){return["value = 0.0;","value += _A(inputIdx);","value = log(value);"]},e}(u);e.WebGLReduceLogSum=h;var d=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.getOps=function(t){return["float t; value = 0.0;","t = _A(inputIdx); value += t * t;",""]},e}(u);e.WebGLReduceSumSquare=d},function(t,e,n){"use strict";var r,o=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0}),e.WebGLSliceV10=e.WebGLSlice=void 0;var i=n(38),a=n(0),u=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.run=function(t,e){return t.run(this,e)},e.prototype.createProgramInfo=function(t,e){return l(t,e[0],this.starts,this.ends,this.axes)},e.prototype.createRunData=function(t,e,n){return c(t,e,n)},e}(i.Slice);e.WebGLSlice=u;var s=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.run=function(t,e){return t.run(this,e)},e.prototype.createProgramInfo=function(t,e){if(!t.session.isInitializer(e[1].dataId)||!t.session.isInitializer(e[2].dataId)||e.length>=4&&!t.session.isInitializer(e[3].dataId)||e.length>=5&&!t.session.isInitializer(e[4].dataId))throw new Error("dynamic slice attributes are not allowed");if(e.length>=5&&e[4].integerData.some((function(t){return 1!==t})))throw new Error("currently non-1 steps is not supported for Slice");var n=Array.from(e[1].integerData),r=Array.from(e[2].integerData),o=e.length>=4?Array.from(e[3].integerData):[];return l(t,e[0],n,r,o)},e.prototype.createRunData=function(t,e,n){return c(t,e,n)},e}(i.SliceV10);function l(t,e,n,r,o){0===o.length&&(o=e.dims.slice(0).map((function(t,e){return e}))),o=a.ShapeUtil.normalizeAxes(o,e.dims.length),n=n.map((function(t,n){return t>e.dims[o[n]]-1?e.dims[o[n]]:a.ShapeUtil.normalizeAxis(t,e.dims[o[n]])})),r=r.map((function(t,n){return t>e.dims[o[n]]-1?e.dims[o[n]]:a.ShapeUtil.normalizeAxis(t,e.dims[o[n]])}));for(var i=e.dims.slice(),u=[],s=0;s0&&u.push("outputIdx["+o[s]+"] += "+n[s]+";");var l="\n float process(int outputIdx["+i.length+"]) {\n "+u.join("\n ")+"\n return _A(outputIdx);\n }";return{inputLayouts:[t.getOrCreateTextureLayout(e)],outputLayout:t.createTextureLayoutFromShape(i),samplers:["A"],shaderSource:l}}function c(t,e,n){var r=[t.getOrCreateTextureData(n[0],e.inputLayouts[0])];return{inputTextureDatas:r,outputTextureData:t.createTextureDataFromLayout(e.outputLayout,r[0].tensor.type),uniformData:{}}}e.WebGLSliceV10=s},function(t,e,n){"use strict";var r,o=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),i=this&&this.__read||function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a},a=this&&this.__spread||function(){for(var t=[],e=0;e max)\n max = current;\n }\n\n return max;\n }";return{inputLayouts:[i],outputLayout:t.createTextureLayoutFromShape(o),samplers:["A"],shaderSource:f}},e.prototype.createProgramInfos=function(t,e){var n=e[0].dims.slice(),r=s.ShapeUtil.normalizeAxis(this.axis,n.length),o=s.ShapeUtil.sizeToDimension(n,r),i=s.ShapeUtil.sizeFromDimension(n,r),a=this.createComputeMaxProgramInfo(t,e[0],o,i,[o]),u=this.createComputScaleProgramInfo(t,e[0],o,i,a.outputLayout,[o]);return[a,u,this.createSoftMaxProgramInfo(t,e[0],o,i,a.outputLayout,u.outputLayout)]},e.prototype.createRunDatas=function(t,e,n){var r=n[0].type,o=t.getOrCreateTextureData(n[0],e[0].inputLayouts[0]),i=[];i.push({inputTextureDatas:[o],outputTextureData:t.createTextureDataFromLayout(e[0].outputLayout,r),uniformData:{}});for(var u=1;u0)&&!(r=i.next()).done;)a.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a};Object.defineProperty(e,"__esModule",{value:!0}),e.WebGLSplit=void 0;var a=n(146),u=n(0),s=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.run=function(t,e){var n=this;if(!this.artifacts){this.artifacts=[];for(var r=u.ShapeUtil.normalizeAxis(this.axis,e[0].dims.length),o=this.getProgramCount(t,e,r),i=0;i0)&&!(r=i.next()).done;)a.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a},a=this&&this.__spread||function(){for(var t=[],e=0;e=0;p--)l[p]=p===u-1?1:l[p+1]*o[p+1],c[p]=p===u-1?1:c[p+1]*e[0].dims[p+1],f+="\n output_pitches["+p+"] = "+l[p]+";\n input_pitches["+p+"] = "+c[p]+";\n ";var h="\n float getInputFloat(int index) {\n vec2 coords = offsetToCoords(index, "+r.width+", "+r.height+");\n float value = getColorAsFloat("+s.texture2D+"(X, coords));\n return value;\n }\n ";return{inputLayouts:[r],outputLayout:i,samplers:["X"],shaderSource:"nearest"===this.mode?"\n "+h+"\n float process(int indices["+u+"]) {\n int input_index = 0;\n int output_index = coordsToOffset(TexCoords, "+i.width+", "+i.height+");\n\n "+f+"\n\n int d, m;\n for (int dim = 0; dim < "+u+"; ++dim) {\n d = output_index / output_pitches[dim];\n m = output_index - d * output_pitches[dim];\n output_index = m;\n\n if (scales[dim] != 1 && d > 0) {\n int d2 = d / scales[dim];\n m = d - d2 * scales[dim];\n d = d2;\n }\n input_index += input_pitches[dim] * d;\n }\n\n return getInputFloat(input_index);\n }":4===u?"\n "+h+"\n float process(int indices[4]) {\n int input_index = 0;\n int output_index = coordsToOffset(TexCoords, "+i.width+", "+i.height+");\n\n "+f+"\n\n int m;\n int index_of_dim0, index_of_dim1, index_of_dim2, index_of_dim3;\n index_of_dim0 = output_index / output_pitches[0];\n m = output_index - index_of_dim0 * output_pitches[0];\n index_of_dim1 = m / output_pitches[1];\n m = m - index_of_dim1 * output_pitches[1];\n index_of_dim2 = m / output_pitches[2];\n m = m - index_of_dim2 * output_pitches[2];\n index_of_dim3 = m;\n\n int index_of_input_dim2, index_of_input_dim3, x_offset, y_offset;\n index_of_input_dim2 = index_of_dim2 / scales[2];\n y_offset = index_of_dim2 - index_of_input_dim2 * scales[2];\n index_of_input_dim3 = index_of_dim3 / scales[3];\n x_offset = index_of_dim3 - index_of_input_dim3 * scales[3];\n\n input_index = index_of_dim0 * input_pitches[0] +\n index_of_dim1 * input_pitches[1] +\n index_of_input_dim2 * input_pitches[2] +\n index_of_input_dim3;\n\n float x00 = getInputFloat(input_index);\n float x10, x01, x11;\n\n bool end_of_dim2 = false;\n if (index_of_input_dim2 == ("+e[0].dims[2]+" - 1)) {\n // It's the end in dimension 2\n x01 = x00;\n end_of_dim2 = true;\n } else {\n x01 = getInputFloat(input_index + input_pitches[2]);\n }\n\n if (index_of_input_dim3 == (input_pitches[2] - 1)) {\n // It's the end in dimension 3\n x10 = x00;\n x11 = x01;\n }\n else {\n x10 = getInputFloat(input_index + 1);\n x11 = end_of_dim2 ? x10 : getInputFloat(input_index + input_pitches[2] + 1);\n }\n\n float y0 = x00 + float(y_offset) * (x01 - x00) / float(scales[2]);\n float y1 = x10 + float(y_offset) * (x11 - x10) / float(scales[2]);\n return y0 + float(x_offset) * (y1 - y0) / float(scales[3]);\n }":"\n "+h+"\n float process(int indices[2]) {\n int input_index = 0;\n int output_index = coordsToOffset(TexCoords, "+i.width+", "+i.height+");\n\n "+f+"\n\n int m;\n int index_of_dim0, index_of_dim1;\n index_of_dim0 = output_index / output_pitches[0];\n m = output_index - index_of_dim0 * output_pitches[0];\n index_of_dim1 = m;\n\n int index_of_input_dim0, index_of_input_dim1, x_offset, y_offset;\n index_of_input_dim0 = index_of_dim0 / scales[0];\n y_offset = index_of_dim0 - index_of_input_dim0 * scales[0];\n index_of_input_dim1 = index_of_dim1 / scales[1];\n x_offset = index_of_dim1 - index_of_input_dim1 * scales[1];\n\n input_index = index_of_input_dim0 * input_pitches[0] + index_of_input_dim1;\n\n float x00 = getInputFloat(input_index);\n float x10, x01, x11;\n\n bool end_of_dim0 = false;\n if (index_of_input_dim0 == ("+e[0].dims[0]+" - 1)) {\n // It's the end in dimension 0\n x01 = x00;\n end_of_dim0 = true;\n } else {\n x01 = getInputFloat(input_index + input_pitches[0]);\n }\n\n if (index_of_input_dim1 == (input_pitches[0] - 1)) {\n // It's the end in dimension 1\n x10 = x00;\n x11 = x01;\n }\n else {\n x10 = getInputFloat(input_index + 1);\n x11 = end_of_dim0 ? x10 : getInputFloat(input_index + input_pitches[0] + 1);\n }\n\n float y0 = x00 + float(y_offset) * (x01 - x00) / float(scales[0]);\n float y1 = x10 + float(y_offset) * (x11 - x10) / float(scales[0]);\n return y0 + float(x_offset) * (y1 - y0) / float(scales[1]);\n }",variables:[{name:"scales",type:"int",arrayLength:this.scales.length}]}},e.prototype.createRunData=function(t,e,n){var r=n.map((function(n,r){return t.getOrCreateTextureData(n,e.inputLayouts[r])}));return{inputTextureDatas:r,outputTextureData:t.createTextureDataFromLayout(e.outputLayout,r[0].tensor.type),uniformData:{scales:this.scales.map((function(t){return Math.ceil(t)}))}}},e}(i.Upsample);e.WebGLUpsample=u},function(t,e,n){"use strict";var r=this&&this.__assign||function(){return(r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(e,"__esModule",{value:!0}),e.ProgramManager=void 0;var i=n(25),a=n(3),u=n(155),s=n(2),l=function(){function t(t,e){this.profiler=t,this.glContext=e,this.repo=new Map,this.attributesBound=!1}return t.prototype.getArtifact=function(t){return this.repo.get(t)},t.prototype.setArtifact=function(t,e){this.repo.set(t,e)},t.prototype.run=function(t,e){var n=this;this.profiler.event("backend","ProgramManager.run",(function(){var r=n.glContext.gl,o=t.program;r.useProgram(o);try{n.bindOutput(e.outputTextureData),n.attributesBound||n.bindAttributes(t.attribLocations),n.bindUniforms(t.uniformLocations,e.uniformData,e.inputTextureDatas)}catch(e){throw a.Logger.error("ProgramManager",t.programInfo.shaderSource),e}n.profiler.event("backend","GlContext.draw()",(function(){n.doDraw(t,e),r.flush()}))}))},t.prototype.dispose=function(){var t=this;this.vertexShader&&this.glContext.deleteShader(this.vertexShader),this.repo.forEach((function(e){return t.glContext.deleteProgram(e.program)}))},t.prototype.build=function(t){var e=this;return this.profiler.event("backend","ProgramManager.build",(function(){var n=new u.GlslPreprocessor(e.glContext,t),r=n.preprocess(),o=e.compile(r);return{programInfo:t,program:o,uniformLocations:e.getUniformLocations(o,n.context.programInfo.samplers,n.context.programInfo.variables),attribLocations:e.getAttribLocations(o)}}))},t.prototype.doDraw=function(t,e){e.draw?(a.Logger.verbose("ProgramManager","Custom draw function"),e.draw(this.glContext,t)):this.glContext.draw()},t.prototype.compile=function(t){if(!this.vertexShader){a.Logger.verbose("ProrgramManager","Compiling and caching Vertex shader for the first time");var e=s.getVertexShaderSource(this.glContext.version);this.vertexShader=this.glContext.compileShader(e,this.glContext.gl.VERTEX_SHADER)}i.env.debug&&a.Logger.verbose("ProrgramManager","FragShader:\n"+t+"\n");var n=this.glContext.compileShader(t,this.glContext.gl.FRAGMENT_SHADER),r=this.glContext.createProgram(this.vertexShader,n);return this.glContext.deleteShader(n),r},t.prototype.bindOutput=function(t){a.Logger.verbose("ProrgramManager","Binding output texture to Framebuffer: w/h="+t.width+"/"+t.height+", shape="+t.shape+", type="+t.tensor.type),this.glContext.attachFramebuffer(t.texture,t.width,t.height)},t.prototype.bindAttributes=function(t){var e=t.position,n=t.textureCoord;this.glContext.setVertexAttributes(e,n),this.attributesBound=!0},t.prototype.bindUniforms=function(t,e,n){var r,i,a=this.glContext.gl,u=0;try{for(var s=o(t),l=s.next();!l.done;l=s.next()){var c=l.value,f=c.name,p=c.type,h=c.location,d=c.arrayLength;switch(p){case"sampler2D":this.bindTexture(n[u],h,u),u++;break;case"float":d?a.uniform1fv(h,e[f]):a.uniform1f(h,e[f]);break;case"int":d?a.uniform1iv(h,e[f]):a.uniform1i(h,e[f]);break;default:throw new Error("Uniform not implemented: "+p)}}}catch(t){r={error:t}}finally{try{l&&!l.done&&(i=s.return)&&i.call(s)}finally{if(r)throw r.error}}},t.prototype.bindTexture=function(t,e,n){this.glContext.bindTextureToUniform(t.texture,n,e)},t.prototype.getAttribLocations=function(t){return{position:this.getAttribLocation(t,"position"),textureCoord:this.getAttribLocation(t,"textureCoord")}},t.prototype.getUniformLocations=function(t,e,n){var i,a,u,s,l=[];if(e)try{for(var c=o(e),f=c.next();!f.done;f=c.next()){var p=f.value;l.push({name:p,type:"sampler2D",location:this.getUniformLocation(t,p)})}}catch(t){i={error:t}}finally{try{f&&!f.done&&(a=c.return)&&a.call(c)}finally{if(i)throw i.error}}if(n)try{for(var h=o(n),d=h.next();!d.done;d=h.next()){var y=d.value;l.push(r(r({},y),{location:this.getUniformLocation(t,y.name)}))}}catch(t){u={error:t}}finally{try{d&&!d.done&&(s=h.return)&&s.call(h)}finally{if(u)throw u.error}}return l},t.prototype.getUniformLocation=function(t,e){var n=this.glContext.gl.getUniformLocation(t,e);if(null===n)throw new Error("Uniform "+e+" not found.");return n},t.prototype.getAttribLocation=function(t,e){return this.glContext.gl.getAttribLocation(t,e)},t}();e.ProgramManager=l},function(t,e,n){"use strict";var r=this&&this.__values||function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(e,"__esModule",{value:!0}),e.GlslPreprocessor=void 0;var o=n(5),i=n(156),a=n(157),u=n(2),s=function(){function t(t,e){var n=this;this.libs={},this.glslLibRoutineDependencyGraph={},this.context=new o.GlslContext(t,e),Object.keys(a.glslRegistry).forEach((function(t){var e=new a.glslRegistry[t](n.context);n.libs[t]=e}));var r=this.glslLibRoutineDependencyGraph;for(var i in this.libs){var u=this.libs[i].getFunctions();for(var s in u){var l=i+"."+s,c=void 0;r[l]?(c=r[l]).routineBody=u[s].routineBody:(c=new o.GlslLibRoutineNode(l,u[s].routineBody),r[l]=c);var f=u[s].dependencies;if(f)for(var p=0;pe)){for(var u=i.length,s=e-u,l="bcastMatmulIndices_"+r,c="",f=0;f=0;--o)r+="\n offset += indices["+o+"] * "+n[o]+";\n ";return"\n int "+t+"(int indices["+e+"]) {\n int offset = 0;\n "+r+"\n return offset;\n }\n "},e.prototype.offsetToIndices=function(){var t=this.context.programInfo,n={};return this.context.programInfo.samplers.forEach((function(r,o){var i=t.inputLayouts[o].shape,u=t.inputLayouts[o].strides,s=i.length,l="offsetToIndices_"+r;n[l]=new a.GlslLibRoutine(e.offsetToIndicesSingle(l,s,u)),n[l="offsetToIndices_"+r+"_T"]=new a.GlslLibRoutine(e.offsetToIndicesSingle(l,s,u.slice().reverse()))})),n},e.offsetToIndicesSingle=function(t,e,n){for(var r=[],o=0;o= 0; --i) {\n if(i > axis) continue;\n indices[i] += 1;\n if(indices[i] < shape[i]) {\n break;\n }\n indices[i] = 0;\n }\n }\n ";e[u]=new a.GlslLibRoutine(c)})),e},e}(a.GlslLib);e.ShapeUtilsGlslLib=u},function(t,e,n){"use strict";var r,o=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),i=this&&this.__assign||function(){return(i=Object.assign||function(t){for(var e,n=1,r=arguments.length;n=t.length?1:t.slice(e.breakAxis).reduce((function(t,e){return t*e})),i=e.breakAxis<=0?1:t.slice(0,e.breakAxis).reduce((function(t,e){return t*e}));if(!(o>n||i>n))return[o,i];r.Logger.verbose("TextureLayout","Given width/height preferences were unattainable: shape:"+t+", breakAxis:"+e.breakAxis)}for(var a=t.reduce((function(t,e){return t*e})),u=Math.floor(Math.sqrt(a));u=n||a%u!=0)throw new Error("The given dimensions are outside this GPU's boundaries: "+t);return[u,a/u]},t}();e.AlwaysKeepOriginalSizeStrategy=o},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.TextureManager=void 0;var r=n(3),o=function(){function t(t,e,n,r){this.glContext=t,this.layoutStrategy=e,this.profiler=n,this.config=r,r.reuseTextures&&(this.inUseTextures=new Map,this.idleTextures=new Map,this.textureLookup=new Map)}return t.prototype.createTextureFromLayout=function(t,e,n,o){var i,a,u=this.toEncoderType(t),s=this.glContext.getEncoder(u,e.channels||1,o);if(this.config.reuseTextures){i=e.width+"x"+e.height+"_"+s.format+"_"+s.internalFormat+"_"+s.textureType,(a=this.inUseTextures.get(i))||(a=[],this.inUseTextures.set(i,a));var l=this.idleTextures.get(i);if(l&&l.length>0){var c=l.pop();return a.push(c),1===o&&this.glContext.updateTexture(c,e.width,e.height,s,this.toTextureData(t,n)),c}}r.Logger.verbose("TextureManager","Creating new texture of size "+e.width+"x"+e.height);var f=this.glContext.allocateTexture(e.width,e.height,s,this.toTextureData(t,n));return this.config.reuseTextures&&(a.push(f),this.textureLookup.set(f,i)),f},t.prototype.readTexture=function(t,e,n){var r=this;return n||(n=1),this.profiler.event("backend","TextureManager.readTexture",(function(){var o=t.shape.reduce((function(t,e){return t*e}))*n,i=r.glContext.readTexture(t.texture,t.width,t.height,o,r.toEncoderType(e),n);return r.toTensorData(e,i)}))},t.prototype.readUint8TextureAsFloat=function(t){var e=this;return this.profiler.event("backend","TextureManager.readUint8TextureAsFloat",(function(){var n=t.shape.reduce((function(t,e){return t*e})),r=e.glContext.readTexture(t.texture,t.width,t.height,4*n,"byte",4);return new Float32Array(r.buffer,r.byteOffset,n)}))},t.prototype.releaseTexture=function(t,e){var n;if(this.config.reuseTextures&&(n=this.textureLookup.get(t.texture))){e&&this.textureLookup.delete(n);var o=this.inUseTextures.get(n);if(o){var i=o.indexOf(t.texture);if(-1!==i){o.splice(i,1);var a=this.idleTextures.get(n);a||(a=[],this.idleTextures.set(n,a)),a.push(t.texture)}}}n&&!e||(r.Logger.verbose("TextureManager","Deleting texture of size "+t.width+"x"+t.height),this.glContext.deleteTexture(t.texture))},t.prototype.toTensorData=function(t,e){return e instanceof Float32Array?e:new Float32Array(e)},t.prototype.toTextureData=function(t,e){if(e)return e instanceof Float32Array?e:new Float32Array(e)},t.prototype.toEncoderType=function(t){return"float"},t.prototype.clearActiveTextures=function(){this.glContext.clearActiveTextures()},t}();e.TextureManager=o},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.createNewWebGLContext=e.createWebGLContext=void 0;var r=n(3),o=n(166),i={};function a(t){var e,n=function(){var t=document.createElement("canvas");return t.width=1,t.height=1,t}(),i={alpha:!1,depth:!1,antialias:!1,stencil:!1,preserveDrawingBuffer:!1,premultipliedAlpha:!1,failIfMajorPerformanceCaveat:!1};if((!t||"webgl2"===t)&&(e=n.getContext("webgl2",i)))try{return new o.WebGLContext(e,2)}catch(t){r.Logger.warning("GlContextFactory","failed to create WebGLContext using contextId 'webgl2'. Error: "+t)}if((!t||"webgl"===t)&&(e=n.getContext("webgl",i)||n.getContext("experimental-webgl",i)))try{return new o.WebGLContext(e,1)}catch(t){r.Logger.warning("GlContextFactory","failed to create WebGLContext using contextId 'webgl' or 'experimental-webgl'. Error: "+t)}throw new Error("WebGL is not supported")}e.createWebGLContext=function t(e){var n;e&&"webgl2"!==e||!("webgl2"in i)?e&&"webgl"!==e||!("webgl"in i)||(n=i.webgl):n=i.webgl2,n=n||a(e),e=e||1===n.version?"webgl":"webgl2";var r=n.gl;return i[e]=n,r.isContextLost()?(delete i[e],t(e)):(r.disable(r.DEPTH_TEST),r.disable(r.STENCIL_TEST),r.disable(r.BLEND),r.disable(r.DITHER),r.disable(r.POLYGON_OFFSET_FILL),r.disable(r.SAMPLE_COVERAGE),r.enable(r.SCISSOR_TEST),r.enable(r.CULL_FACE),r.cullFace(r.BACK),n)},e.createNewWebGLContext=a},function(t,e,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n),Object.defineProperty(t,r,{enumerable:!0,get:function(){return e[n]}})}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),o=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),i=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.hasOwnProperty.call(t,n)&&r(e,t,n);return o(e,t),e};Object.defineProperty(e,"__esModule",{value:!0}),e.WebGLContext=void 0;var a=n(25),u=i(n(167)),s=function(){function t(t,e){this.frameBufferBound=!1,this.gl=t,this.version=e,this.getExtensions(),this.vertexbuffer=this.createVertexbuffer(),this.framebuffer=this.createFramebuffer(),this.queryVitalParameters()}return t.prototype.allocateTexture=function(t,e,n,r){var o=this.gl,i=o.createTexture();o.bindTexture(o.TEXTURE_2D,i),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,o.NEAREST),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,o.NEAREST),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE);var a=r?n.encode(r,t*e):null;return o.texImage2D(o.TEXTURE_2D,0,n.internalFormat,t,e,0,n.format,n.textureType,a),this.checkError(),i},t.prototype.updateTexture=function(t,e,n,r,o){var i=this.gl;i.bindTexture(i.TEXTURE_2D,t);var a=r.encode(o,e*n);i.texSubImage2D(i.TEXTURE_2D,0,0,0,e,n,r.format,r.textureType,a),this.checkError()},t.prototype.attachFramebuffer=function(t,e,n){var r=this.gl;r.bindTexture(r.TEXTURE_2D,t),r.bindFramebuffer(r.FRAMEBUFFER,this.framebuffer),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,t,0),this.checkError(),r.viewport(0,0,e,n),r.scissor(0,0,e,n)},t.prototype.readTexture=function(t,e,n,r,o,i){var a=this.gl;i||(i=1),this.frameBufferBound||this.attachFramebuffer(t,e,n);var u=this.getEncoder(o,i),s=u.allocate(e*n);return a.bindTexture(a.TEXTURE_2D,t),a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,t,0),a.readPixels(0,0,e,n,a.RGBA,u.textureType,s),this.checkError(),u.decode(s,r)},t.prototype.isFramebufferReady=function(){return!0},t.prototype.getActiveTexture=function(){var t=this.gl;return"TEXTURE"+(t.getParameter(this.gl.ACTIVE_TEXTURE)-t.TEXTURE0)},t.prototype.getTextureBinding=function(){return this.gl.getParameter(this.gl.TEXTURE_BINDING_2D)},t.prototype.getFramebufferBinding=function(){return this.gl.getParameter(this.gl.FRAMEBUFFER_BINDING)},t.prototype.setVertexAttributes=function(t,e){var n=this.gl;n.vertexAttribPointer(t,3,n.FLOAT,!1,20,0),n.enableVertexAttribArray(t),-1!==e&&(n.vertexAttribPointer(e,2,n.FLOAT,!1,20,12),n.enableVertexAttribArray(e)),this.checkError()},t.prototype.createProgram=function(t,e){var n=this.gl,r=n.createProgram();return n.attachShader(r,t),n.attachShader(r,e),n.linkProgram(r),r},t.prototype.compileShader=function(t,e){var n=this.gl,r=n.createShader(e);if(!r)throw new Error("createShader() returned null with type "+e);if(n.shaderSource(r,t),n.compileShader(r),!1===n.getShaderParameter(r,n.COMPILE_STATUS))throw new Error("Failed to compile shader: "+n.getShaderInfoLog(r));return r},t.prototype.deleteShader=function(t){this.gl.deleteShader(t)},t.prototype.bindTextureToUniform=function(t,e,n){var r=this.gl;r.activeTexture(r.TEXTURE0+e),this.checkError(),r.bindTexture(r.TEXTURE_2D,t),this.checkError(),r.uniform1i(n,e),this.checkError()},t.prototype.draw=function(){this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4),this.checkError()},t.prototype.checkError=function(){if(a.env.debug){var t=this.gl,e=t.getError(),n="";switch(e){case t.NO_ERROR:return;case t.INVALID_ENUM:n="INVALID_ENUM";break;case t.INVALID_VALUE:n="INVALID_VALUE";break;case t.INVALID_OPERATION:n="INVALID_OPERATION";break;case t.INVALID_FRAMEBUFFER_OPERATION:n="INVALID_FRAMEBUFFER_OPERATION";break;case t.OUT_OF_MEMORY:n="OUT_OF_MEMORY";break;case t.CONTEXT_LOST_WEBGL:n="CONTEXT_LOST_WEBGL";break;default:n="Unknown WebGL Error: "+e.toString(16)}throw new Error(n)}},t.prototype.deleteTexture=function(t){this.gl.deleteTexture(t)},t.prototype.deleteProgram=function(t){this.gl.deleteProgram(t)},t.prototype.getEncoder=function(t,e,n){if(void 0===n&&(n=0),2===this.version)return new u.RedFloat32DataEncoder(this.gl,e);switch(t){case"float":return 1===n||this.isRenderFloat32Supported?new u.RGBAFloatDataEncoder(this.gl,e):new u.RGBAFloatDataEncoder(this.gl,e,this.textureHalfFloatExtension.HALF_FLOAT_OES);case"int":throw new Error("not implemented");case"byte":return new u.Uint8DataEncoder(this.gl,e);default:throw new Error("Invalid dataType: "+t)}},t.prototype.clearActiveTextures=function(){for(var t=this.gl,e=0;et.length?(r.Logger.warning("Encoder","Source data too small. Allocating larger array"),o=t,n=this.allocate(e*this.channelSize),o.forEach((function(t,e){return n[e]=t}))):n=o=t,n},t.prototype.allocate=function(t){return new Float32Array(4*t)},t.prototype.decode=function(t,e){return 1===this.channelSize?t.filter((function(t,e){return e%4==0})).subarray(0,e):t.subarray(0,e)},t}();e.RedFloat32DataEncoder=o;var i=function(){function t(t,e,n){if(void 0===e&&(e=1),1!==e&&4!==e)throw new Error("Invalid number of channels: "+e);this.internalFormat=t.RGBA,this.format=t.RGBA,this.channelSize=e,this.textureType=n||t.FLOAT}return t.prototype.encode=function(t,e){var n=t;return 1===this.channelSize&&(r.Logger.verbose("Encoder","Exploding into a larger array"),n=this.allocate(e),t.forEach((function(t,e){return n[4*e]=t}))),n},t.prototype.allocate=function(t){return new Float32Array(4*t)},t.prototype.decode=function(t,e){return 1===this.channelSize?t.filter((function(t,e){return e%4==0})).subarray(0,e):t.subarray(0,e)},t}();e.RGBAFloatDataEncoder=i;var a=function(){function t(t,e){if(void 0===e&&(e=1),this.channelSize=4,1===e)this.internalFormat=t.ALPHA,this.format=t.ALPHA,this.textureType=t.UNSIGNED_BYTE,this.channelSize=e;else{if(4!==e)throw new Error("Invalid number of channels: "+e);this.internalFormat=t.RGBA,this.format=t.RGBA,this.textureType=t.UNSIGNED_BYTE,this.channelSize=e}}return t.prototype.encode=function(t,e){return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)},t.prototype.allocate=function(t){return new Uint8Array(t*this.channelSize)},t.prototype.decode=function(t,e){if(t instanceof Uint8Array)return t.subarray(0,e);throw new Error("Invalid array type: "+t.constructor)},t}();e.Uint8DataEncoder=a},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.envImpl=void 0;var r=n(25),o=function(){function t(){}return Object.defineProperty(t.prototype,"debug",{get:function(){return r.env.debug},set:function(t){r.env.debug=t},enumerable:!1,configurable:!0}),t}();e.envImpl=new o},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},function(t,e,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n),Object.defineProperty(t,r,{enumerable:!0,get:function(){return e[n]}})}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),o=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),i=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.hasOwnProperty.call(t,n)&&r(e,t,n);return o(e,t),e};Object.defineProperty(e,"__esModule",{value:!0}),e.Tensor=void 0;var a=i(n(51));e.Tensor=a.Tensor},function(t,e,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n),Object.defineProperty(t,r,{enumerable:!0,get:function(){return e[n]}})}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),o=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),i=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.hasOwnProperty.call(t,n)&&r(e,t,n);return o(e,t),e};Object.defineProperty(e,"__esModule",{value:!0}),e.InferenceSession=void 0;var a=i(n(173));e.InferenceSession=a.InferenceSession},function(t,e,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n),Object.defineProperty(t,r,{enumerable:!0,get:function(){return e[n]}})}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),o=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),i=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.hasOwnProperty.call(t,n)&&r(e,t,n);return o(e,t),e},a=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function u(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}s((r=r.apply(t,e||[])).next())}))},u=this&&this.__generator||function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]=i)return t;switch(t){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(t){return"[Circular]"}default:return t}})),s=r[n];n=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),d(n)?r.showHidden=n:n&&e._extend(r,n),v(r.showHidden)&&(r.showHidden=!1),v(r.depth)&&(r.depth=2),v(r.colors)&&(r.colors=!1),v(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=s),c(r,t,r.depth)}function s(t,e){var n=u.styles[e];return n?"["+u.colors[n][0]+"m"+t+"["+u.colors[n][1]+"m":t}function l(t,e){return t}function c(t,n,r){if(t.customInspect&&n&&T(n.inspect)&&n.inspect!==e.inspect&&(!n.constructor||n.constructor.prototype!==n)){var o=n.inspect(r,t);return m(o)||(o=c(t,o,r)),o}var i=function(t,e){if(v(e))return t.stylize("undefined","undefined");if(m(e)){var n="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(n,"string")}if(g(e))return t.stylize(""+e,"number");if(d(e))return t.stylize(""+e,"boolean");if(y(e))return t.stylize("null","null")}(t,n);if(i)return i;var a=Object.keys(n),u=function(t){var e={};return t.forEach((function(t,n){e[t]=!0})),e}(a);if(t.showHidden&&(a=Object.getOwnPropertyNames(n)),x(n)&&(a.indexOf("message")>=0||a.indexOf("description")>=0))return f(n);if(0===a.length){if(T(n)){var s=n.name?": "+n.name:"";return t.stylize("[Function"+s+"]","special")}if(b(n))return t.stylize(RegExp.prototype.toString.call(n),"regexp");if(w(n))return t.stylize(Date.prototype.toString.call(n),"date");if(x(n))return f(n)}var l,_="",O=!1,S=["{","}"];(h(n)&&(O=!0,S=["[","]"]),T(n))&&(_=" [Function"+(n.name?": "+n.name:"")+"]");return b(n)&&(_=" "+RegExp.prototype.toString.call(n)),w(n)&&(_=" "+Date.prototype.toUTCString.call(n)),x(n)&&(_=" "+f(n)),0!==a.length||O&&0!=n.length?r<0?b(n)?t.stylize(RegExp.prototype.toString.call(n),"regexp"):t.stylize("[Object]","special"):(t.seen.push(n),l=O?function(t,e,n,r,o){for(var i=[],a=0,u=e.length;a=0&&0,t+e.replace(/\u001b\[\d\d?m/g,"").length+1}),0)>60)return n[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+n[1];return n[0]+e+" "+t.join(", ")+" "+n[1]}(l,_,S)):S[0]+_+S[1]}function f(t){return"["+Error.prototype.toString.call(t)+"]"}function p(t,e,n,r,o,i){var a,u,s;if((s=Object.getOwnPropertyDescriptor(e,o)||{value:e[o]}).get?u=s.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):s.set&&(u=t.stylize("[Setter]","special")),D(r,o)||(a="["+o+"]"),u||(t.seen.indexOf(s.value)<0?(u=y(n)?c(t,s.value,null):c(t,s.value,n-1)).indexOf("\n")>-1&&(u=i?u.split("\n").map((function(t){return" "+t})).join("\n").substr(2):"\n"+u.split("\n").map((function(t){return" "+t})).join("\n")):u=t.stylize("[Circular]","special")),v(a)){if(i&&o.match(/^\d+$/))return u;(a=JSON.stringify(""+o)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.substr(1,a.length-2),a=t.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=t.stylize(a,"string"))}return a+": "+u}function h(t){return Array.isArray(t)}function d(t){return"boolean"==typeof t}function y(t){return null===t}function g(t){return"number"==typeof t}function m(t){return"string"==typeof t}function v(t){return void 0===t}function b(t){return _(t)&&"[object RegExp]"===O(t)}function _(t){return"object"==typeof t&&null!==t}function w(t){return _(t)&&"[object Date]"===O(t)}function x(t){return _(t)&&("[object Error]"===O(t)||t instanceof Error)}function T(t){return"function"==typeof t}function O(t){return Object.prototype.toString.call(t)}function S(t){return t<10?"0"+t.toString(10):t.toString(10)}e.debuglog=function(n){if(v(i)&&(i=t.env.NODE_DEBUG||""),n=n.toUpperCase(),!a[n])if(new RegExp("\\b"+n+"\\b","i").test(i)){var r=t.pid;a[n]=function(){var t=e.format.apply(e,arguments);console.error("%s %d: %s",n,r,t)}}else a[n]=function(){};return a[n]},e.inspect=u,u.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},u.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},e.isArray=h,e.isBoolean=d,e.isNull=y,e.isNullOrUndefined=function(t){return null==t},e.isNumber=g,e.isString=m,e.isSymbol=function(t){return"symbol"==typeof t},e.isUndefined=v,e.isRegExp=b,e.isObject=_,e.isDate=w,e.isError=x,e.isFunction=T,e.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},e.isBuffer=n(176);var P=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function A(){var t=new Date,e=[S(t.getHours()),S(t.getMinutes()),S(t.getSeconds())].join(":");return[t.getDate(),P[t.getMonth()],e].join(" ")}function D(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.log=function(){console.log("%s - %s",A(),e.format.apply(e,arguments))},e.inherits=n(177),e._extend=function(t,e){if(!e||!_(e))return t;for(var n=Object.keys(e),r=n.length;r--;)t[n[r]]=e[n[r]];return t};var E="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function I(t,e){if(!t){var n=new Error("Promise was rejected with a falsy value");n.reason=t,t=n}return e(t)}e.promisify=function(t){if("function"!=typeof t)throw new TypeError('The "original" argument must be of type Function');if(E&&t[E]){var e;if("function"!=typeof(e=t[E]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(e,E,{value:e,enumerable:!1,writable:!1,configurable:!0}),e}function e(){for(var e,n,r=new Promise((function(t,r){e=t,n=r})),o=[],i=0;i0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(e,"__esModule",{value:!0}),e.Backend=void 0;var a=new Map;function u(t){return r(this,void 0,void 0,(function(){var e,n,r;return o(this,(function(o){switch(o.label){case 0:return void 0!==(e=onnx.backend)[t]&&function(t){var e=t;if("initialize"in e&&"function"==typeof e.initialize&&"createSessionHandler"in e&&"function"==typeof e.createSessionHandler&&"dispose"in e&&"function"==typeof e.dispose)return!0;return!1}(e[t])?e[t].disabled?[3,3]:(n=e[t],"object"==typeof(r=n.initialize())&&"then"in r?[4,r]:[3,2]):[3,3];case 1:r=o.sent(),o.label=2;case 2:if(r)return a.set(t,n),[2,n];o.label=3;case 3:return[2,void 0]}}))}))}e.Backend=function t(e){return r(this,void 0,void 0,(function(){var n,r,s,l,c,f,p,h,d;return o(this,(function(o){switch(o.label){case 0:return e?[3,1]:[2,t(["webgl","wasm","cpu"])];case 1:n="string"==typeof e?[e]:e,o.label=2;case 2:o.trys.push([2,7,8,9]),r=i(n),s=r.next(),o.label=3;case 3:return s.done?[3,6]:(l=s.value,(c=a.get(l))?[2,c]:[4,u(l)]);case 4:if(f=o.sent())return[2,f];o.label=5;case 5:return s=r.next(),[3,3];case 6:return[3,9];case 7:return p=o.sent(),h={error:p},[3,9];case 8:try{s&&!s.done&&(d=r.return)&&d.call(r)}finally{if(h)throw h.error}return[7];case 9:throw new Error("no available backend to use")}}))}))}},function(t,e,n){"use strict";var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function u(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}s((r=r.apply(t,e||[])).next())}))},o=this&&this.__generator||function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},a=this&&this.__read||function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a},u=this&&this.__spread||function(){for(var t=[],e=0;e=3");this._opsets=n.opsetImport.map((function(t){return{domain:t.domain,version:i.LongUtil.longToNumber(t.version)}})),this._graph=o.Graph.from(n.graph,e)},Object.defineProperty(t.prototype,"graph",{get:function(){return this._graph},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"opsets",{get:function(){return this._opsets},enumerable:!1,configurable:!0}),t}();e.Model=a},function(t,e,n){"use strict";var r=this&&this.__values||function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(e,"__esModule",{value:!0}),e.Graph=void 0;var o=n(182),i=n(1),a=n(0);e.Graph={from:function(t,e){return new l(t,e)}};var u=function(){function t(t){this._from=void 0,this._to=[],this.tensor=void 0,this.type=void 0,t&&(this.type=a.ProtoUtil.tensorValueTypeFromProto(t.type.tensorType))}return Object.defineProperty(t.prototype,"from",{get:function(){return this._from},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"to",{get:function(){return this._to},enumerable:!1,configurable:!0}),t}(),s=function(t){this.name=t.name,this.opType=t.opType,this.inputs=[],this.outputs=[],this.attributes=new o.Attribute(t.attribute),this.executeNode=!0},l=function(){function t(t,e){if(!t)throw new TypeError("graph is empty");this.buildGraph(t),this.transformGraph(e),this.checkIsAcyclic()}return t.prototype.getInputIndices=function(){return this._allInputIndices},t.prototype.getInputNames=function(){return this._allInputNames},t.prototype.getOutputIndices=function(){return this._allOutputIndices},t.prototype.getOutputNames=function(){return this._allOutputNames},t.prototype.getValues=function(){return this._allData},t.prototype.getNodes=function(){return this._nodes},t.prototype.buildGraph=function(t){var e,n,o,l,c,f,p,h,d,y,g,m,v=new Map;this._allData=[],this._allInputIndices=[],this._allInputNames=[],this._allOutputIndices=[],this._allOutputNames=[],this._nodes=[];var b=new Map;if(!t.input)throw new Error("missing information in graph: input");var _=[];try{for(var w=r(t.input),x=w.next();!x.done;x=w.next()){var T=x.value;if(v.has(T.name))throw new Error("duplicated input name: "+T.name);var O=this._allData.push(new u(T))-1;v.set(T.name,O),_.push(T.name)}}catch(t){e={error:t}}finally{try{x&&!x.done&&(n=w.return)&&n.call(w)}finally{if(e)throw e.error}}if(!t.initializer)throw new Error("missing information in graph: initializer");try{for(var S=r(t.initializer),P=S.next();!P.done;P=S.next()){T=P.value;var A=v.get(T.name);if(void 0===A){var D=new u;D.type={shape:{dims:a.ProtoUtil.tensorDimsFromProto(T.dims)},tensorType:a.ProtoUtil.tensorDataTypeFromProto(T.dataType)},A=this._allData.push(D)-1,v.set(T.name,A)}this._allData[A]._from=-1,this._allData[A].tensor=i.Tensor.fromProto(T)}}catch(t){o={error:t}}finally{try{P&&!P.done&&(l=S.return)&&l.call(S)}finally{if(o)throw o.error}}for(T=0;T0;)o()},t.prototype.transformGraph=function(t){this.removeAllIdentityNodes(),this.removeAllDropoutNodes(),t&&t.transformGraph(this),this.finalizeGraph()},t.prototype.finalizeGraph=function(){for(var t,e=this,n=0,r=function(r){if(!o._nodes[r].executeNode)return n++,o._nodes[r].outputs.forEach((function(t){e._allData[t]._from=-2})),o._nodes.splice(r,1),r--,t=r,"continue";n>0&&(o._nodes[r].inputs.forEach((function(t){var o=e._allData[t]._to.indexOf(r+n);-1!==o&&(e._allData[t]._to[o]=r)})),o._nodes[r].outputs.forEach((function(t){e._allData[t]._from&&e._allData[t]._from===r+n&&(e._allData[t]._from=r)}))),t=r},o=this,i=0;i0){var r=-1;void 0!==s._allData[t].from&&-1!==s._allData[t].from?-1!==(r=s._nodes[s._allData[t].from].outputs.indexOf(t+n))&&(s._nodes[s._allData[t].from].outputs[r]=t):-1!==(r=s._allInputIndices.indexOf(t+n))&&(s._allInputIndices[r]=t),s._allData[t].to.forEach((function(o){-1!==(r=e._nodes[o].inputs.indexOf(t+n))&&(e._nodes[o].inputs[r]=t)})),0===s._allData[t].to.length&&-1!==(r=s._allOutputIndices.indexOf(t+n))&&(s._allOutputIndices[r]=t)}a=t},s=this;for(i=0;i1)throw new Error("Node deletion with multiple inputs is not supported. ");if(o.outputs.length>1)for(var i=1;i0)throw new Error("Node deletion with more than one output connected to other nodes is not supported. ");o.executeNode=!1;var a=o.inputs[0],u=o.outputs[0],s=this._allData[u].to,l=this._allData[a].to.indexOf(t);if(-1===l)throw new Error("The Value object doesn't have the current Node in it's 'to' property ");this._allData[a].to.splice(l,1),this._allData[u]._to=[];var c=this._allOutputIndices.indexOf(u);if(-1!==c&&(this._allOutputIndices[c]=a),s&&s.length>0)try{for(var f=r(s),p=f.next();!p.done;p=f.next()){var h=p.value,d=this._nodes[h].inputs.indexOf(u);if(-1===d)throw new Error("The Node object doesn't have the output Value in it's 'inputs' property ");this._nodes[h].inputs[d]=a,this._allData[a].to.push(h)}}catch(t){e={error:t}}finally{try{p&&!p.done&&(n=f.return)&&n.call(f)}finally{if(e)throw e.error}}},t.prototype.removeAllDropoutNodes=function(){var t,e,n=0;try{for(var o=r(this._nodes),i=o.next();!i.done;i=o.next()){var a=i.value;if("Dropout"===a.opType){if(1!==a.inputs.length)throw new Error("Dropout nodes should only contain one input. ");if(1!==a.outputs.length&&2!==a.outputs.length)throw new Error("Dropout nodes should contain either 1 or 2 output(s)");if(2===a.outputs.length&&0!==this._allData[a.outputs[1]]._to.length)throw new Error("Dropout nodes's second output should not be referenced by other nodes");this.deleteNode(n)}n++}}catch(e){t={error:e}}finally{try{i&&!i.done&&(e=o.return)&&e.call(o)}finally{if(t)throw t.error}}},t.prototype.removeAllIdentityNodes=function(){var t,e,n=0;try{for(var o=r(this._nodes),i=o.next();!i.done;i=o.next()){"Identity"===i.value.opType&&this.deleteNode(n),n++}}catch(e){t={error:e}}finally{try{i&&!i.done&&(e=o.return)&&e.call(o)}finally{if(t)throw t.error}}},t}()},function(t,e,n){"use strict";(function(t){var r=this&&this.__values||function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.Attribute=void 0;var i=o(n(13)),a=n(9),u=n(1),s=n(0),l=function(){function e(t){var n,o;if(this._attributes=new Map,null!=t){try{for(var i=r(t),a=i.next();!a.done;a=i.next()){var u=a.value;this._attributes.set(u.name,[e.getValue(u),e.getType(u)])}}catch(t){n={error:t}}finally{try{a&&!a.done&&(o=i.return)&&o.call(i)}finally{if(n)throw n.error}}if(this._attributes.size