base.js 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285
  1. const base = {};
  2. base.Complex = class Complex {
  3. constructor(real, imaginary) {
  4. this.real = real;
  5. this.imaginary = imaginary;
  6. }
  7. toString(/* radix */) {
  8. const sign = this.imaginary < 0 ? '-' : '+';
  9. const imaginary = Math.abs(this.imaginary);
  10. return `${this.real} ${sign} ${imaginary}i`;
  11. }
  12. };
  13. /* eslint-disable no-extend-native */
  14. BigInt.prototype.toNumber = function() {
  15. if (this > Number.MAX_SAFE_INTEGER || this < Number.MIN_SAFE_INTEGER) {
  16. throw new Error(`64-bit value 0x${this.toString(16)} exceeds safe integer.`);
  17. }
  18. return Number(this);
  19. };
  20. if (!DataView.prototype.getFloat16) {
  21. DataView.prototype.getFloat16 = function(byteOffset, littleEndian) {
  22. const value = this.getUint16(byteOffset, littleEndian);
  23. const e = (value & 0x7C00) >> 10;
  24. let f = value & 0x03FF;
  25. if (e === 0) {
  26. f = 0.00006103515625 * (f / 1024);
  27. } else if (e === 0x1F) {
  28. f = f ? NaN : Infinity;
  29. } else {
  30. f = DataView.__float16_pow[e] * (1 + (f / 1024));
  31. }
  32. return value & 0x8000 ? -f : f;
  33. };
  34. DataView.__float16_pow = {
  35. 1: 1 / 16384, 2: 1 / 8192, 3: 1 / 4096, 4: 1 / 2048, 5: 1 / 1024, 6: 1 / 512, 7: 1 / 256, 8: 1 / 128,
  36. 9: 1 / 64, 10: 1 / 32, 11: 1 / 16, 12: 1 / 8, 13: 1 / 4, 14: 1 / 2, 15: 1, 16: 2,
  37. 17: 4, 18: 8, 19: 16, 20: 32, 21: 64, 22: 128, 23: 256, 24: 512,
  38. 25: 1024, 26: 2048, 27: 4096, 28: 8192, 29: 16384, 30: 32768, 31: 65536
  39. };
  40. }
  41. if (!DataView.prototype.setFloat16) {
  42. DataView.prototype.setFloat16 = function(byteOffset, value, littleEndian) {
  43. DataView.__float16_float[0] = value;
  44. [value] = DataView.__float16_int;
  45. const s = (value >>> 16) & 0x8000;
  46. const e = (value >>> 23) & 0xff;
  47. const f = value & 0x7fffff;
  48. const v = s | DataView.__float16_base[e] | (f >> DataView.__float16_shift[e]);
  49. this.setUint16(byteOffset, v, littleEndian);
  50. };
  51. DataView.__float16_float = new Float32Array(1);
  52. DataView.__float16_int = new Uint32Array(DataView.__float16_float.buffer, 0, DataView.__float16_float.length);
  53. DataView.__float16_base = new Uint32Array(256);
  54. DataView.__float16_shift = new Uint32Array(256);
  55. for (let i = 0; i < 256; ++i) {
  56. const e = i - 127;
  57. if (e < -27) {
  58. DataView.__float16_base[i] = 0x0000;
  59. DataView.__float16_shift[i] = 24;
  60. } else if (e < -14) {
  61. DataView.__float16_base[i] = 0x0400 >> -e - 14;
  62. DataView.__float16_shift[i] = -e - 1;
  63. } else if (e <= 15) {
  64. DataView.__float16_base[i] = e + 15 << 10;
  65. DataView.__float16_shift[i] = 13;
  66. } else if (e < 128) {
  67. DataView.__float16_base[i] = 0x7c00;
  68. DataView.__float16_shift[i] = 24;
  69. } else {
  70. DataView.__float16_base[i] = 0x7c00;
  71. DataView.__float16_shift[i] = 13;
  72. }
  73. }
  74. }
  75. if (!DataView.prototype.getBfloat16) {
  76. DataView.prototype.getBfloat16 = function(byteOffset, littleEndian) {
  77. const value = this.getUint16(byteOffset, littleEndian);
  78. DataView.__bfloat16_get_u32[0] = (value << 16) >>> 0;
  79. return DataView.__bfloat16_get_f32[0];
  80. };
  81. DataView.__bfloat16_get_f32 = new Float32Array(1);
  82. DataView.__bfloat16_get_u32 = new Uint32Array(DataView.__bfloat16_get_f32.buffer);
  83. }
  84. if (!DataView.prototype.getFloat4e2m1) {
  85. DataView.__float4e2m1_float32 = new Float32Array([0, 0.5, 1, 1.5, 2, 3, 4, 6, -0, -0.5, -1, -1.5, -2, -3, -4, -6]);
  86. DataView.prototype.getFloat4e2m1 = function(byteOffset) {
  87. let value = this.getUint8(byteOffset >> 1);
  88. value = byteOffset & 1 ? value >> 4 : value & 0x0F;
  89. return DataView.__float4e2m1_float32[value];
  90. };
  91. }
  92. if (!DataView.prototype.getFloat8e4m3) {
  93. DataView.__float8e4m3_float32 = new Float32Array(1);
  94. DataView.__float8e4m3_uint32 = new Uint32Array(DataView.__float8e4m3_float32.buffer, DataView.__float8e4m3_float32.byteOffset, 1);
  95. DataView.prototype.getFloat8e4m3 = function(byteOffset, fn, uz) {
  96. const value = this.getUint8(byteOffset);
  97. let exponent_bias = 7;
  98. if (uz) {
  99. exponent_bias = 8;
  100. if (value === 0x80) {
  101. return NaN;
  102. }
  103. } else if (value === 255) {
  104. return -NaN;
  105. } else if (value === 0x7f) {
  106. return NaN;
  107. }
  108. let expo = (value & 0x78) >> 3;
  109. let mant = value & 0x07;
  110. const sign = value & 0x80;
  111. let res = sign << 24;
  112. if (expo === 0) {
  113. if (mant > 0) {
  114. expo = 0x7F - exponent_bias;
  115. if ((mant & 0x4) === 0) {
  116. mant &= 0x3;
  117. mant <<= 1;
  118. expo -= 1;
  119. }
  120. if ((mant & 0x4) === 0) {
  121. mant &= 0x3;
  122. mant <<= 1;
  123. expo -= 1;
  124. }
  125. res |= (mant & 0x3) << 21;
  126. res |= expo << 23;
  127. }
  128. } else {
  129. res |= mant << 20;
  130. expo += 0x7F - exponent_bias;
  131. res |= expo << 23;
  132. }
  133. DataView.__float8e4m3_uint32[0] = res;
  134. return DataView.__float8e4m3_float32[0];
  135. };
  136. }
  137. if (!DataView.prototype.getFloat8e5m2) {
  138. DataView.__float8e5m2_float32 = new Float32Array(1);
  139. DataView.__float8e5m2_uint32 = new Uint32Array(DataView.__float8e5m2_float32.buffer, DataView.__float8e5m2_float32.byteOffset, 1);
  140. DataView.prototype.getFloat8e5m2 = function(byteOffset, fn, uz) {
  141. const value = this.getUint8(byteOffset);
  142. let exponent_bias = NaN;
  143. if (fn && uz) {
  144. if (value === 0x80) {
  145. return NaN;
  146. }
  147. exponent_bias = 16;
  148. } else if (!fn && !uz) {
  149. if (value >= 253 && value <= 255) {
  150. return -NaN;
  151. }
  152. if (value >= 126 && value <= 127) {
  153. return NaN;
  154. }
  155. if (value === 252) {
  156. return -Infinity;
  157. }
  158. if (value === 124) {
  159. return Infinity;
  160. }
  161. exponent_bias = 15;
  162. }
  163. let expo = (value & 0x7C) >> 2;
  164. let mant = value & 0x03;
  165. let res = (value & 0x80) << 24;
  166. if (expo === 0) {
  167. if (mant > 0) {
  168. expo = 0x7F - exponent_bias;
  169. if ((mant & 0x2) === 0) {
  170. mant &= 0x1;
  171. mant <<= 1;
  172. expo -= 1;
  173. }
  174. res |= (mant & 0x1) << 22;
  175. res |= expo << 23;
  176. }
  177. } else {
  178. res |= mant << 21;
  179. expo += 0x7F - exponent_bias;
  180. res |= expo << 23;
  181. }
  182. DataView.__float8e5m2_uint32[0] = res;
  183. return DataView.__float8e5m2_float32[0];
  184. };
  185. }
  186. DataView.prototype.getIntBits = DataView.prototype.getUintBits || function(offset, bits, littleEndian) {
  187. offset *= bits;
  188. const position = Math.floor(offset / 8);
  189. const remainder = offset % 8;
  190. let value = 0;
  191. if ((remainder + bits) <= 8) {
  192. value = littleEndian ? this.getUint8(position) >> remainder : this.getUint8(position) >> (8 - remainder - bits);
  193. } else {
  194. value = littleEndian ? this.getUint16(position, true) >> remainder : this.getUint16(position, false) >> (16 - remainder - bits);
  195. }
  196. value &= (1 << bits) - 1;
  197. if (value & (1 << (bits - 1))) {
  198. value -= 1 << bits;
  199. }
  200. return value;
  201. };
  202. DataView.prototype.getUintBits = DataView.prototype.getUintBits || function(offset, bits, littleEndian) {
  203. offset *= bits;
  204. const position = Math.floor(offset / 8);
  205. const remainder = offset % 8;
  206. let value = 0;
  207. if ((remainder + bits) <= 8) {
  208. value = littleEndian ? this.getUint8(position) >> remainder : this.getUint8(position) >> (8 - remainder - bits);
  209. } else {
  210. value = littleEndian ? this.getUint16(position, true) >> remainder : this.getUint16(position, false) >> (16 - remainder - bits);
  211. }
  212. return value & ((1 << bits) - 1);
  213. };
  214. DataView.prototype.getComplex32 = DataView.prototype.getComplex32 || function(byteOffset, littleEndian) {
  215. const real = littleEndian ? this.getFloat16(byteOffset, littleEndian) : this.getFloat16(byteOffset + 4, littleEndian);
  216. const imaginary = littleEndian ? this.getFloat16(byteOffset + 4, littleEndian) : this.getFloat16(byteOffset, littleEndian);
  217. return new base.Complex(real, imaginary);
  218. };
  219. DataView.prototype.getComplex64 = DataView.prototype.getComplex64 || function(byteOffset, littleEndian) {
  220. const real = littleEndian ? this.getFloat32(byteOffset, littleEndian) : this.getFloat32(byteOffset + 4, littleEndian);
  221. const imaginary = littleEndian ? this.getFloat32(byteOffset + 4, littleEndian) : this.getFloat32(byteOffset, littleEndian);
  222. return new base.Complex(real, imaginary);
  223. };
  224. DataView.prototype.setComplex64 = DataView.prototype.setComplex64 || function(byteOffset, value, littleEndian) {
  225. if (littleEndian) {
  226. this.setFloat32(byteOffset, value.real, littleEndian);
  227. this.setFloat32(byteOffset + 4, value.imaginary, littleEndian);
  228. } else {
  229. this.setFloat32(byteOffset + 4, value.real, littleEndian);
  230. this.setFloat32(byteOffset, value.imaginary, littleEndian);
  231. }
  232. };
  233. DataView.prototype.getComplex128 = DataView.prototype.getComplex128 || function(byteOffset, littleEndian) {
  234. const real = littleEndian ? this.getFloat64(byteOffset, littleEndian) : this.getFloat64(byteOffset + 8, littleEndian);
  235. const imaginary = littleEndian ? this.getFloat64(byteOffset + 8, littleEndian) : this.getFloat64(byteOffset, littleEndian);
  236. return new base.Complex(real, imaginary);
  237. };
  238. DataView.prototype.setComplex128 = DataView.prototype.setComplex128 || function(byteOffset, value, littleEndian) {
  239. if (littleEndian) {
  240. this.setFloat64(byteOffset, value.real, littleEndian);
  241. this.setFloat64(byteOffset + 8, value.imaginary, littleEndian);
  242. } else {
  243. this.setFloat64(byteOffset + 8, value.real, littleEndian);
  244. this.setFloat64(byteOffset, value.imaginary, littleEndian);
  245. }
  246. };
  247. if (typeof Element !== 'undefined' && Element.prototype && !Element.prototype.replaceChildren) {
  248. Element.prototype.replaceChildren = function(...args) {
  249. while (this.lastChild) {
  250. this.removeChild(this.lastChild);
  251. }
  252. this.append(...args);
  253. };
  254. }
  255. /* eslint-enable no-extend-native */
  256. base.BinaryStream = class {
  257. constructor(buffer) {
  258. this._buffer = buffer;
  259. this._length = buffer.length;
  260. this._position = 0;
  261. }
  262. get position() {
  263. return this._position;
  264. }
  265. get length() {
  266. return this._length;
  267. }
  268. stream(length) {
  269. const buffer = this.read(length);
  270. return new base.BinaryStream(buffer.slice(0));
  271. }
  272. seek(position) {
  273. this._position = position >= 0 ? position : this._length + position;
  274. if (this._position > this._buffer.length) {
  275. throw new Error(`Expected ${this._position - this._buffer.length} more bytes. The file might be corrupted. Unexpected end of file.`);
  276. }
  277. }
  278. skip(offset) {
  279. this._position += offset;
  280. if (this._position > this._buffer.length) {
  281. throw new Error(`Expected ${this._position - this._buffer.length} more bytes. The file might be corrupted. Unexpected end of file.`);
  282. }
  283. }
  284. peek(length) {
  285. if (this._position === 0 && length === undefined) {
  286. return this._buffer;
  287. }
  288. const position = this._position;
  289. this.skip(length === undefined ? this._length - this._position : length);
  290. const end = this._position;
  291. this.seek(position);
  292. return this._buffer.subarray(position, end);
  293. }
  294. read(length) {
  295. if (this._position === 0 && length === undefined) {
  296. this._position = this._length;
  297. return this._buffer;
  298. }
  299. const position = this._position;
  300. this.skip(length === undefined ? this._length - this._position : length);
  301. return this._buffer.subarray(position, this._position);
  302. }
  303. };
  304. base.BinaryReader = class {
  305. static open(data, littleEndian) {
  306. if (data instanceof Uint8Array || data.length <= 0x20000000) {
  307. return new base.BufferReader(data, littleEndian);
  308. }
  309. return new base.StreamReader(data, littleEndian);
  310. }
  311. };
  312. base.BufferReader = class {
  313. constructor(data, littleEndian) {
  314. this._buffer = data instanceof Uint8Array ? data : data.peek();
  315. this._littleEndian = littleEndian !== false;
  316. this._position = 0;
  317. this._length = this._buffer.length;
  318. this._view = new DataView(this._buffer.buffer, this._buffer.byteOffset, this._buffer.byteLength);
  319. }
  320. get length() {
  321. return this._length;
  322. }
  323. get position() {
  324. return this._position;
  325. }
  326. seek(position) {
  327. this._position = position >= 0 ? position : this._length + position;
  328. if (this._position > this._length || this._position < 0) {
  329. throw new Error(`Expected ${this._position - this._length} more bytes. The file might be corrupted. Unexpected end of file.`);
  330. }
  331. }
  332. skip(offset) {
  333. this._position += offset;
  334. if (this._position > this._length) {
  335. throw new Error(`Expected ${this._position - this._length} more bytes. The file might be corrupted. Unexpected end of file.`);
  336. }
  337. }
  338. align(size) {
  339. const remainder = this.position % size;
  340. if (remainder !== 0) {
  341. this.skip(size - remainder);
  342. }
  343. }
  344. stream(length) {
  345. const buffer = this.read(length);
  346. return new base.BinaryStream(buffer);
  347. }
  348. peek(length) {
  349. if (this._position === 0 && length === undefined) {
  350. return this._buffer;
  351. }
  352. const position = this._position;
  353. this.skip(length === undefined ? this._length - this._position : length);
  354. const end = this._position;
  355. this._position = position;
  356. return this._buffer.slice(position, end);
  357. }
  358. read(length) {
  359. if (this._position === 0 && length === undefined) {
  360. this._position = this._length;
  361. return this._buffer;
  362. }
  363. const position = this._position;
  364. this.skip(length === undefined ? this._length - this._position : length);
  365. return this._buffer.slice(position, this._position);
  366. }
  367. byte() {
  368. const position = this._position;
  369. this.skip(1);
  370. return this._buffer[position];
  371. }
  372. int8() {
  373. const position = this._position;
  374. this.skip(1);
  375. return this._view.getInt8(position, this._littleEndian);
  376. }
  377. int16() {
  378. const position = this._position;
  379. this.skip(2);
  380. return this._view.getInt16(position, this._littleEndian);
  381. }
  382. int32() {
  383. const position = this._position;
  384. this.skip(4);
  385. return this._view.getInt32(position, this._littleEndian);
  386. }
  387. int64() {
  388. const position = this._position;
  389. this.skip(8);
  390. return this._view.getBigInt64(position, this._littleEndian);
  391. }
  392. uint16() {
  393. const position = this._position;
  394. this.skip(2);
  395. return this._view.getUint16(position, this._littleEndian);
  396. }
  397. uint32() {
  398. const position = this._position;
  399. this.skip(4);
  400. return this._view.getUint32(position, this._littleEndian);
  401. }
  402. uint64() {
  403. const position = this._position;
  404. this.skip(8);
  405. return this._view.getBigUint64(position, this._littleEndian);
  406. }
  407. float32() {
  408. const position = this._position;
  409. this.skip(4);
  410. return this._view.getFloat32(position, this._littleEndian);
  411. }
  412. float64() {
  413. const position = this._position;
  414. this.skip(8);
  415. return this._view.getFloat64(position, this._littleEndian);
  416. }
  417. string() {
  418. const length = this.uint32();
  419. const position = this._position;
  420. this.skip(length);
  421. const data = this._buffer.subarray(position, this._position);
  422. this._decoder = this._decoder || new TextDecoder('utf-8');
  423. return this._decoder.decode(data);
  424. }
  425. boolean() {
  426. return this.byte() === 0 ? false : true;
  427. }
  428. };
  429. base.StreamReader = class {
  430. constructor(stream, littleEndian) {
  431. this._stream = stream;
  432. this._littleEndian = littleEndian !== false;
  433. this._buffer = new Uint8Array(8);
  434. this._view = new DataView(this._buffer.buffer, this._buffer.byteOffset, this._buffer.byteLength);
  435. }
  436. get position() {
  437. return this._stream.position;
  438. }
  439. get length() {
  440. return this._stream.length;
  441. }
  442. seek(position) {
  443. this._stream.seek(position);
  444. }
  445. skip(offset) {
  446. this._stream.skip(offset);
  447. }
  448. align(size) {
  449. const remainder = this.position % size;
  450. if (remainder !== 0) {
  451. this.skip(size - remainder);
  452. }
  453. }
  454. stream(length) {
  455. return this._stream.stream(length);
  456. }
  457. peek(length) {
  458. return this._stream.peek(length).slice(0);
  459. }
  460. read(length) {
  461. return this._stream.read(length).slice(0);
  462. }
  463. byte() {
  464. return this._stream.read(1)[0];
  465. }
  466. int8() {
  467. const buffer = this._stream.read(1);
  468. this._buffer.set(buffer, 0);
  469. return this._view.getInt8(0);
  470. }
  471. int16() {
  472. const buffer = this._stream.read(2);
  473. this._buffer.set(buffer, 0);
  474. return this._view.getInt16(0, this._littleEndian);
  475. }
  476. int32() {
  477. const buffer = this._stream.read(4);
  478. this._buffer.set(buffer, 0);
  479. return this._view.getInt32(0, this._littleEndian);
  480. }
  481. int64() {
  482. const buffer = this._stream.read(8);
  483. this._buffer.set(buffer, 0);
  484. return this._view.getBigInt64(0, this._littleEndian);
  485. }
  486. uint16() {
  487. const buffer = this._stream.read(2);
  488. this._buffer.set(buffer, 0);
  489. return this._view.getUint16(0, this._littleEndian);
  490. }
  491. uint32() {
  492. const buffer = this._stream.read(4);
  493. this._buffer.set(buffer, 0);
  494. return this._view.getUint32(0, this._littleEndian);
  495. }
  496. uint64() {
  497. const buffer = this._stream.read(8);
  498. this._buffer.set(buffer, 0);
  499. return this._view.getBigUint64(0, this._littleEndian);
  500. }
  501. float32() {
  502. const buffer = this._stream.read(4);
  503. this._buffer.set(buffer, 0);
  504. return this._view.getFloat32(0, this._littleEndian);
  505. }
  506. float64() {
  507. const buffer = this._stream.read(8);
  508. this._buffer.set(buffer, 0);
  509. return this._view.getFloat64(0, this._littleEndian);
  510. }
  511. boolean() {
  512. return this.byte() === 0 ? false : true;
  513. }
  514. };
  515. base.Tensor = class {
  516. constructor(tensor) {
  517. this._tensor = tensor;
  518. this.name = tensor.name || '';
  519. this.encoding = tensor.encoding;
  520. this.encoding = this.encoding === '' || this.encoding === undefined ? '<' : this.encoding;
  521. this.type = tensor.type;
  522. this.layout = tensor.type.layout;
  523. this.stride = tensor.stride;
  524. base.Tensor._dataTypes = base.Tensor._dataTypes || new Map([
  525. ['boolean', 1],
  526. ['qint8', 1], ['qint16', 2], ['qint32', 4],
  527. ['quint8', 1], ['quint16', 2], ['quint32', 4],
  528. ['xint8', 1],
  529. ['int8', 1], ['int16', 2], ['int32', 4], ['int64', 8],
  530. ['uint8', 1], ['uint16', 2], ['uint32', 4,], ['uint64', 8],
  531. ['float16', 2], ['float32', 4], ['float64', 8], ['bfloat16', 2],
  532. ['complex<float32>', 8], ['complex<float64>', 16],
  533. ['float8e4m3fn', 1], ['float8e4m3fnuz', 1], ['float8e5m2', 1], ['float8e5m2fnuz', 1]
  534. ]);
  535. }
  536. get values() {
  537. this._read();
  538. return this._values;
  539. }
  540. get indices() {
  541. this._read();
  542. return this._indices;
  543. }
  544. get data() {
  545. this._read();
  546. if (this._data && this._data.peek) {
  547. this._data = this._data.peek();
  548. }
  549. return this._data;
  550. }
  551. get metrics() {
  552. return this._tensor.metrics;
  553. }
  554. get empty() {
  555. switch (this.layout) {
  556. case 'sparse':
  557. case 'sparse.coo': {
  558. return !this.values || !this.indices || this.values.values === null || this.values.values.length === 0;
  559. }
  560. default: {
  561. switch (this.encoding) {
  562. case '<':
  563. case '>':
  564. return !(Array.isArray(this.data) || this.data instanceof Uint8Array || this.data instanceof Int8Array) || this.data.length === 0;
  565. case '|':
  566. return !(Array.isArray(this.values) || ArrayBuffer.isView(this.values)) || this.values.length === 0;
  567. default:
  568. throw new Error(`Unsupported tensor encoding '${this.encoding}'.`);
  569. }
  570. }
  571. }
  572. }
  573. get value() {
  574. const context = this._context();
  575. context.limit = Number.MAX_SAFE_INTEGER;
  576. switch (context.encoding) {
  577. case '<':
  578. case '>': {
  579. return this._decodeData(context, 0, 0);
  580. }
  581. case '|': {
  582. return this._decodeValues(context, 0, 0);
  583. }
  584. default: {
  585. throw new Error(`Unsupported tensor encoding '${context.encoding}'.`);
  586. }
  587. }
  588. }
  589. toString() {
  590. const context = this._context();
  591. context.limit = 10000;
  592. switch (context.encoding) {
  593. case '<':
  594. case '>': {
  595. const value = this._decodeData(context, 0, 0);
  596. return base.Tensor._stringify(value, '', ' ');
  597. }
  598. case '|': {
  599. const value = this._decodeValues(context, 0, 0);
  600. return base.Tensor._stringify(value, '', ' ');
  601. }
  602. default: {
  603. throw new Error(`Unsupported tensor encoding '${context.encoding}'.`);
  604. }
  605. }
  606. }
  607. _context() {
  608. this._read();
  609. if (this.encoding !== '<' && this.encoding !== '>' && this.encoding !== '|') {
  610. throw new Error(`Tensor encoding '${this.encoding}' is not supported.`);
  611. }
  612. if (this.layout && (this.layout !== 'sparse' && this.layout !== 'sparse.coo')) {
  613. throw new Error(`Tensor layout '${this.layout}' is not supported.`);
  614. }
  615. const dataType = this.type.dataType;
  616. const context = {};
  617. context.encoding = this.encoding;
  618. context.dimensions = this.type.shape.dimensions.map((value) => typeof value === 'bigint' ? value.toNumber() : value);
  619. context.dataType = dataType;
  620. const shape = context.dimensions;
  621. context.stride = this.stride;
  622. if (!Array.isArray(context.stride) ||
  623. (Array.isArray(context.stride) && context.stride.length === 0 && shape.length === 0)) {
  624. const length = shape.length === 0 ? 1 : shape.length;
  625. context.stride = new Array(length);
  626. let value = 1;
  627. for (let i = length - 1; i >= 0; i--) {
  628. context.stride[i] = value;
  629. value *= shape[i];
  630. }
  631. }
  632. switch (this.layout) {
  633. case 'sparse': {
  634. const indices = new base.Tensor(this.indices).value;
  635. const values = new base.Tensor(this.values).value;
  636. context.data = this._decodeSparse(dataType, context.dimensions, indices, values);
  637. context.encoding = '|';
  638. break;
  639. }
  640. case 'sparse.coo': {
  641. const values = new base.Tensor(this.values).value;
  642. const data = new base.Tensor(this.indices).value;
  643. const dimensions = context.dimensions.length;
  644. let stride = 1;
  645. const strides = context.dimensions.slice().reverse().map((dim) => {
  646. const value = stride;
  647. stride *= dim;
  648. return value;
  649. }).reverse();
  650. const indices = new Uint32Array(values.length);
  651. for (let i = 0; i < dimensions; i++) {
  652. const stride = strides[i];
  653. const dimension = data[i];
  654. for (let j = 0; j < indices.length; j++) {
  655. indices[j] += dimension[j].toNumber() * stride;
  656. }
  657. }
  658. context.data = this._decodeSparse(dataType, context.dimensions, indices, values);
  659. context.encoding = '|';
  660. break;
  661. }
  662. default: {
  663. switch (this.encoding) {
  664. case '<':
  665. case '>': {
  666. context.data = (this.data instanceof Uint8Array || this.data instanceof Int8Array) ? this.data : this.data.peek();
  667. context.view = new DataView(context.data.buffer, context.data.byteOffset, context.data.byteLength);
  668. if (base.Tensor._dataTypes.has(dataType)) {
  669. const itemsize = base.Tensor._dataTypes.get(dataType);
  670. const length = context.data.length;
  671. const stride = context.stride;
  672. if (length < (itemsize * shape.reduce((a, v) => a * v, 1))) {
  673. const max = stride.reduce((a, v, i) => v > stride[i] ? i : a, 0);
  674. if (length !== (itemsize * stride[max] * shape[max])) {
  675. throw new Error('Invalid tensor data size.');
  676. }
  677. }
  678. context.itemsize = itemsize;
  679. context.stride = stride.map((v) => v * itemsize);
  680. } else if (dataType.startsWith('uint') && !isNaN(parseInt(dataType.substring(4), 10))) {
  681. context.dataType = 'uint';
  682. context.bits = parseInt(dataType.substring(4), 10);
  683. context.itemsize = 1;
  684. } else if (dataType.startsWith('int') && !isNaN(parseInt(dataType.substring(3), 10))) {
  685. context.dataType = 'int';
  686. context.bits = parseInt(dataType.substring(3), 10);
  687. context.itemsize = 1;
  688. } else if (dataType === 'float4e2m1') {
  689. context.dataType = 'float4e2m1';
  690. context.bits = 4;
  691. context.itemsize = 1;
  692. } else {
  693. throw new Error(`Tensor data type '${dataType}' is not implemented.`);
  694. }
  695. break;
  696. }
  697. case '|': {
  698. context.data = this.values;
  699. const integer = (dataType.startsWith('int') && !isNaN(parseInt(dataType.substring(3), 10))) || (dataType.startsWith('uint') && !isNaN(parseInt(dataType.substring(4), 10)));
  700. if (!base.Tensor._dataTypes.has(dataType) && dataType !== 'string' && dataType !== 'object' && dataType !== 'datetime' && dataType !== 'void' && !integer) {
  701. throw new Error(`Tensor data type '${dataType}' is not implemented.`);
  702. }
  703. const size = context.dimensions.reduce((a, v) => a * v, 1);
  704. if (size !== this.values.length) {
  705. throw new Error('Invalid tensor data length.');
  706. }
  707. break;
  708. }
  709. default: {
  710. throw new Error(`Unsupported tensor encoding '${this.encoding}'.`);
  711. }
  712. }
  713. }
  714. }
  715. context.index = 0;
  716. context.count = 0;
  717. return context;
  718. }
  719. _decodeSparse(dataType, dimensions, indices, values) {
  720. const size = dimensions.reduce((a, b) => a * b, 1);
  721. const array = new Array(size);
  722. switch (dataType) {
  723. case 'boolean':
  724. array.fill(false);
  725. break;
  726. default:
  727. array.fill(0);
  728. break;
  729. }
  730. if (indices.length > 0) {
  731. if (Object.prototype.hasOwnProperty.call(indices[0], 'low')) {
  732. for (let i = 0; i < indices.length; i++) {
  733. const index = indices[i].toNumber();
  734. array[index] = values[i];
  735. }
  736. } else {
  737. for (let i = 0; i < indices.length; i++) {
  738. array[indices[i]] = values[i];
  739. }
  740. }
  741. }
  742. return array;
  743. }
  744. _decodeData(context, dimension, offset) {
  745. const results = [];
  746. const shape = context.dimensions.length === 0 ? [1] : context.dimensions;
  747. const size = shape[dimension];
  748. const dataType = context.dataType;
  749. const view = context.view;
  750. const stride = context.stride[dimension];
  751. if (dimension === shape.length - 1) {
  752. const ellipsis = (context.count + size) > context.limit;
  753. const length = ellipsis ? context.limit - context.count : size;
  754. const max = offset + (length * stride);
  755. switch (dataType) {
  756. case 'boolean':
  757. for (; offset < max; offset += stride) {
  758. results.push(view.getUint8(offset) !== 0);
  759. }
  760. break;
  761. case 'qint8':
  762. case 'xint8':
  763. case 'int8':
  764. for (; offset < max; offset += stride) {
  765. results.push(view.getInt8(offset));
  766. }
  767. break;
  768. case 'qint16':
  769. case 'int16':
  770. for (; offset < max; offset += stride) {
  771. results.push(view.getInt16(offset, this._littleEndian));
  772. }
  773. break;
  774. case 'qint32':
  775. case 'int32':
  776. for (; offset < max; offset += stride) {
  777. results.push(view.getInt32(offset, this._littleEndian));
  778. }
  779. break;
  780. case 'int64':
  781. for (; offset < max; offset += stride) {
  782. results.push(view.getBigInt64(offset, this._littleEndian));
  783. }
  784. break;
  785. case 'int':
  786. for (; offset < max; offset += stride) {
  787. results.push(view.getIntBits(offset, context.bits, this._littleEndian));
  788. }
  789. break;
  790. case 'quint8':
  791. case 'uint8':
  792. for (; offset < max; offset += stride) {
  793. results.push(view.getUint8(offset));
  794. }
  795. break;
  796. case 'quint16':
  797. case 'uint16':
  798. for (; offset < max; offset += stride) {
  799. results.push(view.getUint16(offset, this._littleEndian));
  800. }
  801. break;
  802. case 'quint32':
  803. case 'uint32':
  804. for (; offset < max; offset += stride) {
  805. results.push(view.getUint32(offset, this._littleEndian));
  806. }
  807. break;
  808. case 'uint64':
  809. for (; offset < max; offset += stride) {
  810. results.push(view.getBigUint64(offset, this._littleEndian));
  811. }
  812. break;
  813. case 'uint':
  814. for (; offset < max; offset += stride) {
  815. results.push(view.getUintBits(offset, context.bits, this._littleEndian));
  816. }
  817. break;
  818. case 'float16':
  819. for (; offset < max; offset += stride) {
  820. results.push(view.getFloat16(offset, this._littleEndian));
  821. }
  822. break;
  823. case 'float32':
  824. for (; offset < max; offset += stride) {
  825. results.push(view.getFloat32(offset, this._littleEndian));
  826. }
  827. break;
  828. case 'float64':
  829. for (; offset < max; offset += stride) {
  830. results.push(view.getFloat64(offset, this._littleEndian));
  831. }
  832. break;
  833. case 'bfloat16':
  834. for (; offset < max; offset += stride) {
  835. results.push(view.getBfloat16(offset, this._littleEndian));
  836. }
  837. break;
  838. case 'complex<float16>':
  839. for (; offset < max; offset += stride) {
  840. results.push(view.getComplex32(offset, this._littleEndian));
  841. }
  842. break;
  843. case 'complex<float32>':
  844. for (; offset < max; offset += stride) {
  845. results.push(view.getComplex64(offset, this._littleEndian));
  846. }
  847. break;
  848. case 'complex<float64>':
  849. for (; offset < max; offset += stride) {
  850. results.push(view.getComplex128(offset, this._littleEndian));
  851. }
  852. break;
  853. case 'float4e2m1':
  854. for (; offset < max; offset += stride) {
  855. results.push(view.getFloat4e2m1(offset));
  856. }
  857. break;
  858. case 'float8e4m3fn':
  859. for (; offset < max; offset += stride) {
  860. results.push(view.getFloat8e4m3(offset, true, false));
  861. }
  862. break;
  863. case 'float8e4m3fnuz':
  864. for (; offset < max; offset += stride) {
  865. results.push(view.getFloat8e4m3(offset, true, true));
  866. }
  867. break;
  868. case 'float8e5m2':
  869. for (; offset < max; offset += stride) {
  870. results.push(view.getFloat8e5m2(offset, false, false));
  871. }
  872. break;
  873. case 'float8e5m2fnuz':
  874. for (; offset < max; offset += stride) {
  875. results.push(view.getFloat8e5m2(offset, true, true));
  876. }
  877. break;
  878. default:
  879. throw new Error(`Unsupported tensor data type '${dataType}'.`);
  880. }
  881. context.count += length;
  882. if (ellipsis) {
  883. results.push('...');
  884. }
  885. } else {
  886. for (let j = 0; j < size; j++) {
  887. if (context.count >= context.limit) {
  888. results.push('...');
  889. return results;
  890. }
  891. const nextOffset = offset + (j * stride);
  892. results.push(this._decodeData(context, dimension + 1, nextOffset));
  893. }
  894. }
  895. if (context.dimensions.length === 0) {
  896. return results[0];
  897. }
  898. return results;
  899. }
  900. _decodeValues(context, dimension, position) {
  901. const results = [];
  902. const shape = (context.dimensions.length === 0) ? [1] : context.dimensions;
  903. const size = shape[dimension];
  904. const dataType = context.dataType;
  905. const stride = context.stride[dimension];
  906. if (dimension === shape.length - 1) {
  907. const ellipsis = (context.count + size) > context.limit;
  908. const length = ellipsis ? context.limit - context.count : size;
  909. const data = context.data;
  910. for (let i = 0; i < length; i++) {
  911. if (context.count > context.limit) {
  912. results.push('...');
  913. return results;
  914. }
  915. switch (dataType) {
  916. case 'boolean':
  917. results.push(data[position] === 0 || data[position] === false ? false : true);
  918. break;
  919. default:
  920. results.push(data[position]);
  921. break;
  922. }
  923. position += stride;
  924. context.count++;
  925. }
  926. } else {
  927. for (let i = 0; i < size; i++) {
  928. if (context.count >= context.limit) {
  929. results.push('...');
  930. return results;
  931. }
  932. const nextPosition = position + (i * stride);
  933. results.push(this._decodeValues(context, dimension + 1, nextPosition));
  934. }
  935. }
  936. if (context.dimensions.length === 0) {
  937. return results[0];
  938. }
  939. return results;
  940. }
  941. static _stringify(value, indentation, indent) {
  942. if (Array.isArray(value)) {
  943. const length = value.length;
  944. if (length > 0) {
  945. const array = new Array(length);
  946. const space = indentation + indent;
  947. for (let i = 0; i < length; i++) {
  948. array[i] = base.Tensor._stringify(value[i], space, indent);
  949. }
  950. return `${indentation}[\n${array.join(',\n')}\n${indentation}]`;
  951. }
  952. return `${indentation}[\n${indentation}]`;
  953. }
  954. if (value === null) {
  955. return `${indentation}null`;
  956. }
  957. switch (typeof value) {
  958. case 'boolean':
  959. case 'number':
  960. case 'bigint':
  961. return `${indentation}${value}`;
  962. case 'string':
  963. return `${indentation}"${value}"`;
  964. default:
  965. if (value instanceof Uint8Array) {
  966. let content = '';
  967. for (let i = 0; i < value.length; i++) {
  968. const x = value[i];
  969. content += x >= 32 && x <= 126 ? String.fromCharCode(x) : `\\x${x.toString(16).padStart(2, '0')}`;
  970. }
  971. return `${indentation}"${content}"`;
  972. }
  973. if (value && value.toString) {
  974. return `${indentation}${value.toString()}`;
  975. }
  976. return `${indentation}(undefined)`;
  977. }
  978. }
  979. _read() {
  980. if (this._values === undefined) {
  981. this._values = null;
  982. switch (this.encoding) {
  983. case undefined:
  984. case '<': {
  985. this._data = this._tensor.values;
  986. this._littleEndian = true;
  987. break;
  988. }
  989. case '>': {
  990. this._data = this._tensor.values;
  991. this._littleEndian = false;
  992. break;
  993. }
  994. case '|': {
  995. this._values = this._tensor.values;
  996. break;
  997. }
  998. default: {
  999. throw new Error(`Unsupported tensor encoding '${this.encoding}'.`);
  1000. }
  1001. }
  1002. switch (this.layout) {
  1003. case 'sparse':
  1004. case 'sparse.coo': {
  1005. this._indices = this._tensor.indices;
  1006. this._values = this._tensor.values;
  1007. break;
  1008. }
  1009. default: {
  1010. break;
  1011. }
  1012. }
  1013. }
  1014. }
  1015. };
  1016. base.Telemetry = class {
  1017. constructor(window) {
  1018. this._window = window;
  1019. this._navigator = window.navigator;
  1020. this._config = new Map();
  1021. this._metadata = {};
  1022. this._schema = new Map([
  1023. ['protocol_version', 'v'],
  1024. ['tracking_id', 'tid'],
  1025. ['hash_info', 'gtm'],
  1026. ['_page_id', '_p'],
  1027. ['client_id', 'cid'],
  1028. ['language', 'ul'],
  1029. ['screen_resolution', 'sr'],
  1030. ['_user_agent_architecture', 'uaa'],
  1031. ['_user_agent_bitness', 'uab'],
  1032. ['_user_agent_full_version_list', 'uafvl'],
  1033. ['_user_agent_mobile', 'uamb'],
  1034. ['_user_agent_model', 'uam'],
  1035. ['_user_agent_platform', 'uap'],
  1036. ['_user_agent_platform_version', 'uapv'],
  1037. ['_user_agent_wow64', 'uaw'],
  1038. ['hit_count', '_s'],
  1039. ['session_id', 'sid'],
  1040. ['session_number', 'sct'],
  1041. ['session_engaged', 'seg'],
  1042. ['engagement_time_msec', '_et'],
  1043. ['page_location', 'dl'],
  1044. ['page_title', 'dt'],
  1045. ['page_referrer', 'dr'],
  1046. ['is_first_visit', '_fv'],
  1047. ['is_external_event', '_ee'],
  1048. ['is_new_to_site', '_nsi'],
  1049. ['is_session_start', '_ss'],
  1050. ['event_name', 'en']
  1051. ]);
  1052. }
  1053. async start(measurement_id, client_id, session) {
  1054. this._session = session && typeof session === 'string' ? session.replace(/^GS1\.1\./, '').split('.') : null;
  1055. this._session = Array.isArray(this._session) && this._session.length >= 7 ? this._session : ['0', '0', '0', '0', '0', '0', '0'];
  1056. this._session[0] = Date.now();
  1057. this._session[1] = parseInt(this._session[1], 10) + 1;
  1058. this._engagement_time_msec = 0;
  1059. if (this._config.size > 0) {
  1060. throw new Error('Invalid session state.');
  1061. }
  1062. this.set('protocol_version', 2);
  1063. this.set('tracking_id', measurement_id);
  1064. this.set('hash_info', '2oebu0');
  1065. this.set('_page_id', Math.floor(Math.random() * 2147483648));
  1066. client_id = client_id ? client_id.replace(/^(GA1\.\d\.)*/, '') : null;
  1067. if (client_id && client_id.indexOf('.') !== 1) {
  1068. this.set('client_id', client_id);
  1069. } else {
  1070. const random = String(Math.round(0x7FFFFFFF * Math.random()));
  1071. const time = Date.now();
  1072. const value = [random, Math.round(time / 1e3)].join('.');
  1073. this.set('client_id', value);
  1074. this._metadata.is_first_visit = 1;
  1075. this._metadata.is_new_to_site = 1;
  1076. }
  1077. this.set('language', ((this._navigator && (this._navigator.language || this._navigator.browserLanguage)) || '').toLowerCase());
  1078. this.set('screen_resolution', `${window.screen ? window.screen.width : 0}x${window.screen ? window.screen.height : 0}`);
  1079. if (this._navigator && this._navigator.userAgentData && this._navigator.userAgentData.getHighEntropyValues) {
  1080. const values = await this._navigator.userAgentData.getHighEntropyValues(['platform', 'platformVersion', 'architecture', 'model', 'uaFullVersion', 'bitness', 'fullVersionList', 'wow64']);
  1081. if (values) {
  1082. this.set('_user_agent_architecture', values.architecture);
  1083. this.set('_user_agent_bitness', values.bitness);
  1084. this.set('_user_agent_full_version_list', Array.isArray(values.fullVersionList) ? values.fullVersionList.map((h) => `${encodeURIComponent(h.brand || '')};${encodeURIComponent(h.version || '')}`).join('|') : '');
  1085. this.set('_user_agent_mobile', values.mobile ? 1 : 0);
  1086. this.set('_user_agent_model', values.model);
  1087. this.set('_user_agent_platform', values.platform);
  1088. this.set('_user_agent_platform_version', values.platformVersion);
  1089. this.set('_user_agent_wow64', values.wow64 ? 1 : 0);
  1090. }
  1091. }
  1092. this.set('hit_count', 1);
  1093. this.set('session_id', this._session[0]);
  1094. this.set('session_number', this._session[1]);
  1095. this.set('session_engaged', 0);
  1096. this._metadata.is_session_start = 1;
  1097. this._metadata.is_external_event = 1;
  1098. window.addEventListener('focus', () => this._update(true, undefined, undefined));
  1099. window.addEventListener('blur', () => this._update(false, undefined, undefined));
  1100. window.addEventListener('pageshow', () => this._update(undefined, true, undefined));
  1101. window.addEventListener('pagehide', () => this._update(undefined, false, undefined));
  1102. window.addEventListener('visibilitychange', () => this._update(undefined, undefined, window.document.visibilityState !== 'hidden'));
  1103. window.addEventListener('beforeunload', () => this._update() && this.send('user_engagement', {}));
  1104. }
  1105. get session() {
  1106. return this._session ? this._session.join('.') : null;
  1107. }
  1108. set(name, value) {
  1109. const key = this._schema.get(name);
  1110. if (value !== undefined && value !== null) {
  1111. this._config.set(key, value);
  1112. } else if (this._config.has(key)) {
  1113. this._config.delete(key);
  1114. }
  1115. this._cache = null;
  1116. }
  1117. get(name) {
  1118. const key = this._schema.get(name);
  1119. return this._config.get(key);
  1120. }
  1121. send(name, params) {
  1122. if (this._session) {
  1123. try {
  1124. params = { event_name: name, ...this._metadata, ...params };
  1125. this._metadata = {};
  1126. if (this._update()) {
  1127. params.engagement_time_msec = this._engagement_time_msec;
  1128. this._engagement_time_msec = 0;
  1129. }
  1130. const build = (entries) => entries.map(([name, value]) => `${name}=${encodeURIComponent(value)}`).join('&');
  1131. this._cache = this._cache || build(Array.from(this._config));
  1132. const key = (name, value) => this._schema.get(name) || (typeof value === 'number' && !isNaN(value) ? 'epn.' : 'ep.') + name;
  1133. const body = build(Object.entries(params).map(([name, value]) => [key(name, value), value]));
  1134. const url = `https://analytics.google.com/g/collect?${this._cache}`;
  1135. this._navigator.sendBeacon(url, body);
  1136. this._session[2] = this.get('session_engaged') || '0';
  1137. this.set('hit_count', this.get('hit_count') + 1);
  1138. } catch {
  1139. // continue regardless of error
  1140. }
  1141. }
  1142. }
  1143. _update(focused, page, visible) {
  1144. this._focused = focused === true || focused === false ? focused : this._focused;
  1145. this._page = page === true || page === false ? page : this._page;
  1146. this._visible = visible === true || visible === false ? visible : this._visible;
  1147. const time = Date.now();
  1148. if (this._start_time) {
  1149. this._engagement_time_msec += (time - this._start_time);
  1150. this._start_time = 0;
  1151. }
  1152. if (this._focused !== false && this._page !== false && this._visible !== false) {
  1153. this._start_time = time;
  1154. }
  1155. return this._engagement_time_msec > 20;
  1156. }
  1157. };
  1158. base.Metadata = class {
  1159. get extensions() {
  1160. return [
  1161. 'onnx', 'tflite', 'pb', 'pt', 'pt2', 'pte', 'pth', 'h5', 'pbtxt', 'prototxt', 'caffemodel', 'mlmodel', 'mlpackage',
  1162. 'model', 'json', 'xml', 'cfg', 'weights', 'bin',
  1163. 'ort',
  1164. 'dnn', 'cmf',
  1165. 'gguf',
  1166. 'hd5', 'hdf5', 'keras',
  1167. 'tfl', 'circle', 'lite',
  1168. 'mlir', 'mlnet', 'mar', 'maxviz', 'meta', 'nn', 'ngf', 'hn',
  1169. 'param', 'params',
  1170. 'paddle', 'pdiparams', 'pdmodel', 'pdopt', 'pdparams', 'nb',
  1171. 'pkl', 'pickle', 'joblib', 'safetensors',
  1172. 'ptl', 't7',
  1173. 'dlc', 'uff', 'armnn', 'kann', 'kgraph',
  1174. 'mnn', 'ms', 'ncnn', 'om', 'tm', 'mge', 'tmfile', 'tnnproto', 'xmodel', 'kmodel', 'rknn',
  1175. 'tar', 'zip'
  1176. ];
  1177. }
  1178. };
  1179. export const Complex = base.Complex;
  1180. export const BinaryStream = base.BinaryStream;
  1181. export const BinaryReader = base.BinaryReader;
  1182. export const Tensor = base.Tensor;
  1183. export const Telemetry = base.Telemetry;
  1184. export const Metadata = base.Metadata;