//
// Copyright 2019 Xilinx Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

syntax = "proto3";
package serial_v2;
message Graph {
  string graph_name = 1;
  repeated OPNode op_node = 5;
  SubGraph subg_root = 10;
  map<string, AttrValue> graph_attr = 11;
  repeated OpDef op_defs = 101;
};
message OPNode {
  string op_name = 1;
  string op_type = 2;
  map<string, AttrValue> op_attr = 3;
  repeated OpArg args = 4;
  Tensor output_tensor = 5;
};
message OpArg {
  string arg_name = 1;
  repeated string arg_ops = 2;
};
message Tensor {
  string tensor_name = 1;
  repeated uint32 tensor_dim = 2;

  int32 data_type = 5;
  int32 tensor_bit_width = 6;

  map<string, AttrValue> tensor_attr = 10;
};
message SubGraph {
  string subgraph_name = 1;
  repeated string op_name = 3;
  map<string, AttrValue> subg_attr = 5;
  repeated SubGraph subg_child = 10;
};
message OpDef {
  string name = 1;
  repeated OpArgDef input_args = 2;
  repeated AttrDef attrs = 3;
  string annotation = 4;
};
message AttrDef {
  string name = 1;
  enum OccurType {
    REQUIRED = 0;
    OPTIONAL = 1;
  };
  OccurType occur_type = 3;
  AttrValue default_value = 4;
  int32 list_length = 6;
  string annotation = 7;
};
message OpArgDef  {
  string name = 1;
  enum OccurType {
    REQUIRED = 0;
    OPTIONAL = 1;
    REPEATED = 2;
    REQUIRED_AND_REPEATED = 3;
  };
  OccurType occur_type = 2;
  int32 data_type = 3;
  string annotation = 4;
};

// AttrValue
message AttrValue {
  oneof value {
    bool bool_value = 4;
    int32 int32_value = 5;
    uint32 uint32_value = 6;
    int64 int64_value = 7;
    uint64 uint64_value = 8;
    float float_value = 9;
    double double_value = 10;
    string string_value = 11;
    Bytes bytes_value = 12;
    BoolVec bool_vec_value = 13;
    Int32Vec int32_vec_value = 14;
    Uint32Vec uint32_vec_value = 15;
    Int64Vec  int64_vec_value = 16;
    Uint64Vec uint64_vec_value = 17;
    FloatVec float_vec_value = 18;
    DoubleVec double_vec_value = 19;
    StringVec string_vec_value = 20;
    BytesVec  bytes_vec_value = 21;
    MapString2Int32 map_string_2_int32_value = 22;
    MapString2Uint32 map_string_2_uint32_value = 23;
    MapString2Int64 map_string_2_int64_value = 24;
    MapString2Uint64 map_string_2_uint64_value = 25;
    MapString2String map_string_2_string_value = 26;
    MapString2Bytes map_string_2_bytes_value = 27;
    MapString2Int32Vec map_string_2_int32_vec_value = 28;
    MapString2Uint32Vec map_string_2_uint32_vec_value = 29;
    MapString2Int64Vec map_string_2_int64_vec_value = 30;
    MapString2Uint64Vec map_string_2_uint64_vec_value = 31;
    MapString2StringVec map_string_2_string_vec_value = 32;
  }
};

// vector
message Bytes {
  bytes value = 1;
};
message BoolVec {
  repeated bool value = 1;
};
message Int32Vec {
  repeated int32 value = 1;
};
message Uint32Vec {
  repeated uint32 value = 1;
};

message Int64Vec {
  repeated int64 value = 1;
};
message Uint64Vec {
  repeated uint64 value = 1;
};
message FloatVec {
  repeated float value = 1;
};
message DoubleVec {
  repeated double value = 1;
};
message StringVec {
  repeated string value = 1;
};
message BytesVec {
  repeated Bytes value = 1;
};
message MapString2Int32{
  map<string, int32> value = 1;
};
message MapString2Uint32{
  map<string, uint32> value = 1;
};
message MapString2Int64{
  map<string, int64> value = 1;
};
message MapString2Uint64{
  map<string, uint64> value = 1;
};
message MapString2Bytes{
  map<string, Bytes> value = 1;
};
message MapString2String{
  map<string, string> value  = 1;
};
message MapString2Int32Vec{
  map<string, Int32Vec> value = 1;
};
message MapString2Uint32Vec{
  map<string, Uint32Vec> value = 1;
};
message MapString2Int64Vec{
  map<string, Int64Vec> value = 1;
};
message MapString2Uint64Vec{
  map<string, Uint64Vec> value = 1;
};
message MapString2BytesVec{
  map<string, BytesVec> value = 1;
};
message MapString2StringVec{
  map<string, StringVec> value  = 1;
};