-
Notifications
You must be signed in to change notification settings - Fork 17
/
CMakeLists.txt
69 lines (55 loc) · 2.02 KB
/
CMakeLists.txt
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
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
project(dlprim_backend)
find_package(PythonLibs 3 REQUIRED)
find_package(Torch 1.13 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)
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)
message(" Pytorch libraries ${TORCH_LIBRARIES}")
message(" Python libraries ${PYTHON_LIBRARIES}")
message(" Python include ${PYTHON_INCLUDE_DIR}")
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)
if(WIN32)
target_link_libraries(pt_ocl ${PYTHON_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
)