* Copyright (c) Huawei Technologies Co., Ltd. 2026-2026. All rights reserved.
* MindIE is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* 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 FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
* \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