-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
179 lines (154 loc) · 5.02 KB
/
Copy pathCMakeLists.txt
File metadata and controls
179 lines (154 loc) · 5.02 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# Copyright 2024-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of NVIDIA CORPORATION nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
cmake_minimum_required(VERSION 3.31.8)
# ================= Ensures Package is Structured Properly ==================
# Top level module entry point and typed marker
file(COPY __init__.py DESTINATION .)
file(COPY py.typed DESTINATION .)
# Copy the '__init__.py' for the '_c' module
file(COPY _c/__init__.py DESTINATION ./_c/.)
file(COPY _c/__init__.pyi DESTINATION ./_c/.)
file(COPY _c/tritonfrontend_bindings.pyi DESTINATION ./_c/.)
# Find and copy _api modules
file(GLOB PYTHON_MODULE_FILES ./_api/*.py)
file(COPY ${PYTHON_MODULE_FILES} DESTINATION ./_api/.)
# ================================= END =====================================
# =================== Downloading and Installing pybind11 ===================
include(FetchContent)
FetchContent_Declare(
pybind11
GIT_REPOSITORY https://github.com/pybind/pybind11.git
GIT_TAG v2.13.1
GIT_SHALLOW ON
)
FetchContent_MakeAvailable(pybind11)
# ================================= END =====================================
# ================== Collect the Dependencies ===============================
set(
PYTHON_FRONTEND_BINDING_DEPS
../../shared_memory_manager.h
../../shared_memory_manager.cc
../../data_compressor.h
../../restricted_features.h
../../classification.cc
../../common.h
../../common.cc
)
set(PY_BINDING_DEPENDENCY_LIBS
b64) # Dependency from common.h
# Conditional Linking Based on Flags
if(${TRITON_ENABLE_HTTP})
list(APPEND PY_BINDING_DEPENDENCY_LIBS
http-endpoint-library
)
endif()
if(${TRITON_ENABLE_GRPC})
list(APPEND PY_BINDING_DEPENDENCY_LIBS
grpc-endpoint-library
)
endif()
if(${TRITON_ENABLE_GPU})
find_package(CUDAToolkit REQUIRED)
list(APPEND PY_BINDING_DEPENDENCY_LIBS
CUDA::cudart
)
endif()
if(${TRITON_ENABLE_TRACING})
message("TRACING/STATS IS CURRENTLY NOT SUPPORTED.")
list(
APPEND PY_BINDING_DEPENDENCY_LIBS
tracing-library
)
endif()
# ===================== End of Collection ===================================
# ================== Create Python Frontend Bindings ========================
set(
PYTHON_FRONTEND_BINDING_SRCS
_c/tritonfrontend.h
_c/tritonfrontend_pybind.cc
)
pybind11_add_module(
py-bindings
MODULE
${PYTHON_FRONTEND_BINDING_DEPS}
${PYTHON_FRONTEND_BINDING_SRCS}
)
target_link_libraries(
py-bindings
PRIVATE
${PY_BINDING_DEPENDENCY_LIBS}
)
if(${TRITON_ENABLE_HTTP})
target_compile_definitions(
py-bindings
PRIVATE TRITON_ENABLE_HTTP=1
)
endif()
if(${TRITON_ENABLE_GRPC})
target_compile_definitions(
py-bindings
PRIVATE TRITON_ENABLE_GRPC=1
)
endif()
if(${TRITON_ENABLE_GPU})
target_compile_definitions(
py-bindings
PRIVATE TRITON_ENABLE_GPU=1
PRIVATE TRITON_MIN_COMPUTE_CAPABILITY=${TRITON_MIN_COMPUTE_CAPABILITY}
)
endif()
if(${TRITON_ENABLE_TRACING})
target_compile_definitions(
py-bindings
PRIVATE TRITON_ENABLE_TRACING=1
)
endif()
if(${TRITON_ENABLE_STATS})
target_compile_definitions(
py-bindings
PRIVATE TRITON_ENABLE_STATS=1
)
endif()
if(${TRITON_ENABLE_METRICS})
target_compile_definitions(
py-bindings
PRIVATE TRITON_ENABLE_METRICS=1
)
endif()
set_property(TARGET py-bindings PROPERTY OUTPUT_NAME tritonfrontend_bindings)
target_include_directories(
py-bindings
PRIVATE
${repo-core_SOURCE_DIR}/include
${repo-common_SOURCE_DIR}/include
)
set_target_properties(
py-bindings
PROPERTIES
BUILD_RPATH "$ORIGIN:/opt/tritonserver/lib"
POSITION_INDEPENDENT_CODE ON
)
# ===================== End of Python Bindings ==============================