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_OUTPUT_H
12 : #define OPERATOR_KERNEL_PREPARE_OUTPUT_H
13 :
14 : #include "operator_kernel.h"
15 : #include "operator_kernel_context.h"
16 :
17 :
18 : namespace AicpuSchedule {
19 : class OperatorKernelPrepareOutputBase {
20 : public:
21 72 : OperatorKernelPrepareOutputBase() = default;
22 72 : virtual ~OperatorKernelPrepareOutputBase() {};
23 :
24 : int32_t PrepareOutput(ProcessOutputInfo &outputInfo, const RunContext &taskContext, const bool zeroCpy,
25 : RuntimeTensorDesc *const tensorDesc) const;
26 : int32_t PrepareOutWithTensorDesc(const AicpuTaskInfo &kernelTaskInfo, const bool zeroCpy,
27 : const RunContext &taskContext) const;
28 : private:
29 : int32_t PrepareOutputNonZeroCpy(const ProcessOutputInfo &outputInfo, Mbuf * const outMBuf,
30 : RuntimeTensorDesc *const tensorDesc) const;
31 : int32_t GetStaticNNOutPutIndex(const uint32_t modelId) const;
32 : void MarkStaticNNOutPutIndex(const uint32_t modelId) const;
33 : };
34 :
35 : class OperatorKernelModelPrepareOutput : public OperatorKernel, public OperatorKernelPrepareOutputBase {
36 : public:
37 15 : OperatorKernelModelPrepareOutput() = default;
38 18 : ~OperatorKernelModelPrepareOutput() = default;
39 :
40 : int32_t Compute(const AicpuTaskInfo &kernelTaskInfo, const RunContext &taskContext) override;
41 : };
42 :
43 : class OperatorKernelModelPrepareOutputWithTensorDesc : public OperatorKernel, public OperatorKernelPrepareOutputBase {
44 : public:
45 15 : OperatorKernelModelPrepareOutputWithTensorDesc() = default;
46 18 : ~OperatorKernelModelPrepareOutputWithTensorDesc() = default;
47 :
48 : int32_t Compute(const AicpuTaskInfo &kernelTaskInfo, const RunContext &taskContext) override;
49 : };
50 :
51 : class OperatorKernelBufferPrepareOutput : public OperatorKernel, public OperatorKernelPrepareOutputBase {
52 : public:
53 15 : OperatorKernelBufferPrepareOutput() = default;
54 18 : ~OperatorKernelBufferPrepareOutput() = default;
55 :
56 : int32_t Compute(const AicpuTaskInfo &kernelTaskInfo, const RunContext &taskContext) override;
57 : };
58 :
59 : class OperatorKernelBufferPrepareOutputWithTensorDesc : public OperatorKernel, public OperatorKernelPrepareOutputBase {
60 : public:
61 15 : OperatorKernelBufferPrepareOutputWithTensorDesc() = default;
62 18 : ~OperatorKernelBufferPrepareOutputWithTensorDesc() = default;
63 :
64 : int32_t Compute(const AicpuTaskInfo &kernelTaskInfo, const RunContext &taskContext) override;
65 : };
66 :
67 : } // namespace AicpuSchedule
68 :
69 : #endif // OPERATOR_KERNEL_PREPARE_OUTPUT_H
|