onnx-schema.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  1. export const onnxruntime = {};
  2. onnxruntime.fbs = onnxruntime.fbs || {};
  3. onnxruntime.fbs.AttributeType = {
  4. UNDEFINED: 0,
  5. FLOAT: 1,
  6. INT: 2,
  7. STRING: 3,
  8. TENSOR: 4,
  9. GRAPH: 5,
  10. FLOATS: 6,
  11. INTS: 7,
  12. STRINGS: 8,
  13. TENSORS: 9,
  14. GRAPHS: 10,
  15. SPARSE_TENSOR: 11,
  16. SPARSE_TENSORS: 12
  17. };
  18. onnxruntime.fbs.Shape = class Shape {
  19. static decode(reader, position) {
  20. const $ = new onnxruntime.fbs.Shape();
  21. $.dim = reader.tables(position, 4, onnxruntime.fbs.Dimension);
  22. return $;
  23. }
  24. };
  25. onnxruntime.fbs.Dimension = class Dimension {
  26. static decode(reader, position) {
  27. const $ = new onnxruntime.fbs.Dimension();
  28. $.value = reader.table(position, 4, onnxruntime.fbs.DimensionValue);
  29. $.denotation = reader.string_(position, 6, null);
  30. return $;
  31. }
  32. };
  33. onnxruntime.fbs.DimensionValueType = {
  34. UNKNOWN: 0,
  35. VALUE: 1,
  36. PARAM: 2
  37. };
  38. onnxruntime.fbs.DimensionValue = class DimensionValue {
  39. static decode(reader, position) {
  40. const $ = new onnxruntime.fbs.DimensionValue();
  41. $.dim_type = reader.int8_(position, 4, 0);
  42. $.dim_value = reader.int64_(position, 6, 0n);
  43. $.dim_param = reader.string_(position, 8, null);
  44. return $;
  45. }
  46. };
  47. onnxruntime.fbs.TensorDataType = {
  48. UNDEFINED: 0,
  49. FLOAT: 1,
  50. UINT8: 2,
  51. INT8: 3,
  52. UINT16: 4,
  53. INT16: 5,
  54. INT32: 6,
  55. INT64: 7,
  56. STRING: 8,
  57. BOOL: 9,
  58. FLOAT16: 10,
  59. DOUBLE: 11,
  60. UINT32: 12,
  61. UINT64: 13,
  62. COMPLEX64: 14,
  63. COMPLEX128: 15,
  64. BFLOAT16: 16,
  65. FLOAT8E4M3FN: 17,
  66. FLOAT8E4M3FNUZ: 18,
  67. FLOAT8E5M2: 19,
  68. FLOAT8E5M2FNUZ: 20
  69. };
  70. onnxruntime.fbs.TensorTypeAndShape = class TensorTypeAndShape {
  71. static decode(reader, position) {
  72. const $ = new onnxruntime.fbs.TensorTypeAndShape();
  73. $.elem_type = reader.int32_(position, 4, 0);
  74. $.shape = reader.table(position, 6, onnxruntime.fbs.Shape);
  75. return $;
  76. }
  77. };
  78. onnxruntime.fbs.MapType = class MapType {
  79. static decode(reader, position) {
  80. const $ = new onnxruntime.fbs.MapType();
  81. $.key_type = reader.int32_(position, 4, 0);
  82. $.value_type = reader.table(position, 6, onnxruntime.fbs.TypeInfo);
  83. return $;
  84. }
  85. };
  86. onnxruntime.fbs.SequenceType = class SequenceType {
  87. static decode(reader, position) {
  88. const $ = new onnxruntime.fbs.SequenceType();
  89. $.elem_type = reader.table(position, 4, onnxruntime.fbs.TypeInfo);
  90. return $;
  91. }
  92. };
  93. onnxruntime.fbs.NodeType = {
  94. Primitive: 0,
  95. Fused: 1
  96. };
  97. onnxruntime.fbs.EdgeEnd = class EdgeEnd {
  98. static decode(reader, position) {
  99. const $ = new onnxruntime.fbs.EdgeEnd();
  100. $.node_index = reader.uint32(position + 0);
  101. $.src_arg_index = reader.int32(position + 4);
  102. $.dst_arg_index = reader.int32(position + 8);
  103. return $;
  104. }
  105. };
  106. onnxruntime.fbs.NodeEdge = class NodeEdge {
  107. static decode(reader, position) {
  108. const $ = new onnxruntime.fbs.NodeEdge();
  109. $.node_index = reader.uint32_(position, 4, 0);
  110. $.input_edges = reader.structs(position, 6, onnxruntime.fbs.EdgeEnd);
  111. $.output_edges = reader.structs(position, 8, onnxruntime.fbs.EdgeEnd);
  112. return $;
  113. }
  114. };
  115. onnxruntime.fbs.Node = class Node {
  116. static decode(reader, position) {
  117. const $ = new onnxruntime.fbs.Node();
  118. $.name = reader.string_(position, 4, null);
  119. $.doc_string = reader.string_(position, 6, null);
  120. $.domain = reader.string_(position, 8, null);
  121. $.since_version = reader.int32_(position, 10, 0);
  122. $.index = reader.uint32_(position, 12, 0);
  123. $.op_type = reader.string_(position, 14, null);
  124. $.type = reader.int32_(position, 16, 0);
  125. $.execution_provider_type = reader.string_(position, 18, null);
  126. $.inputs = reader.strings_(position, 20);
  127. $.outputs = reader.strings_(position, 22);
  128. $.attributes = reader.tables(position, 24, onnxruntime.fbs.Attribute);
  129. $.input_arg_counts = reader.array(position, 26, Int32Array);
  130. $.implicit_inputs = reader.strings_(position, 28);
  131. return $;
  132. }
  133. };
  134. onnxruntime.fbs.ValueInfo = class ValueInfo {
  135. static decode(reader, position) {
  136. const $ = new onnxruntime.fbs.ValueInfo();
  137. $.name = reader.string_(position, 4, null);
  138. $.doc_string = reader.string_(position, 6, null);
  139. $.type = reader.table(position, 8, onnxruntime.fbs.TypeInfo);
  140. return $;
  141. }
  142. };
  143. onnxruntime.fbs.TypeInfoValue = class {
  144. static decode(reader, position, type) {
  145. switch (type) {
  146. case 1: return onnxruntime.fbs.TensorTypeAndShape.decode(reader, position);
  147. case 2: return onnxruntime.fbs.SequenceType.decode(reader, position);
  148. case 3: return onnxruntime.fbs.MapType.decode(reader, position);
  149. default: return undefined;
  150. }
  151. }
  152. };
  153. onnxruntime.fbs.TypeInfo = class TypeInfo {
  154. static decode(reader, position) {
  155. const $ = new onnxruntime.fbs.TypeInfo();
  156. $.denotation = reader.string_(position, 4, null);
  157. $.value = reader.union(position, 6, onnxruntime.fbs.TypeInfoValue);
  158. return $;
  159. }
  160. };
  161. onnxruntime.fbs.OperatorSetId = class OperatorSetId {
  162. static decode(reader, position) {
  163. const $ = new onnxruntime.fbs.OperatorSetId();
  164. $.domain = reader.string_(position, 4, null);
  165. $.version = reader.int64_(position, 6, 0n);
  166. return $;
  167. }
  168. };
  169. onnxruntime.fbs.Tensor = class Tensor {
  170. static decode(reader, position) {
  171. const $ = new onnxruntime.fbs.Tensor();
  172. $.name = reader.string_(position, 4, null);
  173. $.doc_string = reader.string_(position, 6, null);
  174. $.dims = reader.int64s_(position, 8);
  175. $.data_type = reader.int32_(position, 10, 0);
  176. $.raw_data = reader.array(position, 12, Uint8Array);
  177. $.string_data = reader.strings_(position, 14);
  178. $.external_data_offset = reader.int64_(position, 16, -1n);
  179. return $;
  180. }
  181. };
  182. onnxruntime.fbs.SparseTensor = class SparseTensor {
  183. static decode(reader, position) {
  184. const $ = new onnxruntime.fbs.SparseTensor();
  185. $.values = reader.table(position, 4, onnxruntime.fbs.Tensor);
  186. $.indices = reader.table(position, 6, onnxruntime.fbs.Tensor);
  187. $.dims = reader.int64s_(position, 8);
  188. return $;
  189. }
  190. };
  191. onnxruntime.fbs.Attribute = class Attribute {
  192. static decode(reader, position) {
  193. const $ = new onnxruntime.fbs.Attribute();
  194. $.name = reader.string_(position, 4, null);
  195. $.doc_string = reader.string_(position, 6, null);
  196. $.type = reader.int32_(position, 8, 0);
  197. $.f = reader.float32_(position, 10, 0);
  198. $.i = reader.int64_(position, 12, 0n);
  199. $.s = reader.string_(position, 14, null);
  200. $.t = reader.table(position, 16, onnxruntime.fbs.Tensor);
  201. $.g = reader.table(position, 18, onnxruntime.fbs.Graph);
  202. $.floats = reader.array(position, 20, Float32Array);
  203. $.ints = reader.int64s_(position, 22);
  204. $.strings = reader.strings_(position, 24);
  205. $.tensors = reader.tables(position, 26, onnxruntime.fbs.Tensor);
  206. $.graphs = reader.tables(position, 28, onnxruntime.fbs.Graph);
  207. return $;
  208. }
  209. };
  210. onnxruntime.fbs.NodesToOptimizeIndices = class NodesToOptimizeIndices {
  211. static decode(reader, position) {
  212. const $ = new onnxruntime.fbs.NodesToOptimizeIndices();
  213. $.node_indices = reader.array(position, 4, Uint32Array);
  214. $.num_inputs = reader.uint32_(position, 6, 0);
  215. $.num_outputs = reader.uint32_(position, 8, 0);
  216. $.has_variadic_input = reader.bool_(position, 10, false);
  217. $.has_variadic_output = reader.bool_(position, 12, false);
  218. $.num_variadic_inputs = reader.uint32_(position, 14, 0);
  219. $.num_variadic_outputs = reader.uint32_(position, 16, 0);
  220. return $;
  221. }
  222. };
  223. onnxruntime.fbs.DeprecatedNodeIndexAndKernelDefHash = class DeprecatedNodeIndexAndKernelDefHash {
  224. static decode(reader, position) {
  225. const $ = new onnxruntime.fbs.DeprecatedNodeIndexAndKernelDefHash();
  226. $.node_index = reader.uint32_(position, 4, 0);
  227. $.kernel_def_hash = reader.uint64_(position, 6, 0n);
  228. return $;
  229. }
  230. };
  231. onnxruntime.fbs.RuntimeOptimizationRecord = class RuntimeOptimizationRecord {
  232. static decode(reader, position) {
  233. const $ = new onnxruntime.fbs.RuntimeOptimizationRecord();
  234. $.action_id = reader.string_(position, 4, null);
  235. $.nodes_to_optimize_indices = reader.table(position, 6, onnxruntime.fbs.NodesToOptimizeIndices);
  236. $.produced_nodes = reader.tables(position, 8, onnxruntime.fbs.DeprecatedNodeIndexAndKernelDefHash);
  237. $.produced_op_ids = reader.strings_(position, 10);
  238. return $;
  239. }
  240. };
  241. onnxruntime.fbs.RuntimeOptimizationRecordContainerEntry = class RuntimeOptimizationRecordContainerEntry {
  242. static decode(reader, position) {
  243. const $ = new onnxruntime.fbs.RuntimeOptimizationRecordContainerEntry();
  244. $.optimizer_name = reader.string_(position, 4, null);
  245. $.runtime_optimization_records = reader.tables(position, 6, onnxruntime.fbs.RuntimeOptimizationRecord);
  246. return $;
  247. }
  248. };
  249. onnxruntime.fbs.RuntimeOptimizations = class RuntimeOptimizations {
  250. static decode(reader, position) {
  251. const $ = new onnxruntime.fbs.RuntimeOptimizations();
  252. $.records = reader.tables(position, 4, onnxruntime.fbs.RuntimeOptimizationRecordContainerEntry);
  253. return $;
  254. }
  255. };
  256. onnxruntime.fbs.Graph = class Graph {
  257. static decode(reader, position) {
  258. const $ = new onnxruntime.fbs.Graph();
  259. $.initializers = reader.tables(position, 4, onnxruntime.fbs.Tensor);
  260. $.node_args = reader.tables(position, 6, onnxruntime.fbs.ValueInfo);
  261. $.nodes = reader.tables(position, 8, onnxruntime.fbs.Node);
  262. $.max_node_index = reader.uint32_(position, 10, 0);
  263. $.node_edges = reader.tables(position, 12, onnxruntime.fbs.NodeEdge);
  264. $.inputs = reader.strings_(position, 14);
  265. $.outputs = reader.strings_(position, 16);
  266. $.sparse_initializers = reader.tables(position, 18, onnxruntime.fbs.SparseTensor);
  267. $.runtime_optimizations = reader.table(position, 20, onnxruntime.fbs.RuntimeOptimizations);
  268. return $;
  269. }
  270. };
  271. onnxruntime.fbs.StringStringEntry = class StringStringEntry {
  272. static decode(reader, position) {
  273. const $ = new onnxruntime.fbs.StringStringEntry();
  274. $.key = reader.string_(position, 4, null);
  275. $.value = reader.string_(position, 6, null);
  276. return $;
  277. }
  278. };
  279. onnxruntime.fbs.Model = class Model {
  280. static decode(reader, position) {
  281. const $ = new onnxruntime.fbs.Model();
  282. $.ir_version = reader.int64_(position, 4, 0n);
  283. $.opset_import = reader.tables(position, 6, onnxruntime.fbs.OperatorSetId);
  284. $.producer_name = reader.string_(position, 8, null);
  285. $.producer_version = reader.string_(position, 10, null);
  286. $.domain = reader.string_(position, 12, null);
  287. $.model_version = reader.int64_(position, 14, 0n);
  288. $.doc_string = reader.string_(position, 16, null);
  289. $.graph = reader.table(position, 18, onnxruntime.fbs.Graph);
  290. $.graph_doc_string = reader.string_(position, 20, null);
  291. $.metadata_props = reader.tables(position, 22, onnxruntime.fbs.StringStringEntry);
  292. return $;
  293. }
  294. };
  295. onnxruntime.fbs.DeprecatedKernelCreateInfos = class DeprecatedKernelCreateInfos {
  296. static decode(reader, position) {
  297. const $ = new onnxruntime.fbs.DeprecatedKernelCreateInfos();
  298. $.node_indices = reader.array(position, 4, Uint32Array);
  299. $.kernel_def_hashes = reader.uint64s_(position, 6);
  300. return $;
  301. }
  302. };
  303. onnxruntime.fbs.DeprecatedSubGraphSessionState = class DeprecatedSubGraphSessionState {
  304. static decode(reader, position) {
  305. const $ = new onnxruntime.fbs.DeprecatedSubGraphSessionState();
  306. $.graph_id = reader.string_(position, 4, null);
  307. $.session_state = reader.table(position, 6, onnxruntime.fbs.DeprecatedSessionState);
  308. return $;
  309. }
  310. };
  311. onnxruntime.fbs.DeprecatedSessionState = class DeprecatedSessionState {
  312. static decode(reader, position) {
  313. const $ = new onnxruntime.fbs.DeprecatedSessionState();
  314. $.kernels = reader.table(position, 4, onnxruntime.fbs.DeprecatedKernelCreateInfos);
  315. $.sub_graph_session_states = reader.tables(position, 6, onnxruntime.fbs.DeprecatedSubGraphSessionState);
  316. return $;
  317. }
  318. };
  319. onnxruntime.fbs.ArgType = {
  320. INPUT: 0,
  321. OUTPUT: 1
  322. };
  323. onnxruntime.fbs.ArgTypeAndIndex = class ArgTypeAndIndex {
  324. static decode(reader, position) {
  325. const $ = new onnxruntime.fbs.ArgTypeAndIndex();
  326. $.arg_type = reader.int8_(position, 4, 0);
  327. $.index = reader.uint32_(position, 6, 0);
  328. return $;
  329. }
  330. };
  331. onnxruntime.fbs.KernelTypeStrArgsEntry = class KernelTypeStrArgsEntry {
  332. static decode(reader, position) {
  333. const $ = new onnxruntime.fbs.KernelTypeStrArgsEntry();
  334. $.kernel_type_str = reader.string_(position, 4, null);
  335. $.args = reader.tables(position, 6, onnxruntime.fbs.ArgTypeAndIndex);
  336. return $;
  337. }
  338. };
  339. onnxruntime.fbs.OpIdKernelTypeStrArgsEntry = class OpIdKernelTypeStrArgsEntry {
  340. static decode(reader, position) {
  341. const $ = new onnxruntime.fbs.OpIdKernelTypeStrArgsEntry();
  342. $.op_id = reader.string_(position, 4, null);
  343. $.kernel_type_str_args = reader.tables(position, 6, onnxruntime.fbs.KernelTypeStrArgsEntry);
  344. return $;
  345. }
  346. };
  347. onnxruntime.fbs.KernelTypeStrResolver = class KernelTypeStrResolver {
  348. static decode(reader, position) {
  349. const $ = new onnxruntime.fbs.KernelTypeStrResolver();
  350. $.op_kernel_type_str_args = reader.tables(position, 4, onnxruntime.fbs.OpIdKernelTypeStrArgsEntry);
  351. return $;
  352. }
  353. };
  354. onnxruntime.fbs.InferenceSession = class InferenceSession {
  355. static identifier(reader) {
  356. return reader.identifier === 'ORTM';
  357. }
  358. static create(reader) {
  359. return onnxruntime.fbs.InferenceSession.decode(reader, reader.root);
  360. }
  361. static decode(reader, position) {
  362. const $ = new onnxruntime.fbs.InferenceSession();
  363. $.ort_version = reader.string_(position, 4, null);
  364. $.model = reader.table(position, 6, onnxruntime.fbs.Model);
  365. $.session_state = reader.table(position, 8, onnxruntime.fbs.DeprecatedSessionState);
  366. $.kernel_type_str_resolver = reader.table(position, 10, onnxruntime.fbs.KernelTypeStrResolver);
  367. return $;
  368. }
  369. };