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