/*
 * Copyright (C) 2019 The Android Open Source Project
 *
 * 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 android.nn.fuzz;

enum OperandType {
    FLOAT32 = 0;
    INT32 = 1;
    UINT32 = 2;
    TENSOR_FLOAT32 = 3;
    TENSOR_INT32 = 4;
    TENSOR_QUANT8_ASYMM = 5;
    BOOL = 6;
    TENSOR_QUANT16_SYMM = 7;
    TENSOR_FLOAT16 = 8;
    TENSOR_BOOL8 = 9;
    FLOAT16 = 10;
    TENSOR_QUANT8_SYMM_PER_CHANNEL = 11;
    TENSOR_QUANT16_ASYMM = 12;
    TENSOR_QUANT8_SYMM = 13;
    TENSOR_QUANT8_ASYMM_SIGNED = 14;
    SUBGRAPH_OPERAND = 15;
}

enum OperationType {
    ADD = 0;
    AVERAGE_POOL_2D = 1;
    CONCATENATION = 2;
    CONV_2D = 3;
    DEPTHWISE_CONV_2D = 4;
    DEPTH_TO_SPACE = 5;
    DEQUANTIZE = 6;
    EMBEDDING_LOOKUP = 7;
    FLOOR = 8;
    FULLY_CONNECTED = 9;
    HASHTABLE_LOOKUP = 10;
    L2_NORMALIZATION = 11;
    L2_POOL_2D = 12;
    LOCAL_RESPONSE_NORMALIZATION = 13;
    LOGISTIC = 14;
    LSH_PROJECTION = 15;
    LSTM = 16;
    MAX_POOL_2D = 17;
    MUL = 18;
    RELU = 19;
    RELU1 = 20;
    RELU6 = 21;
    RESHAPE = 22;
    RESIZE_BILINEAR = 23;
    RNN = 24;
    SOFTMAX = 25;
    SPACE_TO_DEPTH = 26;
    SVDF = 27;
    TANH = 28;
    BATCH_TO_SPACE_ND = 29;
    DIV = 30;
    MEAN = 31;
    PAD = 32;
    SPACE_TO_BATCH_ND = 33;
    SQUEEZE = 34;
    STRIDED_SLICE = 35;
    SUB = 36;
    TRANSPOSE = 37;
    ABS = 38;
    ARGMAX = 39;
    ARGMIN = 40;
    AXIS_ALIGNED_BBOX_TRANSFORM = 41;
    BIDIRECTIONAL_SEQUENCE_LSTM = 42;
    BIDIRECTIONAL_SEQUENCE_RNN = 43;
    BOX_WITH_NMS_LIMIT = 44;
    CAST = 45;
    CHANNEL_SHUFFLE = 46;
    DETECTION_POSTPROCESSING = 47;
    EQUAL = 48;
    EXP = 49;
    EXPAND_DIMS = 50;
    GATHER = 51;
    GENERATE_PROPOSALS = 52;
    GREATER = 53;
    GREATER_EQUAL = 54;
    GROUPED_CONV_2D = 55;
    HEATMAP_MAX_KEYPOINT = 56;
    INSTANCE_NORMALIZATION = 57;
    LESS = 58;
    LESS_EQUAL = 59;
    LOG = 60;
    LOGICAL_AND = 61;
    LOGICAL_NOT = 62;
    LOGICAL_OR = 63;
    LOG_SOFTMAX = 64;
    MAXIMUM = 65;
    MINIMUM = 66;
    NEG = 67;
    NOT_EQUAL = 68;
    PAD_V2 = 69;
    POW = 70;
    PRELU = 71;
    QUANTIZE = 72;
    QUANTIZED_16BIT_LSTM = 73;
    RANDOM_MULTINOMIAL = 74;
    REDUCE_ALL = 75;
    REDUCE_ANY = 76;
    REDUCE_MAX = 77;
    REDUCE_MIN = 78;
    REDUCE_PROD = 79;
    REDUCE_SUM = 80;
    ROI_ALIGN = 81;
    ROI_POOLING = 82;
    RSQRT = 83;
    SELECT = 84;
    SIN = 85;
    SLICE = 86;
    SPLIT = 87;
    SQRT = 88;
    TILE = 89;
    TOPK_V2 = 90;
    TRANSPOSE_CONV_2D = 91;
    UNIDIRECTIONAL_SEQUENCE_LSTM = 92;
    UNIDIRECTIONAL_SEQUENCE_RNN = 93;
    RESIZE_NEAREST_NEIGHBOR = 94;
    QUANTIZED_LSTM = 95;
    IF = 96;
    WHILE = 97;
    ELU = 98;
    HARD_SWISH = 99;
    FILL = 100;
    RANK = 101;
    BATCH_MATMUL = 102;
    PACK = 103;
    MIRROR_PAD = 104;
    REVERSE = 105;
}

enum OperandLifeTime {
    TEMPORARY_VARIABLE = 0;
    SUBGRAPH_INPUT = 1;
    SUBGRAPH_OUTPUT = 2;
    CONSTANT_COPY = 3;
    CONSTANT_REFERENCE = 4;
    NO_VALUE = 5;
    SUBGRAPH_LIFETIME = 6;
}

message EmptyBuffer {}

message Buffer {
    oneof type {
        EmptyBuffer empty = 1;
        uint32 scalar = 2;
        uint32 random_seed = 3;
    }
}

message Scales {
    repeated float scale = 1;
}

message SymmPerChannelQuantParams {
    Scales scales = 1;
    uint32 channel_dim = 2;
}

message Dimensions {
    repeated uint32 dimension = 1;
}

message Operand {
    OperandType type = 1;
    Dimensions dimensions = 2;
    float scale = 4;
    int32 zero_point = 5;
    OperandLifeTime lifetime = 6;
    SymmPerChannelQuantParams channel_quant = 7;
    Buffer data = 8;
}

message Operands {
    repeated Operand operand = 1;
}

message Indexes {
    repeated uint32 index = 1;
}

message Operation {
    OperationType type = 1;
    Indexes inputs = 2;
    Indexes outputs = 3;
}

message Operations {
    repeated Operation operation = 1;
}

message Subgraph {
    Operands operands = 1;
    Operations operations = 2;
    Indexes input_indexes = 3;
    Indexes output_indexes = 4;
}

message Subgraphs {
    repeated Subgraph subgraph = 1;
}

message Model {
    Subgraph main = 1;
    Subgraphs referenced = 2;
    bool is_relaxed = 3;
}

message Test {
    Model model = 1;
}
