Line data Source code
1 : /**
2 : * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3 : * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4 : * CANN Open Software License Agreement Version 2.0 (the "License").
5 : * Please refer to the License for details. You may not use this file except in compliance with the License.
6 : * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7 : * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8 : * See LICENSE in the root of the software repository for the full text of the License.
9 : */
10 :
11 : #include "operator_kernel_active_model.h"
12 :
13 : #include "aicpusd_info.h"
14 : #include "aicpusd_status.h"
15 : #include "aicpusd_event_process.h"
16 : #include "aicpusd_msg_send.h"
17 : #include "aicpusd_resource_manager.h"
18 :
19 : namespace AicpuSchedule {
20 : namespace {
21 : const std::string KERNEL_ACTIVE_MODEL = "activeModel";
22 : constexpr uint32_t GE_GROUP_ID = 10U;
23 : } // namespace
24 :
25 2 : int32_t OperatorKernelActiveModel::Compute(const AicpuTaskInfo &kernelTaskInfo, const RunContext &taskContext)
26 : {
27 2 : const auto modelIdPtr = PtrToPtr<void, uint32_t>(ValueToPtr(kernelTaskInfo.paraBase));
28 2 : if (modelIdPtr == nullptr) {
29 1 : aicpusd_err("ModelActive kernelTaskInfo paramBase is null, modelId[%u], streamId[%u], taskId[%u]",
30 : taskContext.modelId, taskContext.streamId, kernelTaskInfo.taskID);
31 1 : return AICPU_SCHEDULE_ERROR_PARAMETER_NOT_VALID;
32 : }
33 :
34 1 : aicpusd_info("Begin to active modelId[%u].", *modelIdPtr);
35 1 : AICPUSubEventInfo subEventInfo = {};
36 1 : subEventInfo.modelId = taskContext.modelId;
37 1 : return AicpuMsgSend::SendAICPUSubEvent(PtrToPtr<AICPUSubEventInfo, const char_t>(&subEventInfo),
38 : static_cast<uint32_t>(sizeof(AICPUSubEventInfo)),
39 : AICPU_SUB_EVENT_ACTIVE_MODEL,
40 : GE_GROUP_ID,
41 1 : true);
42 : }
43 :
44 :
45 6 : REGISTER_OPERATOR_KERNEL(KERNEL_ACTIVE_MODEL, OperatorKernelActiveModel);
46 : } // namespace AicpuSchedule
|