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