Copyright (c) 2025-2025 Huawei Technologies Co., Ltd.
sysHAX-adapter 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.
Created: 2026-1-31
Desc: CPU inference
*/
#include "cpu_inference.h"
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include "cpu_inference_manager.h"
namespace py = pybind11;
namespace {
cpu_inference::CPUInferenceManager cpuInferceMananger;
}
void load_config(py::dict run_config, py::dict model_config){
cpuInferceMananger.init(run_config, model_config);
}
void load_weight(py::list weight_infos, bool is_load_over){
cpuInferceMananger.load_model(weight_infos, is_load_over);
}
void cal_experts(
torch::Tensor& expert_output,
const torch::Tensor& hidden_states,
const torch::Tensor& router_logits,
int64_t layer_id
){
cpuInferceMananger.forward(expert_output, hidden_states, router_logits, layer_id);
}