|
| 1 | + |
| 2 | +aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} ops_srcs) |
| 3 | + |
| 4 | +opbuild(OPS_SRC ${ops_srcs} |
| 5 | + OUT_DIR ${ASCEND_AUTOGEN_PATH} |
| 6 | +) |
| 7 | + |
| 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 |
| 14 | +) |
| 15 | +target_compile_definitions(cust_op_proto PRIVATE OP_PROTO_LIB) |
| 16 | +target_compile_options(cust_op_proto PRIVATE |
| 17 | + -fvisibility=hidden |
| 18 | +) |
| 19 | +if(ENABLE_CROSS_COMPILE) |
| 20 | + target_link_directories(cust_op_proto PRIVATE |
| 21 | + ${CMAKE_COMPILE_COMPILER_LIBRARY} |
| 22 | + ${CMAKE_COMPILE_RUNTIME_LIBRARY} |
| 23 | + ) |
| 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} |
| 50 | + ) |
| 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 | +) |
| 65 | + |
| 66 | +file(GLOB_RECURSE pregen_file |
| 67 | + "${CMAKE_CURRENT_SOURCE_DIR}/op_api/*" |
| 68 | +) |
| 69 | + |
| 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() |
| 138 | + |
| 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/ |
| 142 | +) |
| 143 | +include_directories($ENV{ASCEND_HOME_PATH}/../opp/vendors/CAM/op_impl/ai_core/tbe/CAM_impl/dynamic/) |
| 144 | + |
| 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 |
| 148 | +) |
| 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