-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
77 lines (63 loc) · 2.37 KB
/
Copy pathCMakeLists.txt
File metadata and controls
77 lines (63 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
project(dlprim_backend)
find_package(Python3 COMPONENTS Interpreter Development REQUIRED)
find_package(Torch 1.13 REQUIRED)
find_package(pybind11 REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")
option(BUILD_CORE_ONLY "Core Build" ON)
option(DLPRIM_STATIC_BUILD "Build static version only" ON)
option(BUILD_CPLUS_EXAMPLE "Build C++ examples" OFF)
add_subdirectory(dlprimitives)
include_directories("${OCL_PATH}")
include_directories(${PYTHON_INCLUDE_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR}/dlprimitives)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/dlprimitives/include)
include_directories(${Python3_INCLUDE_DIRS}) # Python include
include_directories(${pybind11_INCLUDE_DIRS}) # pybind11 include
message(" Pytorch libraries: ${TORCH_LIBRARIES}")
message(" Python libraries: ${Python3_LIBRARIES}")
message(" Python include: ${Python3_INCLUDE_DIRS}")
if(NOT WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O2 -Wall")
endif()
# Define our library target
add_library(pt_ocl SHARED
src/pointwise_ops.cpp
src/tensor_ops.cpp
src/vision_ops.cpp
src/loss_ops.cpp
src/random_ops.cpp
src/norm_ops.cpp
src/utils.cpp
src/registeration.cpp
src/CLTensor.cpp
src/guard.cpp
src/python_iface.cpp
)
target_compile_features(pt_ocl PRIVATE cxx_std_17)
# Link against LibTorch
target_link_libraries(pt_ocl ${TORCH_LIBRARIES} ${OCL_LIB} dlprim_core ${Python3_LIBRARIES})
if(WIN32)
target_link_libraries(pt_ocl ${Python3_LIBRARIES})
endif()
set_target_properties(pt_ocl PROPERTIES PREFIX "" OUTPUT_NAME "pt_ocl")
if(NOT WIN32)
set_target_properties(pt_ocl PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/pytorch_ocl/")
else()
set_target_properties(pt_ocl PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/pytorch_ocl/"
SUFFIX ".pyd"
)
endif()
foreach(PYNAME __init__.py)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/python/pytorch_ocl/${PYNAME} "${CMAKE_BINARY_DIR}/pytorch_ocl/${PYNAME}" COPYONLY)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/python/pytorch_ocl/${PYNAME} DESTINATION python/pytorch_ocl)
endforeach()
install(TARGETS pt_ocl
LIBRARY DESTINATION python/pytorch_ocl
RUNTIME DESTINATION python/pytorch_ocl
)
# Add C++ examples
if(BUILD_CPLUS_EXAMPLE)
add_subdirectory(examples/cplus)
endif()