onnx-schema.js 14 KB

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