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_PREPARE_DYNAMIC_INPUT_OUTPUT_H
12 : #define OPERATOR_KERNEL_PREPARE_DYNAMIC_INPUT_OUTPUT_H
13 :
14 : #include <vector>
15 : #include "operator_kernel.h"
16 :
17 : namespace AicpuSchedule {
18 : class PrepareDynamicInputOutputBase {
19 : public:
20 : PrepareDynamicInputOutputBase() = default;
21 : ~PrepareDynamicInputOutputBase() = default;
22 : int32_t PrepareDynamicInputOutput(
23 : const AicpuTaskInfo& kernelTaskInfo, const RunContext& taskContext, const bool hostAllocDynamicOutput) const;
24 :
25 : private:
26 : int32_t AllocateAndInitOutput(
27 : const PrepareDynamicInputOutputKernelArgs* const param, const RunContext& taskContext,
28 : std::vector<Mbuf*>& mbufsToFree, const bool hostAllocDynamicOutput) const;
29 : int32_t PrepareReqMsg(
30 : const PrepareDynamicInputOutputKernelArgs* const param, const RunContext& taskContext,
31 : std::vector<Mbuf*>& mbufsToFree, const bool hostAllocDynamicOutput) const;
32 : int32_t UpdateReqMsgHead(
33 : Mbuf* const reqMbuf, const uint64_t* const inputPptrs, const uint32_t inputNum,
34 : const RunContext& taskContext) const;
35 : void ExtractHeadInfo(Mbuf* const mbuf, int32_t& retCode, bool& nullDataFlag, bool& isEndofSequence) const;
36 : };
37 :
38 : class OperatorKernelPrepareDynamicInputOutput : public OperatorKernel, public PrepareDynamicInputOutputBase {
39 : public:
40 14 : OperatorKernelPrepareDynamicInputOutput() = default;
41 17 : ~OperatorKernelPrepareDynamicInputOutput() = default;
42 : int32_t Compute(const AicpuTaskInfo& kernelTaskInfo, const RunContext& taskContext) override;
43 : };
44 :
45 : class OperatorKernelPrepareDynamicInputOutputV2 : public OperatorKernel, public PrepareDynamicInputOutputBase {
46 : public:
47 14 : OperatorKernelPrepareDynamicInputOutputV2() = default;
48 17 : ~OperatorKernelPrepareDynamicInputOutputV2() = default;
49 : int32_t Compute(const AicpuTaskInfo& kernelTaskInfo, const RunContext& taskContext) override;
50 : };
51 : } // namespace AicpuSchedule
52 : #endif // OPERATOR_KERNEL_PREPARE_DYNAMIC_INPUT_OUTPUT_H
|