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.

debug_graph.proto 10 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. /**
  2. * Copyright 2019 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. // auto_monad type
  75. DT_UMONAD = 43;
  76. DT_IOMONAD = 44;
  77. }
  78. // Value definition for attribute value or parameter default value
  79. message ValueProto {
  80. // data type of value
  81. optional DataType dtype = 1; // discriminator that indicates which field below is in use
  82. // Exactly ONE of the following fields must be present for this version of the IR
  83. optional bool bool_val = 2; // bool
  84. optional int64 int_val = 3; // int
  85. optional uint64 uint_val = 4; // uint
  86. optional float float_val = 5; // float
  87. optional double double_val = 6; // double
  88. optional string str_val = 7; // string
  89. optional TensorProto tensor_val = 8; // tensor value
  90. optional GraphProto graph = 9; // graph
  91. repeated bool bool_vals = 10; // list of bool
  92. repeated int64 int_vals = 11; // list of int
  93. repeated uint64 uint_vals = 12; // list of uint
  94. repeated float float_vals = 13; // list of float
  95. repeated double double_vals = 14; // list of double
  96. repeated string str_vals = 15; // list of string
  97. repeated TensorProto tensor_vals = 16; // list of tensor value
  98. repeated GraphProto graphs = 17; // list of graph
  99. // tuple or list
  100. repeated ValueProto values = 18; // tuple, list of value
  101. // dictionary
  102. repeated NamedValueProto dict_val = 19; // dictionary info
  103. // filed for type type
  104. optional TypeProto type_val = 20; // type type info
  105. }
  106. message AttributeProto {
  107. optional string name = 1; // attribute name
  108. optional ValueProto value = 2; // attribute value
  109. }
  110. message NamedValueProto {
  111. optional string key = 1; // attribute name
  112. optional ValueProto value = 2; // attribute value
  113. }
  114. // Defines a tensor shape.
  115. message TensorShapeProto {
  116. // One dimension of the tensor.
  117. message Dimension {
  118. // Size of the tensor in that dimension.
  119. // This value must be >= -1, but values of -1 are reserved for "unknown"
  120. // shapes (values of -1 mean "unknown" dimension).
  121. optional int64 size = 1;
  122. // Optional name of the tensor dimension.
  123. optional string name = 2;
  124. };
  125. repeated Dimension dim = 1;
  126. }
  127. // Types for graph input(parameter) and output
  128. message TypeProto {
  129. message Tensor {
  130. // This field MUST have a valid DataType value except DT_TENSOR
  131. optional DataType elem_type = 1;
  132. optional TensorShapeProto shape = 2; // for scalar, this field is not set
  133. }
  134. // tuple type
  135. message Sequence {
  136. // The type and optional shape of elements of the tuple.
  137. repeated TypeProto elem_types = 1;
  138. };
  139. // data type
  140. optional DataType data_type = 1;
  141. oneof value {
  142. // The type of a tensor.
  143. Tensor tensor_type = 2;
  144. // The type of a tuple.
  145. Sequence sequence_type = 3;
  146. }
  147. }
  148. // Defines information on graph parameters, including the name, the type, and
  149. // the default value of parameter if exists.
  150. message ParameterProto {
  151. optional string name = 1; // parameter name
  152. optional TypeProto type = 2; // parameter type
  153. optional ValueProto default_val = 3; // default value of parameter if exists
  154. }
  155. // Defines graph output information
  156. message OutputProto {
  157. optional string name = 1; // output node name
  158. optional TypeProto type = 2; // output node type
  159. }
  160. // Define node input information
  161. message InputProto {
  162. enum EdgeType {
  163. DATA_EDGE = 0; // data edge
  164. CONTROL_EDGE = 1; // control edge
  165. }
  166. optional string name = 1;
  167. optional EdgeType type = 2;
  168. }
  169. // Nodes
  170. //
  171. // Computation graphs are made up of a DAG of nodes, which represent what is
  172. // commonly called a "layer" or "pipeline stage" in machine learning frameworks.
  173. //
  174. // For example, it can be a node of type "Conv" that takes in an image, a filter
  175. // tensor and a bias tensor, and produces the convolved output.
  176. message NodeProto {
  177. repeated InputProto input = 1; // namespace Value
  178. optional string name = 2; // namespace Value
  179. // The symbolic identifier of the Operator to execute.
  180. optional string op_type = 3; // namespace Operator
  181. // The domain of the OperatorSet that specifies the operator named by op_type.
  182. optional string scope = 4; // namespace Domain
  183. // Additional named attributes.
  184. repeated AttributeProto attribute = 5;
  185. // Optional type info of this node
  186. optional TypeProto output_type = 6;
  187. // other fields for debug
  188. optional uint64 output_i = 7;
  189. // for debugger, full name with scope
  190. optional string full_name = 8;
  191. optional string source_address = 9;
  192. }
  193. // Models
  194. //
  195. // ModelProto is a top-level file/container format for bundling a ML model and
  196. // associating its computation graph with metadata.
  197. //
  198. // The semantics of the model are described by the associated GraphProto.
  199. message ModelProto {
  200. // ir version
  201. optional int64 ir_version = 1;
  202. // Domain name of the model.
  203. // We use reverse domain names as name space indicators. For example:
  204. // `com.facebook.fair` or `com.microsoft.cognitiveservices`
  205. //
  206. // Together with `model_version` and GraphProto.name, this forms the unique identity of
  207. // the graph.
  208. optional string domain = 2;
  209. // The version of the graph encoded. See Version enum below.
  210. optional int64 model_version = 3;
  211. // The parameterized graph that is evaluated to execute the model.
  212. optional GraphProto graph = 4;
  213. // metadata info of operators
  214. optional OperatorSetProto metadata_operators = 5;
  215. };
  216. message OperatorProto {
  217. optional string name = 1; // used as key, must be distinct
  218. optional bytes config = 2; // operator config info
  219. optional bytes obj_info = 3; // operator related object info, e.g. content of operator binary or name
  220. };
  221. message OperatorSetProto {
  222. repeated OperatorProto operators = 1;
  223. optional string summary = 2; // summary info of operators, e.g. file position of operators file
  224. }
  225. // Graphs
  226. //
  227. // A graph defines the computational logic of a model and is comprised of a parameterized
  228. // list of nodes that form a directed acyclic graph based on their inputs and outputs.
  229. // This is the equivalent of the "network" or "graph" in many deep learning
  230. // frameworks.
  231. message GraphProto {
  232. // The nodes in the graph, sorted topologically.
  233. repeated NodeProto node = 1;
  234. // The name of the graph.
  235. optional string name = 2; // namespace Graph
  236. // The parameters(inputs) and outputs of the graph.
  237. repeated ParameterProto parameters = 3;
  238. repeated OutputProto outputs = 4;
  239. // Constants used in this graph
  240. repeated NamedValueProto const_vals = 5;
  241. // The name of the root_graph.
  242. optional string root_name = 6;
  243. }
  244. // Tensors
  245. //
  246. // A serialized tensor value.
  247. message TensorProto {
  248. // The node name of the tensor.
  249. optional string node_name = 1;
  250. // The slot of the tensor in its node.
  251. optional string slot = 2;
  252. // The serialized tensor content.
  253. optional bytes tensor_content = 3;
  254. // The shape of the tensor.
  255. repeated int64 dims = 4;
  256. // The data type of the tensor.
  257. // This field MUST have a valid DataType value except DT_TENSOR
  258. optional DataType data_type = 5;
  259. // If the tensor content transferring is finished.
  260. optional bool finished = 6;
  261. // The iteration of the tensor. Supported: "prev" or leave empty.
  262. optional string iter = 7;
  263. // If the tensor name should be truncated.
  264. optional bool truncate = 8;
  265. }