@@ -17,64 +17,37 @@ message(STATUS "op-plugin download done")
17
17
add_custom_target (op_plugin_gen
18
18
COMMAND cd ${op_plugin_SOURCE_DIR} && bash ./gencode.sh 2.0 python
19
19
)
20
-
21
20
add_subdirectory (third_party/acl)
22
21
include_directories (SYSTEM ${CMAKE_CURRENT_SOURCE_DIR} /third_party/acl/inc)
23
22
24
- if (NOT DEFINED PYTHON_INCLUDE_DIR)
25
- execute_process (
26
- COMMAND sh -c "dirname $(find $(dirname $(which python))/../ -name Python.h)"
27
- OUTPUT_VARIABLE PYTHON_INCLUDE_DIR)
28
- endif ()
29
- include_directories (SYSTEM ${PYTHON_INCLUDE_DIR} )
30
- message (STATUS "PYTHON_INCLUDE_DIR: " ${PYTHON_INCLUDE_DIR} )
23
+ # find python3
24
+ find_package (Python COMPONENTS Interpreter Development)
25
+ MESSAGE (STATUS "Python_INCLUDE_DIRS: ${Python_INCLUDE_DIRS} " )
26
+ MESSAGE (STATUS "Python_LIBRARIES: ${Python_LIBRARIES} " )
27
+ include_directories (SYSTEM ${Python_INCLUDE_DIRS} )
28
+ link_directories (${Python_LIBRARIES} )
31
29
30
+ # find torch
32
31
if (NOT DEFINED PYTORCH_DIR)
33
32
execute_process (
34
- COMMAND sh -c "dirname $( python -c 'import torch;print(torch.__path__[0])') "
33
+ COMMAND sh -c "python -c 'import torch;print(torch.__path__[0])'"
35
34
OUTPUT_VARIABLE PYTORCH_DIR
36
35
OUTPUT_STRIP_TRAILING_WHITESPACE)
37
36
endif ()
38
- set (TORCH_LIBRARY_DIR "${PYTORCH_DIR} /torch/lib" )
39
- link_directories (${TORCH_LIBRARY_DIR} )
40
- list (APPEND TORCH_INCLUDE_DIRS ${PYTORCH_DIR} /torch/include /
41
- ${PYTORCH_DIR} /torch/include /torch/csrc/api/include /)
42
- include_directories (SYSTEM ${TORCH_INCLUDE_DIRS} )
43
- message (STATUS "Torch TORCH_INCLUDE_DIRS: ${TORCH_INCLUDE_DIRS} " )
44
-
45
- # if(NOT DEFINED DIPU_ABI_V)
46
- # execute_process(
47
- # COMMAND
48
- # sh -x -c
49
- # "python -c 'import torch, builtins; print(next(item[-4:-2] for item in dir(builtins) \
50
- # if \"__pybind11_internals_v4_gcc_libstdcpp_cxxabi10\" in item))'"
51
- # OUTPUT_VARIABLE DIPU_ABI_V)
52
- # endif()
53
-
54
- if (NOT DEFINED DIPU_COMPILED_WITH_CXX11_ABI)
55
- execute_process (
56
- COMMAND
57
- sh -x -c
58
- "python -c 'import torch;print(1 if torch.compiled_with_cxx11_abi() else 0)'"
59
- OUTPUT_VARIABLE DIPU_COMPILED_WITH_CXX11_ABI)
60
- endif ()
61
-
62
- if (DIPU_COMPILED_WITH_CXX11_ABI GREATER 0)
63
- set (DIPU_COMPILED_WITH_CXX11_ABI 1)
64
- else ()
65
- set (DIPU_COMPILED_WITH_CXX11_ABI 0)
66
- endif ()
37
+ find_package (Torch REQUIRED
38
+ PATHS ${PYTORCH_DIR}
39
+ )
40
+ message (STATUS "TORCH_INSTALL_PREFIX:" ${TORCH_INSTALL_PREFIX} )
41
+ message (STATUS "TORCH_CXX_FLAGS:" ${TORCH_CXX_FLAGS} ) # include -D_GLIBCXX_USE_CXX11_ABI
42
+ message (STATUS "TORCH_INCLUDE_DIRS:" ${TORCH_INCLUDE_DIRS} )
67
43
68
- # add_definitions(-fabi-version=${DIPU_ABI_V })
69
- # message(STATUS "DIPU_ABI_V: ${DIPU_ABI_V}" )
44
+ include_directories ( SYSTEM ${TORCH_INCLUDE_DIRS } )
45
+ link_directories ( ${TORCH_INSTALL_PREFIX} /lib )
70
46
71
47
# Because many interfaces have not yet been implemented, -Wreturn-type=0 option is temporarily added.
72
48
set (CMAKE_CXX_FLAGS
73
- "${CMAKE_CXX_FLAGS} -D_GLIBCXX_USE_CXX11_ABI= ${DIPU_COMPILED_WITH_CXX11_ABI } -Wno-return-type -Wno-unused-function -Wno-unused-but-set-variable -Wno-unused-variable -g -O0 "
49
+ "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS } -Wno-return-type -Wno-unused-function -Wno-unused-but-set-variable -Wno-unused-variable -g -O0 "
74
50
)
75
- add_compile_options (-D_GLIBCXX_USE_CXX11_ABI=${DIPU_COMPILED_WITH_CXX11_ABI} )
76
- message (STATUS "DIPU_COMPILED_WITH_CXX11_ABI:" ${DIPU_COMPILED_WITH_CXX11_ABI} )
77
-
78
51
79
52
set (OP_PLUGIN_DIR ${op_plugin_SOURCE_DIR} /op_plugin/ops/base_ops/aclops/)
80
53
set (OP_PLUGIN_UTILS_DIR ${op_plugin_SOURCE_DIR} /op_plugin/utils/)
@@ -655,6 +628,7 @@ set(OLD_IMPL_SRC
655
628
${OLD_IMPL_DIR} /common/generator_helper.cpp
656
629
${OLD_IMPL_DIR} /common/stream_lock.cpp
657
630
${OLD_IMPL_DIR} /env_vars.cpp
631
+ ${OLD_IMPL_DIR} /init.cpp
658
632
)
659
633
660
634
list (APPEND IMPL_SRC ${OP_PLUGIN_UTILS_SRC} ${OP_PLUGIN_SRC} ${OP_PLUGIN_API_SRC} ${ASCEND_IMPL_SRC} ${DIOPI_IMPL_SRC} ${OLD_IMPL_SRC} )
@@ -702,7 +676,7 @@ add_library(${DEVICEIMPL} SHARED ${IMPL_SRC})
702
676
add_dependencies (${DEVICEIMPL} op_plugin_gen)
703
677
set_target_properties (${DEVICEIMPL} PROPERTIES SUFFIX ".so" )
704
678
target_include_directories (${DEVICEIMPL} SYSTEM PUBLIC ${THIRD_PARTY_INCLUDE_DIRS} )
705
- target_link_libraries (${DEVICEIMPL} ascendcl acl_op_compiler graph c10 torch_cpu)
679
+ target_link_libraries (${DEVICEIMPL} ascendcl acl_op_compiler graph c10 torch_cpu ${Python_LIBRARIES} )
706
680
707
681
if (USE_ADAPTOR)
708
682
add_dependencies (${DEVICEIMPL} adaptor_code_gen)
0 commit comments