/**
 * Copyright 2019 Huawei Technologies Co., Ltd
 *
 * 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 mindspore;

// Data type definition
enum DataType {
  DT_UNDEFINED = 0;
  // Basic types.
  DT_BOOL = 1;          // bool

  DT_INT8 = 2;          // int8_t
  DT_INT16 = 3;         // int16_t
  DT_INT32 = 4;         // int32_t
  DT_INT64 = 5;         // int64_t

  DT_UINT8 = 6;         // uint8_t
  DT_UINT16 = 7;        // uint16_t
  DT_UINT32 = 8;        // uint32_t
  DT_UINT64 = 9;        // uint64_t

  DT_FLOAT16 = 10;      // float 16
  DT_FLOAT32 = 11;      // float 32
  DT_FLOAT64 = 12;      // float 64

  DT_STRING = 13;       // string
  DT_TENSOR = 14;       // tensor
  DT_GRAPH = 15;        // graph

  // list type
  DT_BOOLS = 16;        // list of bool

  DT_INTS8 = 17;        // list of int8_t
  DT_INTS16 = 18;       // list of int16_t
  DT_INTS32 = 19;       // list of int32_t
  DT_INTS64 = 20;       // list of int64_t

  DT_UINTS8 = 21;       // list of uint8_t
  DT_UINTS16 = 22;      // list of uint16_t
  DT_UINTS32 = 23;      // list of uint32_t
  DT_UINTS64 = 24;      // list of uint64_t

  DT_FLOATS16 = 25;       // list of float16
  DT_FLOATS32 = 26;       // list of float32
  DT_FLOATS64 = 27;       // list of float64

  DT_STRINGS = 28;      // list of string
  DT_TENSORS = 29;      // list of tensor
  DT_GRAPHS = 30;       // list of graph

  DT_TUPLE = 31;        // tuple
  DT_LIST = 32;         // list
  DT_DICT = 33;         // dictionary

  // other types
  DT_NONE = 34;         // None
  DT_SYM_INST = 35;     // Symbolic Key Instance

  // type related type
  DT_BASE_INT = 36;     // type generic int
  DT_BASE_UINT = 37;    // type generate unsigned int
  DT_BASE_FLOAT = 38;   // type generate float
  DT_TYPE = 39;         // type type
  DT_ANYTHING = 40;     // type anything
};

enum MSConst {
    DEFAULT_REFCOUNT = 0;
    WEIGHT_REFCOUNT = 999;
};

message TensorDef {
    DataType data_type = 1;

    repeated int64 dims  = 2;

    string format = 3;
    string layout = 4;
    uint32 refCount = 5;
    uint64 offset = 6;
    uint64 size = 7;
    uint64 weight_size = 8;
    bytes data = 9;
}

message OpDef {
    string name = 1;
    string type  = 2;

    string fwk_type  = 3;
    string opAttr = 4;
    repeated int64 input_index = 5;
    repeated int64 output_index = 6;
}

message GraphDef {
    string name = 1;

    repeated int64 input_index = 2;

    repeated int64 output_index = 3;
    uint64 mempool_size = 4;

    repeated OpDef opdefs = 5;

    repeated TensorDef alltensors = 6;
}



