-
Notifications
You must be signed in to change notification settings - Fork 497
/
Copy pathCMakeLists.txt
330 lines (313 loc) · 10.2 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
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
# This file should be formatted with
# ~~~
# cmake-format -i CMakeLists.txt
# ~~~
# It should also be cmake-lint clean.
#
cmake_minimum_required(VERSION 3.19)
set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../..)
include(${EXECUTORCH_ROOT}/build/Test.cmake)
set(_kernels portable optimized quantized)
foreach(kernel ${_kernels})
set(_wrapper_dir
"${CMAKE_CURRENT_BINARY_DIR}/include/${kernel}/executorch/kernels/test"
)
set(_wrapper_path "${_wrapper_dir}/FunctionHeaderWrapper.h")
add_custom_command(
OUTPUT "${_wrapper_path}"
COMMAND mkdir -p ${_wrapper_dir}
COMMAND echo "#include <executorch/kernels/${kernel}/Functions.h>" >
"${_wrapper_path}"
DEPENDS
"${CMAKE_CURRENT_BINARY_DIR}/include/${kernel}/executorch/kernels/${kernel}/Functions.h"
"${CMAKE_CURRENT_BINARY_DIR}/include/${kernel}/executorch/kernels/${kernel}/NativeFunctions.h"
"${CMAKE_CURRENT_BINARY_DIR}/include/${kernel}/executorch/kernels/${kernel}/RegisterKernels.h"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
COMMENT "Generating ${_wrapper_path}"
VERBATIM
)
add_custom_command(
OUTPUT "${_wrapper_dir}/supported_features.cpp"
"${_wrapper_dir}/supported_features.h"
COMMAND mkdir -p ${_wrapper_dir}
COMMAND
python kernels/test/gen_supported_features.py
kernels/${kernel}/test/supported_features_def.yaml >
${_wrapper_dir}/supported_features.cpp
COMMAND
python kernels/test/gen_supported_features.py
kernels/test/supported_features.yaml >
${_wrapper_dir}/supported_features.h
WORKING_DIRECTORY "${EXECUTORCH_ROOT}"
COMMENT "Generating ${_wrapper_dir}/supported_features.cpp and header"
VERBATIM
)
add_custom_command(
OUTPUT
"${CMAKE_CURRENT_BINARY_DIR}/include/${kernel}/executorch/kernels/${kernel}/Functions.h"
"${CMAKE_CURRENT_BINARY_DIR}/include/${kernel}/executorch/kernels/${kernel}/NativeFunctions.h"
"${CMAKE_CURRENT_BINARY_DIR}/include/${kernel}/executorch/kernels/${kernel}/RegisterKernels.h"
COMMAND
mkdir -p
"${CMAKE_CURRENT_BINARY_DIR}/include/${kernel}/executorch/kernels/${kernel}/"
COMMAND
cp
"${CMAKE_CURRENT_BINARY_DIR}/../../kernels/${kernel}/${kernel}_ops_lib/*.h"
"${CMAKE_CURRENT_BINARY_DIR}/include/${kernel}/executorch/kernels/${kernel}/"
DEPENDS "${kernel}_ops_lib"
)
endforeach()
add_custom_target(
generate_wrapper
DEPENDS
"${CMAKE_CURRENT_BINARY_DIR}/include/portable/executorch/kernels/test/FunctionHeaderWrapper.h"
"${CMAKE_CURRENT_BINARY_DIR}/include/portable/executorch/kernels/test/supported_features.h"
"${CMAKE_CURRENT_BINARY_DIR}/include/portable/executorch/kernels/test/supported_features.cpp"
"${CMAKE_CURRENT_BINARY_DIR}/include/optimized/executorch/kernels/test/FunctionHeaderWrapper.h"
"${CMAKE_CURRENT_BINARY_DIR}/include/optimized/executorch/kernels/test/supported_features.h"
"${CMAKE_CURRENT_BINARY_DIR}/include/optimized/executorch/kernels/test/supported_features.cpp"
"${CMAKE_CURRENT_BINARY_DIR}/include/quantized/executorch/kernels/test/FunctionHeaderWrapper.h"
"${CMAKE_CURRENT_BINARY_DIR}/include/quantized/executorch/kernels/test/supported_features.h"
"${CMAKE_CURRENT_BINARY_DIR}/include/quantized/executorch/kernels/test/supported_features.cpp"
)
set(all_test_sources
"BinaryLogicalOpTest.cpp"
"op__to_dim_order_copy_test.cpp"
"op_abs_test.cpp"
"op_acos_test.cpp"
"op_acosh_test.cpp"
"op_add_test.cpp"
"op_addmm_test.cpp"
"op_alias_copy_test.cpp"
"op_amax_test.cpp"
"op_amin_test.cpp"
"op_any_test.cpp"
"op_arange_test.cpp"
"op_argmax_test.cpp"
"op_argmin_test.cpp"
"op_as_strided_copy_test.cpp"
"op_asin_test.cpp"
"op_asinh_test.cpp"
"op_atan_test.cpp"
"op_atan2_test.cpp"
"op_atanh_test.cpp"
"op_avg_pool2d_test.cpp"
"op_bitwise_and_test.cpp"
"op_bitwise_not_test.cpp"
"op_bitwise_or_test.cpp"
"op_bitwise_xor_test.cpp"
"op_bmm_test.cpp"
"op_cat_test.cpp"
"op_cdist_forward_test.cpp"
"op_ceil_test.cpp"
"op_clamp_test.cpp"
"op_clone_test.cpp"
"op_constant_pad_nd_test.cpp"
"op_convolution_test.cpp"
"op_copy_test.cpp"
"op_cos_test.cpp"
"op_cosh_test.cpp"
"op_cumsum_test.cpp"
"op_detach_copy_test.cpp"
"op_diagonal_copy_test.cpp"
"op_div_test.cpp"
"op_embedding_test.cpp"
"op_empty_test.cpp"
"op_eq_test.cpp"
"op_erf_test.cpp"
"op_exp_test.cpp"
"op_expand_copy_test.cpp"
"op_expm1_test.cpp"
"op_fill_test.cpp"
"op_flip_test.cpp"
"op_floor_divide_test.cpp"
"op_floor_test.cpp"
"op_fmod_test.cpp"
"op_full_like_test.cpp"
"op_full_test.cpp"
"op_ge_test.cpp"
"op_gelu_test.cpp"
"op_glu_test.cpp"
"op_gt_test.cpp"
"op_hardtanh_test.cpp"
"op_index_put_test.cpp"
"op_index_select_test.cpp"
"op_index_test.cpp"
"op_isinf_test.cpp"
"op_isnan_test.cpp"
"op_le_test.cpp"
"op_leaky_relu_test.cpp"
"op_lift_fresh_copy_test.cpp"
"op_log_softmax_test.cpp"
"op_log_test.cpp"
"op_log10_test.cpp"
"op_log1p_test.cpp"
"op_log2_test.cpp"
"op_logical_and_test.cpp"
"op_logical_not_test.cpp"
"op_logical_or_test.cpp"
"op_logical_xor_test.cpp"
"op_logit_test.cpp"
"op_lt_test.cpp"
"op_masked_fill_test.cpp"
"op_max_test.cpp"
"op_max_pool2d_with_indices_test.cpp"
"op_maximum_test.cpp"
"op_mean_test.cpp"
"op_min_test.cpp"
"op_minimum_test.cpp"
"op_mm_test.cpp"
"op_mul_test.cpp"
"op_pow_test.cpp"
"op_native_batch_norm_test.cpp"
"op_native_group_norm_test.cpp"
"op_native_layer_norm_test.cpp"
"op_ne_test.cpp"
"op_neg_test.cpp"
"op_nonzero_test.cpp"
"op_ones_test.cpp"
"op_pdist_forward_test.cpp"
"op_permute_copy_test.cpp"
"op_pixel_shuffle_test.cpp"
"op_prod_test.cpp"
"op_reciprocal_test.cpp"
"op_relu_test.cpp"
"op_remainder_test.cpp"
"op_repeat_test.cpp"
"op_reflection_pad1d_test.cpp"
"op_reflection_pad2d_test.cpp"
"op_reflection_pad3d_test.cpp"
"op_replication_pad1d_test.cpp"
"op_replication_pad2d_test.cpp"
"op_replication_pad3d_test.cpp"
"op_roll_test.cpp"
"op_round_test.cpp"
"op_rsqrt_test.cpp"
"op_rsub_test.cpp"
"op_scalar_tensor_test.cpp"
"op_scatter_add_test.cpp"
"op_select_scatter_test.cpp"
"op_select_copy_test.cpp"
"op_sigmoid_test.cpp"
"op_sign_test.cpp"
"op_sin_test.cpp"
"op_sinh_test.cpp"
"op_slice_scatter_test.cpp"
"op_slice_copy_test.cpp"
"op_softmax_test.cpp"
"op_split_copy_test.cpp"
"op_split_with_sizes_copy_test.cpp"
"op_sqrt_test.cpp"
"op_squeeze_copy_test.cpp"
"op_stack_test.cpp"
"op_sub_test.cpp"
"op_sum_test.cpp"
"op_t_copy_test.cpp"
"op_tan_test.cpp"
"op_tanh_test.cpp"
"op_to_copy_test.cpp"
"op_topk_test.cpp"
"op_transpose_copy_test.cpp"
"op_tril_test.cpp"
"op_trunc_test.cpp"
"op_unbind_copy_test.cpp"
"op_unsqueeze_copy_test.cpp"
"op_var_test.cpp"
"op_view_copy_test.cpp"
"op_where_test.cpp"
"op_zeros_test.cpp"
"UnaryUfuncRealHBBF16ToFloatHBF16Test.cpp"
)
# These requires rtti and not working so far.
list(REMOVE_ITEM all_test_sources "op_to_copy_test.cpp"
"op__to_dim_order_copy_test.cpp"
)
set(_portable_kernels_test_sources
${all_test_sources}
${CMAKE_CURRENT_BINARY_DIR}/include/portable/executorch/kernels/test/supported_features.cpp
"${EXECUTORCH_ROOT}/kernels/portable/test/op_div_test.cpp"
"${EXECUTORCH_ROOT}/kernels/portable/test/op_gelu_test.cpp"
"${EXECUTORCH_ROOT}/kernels/portable/test/op_mul_test.cpp"
)
et_cxx_test(
portable_kernels_test SOURCES ${_portable_kernels_test_sources} EXTRA_LIBS
portable_kernels portable_ops_lib
)
add_dependencies(portable_kernels_test generate_wrapper)
target_include_directories(
portable_kernels_test PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/include/portable"
)
set(_optimized_kernels_test_sources
"op_add_test.cpp"
"op_bmm_test.cpp"
"op_div_test.cpp"
"op_exp_test.cpp"
"op_gelu_test.cpp"
"op_le_test.cpp"
"op_log_softmax_test.cpp"
"op_mul_test.cpp"
"op_native_layer_norm_test.cpp"
"op_neg_test.cpp"
"op_sub_test.cpp"
"UnaryUfuncRealHBBF16ToFloatHBF16Test.cpp"
${CMAKE_CURRENT_BINARY_DIR}/include/portable/executorch/kernels/test/supported_features.cpp
)
# We don't have sleef on OSS so we don't have gelu and log_softmax
list(REMOVE_ITEM _optimized_kernels_test_sources "op_gelu_test.cpp"
"op_log_softmax_test.cpp"
)
et_cxx_test(
optimized_kernels_test
SOURCES
${_optimized_kernels_test_sources}
EXTRA_LIBS
cpuinfo
extension_threadpool
optimized_kernels
optimized_ops_lib
portable_kernels
pthreadpool
eigen_blas
)
add_dependencies(optimized_kernels_test generate_wrapper)
target_include_directories(
optimized_kernels_test PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/include/optimized"
"${CMAKE_INSTALL_PREFIX}/include"
)
if(TARGET quantized_kernels)
set(_quantized_kernels_test_sources
"${EXECUTORCH_ROOT}/kernels/quantized/test/op_add_test.cpp"
"${EXECUTORCH_ROOT}/kernels/quantized/test/op_choose_qparams_test.cpp"
"${EXECUTORCH_ROOT}/kernels/quantized/test/op_embedding2b_test.cpp"
"${EXECUTORCH_ROOT}/kernels/quantized/test/op_embedding4b_test.cpp"
"${EXECUTORCH_ROOT}/kernels/quantized/test/op_embedding_test.cpp"
"${EXECUTORCH_ROOT}/kernels/quantized/test/op_mixed_linear_test.cpp"
"${EXECUTORCH_ROOT}/kernels/quantized/test/op_mixed_mm_test.cpp"
"${EXECUTORCH_ROOT}/kernels/quantized/test/op_quantize_test.cpp"
)
et_cxx_test(
quantized_kernels_test
SOURCES
${_quantized_kernels_test_sources}
EXTRA_LIBS
cpuinfo
extension_threadpool
quantized_kernels
quantized_ops_lib
portable_kernels
portable_ops_lib
pthreadpool
eigen_blas
)
add_dependencies(quantized_kernels_test generate_wrapper)
target_include_directories(
quantized_kernels_test
PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/include/quantized"
"${CMAKE_CURRENT_BINARY_DIR}/include/portable"
)
endif()