You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

mindinsight_anf_ir.proto 11 kB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. // Copyright 2019 Huawei Technologies Co., Ltd.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. syntax = "proto2";
  15. package mindinsight;
  16. // Versioning
  17. enum Version {
  18. // unknown version
  19. UNKNOWWN_VERSION = 0;
  20. // Initial version (IR VERSION 1), published on Sep 23, 2019
  21. IR_VERSION = 0x0000000000000001;
  22. }
  23. // Data type definition
  24. enum DataType {
  25. DT_UNDEFINED = 0;
  26. // Basic types.
  27. DT_BOOL = 1; // bool
  28. DT_INT8 = 2; // int8_t
  29. DT_INT16 = 3; // int16_t
  30. DT_INT32 = 4; // int32_t
  31. DT_INT64 = 5; // int64_t
  32. DT_UINT8 = 6; // uint8_t
  33. DT_UINT16 = 7; // uint16_t
  34. DT_UINT32 = 8; // uint32_t
  35. DT_UINT64 = 9; // uint64_t
  36. DT_FLOAT16 = 10; // float 16
  37. DT_FLOAT32 = 11; // float 32
  38. DT_FLOAT64 = 12; // float 64
  39. DT_STRING = 13; // string
  40. DT_TENSOR = 14; // tensor
  41. DT_GRAPH = 15; // graph
  42. // list type
  43. DT_BOOLS = 16; // list of bool
  44. DT_INTS8 = 17; // list of int8_t
  45. DT_INTS16 = 18; // list of int16_t
  46. DT_INTS32 = 19; // list of int32_t
  47. DT_INTS64 = 20; // list of int64_t
  48. DT_UINTS8 = 21; // list of uint8_t
  49. DT_UINTS16 = 22; // list of uint16_t
  50. DT_UINTS32 = 23; // list of uint32_t
  51. DT_UINTS64 = 24; // list of uint64_t
  52. DT_FLOATS16 = 25; // list of float16
  53. DT_FLOATS32 = 26; // list of float32
  54. DT_FLOATS64 = 27; // list of float64
  55. DT_STRINGS = 28; // list of string
  56. DT_TENSORS = 29; // list of tensor
  57. DT_GRAPHS = 30; // list of graph
  58. DT_TUPLE = 31; // tuple
  59. DT_LIST = 32; // list
  60. DT_DICT = 33; // dictionary
  61. // other types
  62. DT_NONE = 34; // None
  63. DT_SYM_INST = 35; // Symbolic Key Instance
  64. // type related type
  65. DT_BASE_INT = 36; // type generic int
  66. DT_BASE_UINT = 37; // type generate unsigned int
  67. DT_BASE_FLOAT = 38; // type generate float
  68. DT_TYPE = 39; // type type
  69. DT_ANYTHING = 40; // type anything
  70. DT_REFKEY = 41; // type refkey
  71. DT_REF = 42; // type ref
  72. }
  73. // Value definition for attribute value or parameter default value
  74. message ValueProto {
  75. // data type of value
  76. optional DataType dtype = 1; // discriminator that indicates which field below is in use
  77. // Exactly ONE of the following fields must be present for this version of the IR
  78. optional bool bool_val = 2; // bool
  79. optional int64 int_val = 3; // int
  80. optional uint64 uint_val = 4; // uint
  81. optional float float_val = 5; // float
  82. optional double double_val = 6; // double
  83. optional string str_val = 7; // string
  84. optional TensorProto tensor_val = 8; // tensor value
  85. optional GraphProto graph = 9; // graph
  86. repeated bool bool_vals = 10; // list of bool
  87. repeated int64 int_vals = 11; // list of int
  88. repeated uint64 uint_vals = 12; // list of uint
  89. repeated float float_vals = 13; // list of float
  90. repeated double double_vals = 14; // list of double
  91. repeated string str_vals = 15; // list of string
  92. repeated TensorProto tensor_vals = 16; // list of tensor value
  93. repeated GraphProto graphs = 17; // list of graph
  94. // tuple or list
  95. repeated ValueProto values = 18; // tuple, list of value
  96. // dictionary
  97. repeated NamedValueProto dict_val = 19; // dictionary info
  98. // filed for type type
  99. optional TypeProto type_val = 20; // type type info
  100. }
  101. message AttributeProto {
  102. optional string name = 1; // attribute name
  103. optional ValueProto value = 2; // attribute value
  104. }
  105. message NamedValueProto {
  106. optional string key = 1; // attribute name
  107. optional ValueProto value = 2; // attribute value
  108. }
  109. // Defines a tensor shape.
  110. message TensorShapeProto {
  111. // One dimension of the tensor.
  112. message Dimension {
  113. // Size of the tensor in that dimension.
  114. // This value must be >= -1, but values of -1 are reserved for "unknown"
  115. // shapes (values of -1 mean "unknown" dimension).
  116. optional int64 size = 1;
  117. // Optional name of the tensor dimension.
  118. optional string name = 2;
  119. };
  120. repeated Dimension dim = 1;
  121. }
  122. // Types for graph input(parameter) and output
  123. message TypeProto {
  124. message Tensor {
  125. // This field MUST have a valid DataType value except DT_TENSOR
  126. optional DataType elem_type = 1;
  127. optional TensorShapeProto shape = 2; // for scalar, this field is not set
  128. }
  129. // tuple type
  130. message Sequence {
  131. // The type and optional shape of elements of the tuple.
  132. repeated TypeProto elem_types = 1;
  133. };
  134. // data type
  135. optional DataType data_type = 1;
  136. oneof value {
  137. // The type of a tensor.
  138. Tensor tensor_type = 2;
  139. // The type of a tuple.
  140. Sequence sequence_type = 3;
  141. }
  142. }
  143. // Defines information on graph parameters, including the name, the type, and
  144. // the default value of parameter if exists.
  145. message ParameterProto {
  146. optional string name = 1; // parameter name
  147. optional TypeProto type = 2; // parameter type
  148. optional ValueProto default_val = 3; // default value of parameter if exists
  149. }
  150. // Defines graph output information
  151. message OutputProto {
  152. optional string name = 1; // output node name
  153. optional TypeProto type = 2; // output node type
  154. }
  155. // Define node input information
  156. message InputProto {
  157. enum EdgeType {
  158. DATA_EDGE = 0; // data edge
  159. CONTROL_EDGE = 1; // control edge
  160. }
  161. optional string name = 1;
  162. optional EdgeType type = 2;
  163. }
  164. // Nodes
  165. //
  166. // Computation graphs are made up of a DAG of nodes, which represent what is
  167. // commonly called a "layer" or "pipeline stage" in machine learning frameworks.
  168. //
  169. // For example, it can be a node of type "Conv" that takes in an image, a filter
  170. // tensor and a bias tensor, and produces the convolved output.
  171. message NodeProto {
  172. repeated InputProto input = 1; // namespace Value
  173. optional string name = 2; // namespace Value
  174. // The symbolic identifier of the Operator to execute.
  175. optional string op_type = 3; // namespace Operator
  176. // The domain of the OperatorSet that specifies the operator named by op_type.
  177. optional string scope = 4; // namespace Domain
  178. // Additional named attributes.
  179. repeated AttributeProto attribute = 5;
  180. // Optional type info of this node
  181. optional TypeProto output_type = 6;
  182. // other fields for debug
  183. optional uint64 output_i = 7;
  184. // The full_name_with_scope of CNode
  185. optional string full_name = 8;
  186. }
  187. // Models
  188. //
  189. // ModelProto is a top-level file/container format for bundling a ML model and
  190. // associating its computation graph with metadata.
  191. //
  192. // The semantics of the model are described by the associated GraphProto.
  193. message ModelProto {
  194. // ir version
  195. optional int64 ir_version = 1;
  196. // Domain name of the model.
  197. // We use reverse domain names as name space indicators. For example:
  198. // `com.facebook.fair` or `com.microsoft.cognitiveservices`
  199. //
  200. // Together with `model_version` and GraphProto.name, this forms the unique identity of
  201. // the graph.
  202. optional string domain = 2;
  203. // The version of the graph encoded. See Version enum below.
  204. optional int64 model_version = 3;
  205. // The parameterized graph that is evaluated to execute the model.
  206. optional GraphProto graph = 4;
  207. // metadata info of operators
  208. optional OperatorSetProto metadata_operators = 5;
  209. };
  210. message OperatorProto {
  211. optional string name = 1; // used as key, must be distinct
  212. optional bytes config = 2; // operator config info
  213. optional bytes obj_info = 3; // operator related object info, e.g. content of operator binary or name
  214. };
  215. message OperatorSetProto {
  216. repeated OperatorProto operators = 1;
  217. optional string summary = 2; // summary info of operators, e.g. file position of operators file
  218. }
  219. // Graphs
  220. //
  221. // A graph defines the computational logic of a model and is comprised of a parameterized
  222. // list of nodes that form a directed acyclic graph based on their inputs and outputs.
  223. // This is the equivalent of the "network" or "graph" in many deep learning
  224. // frameworks.
  225. message GraphProto {
  226. // The nodes in the graph, sorted topologically.
  227. repeated NodeProto node = 1;
  228. // The name of the graph.
  229. optional string name = 2; // namespace Graph
  230. // The parameters(inputs) and outputs of the graph.
  231. repeated ParameterProto parameters = 3;
  232. repeated OutputProto outputs = 4;
  233. // Constants used in this graph
  234. repeated NamedValueProto const_vals = 5;
  235. }
  236. // Tensors
  237. //
  238. // A serialized tensor value.
  239. message TensorProto {
  240. // The shape of the tensor.
  241. repeated int64 dims = 1;
  242. // The data type of the tensor.
  243. // This field MUST have a valid DataType value except DT_TENSOR
  244. optional DataType data_type = 2;
  245. // Tensor content must be organized in row-major order.
  246. //
  247. // Depending on the data_type field, exactly one of the fields below with
  248. // name ending in _data is used to store the elements of the tensor.
  249. // For float values
  250. repeated float float_data = 3 [packed = true];
  251. // For int32, uint8, int8, uint16, int16, and bool values
  252. // When this field is present, the data_type field MUST be
  253. // INT32, INT16, INT8, UINT16, UINT8, or BOOL
  254. repeated int32 int32_data = 4 [packed = true];
  255. // For int64.
  256. // When this field is present, the data_type field MUST be INT64
  257. repeated int64 int64_data = 5 [packed = true];
  258. // For double
  259. // When this field is present, the data_type field MUST be DOUBLE
  260. repeated double double_data = 6 [packed = true];
  261. // For uint64 and uint32 values
  262. // When this field is present, the data_type field MUST be
  263. // UINT32 or UINT64
  264. repeated uint64 uint64_data = 7 [packed = true];
  265. // Store raw tensor content. When this raw_data field is used to store tensor value,
  266. // elements MUST be stored in as fixed-width, little-endian order.
  267. optional bytes raw_data = 8;
  268. }