onnx-schema.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  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. return $;
  179. }
  180. };
  181. onnxruntime.fbs.SparseTensor = class SparseTensor {
  182. static decode(reader, position) {
  183. const $ = new onnxruntime.fbs.SparseTensor();
  184. $.values = reader.table(position, 4, onnxruntime.fbs.Tensor);
  185. $.indices = reader.table(position, 6, onnxruntime.fbs.Tensor);
  186. $.dims = reader.int64s_(position, 8);
  187. return $;
  188. }
  189. };
  190. onnxruntime.fbs.Attribute = class Attribute {
  191. static decode(reader, position) {
  192. const $ = new onnxruntime.fbs.Attribute();
  193. $.name = reader.string_(position, 4, null);
  194. $.doc_string = reader.string_(position, 6, null);
  195. $.type = reader.int32_(position, 8, 0);
  196. $.f = reader.float32_(position, 10, 0);
  197. $.i = reader.int64_(position, 12, 0n);
  198. $.s = reader.string_(position, 14, null);
  199. $.t = reader.table(position, 16, onnxruntime.fbs.Tensor);
  200. $.g = reader.table(position, 18, onnxruntime.fbs.Graph);
  201. $.floats = reader.array(position, 20, Float32Array);
  202. $.ints = reader.int64s_(position, 22);
  203. $.strings = reader.strings_(position, 24);
  204. $.tensors = reader.tables(position, 26, onnxruntime.fbs.Tensor);
  205. $.graphs = reader.tables(position, 28, onnxruntime.fbs.Graph);
  206. return $;
  207. }
  208. };
  209. onnxruntime.fbs.NodesToOptimizeIndices = class NodesToOptimizeIndices {
  210. static decode(reader, position) {
  211. const $ = new onnxruntime.fbs.NodesToOptimizeIndices();
  212. $.node_indices = reader.array(position, 4, Uint32Array);
  213. $.num_inputs = reader.uint32_(position, 6, 0);
  214. $.num_outputs = reader.uint32_(position, 8, 0);
  215. $.has_variadic_input = reader.bool_(position, 10, false);
  216. $.has_variadic_output = reader.bool_(position, 12, false);
  217. $.num_variadic_inputs = reader.uint32_(position, 14, 0);
  218. $.num_variadic_outputs = reader.uint32_(position, 16, 0);
  219. return $;
  220. }
  221. };
  222. onnxruntime.fbs.DeprecatedNodeIndexAndKernelDefHash = class DeprecatedNodeIndexAndKernelDefHash {
  223. static decode(reader, position) {
  224. const $ = new onnxruntime.fbs.DeprecatedNodeIndexAndKernelDefHash();
  225. $.node_index = reader.uint32_(position, 4, 0);
  226. $.kernel_def_hash = reader.uint64_(position, 6, 0n);
  227. return $;
  228. }
  229. };
  230. onnxruntime.fbs.RuntimeOptimizationRecord = class RuntimeOptimizationRecord {
  231. static decode(reader, position) {
  232. const $ = new onnxruntime.fbs.RuntimeOptimizationRecord();
  233. $.action_id = reader.string_(position, 4, null);
  234. $.nodes_to_optimize_indices = reader.table(position, 6, onnxruntime.fbs.NodesToOptimizeIndices);
  235. $.produced_nodes = reader.tables(position, 8, onnxruntime.fbs.DeprecatedNodeIndexAndKernelDefHash);
  236. $.produced_op_ids = reader.strings_(position, 10);
  237. return $;
  238. }
  239. };
  240. onnxruntime.fbs.RuntimeOptimizationRecordContainerEntry = class RuntimeOptimizationRecordContainerEntry {
  241. static decode(reader, position) {
  242. const $ = new onnxruntime.fbs.RuntimeOptimizationRecordContainerEntry();
  243. $.optimizer_name = reader.string_(position, 4, null);
  244. $.runtime_optimization_records = reader.tables(position, 6, onnxruntime.fbs.RuntimeOptimizationRecord);
  245. return $;
  246. }
  247. };
  248. onnxruntime.fbs.RuntimeOptimizations = class RuntimeOptimizations {
  249. static decode(reader, position) {
  250. const $ = new onnxruntime.fbs.RuntimeOptimizations();
  251. $.records = reader.tables(position, 4, onnxruntime.fbs.RuntimeOptimizationRecordContainerEntry);
  252. return $;
  253. }
  254. };
  255. onnxruntime.fbs.Graph = class Graph {
  256. static decode(reader, position) {
  257. const $ = new onnxruntime.fbs.Graph();
  258. $.initializers = reader.tables(position, 4, onnxruntime.fbs.Tensor);
  259. $.node_args = reader.tables(position, 6, onnxruntime.fbs.ValueInfo);
  260. $.nodes = reader.tables(position, 8, onnxruntime.fbs.Node);
  261. $.max_node_index = reader.uint32_(position, 10, 0);
  262. $.node_edges = reader.tables(position, 12, onnxruntime.fbs.NodeEdge);
  263. $.inputs = reader.strings_(position, 14);
  264. $.outputs = reader.strings_(position, 16);
  265. $.sparse_initializers = reader.tables(position, 18, onnxruntime.fbs.SparseTensor);
  266. $.runtime_optimizations = reader.table(position, 20, onnxruntime.fbs.RuntimeOptimizations);
  267. return $;
  268. }
  269. };
  270. onnxruntime.fbs.StringStringEntry = class StringStringEntry {
  271. static decode(reader, position) {
  272. const $ = new onnxruntime.fbs.StringStringEntry();
  273. $.key = reader.string_(position, 4, null);
  274. $.value = reader.string_(position, 6, null);
  275. return $;
  276. }
  277. };
  278. onnxruntime.fbs.Model = class Model {
  279. static decode(reader, position) {
  280. const $ = new onnxruntime.fbs.Model();
  281. $.ir_version = reader.int64_(position, 4, 0n);
  282. $.opset_import = reader.tables(position, 6, onnxruntime.fbs.OperatorSetId);
  283. $.producer_name = reader.string_(position, 8, null);
  284. $.producer_version = reader.string_(position, 10, null);
  285. $.domain = reader.string_(position, 12, null);
  286. $.model_version = reader.int64_(position, 14, 0n);
  287. $.doc_string = reader.string_(position, 16, null);
  288. $.graph = reader.table(position, 18, onnxruntime.fbs.Graph);
  289. $.graph_doc_string = reader.string_(position, 20, null);
  290. $.metadata_props = reader.tables(position, 22, onnxruntime.fbs.StringStringEntry);
  291. return $;
  292. }
  293. };
  294. onnxruntime.fbs.DeprecatedKernelCreateInfos = class DeprecatedKernelCreateInfos {
  295. static decode(reader, position) {
  296. const $ = new onnxruntime.fbs.DeprecatedKernelCreateInfos();
  297. $.node_indices = reader.array(position, 4, Uint32Array);
  298. $.kernel_def_hashes = reader.uint64s_(position, 6);
  299. return $;
  300. }
  301. };
  302. onnxruntime.fbs.DeprecatedSubGraphSessionState = class DeprecatedSubGraphSessionState {
  303. static decode(reader, position) {
  304. const $ = new onnxruntime.fbs.DeprecatedSubGraphSessionState();
  305. $.graph_id = reader.string_(position, 4, null);
  306. $.session_state = reader.table(position, 6, onnxruntime.fbs.DeprecatedSessionState);
  307. return $;
  308. }
  309. };
  310. onnxruntime.fbs.DeprecatedSessionState = class DeprecatedSessionState {
  311. static decode(reader, position) {
  312. const $ = new onnxruntime.fbs.DeprecatedSessionState();
  313. $.kernels = reader.table(position, 4, onnxruntime.fbs.DeprecatedKernelCreateInfos);
  314. $.sub_graph_session_states = reader.tables(position, 6, onnxruntime.fbs.DeprecatedSubGraphSessionState);
  315. return $;
  316. }
  317. };
  318. onnxruntime.fbs.ArgType = {
  319. INPUT: 0,
  320. OUTPUT: 1
  321. };
  322. onnxruntime.fbs.ArgTypeAndIndex = class ArgTypeAndIndex {
  323. static decode(reader, position) {
  324. const $ = new onnxruntime.fbs.ArgTypeAndIndex();
  325. $.arg_type = reader.int8_(position, 4, 0);
  326. $.index = reader.uint32_(position, 6, 0);
  327. return $;
  328. }
  329. };
  330. onnxruntime.fbs.KernelTypeStrArgsEntry = class KernelTypeStrArgsEntry {
  331. static decode(reader, position) {
  332. const $ = new onnxruntime.fbs.KernelTypeStrArgsEntry();
  333. $.kernel_type_str = reader.string_(position, 4, null);
  334. $.args = reader.tables(position, 6, onnxruntime.fbs.ArgTypeAndIndex);
  335. return $;
  336. }
  337. };
  338. onnxruntime.fbs.OpIdKernelTypeStrArgsEntry = class OpIdKernelTypeStrArgsEntry {
  339. static decode(reader, position) {
  340. const $ = new onnxruntime.fbs.OpIdKernelTypeStrArgsEntry();
  341. $.op_id = reader.string_(position, 4, null);
  342. $.kernel_type_str_args = reader.tables(position, 6, onnxruntime.fbs.KernelTypeStrArgsEntry);
  343. return $;
  344. }
  345. };
  346. onnxruntime.fbs.KernelTypeStrResolver = class KernelTypeStrResolver {
  347. static decode(reader, position) {
  348. const $ = new onnxruntime.fbs.KernelTypeStrResolver();
  349. $.op_kernel_type_str_args = reader.tables(position, 4, onnxruntime.fbs.OpIdKernelTypeStrArgsEntry);
  350. return $;
  351. }
  352. };
  353. onnxruntime.fbs.InferenceSession = class InferenceSession {
  354. static identifier(reader) {
  355. return reader.identifier === 'ORTM';
  356. }
  357. static create(reader) {
  358. return onnxruntime.fbs.InferenceSession.decode(reader, reader.root);
  359. }
  360. static decode(reader, position) {
  361. const $ = new onnxruntime.fbs.InferenceSession();
  362. $.ort_version = reader.string_(position, 4, null);
  363. $.model = reader.table(position, 6, onnxruntime.fbs.Model);
  364. $.session_state = reader.table(position, 8, onnxruntime.fbs.DeprecatedSessionState);
  365. $.kernel_type_str_resolver = reader.table(position, 10, onnxruntime.fbs.KernelTypeStrResolver);
  366. return $;
  367. }
  368. };