* 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.
*/
* \file attention_ffn_schedule.h
* \brief
*/
#ifndef INCLUDE_KERNEL_ATTENTION_FFN_SCHEDULE_H
#define INCLUDE_KERNEL_ATTENTION_FFN_SCHEDULE_H
#include <cstdint>
namespace aicpu {
#pragma pack(push, 1)
constexpr int32_t kValidFlag = 1;
constexpr int32_t kInvalidFlag = 0;
constexpr int32_t kExecuteModeLoop = 1;
constexpr int32_t kExecuteModeOnce = 0;
constexpr int32_t kScheduleModeFfn = 0;
struct FfnDataDesc {
volatile int32_t flag;
volatile int32_t layer_id;
volatile int32_t expert_ids[0];
};
struct AttentionDataDesc {
int32_t flag[0];
};
struct ScheduleContext {
struct CommonArea {
uint32_t session_num;
uint32_t micro_batch_num;
uint32_t micro_batch_size;
uint32_t selected_expert_num;
uint32_t expert_num;
uint32_t attn_to_ffn_token_size;
uint32_t ffn_to_attn_token_size;
int32_t schedule_mode;
int8_t reserve0[96];
};
struct ControlArea {
int32_t run_flag;
int8_t reserve2[124];
};
struct FfnArea {
uint64_t token_info_buf;
uint64_t token_info_buf_size;
uint64_t token_data_buf;
uint64_t token_data_buf_size;
uint64_t polling_index;
int8_t reserve3[88];
uint64_t layer_ids_buf;
uint64_t layer_ids_buf_size;
uint64_t session_ids_buf;
uint64_t session_ids_buf_size;
uint64_t micro_batch_ids_buf;
uint64_t micro_batch_ids_buf_size;
uint64_t expert_ids_buf;
uint64_t expert_ids_buf_size;
uint32_t out_num;
int8_t reserve4[60];
};
struct AttentionArea {
uint64_t token_info_buf;
uint64_t token_info_buf_size;
uint64_t token_data_buf;
uint64_t token_data_buf_size;
uint32_t micro_batch_id;
int8_t reserve5[92];
};
CommonArea common;
ControlArea control;
AttentionArea attention;
FfnArea ffn;
int8_t reserve6[384];
};
static_assert(sizeof(ScheduleContext) == 1024, "ScheduleContext size must be 1024 bytes");
#pragma pack(pop)
}
#endif