1syntax = "proto2"; 2package mind_ir; 3 4enum Version { 5 IR_VERSION_START = 0; 6 IR_VERSION = 1; 7 IR_VERSION_WITH_PRIM_FUNCTION=2; 8} 9 10message AttributeProto { 11 enum AttributeType { 12 UNDEFINED = 0; 13 FLOAT = 1; 14 UINT8 = 2; 15 INT8 = 3; 16 UINT16 = 4; 17 INT16 = 5; 18 INT32 = 6; 19 INT64 = 7; 20 STRING = 8; 21 BOOL = 9; 22 FLOAT16 = 10; 23 DOUBLE = 11; 24 UINT32 = 12; 25 UINT64 = 13; 26 COMPLEX64 = 14; 27 COMPLEX128 = 15; 28 BFLOAT16 = 16; 29 TENSOR = 17; 30 GRAPH = 18; 31 TENSORS = 19; 32 TUPLE = 20; // tuple 33 LIST = 21; // list 34 DICT = 22; // dictionary 35 UMONAD = 23; 36 IOMONAD = 24; 37 NONE = 25; 38 PRIMITIVECLOSURE = 26; 39 FUNCGRAPHCLOSURE = 27; 40 PARTIALCLOSURE = 28; 41 UNIONFUNCCLOSURE = 29; 42 CSR_TENSOR = 30; 43 COO_TENSOR = 31; 44 ROW_TENSOR = 32; 45 CLASS_TYPE = 33; 46 NAME_SPACE = 34; 47 SYMBOL = 35; 48 TYPE_NULL = 36; 49 MAP_TENSOR = 37; 50 FUNCTOR = 38; 51 SCALAR = 39; 52 } 53 message SeqInfoProto{ 54 optional bool is_dyn_len = 1; // store if tuple is dynamic length 55 optional AttributeProto tuple_elem_item = 2; // store the element of tuple dynamic length 56 } 57 optional string name = 1; 58 optional float f = 2; 59 optional int64 i = 3; 60 optional double d = 4; 61 optional bytes s = 5; 62 optional TensorProto t = 6; 63 optional GraphProto g = 7; 64 repeated float floats = 8; 65 repeated double doubles = 9; 66 repeated int64 ints = 10; 67 repeated bytes strings = 11; 68 repeated TensorProto tensors = 12; 69 repeated GraphProto graphs = 13; 70 optional string doc_string = 14; 71 optional string ref_attr_name = 15; 72 optional AttributeType type = 16; 73 repeated AttributeProto values = 17; // tuple, list, dict of value 74 optional SeqInfoProto seq_info = 18; // tuple, list, structural info 75 optional FunctorProto functor = 19; 76} 77 78message FunctorProto { 79 enum FunctorType { 80 SHAPE_CALC_FUNCTOR = 1; 81 } 82 optional FunctorType type = 1; 83 optional string name = 2; 84 repeated AttributeProto values = 3; 85} 86 87message ValueInfoProto { 88 optional string name = 1; 89 repeated TensorProto tensor = 2; 90 optional string doc_string = 3; 91 optional string denotation = 4; 92 optional AttributeProto attr_info = 5; // graph input info for other type 93} 94 95 96message NodeProto { 97 repeated string input = 1; 98 repeated string output = 2; 99 optional string name = 3; 100 optional string op_type = 4; 101 repeated AttributeProto attribute = 5; 102 optional string doc_string = 6; 103 optional string domain = 7; 104 repeated AttributeProto node_attr = 8; 105 repeated AttributeProto primal_attr = 9; 106} 107 108message ModelProto { 109 optional string ir_version = 1; 110 optional string producer_name = 2; 111 optional string producer_version = 3; 112 optional string domain = 4; 113 optional string model_version = 5; 114 optional string doc_string = 6; 115 optional GraphProto graph = 7; 116 repeated GraphProto functions = 8; // all the graphs without the main graph. 117 optional PreprocessorProto preprocessor = 9; // data graph from MindData. 118 optional bool little_endian = 10; // bytes order in load device. 119 optional ParallelProto parallel = 11; // information for parallel. 120 repeated PrimitiveProto primitives = 12; // all the primitives of the model. 121 optional int64 mind_ir_version = 13; 122 map<string,string> user_info = 14; // data for custom 123} 124 125 126message PreprocessorProto { 127 repeated PreprocessOpProto op = 1; 128} 129 130 131message PreprocessOpProto { 132 optional string input_columns = 1; 133 optional string output_columns = 2; 134 optional string project_columns = 3; 135 optional string op_type = 4; 136 optional string operations = 5; 137 optional bool offload = 6; 138} 139 140 141message GraphProto { 142 repeated NodeProto node = 1; 143 optional string name = 2; 144 repeated TensorProto parameter = 3; 145 optional string doc_string = 4; 146 repeated ValueInfoProto input = 5; 147 repeated ValueInfoProto output = 6; 148 optional string bprop_hash = 7; 149 repeated AttributeProto attribute = 8; 150 optional string bprop_filepath = 9; 151 repeated MapTensorProto map_parameter = 10; 152} 153 154 155message TensorProto { 156 enum DataType { 157 UNDEFINED = 0; 158 // Basic types. 159 FLOAT = 1; // float 160 UINT8 = 2; // uint8_t 161 INT8 = 3; // int8_t 162 UINT16 = 4; // uint16_t 163 INT16 = 5; // int16_t 164 INT32 = 6; // int32_t 165 INT64 = 7; // int64_t 166 STRING = 8; // string 167 BOOL = 9; // bool 168 FLOAT16 = 10; 169 DOUBLE = 11; 170 UINT32 = 12; 171 UINT64 = 13; 172 COMPLEX64 = 14; 173 COMPLEX128 = 15; 174 BFLOAT16 = 16; 175 FLOAT64 = 17; 176 QINT4X2 = 18; 177 } 178 enum CompressionType { 179 NO_COMPRESSION = 0; 180 INDEXING = 1; 181 SPARSE = 2; 182 FSE = 3; 183 BIT_PACKING = 4; 184 FSE_INT = 5; 185 FSE_INFER = 6; 186 } 187 message ExternalDataProto { 188 //POSIX filesystem path relative to the directory where the MindIR model was stored. 189 optional string location = 1; 190 optional int64 offset = 2; 191 optional int64 length = 3; 192 //optional string checksum = 4; 193 } 194 message QuantParamProto { 195 required string quant_algo_name = 1; 196 repeated AttributeProto attribute = 2; 197 } 198 repeated int64 dims = 1; 199 optional int32 data_type = 2; 200 repeated float float_data = 3; 201 repeated int32 int32_data = 4; 202 repeated bytes string_data = 5; 203 repeated int64 int64_data = 6; 204 optional string name = 7; 205 optional string doc_string = 8; 206 optional bytes raw_data = 9; 207 repeated double double_data = 10; 208 repeated uint64 uint64_data = 11; 209 optional ExternalDataProto external_data = 12; 210 optional string ref_key = 13; 211 repeated int64 min_dims = 14; 212 repeated int64 max_dims = 15; 213 optional CompressionType compression_type = 16; 214 repeated QuantParamProto quant_params = 17; 215} 216 217message MapTensorProto { 218 required string name = 1; 219 required AttributeProto default_value = 2; 220 required TensorProto key_tensor = 3; 221 required TensorProto value_tensor = 4; 222 required TensorProto status_tensor = 5; 223} 224 225message ParallelProto { 226 repeated LayoutProto layout = 1; 227} 228 229message LayoutProto { 230 optional string name = 1; 231 repeated int64 device_arrangement_int = 2; 232 repeated int64 tensor_map_int = 3; 233 repeated int64 slice_shape_int = 4; 234 optional int64 field_size = 5; 235 optional bool uniform_split = 6; 236 optional string opt_shard_group = 7; 237 optional bool pipeline_shared = 8; 238 optional bool is_send = 9; 239 optional int64 peer_rank = 10; 240 optional int64 sr_tag = 11; 241} 242 243message PrimitiveProto { 244 enum PrimType { 245 PRIMITIVE = 1; 246 PRIMITIVE_FUNCTION = 2; 247 } 248 optional string name = 1; 249 optional string op_type = 2; 250 repeated AttributeProto attribute = 3; 251 optional string instance_name = 4; 252 optional PrimType prim_type = 5; 253} 254