namespace dlc.v3;

table Model {
    unk1: int;
    nodes: [Node];
    unk2: [int];
    unk3: [int];
    attributes: [Attribute];
}

table Node {
    index: int;
    name: string;
    type: string;
    inputs: [string];
    outputs: [string];
    attributes: [Attribute];
}

table Tensor {
    name: string;
    shape: [int];
    data: TensorData;
    attributes: [Attribute];
}

table TensorData {
    dtype: ubyte;
    bytes: [ubyte];
    floats: [float];
}

table Attribute {
    name: string;
    type: ubyte;
    bool_value: bool;
    int32_value: int;
    uint32_value: uint;
    float32_value: float;
    string_value: string;
    unk6: [byte];
    byte_list: [byte];
    int32_list: [int];
    float32_list: [float];
    unk10: [byte];
    attributes: [Attribute];
}

enum Activation : uint {
    ReLU = 1,
    Sigmoid = 3
}

table ModelParameters {
    nodes: [NodeParameters];
}

table NodeParameters {
    name: string;
    weights: [Tensor];
}

namespace dlc.v4;

table Model {
    graphs: [Graph];
}

table Graph {
    name: string;
    nodes: [Node];
    tensors: [Tensor];
}

table Node {
    name: string;
    type: string;
    inputs: [string];
    outputs: [string];
    attributes: [Attribute];
}

table Attribute {
    name: string;
    kind: int; // 0 = value, 1 = tensor
    flag: ubyte;
    value: Value;
    tensor: Tensor;
}

table Value {
    kind: int;
    int32_value: int;
    float32_value: float;
    string_value: string;
}

table Tensor {
    unk1: uint;
    name: string;
    location: int;
    shape: [int];
    unk2: int;
    info: TensorInfo;
    dtype: int;
    output_dtype: int;
    unk6: ubyte;
}

table TensorInfo {
    i1: int;
    b1: ubyte;
    a: TensorInfo1;
    b: TensorInfo2;
}

table TensorInfo1 {
    i1: int;
    f1: float;
    f2: float;
    f3: float;
    i2: int;
}

table TensorInfo2 {
    i1: int;
    l: [TensorInfo3];
}

table TensorInfo3 {
    i1: int;
    f1: float;
    f2: float;
    f3: float;
    i2: int;
    b1: ubyte;
}

table ModelParameters64 {
    buffers: [Buffer];
    params: [ubyte];
}

table ModelParameters {
    graphs: [GraphParameters];
}

table GraphParameters {
    name: string;
    tensors: [TensorData];
    nodes: [NodeParameters];
}

table NodeParameters {
    tensors: [TensorData];
}

table TensorData {
    name: string;
    bytes: [ubyte];
}

table Buffer {
    bytes: [ubyte];
}
