已合并
update aicpu op tile register func to v2. #2844
liu-wei创建于 5月20日
update aicpu op tile register func to v2. #2844
已合并
liu-wei创建于 5月20日
4 个文件变更+38-1
@@ -244,6 +244,7 @@ function(add_aicpu_host_kernel_modules host_target_name)
244 ${host_target_name} PRIVATE244 ${host_target_name} PRIVATE
245 _FORTIFY_SOURCE=2245 _FORTIFY_SOURCE=2
246 google=ascend_private246 google=ascend_private
247+ OPS_MATH_AICPU_HOST_KERNEL
247 )248 )
248 target_compile_options(249 target_compile_options(
249 ${host_target_name} PRIVATE250 ${host_target_name} PRIVATE
@@ -184,6 +184,7 @@ set(AICPU_INCLUDE
184 ${C_SEC_INCLUDE}184 ${C_SEC_INCLUDE}
185 ${NNOPBASE_INCLUDE_DIRS}185 ${NNOPBASE_INCLUDE_DIRS}
186 ${HCCL_EXTERNAL_INCLUDE}186 ${HCCL_EXTERNAL_INCLUDE}
187+ ${OPS_MATH_DIR}/common/inc
187 ${OPS_MATH_DIR}/common/inc/op_api188 ${OPS_MATH_DIR}/common/inc/op_api
188 ${METADEF_INCLUDE_DIRS}189 ${METADEF_INCLUDE_DIRS}
189)190)
@@ -0,0 +1,34 @@
1+/**
2+ * Copyright (c) 2026 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 OPS_MATH_COMMON_AICPU_MATH_AICPU_REGISTER_H
12+#define OPS_MATH_COMMON_AICPU_MATH_AICPU_REGISTER_H
13+ 
14+#include "cpu_kernel.h"
15+ 
16+namespace aicpu {
17+__attribute__((weak)) bool RegistCpuKernelV2(const std::string &type, const KERNEL_CREATOR_FUN &fun);
18+} // namespace aicpu
19+ 
20+#if defined(OPS_MATH_AICPU_HOST_KERNEL)
21+#define OPS_MATH_REGISTER_CPU_KERNELV2(type, clazz) \
22+ static std::shared_ptr<aicpu::CpuKernel> Creator_##type##_Kernel() \
23+ { \
24+ return aicpu::MakeShared<clazz>(); \
25+ } \
26+ static bool g_##type##_Kernel_Creator __attribute__((unused)) = \
27+ ((&::aicpu::RegistCpuKernelV2) != nullptr) \
28+ ? ::aicpu::RegistCpuKernelV2((type), Creator_##type##_Kernel) \
29+ : ::aicpu::RegistCpuKernel((type), Creator_##type##_Kernel)
30+#else
31+#define OPS_MATH_REGISTER_CPU_KERNELV2(type, clazz) REGISTER_CPU_KERNEL(type, clazz)
32+#endif
33+ 
34+#endif // OPS_MATH_COMMON_AICPU_MATH_AICPU_REGISTER_H
@@ -15,6 +15,7 @@
15 15 
16#include "Eigen/Core"16#include "Eigen/Core"
17#include "cpu_kernel_utils.h"17#include "cpu_kernel_utils.h"
18+#include "aicpu/math_aicpu_register.h"
18#include "securec.h"19#include "securec.h"
19#include "utils/eigen_tensor.h"20#include "utils/eigen_tensor.h"
20#include "utils/kernel_util.h"21#include "utils/kernel_util.h"
@@ -484,7 +485,7 @@ uint32_t TileCpuKernel::Compute(CpuKernelContext &ctx) {
484 return KERNEL_STATUS_OK;485 return KERNEL_STATUS_OK;
485}486}
486 487 
487-REGISTER_CPU_KERNEL(kTile, TileCpuKernel);488+OPS_MATH_REGISTER_CPU_KERNELV2(kTile, TileCpuKernel);
488 489 
489template <typename T>490template <typename T>
490void TileCpuKernel::TileCompute3DSharderFirst(const CpuKernelContext &ctx, T *input_x_data, T *output_data,491void TileCpuKernel::TileCompute3DSharderFirst(const CpuKernelContext &ctx, T *input_x_data, T *output_data,