Skip to content

Commit 3883574

Browse files
committed
fix kernel building issue
Signed-off-by: mojave2 <[email protected]>
1 parent 5b47474 commit 3883574

19 files changed

+276
-257
lines changed

csrc/build_aclnn.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ else
2323
exit 0
2424
fi
2525

26+
git submodule init
27+
git submodule update
28+
2629
# build custom ops
2730
cd csrc
2831
rm -rf build output

csrc/cmake/func.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ function(add_ops_src_copy)
282282
set(_BUILD_FLAG ${SRC_COPY_DST}/${SRC_COPY_TARGET_NAME}.done)
283283
add_custom_command(OUTPUT ${_BUILD_FLAG}
284284
COMMAND mkdir -p ${SRC_COPY_DST}
285-
COMMAND cp -rf ${SRC_COPY_SRC}/op_kernel/*.* ${SRC_COPY_DST}
285+
COMMAND cp -rf ${SRC_COPY_SRC}/op_kernel/* ${SRC_COPY_DST}
286286
COMMAND touch ${_BUILD_FLAG}
287287
)
288288

Lines changed: 51 additions & 162 deletions
Original file line numberDiff line numberDiff line change
@@ -1,177 +1,66 @@
1+
# Copyright (c) 2025 Huawei Technologies Co., Ltd.
2+
# This file is a part of the CANN Open Software.
3+
# Licensed under CANN Open Software License Agreement Version 1.0 (the "License").
4+
# Please refer to the License for details. You may not use this file except in compliance with the License.
5+
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
6+
# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
7+
# See LICENSE in the root of the software repository for the full text of the License.
8+
# ======================================================================================================================
19

2-
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} ops_srcs)
10+
set(_DISPATCH_FFN_INC_OPTS)
11+
if (EXISTS ${ASCEND_CANN_PACKAGE_PATH}/aarch64-linux/ascendc/include)
12+
list(APPEND _DISPATCH_FFN_INC_OPTS -I${ASCEND_CANN_PACKAGE_PATH}/aarch64-linux/ascendc/include)
13+
elseif (EXISTS ${ASCEND_CANN_PACKAGE_PATH}/arm64-linux/ascendc/include)
14+
list(APPEND _DISPATCH_FFN_INC_OPTS -I${ASCEND_CANN_PACKAGE_PATH}/arm64-linux/ascendc/include)
15+
elseif (EXISTS ${ASCEND_CANN_PACKAGE_PATH}/${CMAKE_SYSTEM_PROCESSOR}-linux/ascendc/include)
16+
list(APPEND _DISPATCH_FFN_INC_OPTS -I${ASCEND_CANN_PACKAGE_PATH}/${CMAKE_SYSTEM_PROCESSOR}-linux/ascendc/include)
17+
endif()
18+
if (EXISTS ${CMAKE_SOURCE_DIR}/third_party/catlass/include)
19+
list(APPEND _DISPATCH_FFN_INC_OPTS -I${CMAKE_SOURCE_DIR}/third_party/catlass/include)
20+
endif()
321

4-
opbuild(OPS_SRC ${ops_srcs}
5-
OUT_DIR ${ASCEND_AUTOGEN_PATH}
22+
add_ops_compile_options(
23+
OP_NAME DispatchFFNCombine
24+
OPTIONS --cce-auto-sync=on
25+
-Wno-deprecated-declarations
26+
-Werror
27+
-DHCCL_COMM
28+
${_DISPATCH_FFN_INC_OPTS}
629
)
730

8-
file(GLOB group_proto_src ${ASCEND_AUTOGEN_PATH}/group_proto/*.cc)
9-
10-
add_library(cust_op_proto SHARED
11-
$<$<TARGET_EXISTS:group_proto_src>:${group_proto_src}>
12-
${ops_srcs}
13-
${ASCEND_AUTOGEN_PATH}/op_proto.cc
31+
target_sources(op_host_aclnnInner PRIVATE
32+
dispatch_ffn_combine_def.cpp
1433
)
15-
target_compile_definitions(cust_op_proto PRIVATE OP_PROTO_LIB)
16-
target_compile_options(cust_op_proto PRIVATE
17-
-fvisibility=hidden
34+
35+
target_sources(opapi PRIVATE
36+
aclnn_dispatch_ffn_combine.cpp
1837
)
19-
if(ENABLE_CROSS_COMPILE)
20-
target_link_directories(cust_op_proto PRIVATE
21-
${CMAKE_COMPILE_COMPILER_LIBRARY}
22-
${CMAKE_COMPILE_RUNTIME_LIBRARY}
38+
39+
if (NOT BUILD_OPEN_PROJECT)
40+
target_sources(aclnn_ops_train PRIVATE
41+
aclnn_dispatch_ffn_combine.cpp
2342
)
24-
endif()
25-
target_link_libraries(cust_op_proto PRIVATE
26-
intf_pub
27-
exe_graph
28-
register
29-
tiling_api
30-
-Wl,--whole-archive
31-
rt2_registry
32-
-Wl,--no-whole-archive
33-
)
34-
set_target_properties(cust_op_proto PROPERTIES OUTPUT_NAME
35-
cust_opsproto_rt2.0
36-
)
37-
file(GLOB fallback_src ${ASCEND_AUTOGEN_PATH}/fallback_*.cpp)
38-
add_library(cust_optiling SHARED ${ops_srcs})
39-
if (${fallback_src})
40-
target_sources(cust_optiling PRIVATE ${fallback_src})
41-
endif()
42-
target_compile_definitions(cust_optiling PRIVATE OP_TILING_LIB)
43-
target_compile_options(cust_optiling PRIVATE
44-
-fvisibility=hidden
45-
)
46-
if(ENABLE_CROSS_COMPILE)
47-
target_link_directories(cust_optiling PRIVATE
48-
${CMAKE_COMPILE_COMPILER_LIBRARY}
49-
${CMAKE_COMPILE_RUNTIME_LIBRARY}
43+
44+
target_sources(aclnn_ops_infer PRIVATE
45+
aclnn_dispatch_ffn_combine.cpp
5046
)
51-
endif()
52-
target_link_libraries(cust_optiling PRIVATE
53-
nnopbase
54-
intf_pub
55-
exe_graph
56-
register
57-
tiling_api
58-
-Wl,--whole-archive
59-
rt2_registry
60-
-Wl,--no-whole-archive
61-
)
62-
set_target_properties(cust_optiling PROPERTIES OUTPUT_NAME
63-
cust_opmaster_rt2.0
64-
)
47+
endif ()
6548

66-
file(GLOB_RECURSE pregen_file
67-
"${CMAKE_CURRENT_SOURCE_DIR}/op_api/*"
49+
target_sources(optiling PRIVATE
50+
dispatch_ffn_combine_tiling.cpp
6851
)
6952

70-
file(COPY ${pregen_file} DESTINATION ${ASCEND_AUTOGEN_PATH})
71-
file(GLOB aclnn_src ${ASCEND_AUTOGEN_PATH}/aclnn*.cpp)
72-
file(GLOB aclnn_inc ${ASCEND_AUTOGEN_PATH}/aclnn_*.h)
73-
if(NOT ASCEND_PACK_SHARED_LIBRARY)
74-
add_library(cust_opapi SHARED ${aclnn_src})
75-
else()
76-
file(GLOB op_registry ${ASCEND_AUTOGEN_PATH}/custom_op_registry.cpp)
77-
add_library(cust_opapi SHARED ${aclnn_src} ${op_registry})
78-
target_compile_definitions(cust_opapi PRIVATE ACLNN_WITH_BINARY)
79-
endif()
80-
if(ENABLE_CROSS_COMPILE)
81-
target_link_directories(cust_opapi PRIVATE
82-
${CMAKE_COMPILE_COMPILER_LIBRARY}
83-
${CMAKE_COMPILE_RUNTIME_LIBRARY}
84-
)
85-
endif()
86-
if(NOT ASCEND_PACK_SHARED_LIBRARY)
87-
target_link_libraries(cust_opapi PRIVATE intf_pub ascendcl nnopbase)
88-
else()
89-
add_library(cust_op_proto_obj OBJECT
90-
$<$<TARGET_EXISTS:group_proto_src>:${group_proto_src}>
91-
${ops_srcs}
92-
${ASCEND_AUTOGEN_PATH}/op_proto.cc
93-
)
94-
target_compile_definitions(cust_op_proto_obj PRIVATE OP_PROTO_LIB)
95-
target_compile_options(cust_op_proto_obj PRIVATE
96-
-fvisibility=hidden
97-
)
98-
if(ENABLE_CROSS_COMPILE)
99-
target_link_directories(cust_op_proto_obj PRIVATE
100-
${CMAKE_COMPILE_COMPILER_LIBRARY}
101-
${CMAKE_COMPILE_RUNTIME_LIBRARY}
102-
)
103-
endif()
104-
target_link_libraries(cust_op_proto_obj PRIVATE
105-
intf_pub
106-
exe_graph
107-
register
108-
tiling_api
109-
-Wl,--whole-archive
110-
rt2_registry
111-
-Wl,--no-whole-archive
112-
)
113-
add_library(cust_optiling_obj OBJECT ${ops_srcs})
114-
target_compile_definitions(cust_optiling_obj PRIVATE OP_TILING_LIB)
115-
target_compile_options(cust_optiling_obj PRIVATE
116-
-fvisibility=hidden
117-
)
118-
if(ENABLE_CROSS_COMPILE)
119-
target_link_directories(cust_optiling_obj PRIVATE
120-
${CMAKE_COMPILE_COMPILER_LIBRARY}
121-
${CMAKE_COMPILE_RUNTIME_LIBRARY}
122-
)
123-
endif()
124-
target_link_libraries(cust_optiling_obj PRIVATE
125-
intf_pub
126-
exe_graph
127-
register
128-
tiling_api
129-
-Wl,--whole-archive
130-
rt2_registry
131-
-Wl,--no-whole-archive
132-
)
133-
target_compile_options(cust_opapi PRIVATE -DLOG_CPP)
134-
target_include_directories(cust_opapi INTERFACE ${CMAKE_SOURCE_DIR}/build_out/library/)
135-
target_link_libraries(cust_opapi PRIVATE intf_pub ascendcl nnopbase cust_optiling_obj cust_op_proto_obj ascend_opregistry ascend_kernels)
136-
add_dependencies(cust_opapi ascend_opregistry)
137-
endif()
53+
target_include_directories(optiling PRIVATE
54+
${CMAKE_CURRENT_SOURCE_DIR}
55+
${CMAKE_CURRENT_SOURCE_DIR}/../op_kernel
56+
)
13857

139-
target_include_directories(cust_opapi PRIVATE
140-
$ENV{ASCEND_HOME_PATH}/aarch64-linux/include/experiment/platform/
141-
$ENV{ASCEND_HOME_PATH}/x86_64-linux/include/experiment/platform/
58+
target_sources(opsproto PRIVATE
59+
dispatch_ffn_combine_proto.cpp
14260
)
143-
include_directories($ENV{ASCEND_HOME_PATH}/../opp/vendors/CAM/op_impl/ai_core/tbe/CAM_impl/dynamic/)
14461

145-
add_custom_target(optiling_compat ALL
146-
COMMAND ln -sf lib/linux/${CMAKE_SYSTEM_PROCESSOR}/$<TARGET_FILE_NAME:cust_optiling>
147-
${CMAKE_CURRENT_BINARY_DIR}/liboptiling.so
62+
file(GLOB _GMM_Aclnn_header "${CMAKE_CURRENT_SOURCE_DIR}/aclnn_dispatch_ffn_combine.h")
63+
64+
install(FILES ${_GMM_Aclnn_header}
65+
DESTINATION ${ACLNN_INC_INSTALL_DIR} OPTIONAL
14866
)
149-
if(NOT ASCEND_PACK_SHARED_LIBRARY)
150-
install(TARGETS cust_op_proto
151-
LIBRARY DESTINATION packages/vendors/${vendor_name}/op_proto/lib/linux/${CMAKE_SYSTEM_PROCESSOR})
152-
install(FILES ${ASCEND_AUTOGEN_PATH}/op_proto.h
153-
DESTINATION packages/vendors/${vendor_name}/op_proto/inc)
154-
file(GLOB GROUP_PROTO_HEADERS ${ASCEND_AUTOGEN_PATH}/group_proto/*.h)
155-
if (GROUP_PROTO_HEADERS)
156-
install(FILES ${GROUP_PROTO_HEADERS}
157-
DESTINATION packages/vendors/${vendor_name}/op_proto/inc)
158-
endif()
159-
install(TARGETS cust_optiling
160-
LIBRARY DESTINATION packages/vendors/${vendor_name}/op_impl/ai_core/tbe/op_tiling/lib/linux/${CMAKE_SYSTEM_PROCESSOR})
161-
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/liboptiling.so
162-
DESTINATION packages/vendors/${vendor_name}/op_impl/ai_core/tbe/op_tiling)
163-
install(TARGETS cust_opapi
164-
LIBRARY DESTINATION packages/vendors/${vendor_name}/op_api/lib)
165-
install(FILES ${aclnn_inc}
166-
DESTINATION packages/vendors/${vendor_name}/op_api/include)
167-
else()
168-
file(GLOB group_inc ${ASCEND_AUTOGEN_PATH}/group_proto/*.h)
169-
install(TARGETS cust_opapi
170-
LIBRARY DESTINATION op_api/lib)
171-
install(FILES ${ASCEND_AUTOGEN_PATH}/op_proto.h
172-
DESTINATION op_api/include)
173-
install(FILES ${group_inc}
174-
DESTINATION op_api/include)
175-
install(FILES ${aclnn_inc}
176-
DESTINATION op_api/include)
177-
endif()

csrc/dispatch_ffn_combine/op_host/dispatch_ffn_combine_def.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class DispatchFFNCombine : public OpDef {
7979
.ExtendCfgInfo("jitCompile.flag", "static_false")
8080
.ExtendCfgInfo("multiKernelSupportDynamicGraph.value", "multi_kernel");
8181
this->AICore().AddConfig("ascend910_93", aicore_config);
82-
// this->AICore().AddConfig("ascend910b", aicore_config);
82+
this->AICore().AddConfig("ascend910b", aicore_config);
8383
this->MC2().HcclGroup("group");
8484
}
8585
};

csrc/dispatch_ffn_combine/op_kernel/CMakeLists.txt

Lines changed: 0 additions & 7 deletions
This file was deleted.

csrc/dispatch_ffn_combine/op_kernel/dispatch_ffn_combine.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ using namespace AscendC;
2020

2121
#include "kernel_operator.h"
2222

23-
#include "hccl/hccl_common.h"
24-
#include "hccl/common/hccl_inner_def.h"
23+
#include "highlevel_api/lib/hccl/hccl_common.h"
24+
#include "highlevel_api/impl/hccl/common/hccl_inner_def.h"
2525

2626
#include "dispatch_ffn_combine_tiling.h"
2727

@@ -38,7 +38,6 @@ using namespace AscendC;
3838
#include "catlass/gemm/kernel/matmul_epilogue.hpp"
3939
#include "catlass/gemm/gemm_type.hpp"
4040
#include "catlass/layout/layout.hpp"
41-
#include "catlass/status.hpp"
4241

4342
#include "utils/select_helper.hpp"
4443
#include "utils/const_args.hpp"

csrc/dispatch_ffn_combine/op_kernel/utils/hccl_shmem.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
#include "kernel_operator.h"
66
#include "const_args.hpp"
77

8-
#include "hccl/hccl_common.h"
9-
#include "hccl/common/hccl_inner_def.h"
8+
#include "highlevel_api/lib/hccl/hccl_common.h"
9+
#include "highlevel_api/impl/hccl/common/hccl_inner_def.h"
1010

1111
#ifndef HCCL_COMM
1212
#include "shmem_api.h"
@@ -178,4 +178,4 @@ class HcclShmem {
178178
};
179179

180180

181-
#endif
181+
#endif

csrc/torch_binding.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,7 @@ void batch_matmul_transpose(const at::Tensor &tensor_a, const at::Tensor &tensor
618618
});
619619
cmd.Run();
620620
return;
621+
}
621622

622623
at::Tensor& dispatch_ffn_combine(
623624
const at::Tensor& x,

0 commit comments

Comments
 (0)