pytorch-schema.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762
  1. import * as flatbuffers from './flatbuffers.js';
  2. const $root = flatbuffers.get('torch');
  3. $root.torch = $root.torch || {};
  4. $root.torch.jit = $root.torch.jit || {};
  5. $root.torch.jit.mobile = $root.torch.jit.mobile || {};
  6. $root.torch.jit.mobile.serialization = $root.torch.jit.mobile.serialization || {};
  7. $root.torch.jit.mobile.serialization.Int = class Int {
  8. static decode(reader, position) {
  9. const $ = new $root.torch.jit.mobile.serialization.Int();
  10. $.int_val = reader.int64(position + 0);
  11. return $;
  12. }
  13. };
  14. $root.torch.jit.mobile.serialization.Bool = class Bool {
  15. static decode(reader, position) {
  16. const $ = new $root.torch.jit.mobile.serialization.Bool();
  17. $.bool_val = reader.bool(position + 0);
  18. return $;
  19. }
  20. };
  21. $root.torch.jit.mobile.serialization.Double = class Double {
  22. static decode(reader, position) {
  23. const $ = new $root.torch.jit.mobile.serialization.Double();
  24. $.double_val = reader.float64(position + 0);
  25. return $;
  26. }
  27. };
  28. $root.torch.jit.mobile.serialization.PerTensorAffineSchema = class PerTensorAffineSchema {
  29. static decode(reader, position) {
  30. const $ = new $root.torch.jit.mobile.serialization.PerTensorAffineSchema();
  31. $.q_scale = reader.float64(position + 0);
  32. $.q_zero_point = reader.int32(position + 4);
  33. return $;
  34. }
  35. };
  36. $root.torch.jit.mobile.serialization.QuantizedSchema = class QuantizedSchema {
  37. static decode(reader, position) {
  38. const $ = new $root.torch.jit.mobile.serialization.QuantizedSchema();
  39. $.qscheme = reader.int8_(position, 4, 0);
  40. $.scale = reader.float64_(position, 6, 0);
  41. $.zero_point = reader.int32_(position, 8, 0);
  42. $.scales = reader.table(position, 10, $root.torch.jit.mobile.serialization.TensorMetadata.decode);
  43. $.zero_points = reader.table(position, 12, $root.torch.jit.mobile.serialization.TensorMetadata.decode);
  44. $.axis = reader.int32_(position, 14, 0);
  45. return $;
  46. }
  47. };
  48. $root.torch.jit.mobile.serialization.TensorMetadata = class TensorMetadata {
  49. static decode(reader, position) {
  50. const $ = new $root.torch.jit.mobile.serialization.TensorMetadata();
  51. $.storage_location_index = reader.uint32_(position, 4, 0);
  52. $.scalar_type = reader.int8_(position, 6, 0);
  53. $.storage_offset = reader.int32_(position, 8, 0);
  54. $.sizes = reader.typedArray(position, 10, Int32Array);
  55. $.strides = reader.typedArray(position, 12, Int32Array);
  56. $.requires_grad = reader.bool_(position, 14, false);
  57. $.quantized_schema = reader.table(position, 16, $root.torch.jit.mobile.serialization.QuantizedSchema.decode);
  58. return $;
  59. }
  60. };
  61. $root.torch.jit.mobile.serialization.String = class String {
  62. static decode(reader, position) {
  63. const $ = new $root.torch.jit.mobile.serialization.String();
  64. $.data = reader.string_(position, 4, null);
  65. return $;
  66. }
  67. };
  68. $root.torch.jit.mobile.serialization.Device = class Device {
  69. static decode(reader, position) {
  70. const $ = new $root.torch.jit.mobile.serialization.Device();
  71. $.str = reader.string_(position, 4, null);
  72. return $;
  73. }
  74. };
  75. $root.torch.jit.mobile.serialization.List = class List {
  76. static decode(reader, position) {
  77. const $ = new $root.torch.jit.mobile.serialization.List();
  78. $.items = reader.typedArray(position, 4, Uint32Array);
  79. $.annotation_str = reader.string_(position, 6, null);
  80. return $;
  81. }
  82. };
  83. $root.torch.jit.mobile.serialization.IntList = class IntList {
  84. static decode(reader, position) {
  85. const $ = new $root.torch.jit.mobile.serialization.IntList();
  86. $.items = reader.int64s_(position, 4);
  87. return $;
  88. }
  89. };
  90. $root.torch.jit.mobile.serialization.DoubleList = class DoubleList {
  91. static decode(reader, position) {
  92. const $ = new $root.torch.jit.mobile.serialization.DoubleList();
  93. $.items = reader.typedArray(position, 4, Float64Array);
  94. return $;
  95. }
  96. };
  97. $root.torch.jit.mobile.serialization.BoolList = class BoolList {
  98. static decode(reader, position) {
  99. const $ = new $root.torch.jit.mobile.serialization.BoolList();
  100. $.items = reader.bools_(position, 4);
  101. return $;
  102. }
  103. };
  104. $root.torch.jit.mobile.serialization.Tuple = class Tuple {
  105. static decode(reader, position) {
  106. const $ = new $root.torch.jit.mobile.serialization.Tuple();
  107. $.items = reader.typedArray(position, 4, Uint32Array);
  108. return $;
  109. }
  110. };
  111. $root.torch.jit.mobile.serialization.Dict = class Dict {
  112. static decode(reader, position) {
  113. const $ = new $root.torch.jit.mobile.serialization.Dict();
  114. $.keys = reader.typedArray(position, 4, Uint32Array);
  115. $.values = reader.typedArray(position, 6, Uint32Array);
  116. $.annotation_str = reader.string_(position, 8, null);
  117. return $;
  118. }
  119. };
  120. $root.torch.jit.mobile.serialization.TypeType = {
  121. UNSET: 0,
  122. CLASS_WITH_FIELD: 1,
  123. CUSTOM_CLASS: 2,
  124. CLASS_WITH_SETSTATE: 3,
  125. NON_OBJ: 4
  126. };
  127. $root.torch.jit.mobile.serialization.ObjectType = class ObjectType {
  128. static decode(reader, position) {
  129. const $ = new $root.torch.jit.mobile.serialization.ObjectType();
  130. $.type_name = reader.string_(position, 4, null);
  131. $.type = reader.uint8_(position, 6, 0);
  132. $.attr_names = reader.strings_(position, 8);
  133. return $;
  134. }
  135. };
  136. $root.torch.jit.mobile.serialization.Object = class Object {
  137. static decode(reader, position) {
  138. const $ = new $root.torch.jit.mobile.serialization.Object();
  139. $.type_index = reader.uint32_(position, 4, 0);
  140. $.state = reader.uint32_(position, 6, 0);
  141. $.attrs = reader.typedArray(position, 8, Uint32Array);
  142. $.setstate_func = reader.uint32_(position, 10, 0);
  143. return $;
  144. }
  145. };
  146. $root.torch.jit.mobile.serialization.ComplexDouble = class ComplexDouble {
  147. static decode(reader, position) {
  148. const $ = new $root.torch.jit.mobile.serialization.ComplexDouble();
  149. $.real = reader.float64(position + 0);
  150. $.imag = reader.float64(position + 4);
  151. return $;
  152. }
  153. };
  154. $root.torch.jit.mobile.serialization.EnumValue = class EnumValue {
  155. static decode(reader, position) {
  156. const $ = new $root.torch.jit.mobile.serialization.EnumValue();
  157. $.type_name = reader.string_(position, 4, null);
  158. $.value = reader.uint32_(position, 6, 0);
  159. return $;
  160. }
  161. };
  162. $root.torch.jit.mobile.serialization.Instruction = class Instruction {
  163. static decode(reader, position) {
  164. const $ = new $root.torch.jit.mobile.serialization.Instruction();
  165. $.op = reader.int8(position + 0);
  166. $.n = reader.uint16(position + 2);
  167. $.x = reader.int32(position + 4);
  168. return $;
  169. }
  170. };
  171. $root.torch.jit.mobile.serialization.Operator = class Operator {
  172. static decode(reader, position) {
  173. const $ = new $root.torch.jit.mobile.serialization.Operator();
  174. $.name = reader.string_(position, 4, null);
  175. $.overload_name = reader.string_(position, 6, null);
  176. $.num_args_serialized = reader.int32_(position, 8, -1);
  177. return $;
  178. }
  179. };
  180. $root.torch.jit.mobile.serialization.Arg = class Arg {
  181. static decode(reader, position) {
  182. const $ = new $root.torch.jit.mobile.serialization.Arg();
  183. $.name = reader.string_(position, 4, null);
  184. $.type = reader.string_(position, 6, null);
  185. $.default_value = reader.uint32_(position, 8, 0);
  186. return $;
  187. }
  188. };
  189. $root.torch.jit.mobile.serialization.Schema = class Schema {
  190. static decode(reader, position) {
  191. const $ = new $root.torch.jit.mobile.serialization.Schema();
  192. $.arguments = reader.tableArray(position, 4, $root.torch.jit.mobile.serialization.Arg.decode);
  193. $.returns = reader.tableArray(position, 6, $root.torch.jit.mobile.serialization.Arg.decode);
  194. return $;
  195. }
  196. };
  197. $root.torch.jit.mobile.serialization.DebugInfo = class DebugInfo {
  198. static decode(reader, position) {
  199. const $ = new $root.torch.jit.mobile.serialization.DebugInfo();
  200. $.debug_handle = reader.int64s_(position, 4);
  201. return $;
  202. }
  203. };
  204. $root.torch.jit.mobile.serialization.Function = class Function {
  205. static decode(reader, position) {
  206. const $ = new $root.torch.jit.mobile.serialization.Function();
  207. $.qn = reader.string_(position, 4, null);
  208. $.instructions = reader.structArray(position, 6, $root.torch.jit.mobile.serialization.Instruction.decode);
  209. $.operators = reader.tableArray(position, 8, $root.torch.jit.mobile.serialization.Operator.decode);
  210. $.constants = reader.typedArray(position, 10, Uint32Array);
  211. $.type_annotations = reader.strings_(position, 12);
  212. $.register_size = reader.int32_(position, 14, 0);
  213. $.schema = reader.table(position, 16, $root.torch.jit.mobile.serialization.Schema.decode);
  214. $.debug_info = reader.table(position, 18, $root.torch.jit.mobile.serialization.DebugInfo.decode);
  215. $.class_type = reader.uint32_(position, 20, 0);
  216. return $;
  217. }
  218. };
  219. $root.torch.jit.mobile.serialization.StorageData = class StorageData {
  220. static decode(reader, position) {
  221. const $ = new $root.torch.jit.mobile.serialization.StorageData();
  222. $.data = reader.typedArray(position, 4, Uint8Array);
  223. return $;
  224. }
  225. };
  226. $root.torch.jit.mobile.serialization.IValueUnion = class {
  227. static decode(reader, position, type) {
  228. switch (type) {
  229. case 1: return $root.torch.jit.mobile.serialization.Int.decode(reader, position);
  230. case 2: return $root.torch.jit.mobile.serialization.Bool.decode(reader, position);
  231. case 3: return $root.torch.jit.mobile.serialization.Double.decode(reader, position);
  232. case 4: return $root.torch.jit.mobile.serialization.ComplexDouble.decode(reader, position);
  233. case 5: return $root.torch.jit.mobile.serialization.TensorMetadata.decode(reader, position);
  234. case 6: return $root.torch.jit.mobile.serialization.String.decode(reader, position);
  235. case 7: return $root.torch.jit.mobile.serialization.List.decode(reader, position);
  236. case 8: return $root.torch.jit.mobile.serialization.Tuple.decode(reader, position);
  237. case 9: return $root.torch.jit.mobile.serialization.Dict.decode(reader, position);
  238. case 10: return $root.torch.jit.mobile.serialization.Object.decode(reader, position);
  239. case 11: return $root.torch.jit.mobile.serialization.IntList.decode(reader, position);
  240. case 12: return $root.torch.jit.mobile.serialization.DoubleList.decode(reader, position);
  241. case 13: return $root.torch.jit.mobile.serialization.BoolList.decode(reader, position);
  242. case 14: return $root.torch.jit.mobile.serialization.Device.decode(reader, position);
  243. case 15: return $root.torch.jit.mobile.serialization.EnumValue.decode(reader, position);
  244. case 16: return $root.torch.jit.mobile.serialization.Function.decode(reader, position);
  245. default: return undefined;
  246. }
  247. }
  248. };
  249. $root.torch.jit.mobile.serialization.IValue = class IValue {
  250. static decode(reader, position) {
  251. const $ = new $root.torch.jit.mobile.serialization.IValue();
  252. $.val = reader.union(position, 4, $root.torch.jit.mobile.serialization.IValueUnion.decode);
  253. return $;
  254. }
  255. };
  256. $root.torch.jit.mobile.serialization.ExtraFile = class ExtraFile {
  257. static decode(reader, position) {
  258. const $ = new $root.torch.jit.mobile.serialization.ExtraFile();
  259. $.name = reader.string_(position, 4, null);
  260. $.content = reader.string_(position, 6, null);
  261. return $;
  262. }
  263. };
  264. $root.torch.jit.mobile.serialization.Module = class Module {
  265. static identifier(reader) {
  266. return reader.identifier === 'PTMF';
  267. }
  268. static create(reader) {
  269. return $root.torch.jit.mobile.serialization.Module.decode(reader, reader.root);
  270. }
  271. static decode(reader, position) {
  272. const $ = new $root.torch.jit.mobile.serialization.Module();
  273. $.bytecode_version = reader.uint32_(position, 4, 0);
  274. $.extra_files = reader.tableArray(position, 6, $root.torch.jit.mobile.serialization.ExtraFile.decode);
  275. $.methods = reader.typedArray(position, 8, Uint32Array);
  276. $.state_obj = reader.uint32_(position, 10, 0);
  277. $.ivalues = reader.tableArray(position, 12, $root.torch.jit.mobile.serialization.IValue.decode);
  278. $.storage_data_size = reader.int32_(position, 14, 0);
  279. $.storage_data = reader.tableArray(position, 16, $root.torch.jit.mobile.serialization.StorageData.decode);
  280. $.object_types = reader.tableArray(position, 18, $root.torch.jit.mobile.serialization.ObjectType.decode);
  281. $.jit_sources = reader.tableArray(position, 20, $root.torch.jit.mobile.serialization.ExtraFile.decode);
  282. $.jit_constants = reader.typedArray(position, 22, Uint32Array);
  283. $.operator_version = reader.uint32_(position, 24, 0);
  284. $.mobile_ivalue_size = reader.uint32_(position, 26, 0);
  285. return $;
  286. }
  287. };
  288. $root.executorch_flatbuffer = $root.executorch_flatbuffer || {};
  289. $root.executorch_flatbuffer.ScalarType = {
  290. BYTE: 0,
  291. CHAR: 1,
  292. SHORT: 2,
  293. INT: 3,
  294. LONG: 4,
  295. Half: 5,
  296. FLOAT: 6,
  297. DOUBLE: 7,
  298. BOOL: 11,
  299. QINT8: 12,
  300. QUINT8: 13,
  301. QINT32: 14,
  302. QUINT4X2: 16,
  303. QUINT2X4: 17
  304. };
  305. $root.executorch_flatbuffer.ContainerMetadata = class ContainerMetadata {
  306. static decode(reader, position) {
  307. const $ = new $root.executorch_flatbuffer.ContainerMetadata();
  308. $.encoded_inp_str = reader.string_(position, 4, null);
  309. $.encoded_out_str = reader.string_(position, 6, null);
  310. return $;
  311. }
  312. };
  313. $root.executorch_flatbuffer.Null = class Null {
  314. static decode(/* reader, position */) {
  315. const $ = new $root.executorch_flatbuffer.Null();
  316. return $;
  317. }
  318. };
  319. $root.executorch_flatbuffer.AllocationDetails = class AllocationDetails {
  320. static decode(reader, position) {
  321. const $ = new $root.executorch_flatbuffer.AllocationDetails();
  322. $.memory_id = reader.uint32_(position, 4, 0);
  323. $.memory_offset = reader.uint32_(position, 6, 0);
  324. return $;
  325. }
  326. };
  327. $root.executorch_flatbuffer.TensorShapeDynamism = {
  328. STATIC: 0,
  329. DYNAMIC_BOUND: 1,
  330. DYNAMIC_UNBOUND: 2
  331. };
  332. $root.executorch_flatbuffer.Tensor = class Tensor {
  333. static decode(reader, position) {
  334. const $ = new $root.executorch_flatbuffer.Tensor();
  335. $.scalar_type = reader.int8_(position, 4, 0);
  336. $.storage_offset = reader.int32_(position, 6, 0);
  337. $.sizes = reader.typedArray(position, 8, Int32Array);
  338. $.dim_order = reader.typedArray(position, 10, Uint8Array);
  339. $.requires_grad = reader.bool_(position, 12, false);
  340. $.constant_buffer_idx = reader.uint32_(position, 14, 0);
  341. $.allocation_info = reader.table(position, 16, $root.executorch_flatbuffer.AllocationDetails.decode);
  342. $.layout = reader.int8_(position, 18, 0);
  343. $.shape_dynamism = reader.int8_(position, 20, 0);
  344. return $;
  345. }
  346. };
  347. $root.executorch_flatbuffer.Int = class Int {
  348. static decode(reader, position) {
  349. const $ = new $root.executorch_flatbuffer.Int();
  350. $.int_val = reader.int64_(position, 4, 0);
  351. return $;
  352. }
  353. };
  354. $root.executorch_flatbuffer.Bool = class Bool {
  355. static decode(reader, position) {
  356. const $ = new $root.executorch_flatbuffer.Bool();
  357. $.bool_val = reader.bool_(position, 4, false);
  358. return $;
  359. }
  360. };
  361. $root.executorch_flatbuffer.Double = class Double {
  362. static decode(reader, position) {
  363. const $ = new $root.executorch_flatbuffer.Double();
  364. $.double_val = reader.float64_(position, 4, 0);
  365. return $;
  366. }
  367. };
  368. $root.executorch_flatbuffer.String = class String {
  369. static decode(reader, position) {
  370. const $ = new $root.executorch_flatbuffer.String();
  371. $.string_val = reader.string_(position, 4, null);
  372. return $;
  373. }
  374. };
  375. $root.executorch_flatbuffer.IntList = class IntList {
  376. static decode(reader, position) {
  377. const $ = new $root.executorch_flatbuffer.IntList();
  378. $.items = reader.int64s_(position, 4);
  379. return $;
  380. }
  381. };
  382. $root.executorch_flatbuffer.DoubleList = class DoubleList {
  383. static decode(reader, position) {
  384. const $ = new $root.executorch_flatbuffer.DoubleList();
  385. $.items = reader.typedArray(position, 4, Float64Array);
  386. return $;
  387. }
  388. };
  389. $root.executorch_flatbuffer.BoolList = class BoolList {
  390. static decode(reader, position) {
  391. const $ = new $root.executorch_flatbuffer.BoolList();
  392. $.items = reader.bools_(position, 4);
  393. return $;
  394. }
  395. };
  396. $root.executorch_flatbuffer.TensorList = class TensorList {
  397. static decode(reader, position) {
  398. const $ = new $root.executorch_flatbuffer.TensorList();
  399. $.items = reader.typedArray(position, 4, Int32Array);
  400. return $;
  401. }
  402. };
  403. $root.executorch_flatbuffer.OptionalTensorList = class OptionalTensorList {
  404. static decode(reader, position) {
  405. const $ = new $root.executorch_flatbuffer.OptionalTensorList();
  406. $.items = reader.typedArray(position, 4, Int32Array);
  407. return $;
  408. }
  409. };
  410. $root.executorch_flatbuffer.KernelTypes = class {
  411. static decode(reader, position, type) {
  412. switch (type) {
  413. case 1: return $root.executorch_flatbuffer.Null.decode(reader, position);
  414. case 2: return $root.executorch_flatbuffer.Int.decode(reader, position);
  415. case 3: return $root.executorch_flatbuffer.Bool.decode(reader, position);
  416. case 4: return $root.executorch_flatbuffer.Double.decode(reader, position);
  417. case 5: return $root.executorch_flatbuffer.Tensor.decode(reader, position);
  418. case 6: return $root.executorch_flatbuffer.String.decode(reader, position);
  419. case 7: return $root.executorch_flatbuffer.IntList.decode(reader, position);
  420. case 8: return $root.executorch_flatbuffer.DoubleList.decode(reader, position);
  421. case 9: return $root.executorch_flatbuffer.BoolList.decode(reader, position);
  422. case 10: return $root.executorch_flatbuffer.TensorList.decode(reader, position);
  423. case 11: return $root.executorch_flatbuffer.OptionalTensorList.decode(reader, position);
  424. default: return undefined;
  425. }
  426. }
  427. };
  428. $root.executorch_flatbuffer.EValue = class EValue {
  429. static decode(reader, position) {
  430. const $ = new $root.executorch_flatbuffer.EValue();
  431. $.val = reader.union(position, 4, $root.executorch_flatbuffer.KernelTypes.decode);
  432. return $;
  433. }
  434. };
  435. $root.executorch_flatbuffer.Operator = class Operator {
  436. static decode(reader, position) {
  437. const $ = new $root.executorch_flatbuffer.Operator();
  438. $.name = reader.string_(position, 4, null);
  439. $.overload = reader.string_(position, 6, null);
  440. return $;
  441. }
  442. };
  443. $root.executorch_flatbuffer.KernelCall = class KernelCall {
  444. static decode(reader, position) {
  445. const $ = new $root.executorch_flatbuffer.KernelCall();
  446. $.op_index = reader.int32_(position, 4, 0);
  447. $.args = reader.typedArray(position, 6, Int32Array);
  448. return $;
  449. }
  450. };
  451. $root.executorch_flatbuffer.DelegateCall = class DelegateCall {
  452. static decode(reader, position) {
  453. const $ = new $root.executorch_flatbuffer.DelegateCall();
  454. $.delegate_index = reader.int32_(position, 4, 0);
  455. $.args = reader.typedArray(position, 6, Int32Array);
  456. return $;
  457. }
  458. };
  459. $root.executorch_flatbuffer.MoveCall = class MoveCall {
  460. static decode(reader, position) {
  461. const $ = new $root.executorch_flatbuffer.MoveCall();
  462. $.move_from = reader.int32_(position, 4, 0);
  463. $.move_to = reader.int32_(position, 6, 0);
  464. return $;
  465. }
  466. };
  467. $root.executorch_flatbuffer.JumpFalseCall = class JumpFalseCall {
  468. static decode(reader, position) {
  469. const $ = new $root.executorch_flatbuffer.JumpFalseCall();
  470. $.cond_value_index = reader.int32_(position, 4, 0);
  471. $.destination_instruction = reader.int32_(position, 6, 0);
  472. return $;
  473. }
  474. };
  475. $root.executorch_flatbuffer.FreeCall = class FreeCall {
  476. static decode(reader, position) {
  477. const $ = new $root.executorch_flatbuffer.FreeCall();
  478. $.value_index = reader.int32_(position, 4, 0);
  479. return $;
  480. }
  481. };
  482. $root.executorch_flatbuffer.InstructionArguments = class {
  483. static decode(reader, position, type) {
  484. switch (type) {
  485. case 1: return $root.executorch_flatbuffer.KernelCall.decode(reader, position);
  486. case 2: return $root.executorch_flatbuffer.DelegateCall.decode(reader, position);
  487. case 3: return $root.executorch_flatbuffer.MoveCall.decode(reader, position);
  488. case 4: return $root.executorch_flatbuffer.JumpFalseCall.decode(reader, position);
  489. case 5: return $root.executorch_flatbuffer.FreeCall.decode(reader, position);
  490. default: return undefined;
  491. }
  492. }
  493. };
  494. $root.executorch_flatbuffer.Instruction = class Instruction {
  495. static decode(reader, position) {
  496. const $ = new $root.executorch_flatbuffer.Instruction();
  497. $.instr_args = reader.union(position, 4, $root.executorch_flatbuffer.InstructionArguments.decode);
  498. return $;
  499. }
  500. };
  501. $root.executorch_flatbuffer.Frame = class Frame {
  502. static decode(reader, position) {
  503. const $ = new $root.executorch_flatbuffer.Frame();
  504. $.filename = reader.string_(position, 4, null);
  505. $.lineno = reader.int32_(position, 6, 0);
  506. $.name = reader.string_(position, 8, null);
  507. $.context = reader.string_(position, 10, null);
  508. return $;
  509. }
  510. };
  511. $root.executorch_flatbuffer.FrameList = class FrameList {
  512. static decode(reader, position) {
  513. const $ = new $root.executorch_flatbuffer.FrameList();
  514. $.items = reader.tableArray(position, 4, $root.executorch_flatbuffer.Frame.decode);
  515. return $;
  516. }
  517. };
  518. $root.executorch_flatbuffer.DataLocation = {
  519. INLINE: 0,
  520. SEGMENT: 1
  521. };
  522. $root.executorch_flatbuffer.BackendDelegateDataReference = class BackendDelegateDataReference {
  523. static decode(reader, position) {
  524. const $ = new $root.executorch_flatbuffer.BackendDelegateDataReference();
  525. $.location = reader.int8_(position, 4, 0);
  526. $.index = reader.uint32_(position, 6, 0);
  527. return $;
  528. }
  529. };
  530. $root.executorch_flatbuffer.CompileSpec = class CompileSpec {
  531. static decode(reader, position) {
  532. const $ = new $root.executorch_flatbuffer.CompileSpec();
  533. $.key = reader.string_(position, 4, null);
  534. $.value = reader.typedArray(position, 6, Uint8Array);
  535. return $;
  536. }
  537. };
  538. $root.executorch_flatbuffer.BackendDelegate = class BackendDelegate {
  539. static decode(reader, position) {
  540. const $ = new $root.executorch_flatbuffer.BackendDelegate();
  541. $.id = reader.string_(position, 4, null);
  542. $.processed = reader.table(position, 6, $root.executorch_flatbuffer.BackendDelegateDataReference.decode);
  543. $.compile_specs = reader.tableArray(position, 8, $root.executorch_flatbuffer.CompileSpec.decode);
  544. return $;
  545. }
  546. };
  547. $root.executorch_flatbuffer.Chain = class Chain {
  548. static decode(reader, position) {
  549. const $ = new $root.executorch_flatbuffer.Chain();
  550. $.inputs = reader.typedArray(position, 4, Int32Array);
  551. $.outputs = reader.typedArray(position, 6, Int32Array);
  552. $.instructions = reader.tableArray(position, 8, $root.executorch_flatbuffer.Instruction.decode);
  553. $.stacktrace = reader.tableArray(position, 10, $root.executorch_flatbuffer.FrameList.decode);
  554. return $;
  555. }
  556. };
  557. $root.executorch_flatbuffer.ExecutionPlan = class ExecutionPlan {
  558. static decode(reader, position) {
  559. const $ = new $root.executorch_flatbuffer.ExecutionPlan();
  560. $.name = reader.string_(position, 4, null);
  561. $.container_meta_type = reader.table(position, 6, $root.executorch_flatbuffer.ContainerMetadata.decode);
  562. $.values = reader.tableArray(position, 8, $root.executorch_flatbuffer.EValue.decode);
  563. $.inputs = reader.typedArray(position, 10, Int32Array);
  564. $.outputs = reader.typedArray(position, 12, Int32Array);
  565. $.chains = reader.tableArray(position, 14, $root.executorch_flatbuffer.Chain.decode);
  566. $.operators = reader.tableArray(position, 16, $root.executorch_flatbuffer.Operator.decode);
  567. $.delegates = reader.tableArray(position, 18, $root.executorch_flatbuffer.BackendDelegate.decode);
  568. $.non_const_buffer_sizes = reader.int64s_(position, 20);
  569. return $;
  570. }
  571. };
  572. $root.executorch_flatbuffer.Buffer = class Buffer {
  573. static decode(reader, position) {
  574. const $ = new $root.executorch_flatbuffer.Buffer();
  575. $.storage = reader.typedArray(position, 4, Uint8Array);
  576. return $;
  577. }
  578. };
  579. $root.executorch_flatbuffer.BackendDelegateInlineData = class BackendDelegateInlineData {
  580. static decode(reader, position) {
  581. const $ = new $root.executorch_flatbuffer.BackendDelegateInlineData();
  582. $.data = reader.typedArray(position, 4, Uint8Array);
  583. return $;
  584. }
  585. };
  586. $root.executorch_flatbuffer.DataSegment = class DataSegment {
  587. static decode(reader, position) {
  588. const $ = new $root.executorch_flatbuffer.DataSegment();
  589. $.offset = reader.uint64_(position, 4, 0);
  590. $.size = reader.uint64_(position, 6, 0);
  591. return $;
  592. }
  593. };
  594. $root.executorch_flatbuffer.SubsegmentOffsets = class SubsegmentOffsets {
  595. static decode(reader, position) {
  596. const $ = new $root.executorch_flatbuffer.SubsegmentOffsets();
  597. $.segment_index = reader.uint32_(position, 4, 0);
  598. $.offsets = reader.uint64s_(position, 6);
  599. return $;
  600. }
  601. };
  602. $root.executorch_flatbuffer.Program = class Program {
  603. static identifier(reader) {
  604. return reader.identifier === 'ET12';
  605. }
  606. static create(reader) {
  607. return $root.executorch_flatbuffer.Program.decode(reader, reader.root);
  608. }
  609. static decode(reader, position) {
  610. const $ = new $root.executorch_flatbuffer.Program();
  611. $.version = reader.uint32_(position, 4, 0);
  612. $.execution_plan = reader.tableArray(position, 6, $root.executorch_flatbuffer.ExecutionPlan.decode);
  613. $.constant_buffer = reader.tableArray(position, 8, $root.executorch_flatbuffer.Buffer.decode);
  614. $.backend_delegate_data = reader.tableArray(position, 10, $root.executorch_flatbuffer.BackendDelegateInlineData.decode);
  615. $.segments = reader.tableArray(position, 12, $root.executorch_flatbuffer.DataSegment.decode);
  616. $.constant_segment = reader.table(position, 14, $root.executorch_flatbuffer.SubsegmentOffsets.decode);
  617. return $;
  618. }
  619. };