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_POST_PROCESS_DYNAMIC_OUTPUT_H
12 : #define OPERATOR_KERNEL_POST_PROCESS_DYNAMIC_OUTPUT_H
13 :
14 : #include <vector>
15 : #include "operator_kernel.h"
16 :
17 :
18 : namespace AicpuSchedule {
19 : class OperatorKernelPostProcessDynamicOutput : public OperatorKernel {
20 : public:
21 16 : OperatorKernelPostProcessDynamicOutput() = default;
22 22 : ~OperatorKernelPostProcessDynamicOutput() = default;
23 : int32_t Compute(const AicpuTaskInfo &kernelTaskInfo, const RunContext &taskContext) override;
24 : private:
25 : int32_t CopyTensorDesc(const PostprocessDynamicOutputKernelArgs * const param, const RunContext &taskContext) const;
26 : int32_t AllocatedOutput(const PostprocessDynamicOutputKernelArgs * const param, Mbuf *const outputMbuf,
27 : const uint32_t dynamicFlag, const size_t index, RuntimeTensorDesc **dynamicSrcDescPptr,
28 : RuntimeTensorDesc **staticSrcDescPptr) const;
29 : int32_t GetRuntimeTensor(const PostprocessDynamicOutputKernelArgs * const param,
30 : RuntimeTensorDesc **dynamicSrcDescPtr) const;
31 : int32_t PostprocessSetDataLen(const RuntimeTensorDesc * const runtimeTensorDesc, Mbuf *const outputMbuf,
32 : const size_t index) const;
33 : int32_t GetMbufHeadFromResp(Mbuf **const respMbufPtr, const RunContext &taskContext, void **const customBufPtr,
34 : uint32_t *const customBufSizePtr) const;
35 : int32_t PostProcessForOutputToAllocate(const PostprocessDynamicOutputKernelArgs * const param,
36 : Mbuf **const outputMbufPtr, const size_t index,
37 : RuntimeTensorDesc **dynamicSrcDescPptr, void *const customBuf,
38 : const uint32_t customBufSize, const RunContext &taskContext) const;
39 : int32_t MakeupDynamicOutputMbuf(Mbuf **const outputMbufPtr, const size_t index,
40 : const RuntimeTensorDesc *const runtimeTensorDesc, void *const customBuf,
41 : const uint32_t customBufSize, const RunContext &taskContext) const;
42 : int32_t FreeMbuf(const PostprocessDynamicOutputKernelArgs * const param, const RunContext &taskContext) const;
43 :
44 : bool IsSupportSdmaCopy() const;
45 :
46 : bool OptimizedMemCopy(void *const dst_data, const size_t dst_size,
47 : const void *const src_data, const size_t src_size) const;
48 : };
49 : } // namespace AicpuSchedule
50 : #endif // OPERATOR_KERNEL_POST_PROCESS_DYNAMIC_OUTPUT_H
|