/**
 * Copyright (c) 2025 Huawei Technologies Co., Ltd.
 * This program is free software, you can redistribute it and/or modify it under the terms and conditions of 
 * CANN Open Software License Agreement Version 2.0 (the "License").
 * Please refer to the License for details. You may not use this file except in compliance with the License.
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, 
 * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
 * See LICENSE in the root of the software repository for the full text of the License.
 */

syntax = "proto3";

package ge.mobile.proto;

message DumpDef {
    string name = 1;
    string type = 2;
    int64 id = 3;
    int64 stream_id = 4;
    repeated int64 output_addr = 5;
}

message ModelTaskDef {
    string version = 1;

    map<string, string> attr = 9; // 扩展字段
    repeated TaskDef task = 10;

    uint64 memory_size = 11;
    uint32 stream_num = 12;
    uint32 event_num = 13;
    uint64 weight_size = 14;

    repeated bytes op = 15; // input/output opdef in bytes

    uint64 base_addr = 16;    // base addr
    uint64 weight_addr = 17;  // weight addr
    uint32 batch_num = 18;

    repeated bytes layer = 30;   // hidden lay in bytes for profiling & dump
    uint32 label_num = 31;
    repeated DumpDef dumpDef = 32;   // hidden lay in bytes for profiling & dump
    repeated bytes dumpTensor = 33;   // hidden lay in bytes for profiling & dump
}


message TaskDef {
    uint32 id = 1;
    uint32 type = 2;

    uint32 stream_id = 10;
    uint32 event_id = 11;

    KernelDef kernel = 20;
    KernelExDef kernel_ex = 21;
    KernelHcclDef kernel_hccl = 25;
    EventExDef event_ex = 26;

    LabelDef label = 30;
}


message KernelDef {
    KernelContext context = 1;

    string stub_func = 10;
    uint32 block_dim = 11;
    uint32 args_size = 12;
    bytes args = 13;
    bytes sm_desc = 14;
    bytes flowtable = 15;

    uint64 module_addr = 16;
    uint32 module_size = 17;

    uint64 task_offset = 18;

    uint64 kernel_addr = 19;
    uint32 kernel_size = 20;

    uint64 binary_addr = 21;
    uint32 binary_size = 22;
}


message KernelContext {
    uint32 kernel_type = 1;
    uint32 op_id = 2;                              // elem内部中表示op类型
    uint32 kernel_func_id = 3;
    uint32 op_index = 4;                           // TE/自定义算子场景
    bool is_flowtable = 5;                         // 标识args是否为flowtable结构
    bytes args_offset = 6;                         // args参数偏移信息
    uint32 args_count = 7;                         // args参数个数
    repeated uint32 origin_op_index = 8;
}


message KernelExDef {
    uint32 flags = 1;

    uint32 op_index = 4;
    uint32 args_size = 12;
    bytes args = 13;
}


message KernelHcclDef {
    uint32 op_index = 8;
    string hccl_type = 9;
}


message EventExDef {
    uint32 op_index = 1;
    uint32 event_type = 2;
}

message LabelDef {
    uint32 label_id = 1;

    uint32 cond_type = 10;
    uint64 cond_value = 11;
}