|
| 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 | +# ====================================================================================================================== |
1 | 9 |
|
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() |
3 | 21 |
|
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} |
6 | 29 | ) |
7 | 30 |
|
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 |
14 | 33 | ) |
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 |
18 | 37 | ) |
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 |
23 | 42 | ) |
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 |
50 | 46 | ) |
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 () |
65 | 48 |
|
66 | | -file(GLOB_RECURSE pregen_file |
67 | | - "${CMAKE_CURRENT_SOURCE_DIR}/op_api/*" |
| 49 | +target_sources(optiling PRIVATE |
| 50 | + dispatch_ffn_combine_tiling.cpp |
68 | 51 | ) |
69 | 52 |
|
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 | +) |
138 | 57 |
|
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 |
142 | 60 | ) |
143 | | -include_directories($ENV{ASCEND_HOME_PATH}/../opp/vendors/CAM/op_impl/ai_core/tbe/CAM_impl/dynamic/) |
144 | 61 |
|
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 |
148 | 66 | ) |
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() |
0 commit comments