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 : #ifndef OPERATOR_KERNEL_MODEL_PREPARE_H
12 : #define OPERATOR_KERNEL_MODEL_PREPARE_H
13 :
14 : #include <vector>
15 : #include "operator_kernel.h"
16 : #include "operator_kernel_dequeue_base.h"
17 :
18 : namespace AicpuSchedule {
19 : class OperatorKernelModelPrepare : public OperatorKernel, public OperatorKernelDequeueBase {
20 : public:
21 68 : OperatorKernelModelPrepare() = default;
22 71 : ~OperatorKernelModelPrepare() = default;
23 : int32_t Compute(const AicpuTaskInfo& kernelTaskInfo, const RunContext& taskContext) override;
24 :
25 : private:
26 : int32_t ChecPrepareNullptr(const AicpuPrepareInfo& prepareInfo) const;
27 : int32_t CheckPrepareMaxSize(const AicpuPrepareInfo& prepareInfo) const;
28 : bool CheckPointListNullptr(const uint64_t* const pointList, const uint32_t pointSize) const;
29 : int32_t DoCompute(AicpuPrepareInfo& msgInfo, const RunContext& taskContext) const;
30 : int32_t DequeueMbufList(
31 : const AicpuPrepareInfo& msgInfo, ModelPrepareData& prepareData, std::vector<void*>& inputsData,
32 : const RunContext& taskContext) const;
33 : int32_t CopyDequeueDataPtrToInputAddr(AicpuPrepareInfo& msgInfo, const std::vector<void*>& inputsData) const;
34 : int32_t AllocOutputMbufList(
35 : AicpuPrepareInfo& msgInfo, Mbuf** lastInputMbuflistPptr, Mbuf* (&mbufPtrStore)[MAX_SIZE_NUM],
36 : const RunContext& taskContext) const;
37 : int32_t GetDataPtrsFromMbufs(
38 : const AicpuPrepareInfo& msgInfo, Mbuf* (&mbufPtrStore)[MAX_SIZE_NUM],
39 : void* (&dataPtrStore)[MAX_SIZE_NUM]) const;
40 : int32_t CopyOutputDataPtrToOutputAddr(AicpuPrepareInfo& msgInfo, void* const (&dataPtrStore)[MAX_SIZE_NUM]) const;
41 : int32_t BuildEnqueueMbufPtrList(AicpuPrepareInfo& msgInfo, Mbuf* (&mbufPtrStore)[MAX_SIZE_NUM]) const;
42 : int32_t GetMbufListDataPtr(void* mbufPtr, void** dataAddrPtr, const uint32_t mbufIndex) const;
43 : };
44 : } // namespace AicpuSchedule
45 : #endif // OPERATOR_KERNEL_MODEL_PREPARE_H
|