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.

ms_graph.proto 9.9 kB

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