onnxruntime

Форк
0
/
onnxruntime_unittests.cmake 
1803 строки · 83.3 Кб
1
# Copyright (c) Microsoft Corporation. All rights reserved.
2
# Licensed under the MIT License.
3
if (IOS)
4
  find_package(XCTest REQUIRED)
5
endif()
6

7
set(TEST_SRC_DIR ${ONNXRUNTIME_ROOT}/test)
8
set(TEST_INC_DIR ${ONNXRUNTIME_ROOT})
9
if (onnxruntime_ENABLE_TRAINING)
10
  list(APPEND TEST_INC_DIR ${ORTTRAINING_ROOT})
11
endif()
12
if (onnxruntime_USE_TVM)
13
  list(APPEND TEST_INC_DIR ${TVM_INCLUDES})
14
endif()
15

16
set(disabled_warnings)
17
function(AddTest)
18
  cmake_parse_arguments(_UT "DYN" "TARGET" "LIBS;SOURCES;DEPENDS;TEST_ARGS" ${ARGN})
19
  list(REMOVE_DUPLICATES _UT_SOURCES)
20

21
  if (IOS)
22
    onnxruntime_add_executable(${_UT_TARGET} ${TEST_SRC_DIR}/xctest/orttestmain.m)
23
  else()
24
    onnxruntime_add_executable(${_UT_TARGET} ${_UT_SOURCES})
25
  endif()
26
  if (_UT_DEPENDS)
27
    list(REMOVE_DUPLICATES _UT_DEPENDS)
28
  endif(_UT_DEPENDS)
29

30
  if(_UT_LIBS)
31
    list(REMOVE_DUPLICATES _UT_LIBS)
32
  endif()
33

34
  source_group(TREE ${REPO_ROOT} FILES ${_UT_SOURCES})
35

36
  if (MSVC AND NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
37
    #TODO: fix the warnings, they are dangerous
38
    target_compile_options(${_UT_TARGET} PRIVATE "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:--compiler-options /wd4244>"
39
                "$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:/wd4244>")
40
  endif()
41
  if (MSVC)
42
    target_compile_options(${_UT_TARGET} PRIVATE "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:--compiler-options /wd6330>"
43
                "$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:/wd6330>")
44
    #Abseil has a lot of C4127/C4324 warnings.
45
    target_compile_options(${_UT_TARGET} PRIVATE "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:--compiler-options /wd4127>"
46
                "$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:/wd4127>")
47
    target_compile_options(${_UT_TARGET} PRIVATE "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:--compiler-options /wd4324>"
48
                "$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:/wd4324>")
49
  endif()
50

51
  set_target_properties(${_UT_TARGET} PROPERTIES FOLDER "ONNXRuntimeTest")
52

53
  if (MSVC)
54
    # set VS debugger working directory to the test program's directory
55
    set_target_properties(${_UT_TARGET} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY $<TARGET_FILE_DIR:${_UT_TARGET}>)
56
  endif()
57

58
  if (_UT_DEPENDS)
59
    add_dependencies(${_UT_TARGET} ${_UT_DEPENDS})
60
  endif(_UT_DEPENDS)
61

62
  if(_UT_DYN)
63
    target_link_libraries(${_UT_TARGET} PRIVATE ${_UT_LIBS} GTest::gtest GTest::gmock onnxruntime ${CMAKE_DL_LIBS}
64
            Threads::Threads)
65
    target_compile_definitions(${_UT_TARGET} PRIVATE -DUSE_ONNXRUNTIME_DLL)
66
  else()
67
    if(onnxruntime_USE_CUDA)
68
      #XXX: we should not need to do this. onnxruntime_test_all.exe should not have direct dependency on CUDA DLLs,
69
      # otherwise it will impact when CUDA DLLs can be unloaded.
70
      target_link_libraries(${_UT_TARGET} PRIVATE CUDA::cudart cudnn_frontend)
71
    endif()
72
    target_link_libraries(${_UT_TARGET} PRIVATE ${_UT_LIBS} GTest::gtest GTest::gmock ${onnxruntime_EXTERNAL_LIBRARIES})
73
  endif()
74

75
  onnxruntime_add_include_to_target(${_UT_TARGET} date::date flatbuffers::flatbuffers)
76
  target_include_directories(${_UT_TARGET} PRIVATE ${TEST_INC_DIR})
77
  if (onnxruntime_USE_CUDA)
78
    target_include_directories(${_UT_TARGET} PRIVATE ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES} ${CUDNN_INCLUDE_DIR})
79
    if (onnxruntime_USE_NCCL)
80
      target_include_directories(${_UT_TARGET} PRIVATE ${NCCL_INCLUDE_DIRS})
81
    endif()
82
    if(onnxruntime_CUDA_MINIMAL)
83
      target_compile_definitions(${_UT_TARGET} PRIVATE -DUSE_CUDA_MINIMAL)
84
    endif()
85
  endif()
86
  if (onnxruntime_USE_TENSORRT)
87
    # used for instantiating placeholder TRT builder to mitigate TRT library load/unload overhead
88
    target_include_directories(${_UT_TARGET} PRIVATE ${TENSORRT_INCLUDE_DIR})
89
  endif()
90

91
  if(MSVC)
92
    target_compile_options(${_UT_TARGET} PRIVATE "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:--compiler-options /utf-8>"
93
            "$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:/utf-8>")
94
  endif()
95

96
  if (WIN32)
97
    # include dbghelp in case tests throw an ORT exception, as that exception includes a stacktrace, which requires dbghelp.
98
    target_link_libraries(${_UT_TARGET} PRIVATE debug dbghelp)
99

100
    if (MSVC)
101
      # warning C6326: Potential comparison of a constant with another constant.
102
      # Lot of such things came from gtest
103
      target_compile_options(${_UT_TARGET} PRIVATE "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:--compiler-options /wd6326>"
104
                "$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:/wd6326>")
105
      # Raw new and delete. A lot of such things came from googletest.
106
      target_compile_options(${_UT_TARGET} PRIVATE "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:--compiler-options /wd26409>"
107
                "$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:/wd26409>")
108
      # "Global initializer calls a non-constexpr function."
109
      target_compile_options(${_UT_TARGET} PRIVATE "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:--compiler-options /wd26426>"
110
                "$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:/wd26426>")
111
    endif()
112
    target_compile_options(${_UT_TARGET} PRIVATE ${disabled_warnings})
113
  else()
114
    target_compile_options(${_UT_TARGET} PRIVATE ${DISABLED_WARNINGS_FOR_TVM})
115
    target_compile_options(${_UT_TARGET} PRIVATE "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:--compiler-options -Wno-error=sign-compare>"
116
            "$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:-Wno-error=sign-compare>")
117
    if (${HAS_NOERROR})
118
      target_compile_options(${_UT_TARGET} PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:-Wno-error=uninitialized>")
119
    endif()
120
  endif()
121

122
  set(TEST_ARGS ${_UT_TEST_ARGS})
123
  if (onnxruntime_GENERATE_TEST_REPORTS)
124
    # generate a report file next to the test program
125
    if (CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
126
      # WebAssembly use a memory file system, so we do not use full path
127
      list(APPEND TEST_ARGS
128
        "--gtest_output=xml:$<TARGET_FILE_NAME:${_UT_TARGET}>.$<CONFIG>.results.xml")
129
    else()
130
      list(APPEND TEST_ARGS
131
        "--gtest_output=xml:$<SHELL_PATH:$<TARGET_FILE:${_UT_TARGET}>.$<CONFIG>.results.xml>")
132
    endif()
133
  endif(onnxruntime_GENERATE_TEST_REPORTS)
134

135
  if (IOS)
136
    # target_sources(${_UT_TARGET} PRIVATE ${TEST_SRC_DIR}/xctest/orttestmain.m)
137
    set_target_properties(${_UT_TARGET} PROPERTIES FOLDER "ONNXRuntimeTest"
138
      MACOSX_BUNDLE_BUNDLE_NAME ${_UT_TARGET}
139
      MACOSX_BUNDLE_GUI_IDENTIFIER com.onnxruntime.utest.${_UT_TARGET}
140
      MACOSX_BUNDLE_LONG_VERSION_STRING ${ORT_VERSION}
141
      MACOSX_BUNDLE_BUNDLE_VERSION ${ORT_VERSION}
142
      MACOSX_BUNDLE_SHORT_VERSION_STRING ${ORT_VERSION}
143
      XCODE_ATTRIBUTE_CLANG_ENABLE_MODULES "YES"
144
      XCODE_ATTRIBUTE_ENABLE_BITCODE "NO"
145
      XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO")
146

147
    xctest_add_bundle(${_UT_TARGET}_xc ${_UT_TARGET}
148
      ${TEST_SRC_DIR}/xctest/ortxctest.m
149
      ${TEST_SRC_DIR}/xctest/xcgtest.mm
150
      ${_UT_SOURCES})
151
    onnxruntime_configure_target(${_UT_TARGET}_xc)
152
    if(_UT_DYN)
153
      target_link_libraries(${_UT_TARGET}_xc PRIVATE ${_UT_LIBS} GTest::gtest GTest::gmock onnxruntime ${CMAKE_DL_LIBS}
154
              Threads::Threads)
155
      target_compile_definitions(${_UT_TARGET}_xc PRIVATE USE_ONNXRUNTIME_DLL)
156
    else()
157
      target_link_libraries(${_UT_TARGET}_xc PRIVATE ${_UT_LIBS} GTest::gtest GTest::gmock ${onnxruntime_EXTERNAL_LIBRARIES})
158
    endif()
159
    onnxruntime_add_include_to_target(${_UT_TARGET}_xc date::date flatbuffers::flatbuffers)
160
    target_include_directories(${_UT_TARGET}_xc PRIVATE ${TEST_INC_DIR})
161
    get_target_property(${_UT_TARGET}_DEFS ${_UT_TARGET} COMPILE_DEFINITIONS)
162
    target_compile_definitions(${_UT_TARGET}_xc PRIVATE ${_UT_TARGET}_DEFS)
163

164
    set_target_properties(${_UT_TARGET}_xc PROPERTIES FOLDER "ONNXRuntimeXCTest"
165
      MACOSX_BUNDLE_BUNDLE_NAME ${_UT_TARGET}_xc
166
      MACOSX_BUNDLE_GUI_IDENTIFIER com.onnxruntime.utest.${_UT_TARGET}
167
      MACOSX_BUNDLE_LONG_VERSION_STRING ${ORT_VERSION}
168
      MACOSX_BUNDLE_BUNDLE_VERSION ${ORT_VERSION}
169
      MACOSX_BUNDLE_SHORT_VERSION_STRING ${ORT_VERSION}
170
      XCODE_ATTRIBUTE_ENABLE_BITCODE "NO")
171

172
    xctest_add_test(xctest.${_UT_TARGET} ${_UT_TARGET}_xc)
173
  else()
174
    if (CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
175
      # We might have already executed the following "find_program" code when we build ORT nodejs binding.
176
      # Then the program is found the result is stored in the variable and the search will not be repeated.
177
      find_program(NPM_CLI
178
         NAMES "npm.cmd" "npm"
179
         DOC "NPM command line client"
180
         REQUIRED
181
      )
182

183
      if (onnxruntime_WEBASSEMBLY_RUN_TESTS_IN_BROWSER)
184
        add_custom_command(TARGET ${_UT_TARGET} POST_BUILD
185
          COMMAND ${CMAKE_COMMAND} -E copy_if_different ${TEST_SRC_DIR}/wasm/package.json $<TARGET_FILE_DIR:${_UT_TARGET}>
186
          COMMAND ${CMAKE_COMMAND} -E copy_if_different ${TEST_SRC_DIR}/wasm/package-lock.json $<TARGET_FILE_DIR:${_UT_TARGET}>
187
          COMMAND ${CMAKE_COMMAND} -E copy_if_different ${TEST_SRC_DIR}/wasm/karma.conf.js $<TARGET_FILE_DIR:${_UT_TARGET}>
188
          COMMAND ${NPM_CLI} ci
189
          WORKING_DIRECTORY $<TARGET_FILE_DIR:${_UT_TARGET}>
190
        )
191

192
        set(TEST_NPM_FLAGS)
193
        if (onnxruntime_ENABLE_WEBASSEMBLY_THREADS)
194
          list(APPEND TEST_NPM_FLAGS "--wasm-threads")
195
        endif()
196
        add_test(NAME ${_UT_TARGET}
197
          COMMAND ${NPM_CLI} test -- ${TEST_NPM_FLAGS} --entry=${_UT_TARGET} ${TEST_ARGS}
198
          WORKING_DIRECTORY $<TARGET_FILE_DIR:${_UT_TARGET}>
199
        )
200
      else()
201
        set(TEST_NODE_FLAGS)
202
        if (onnxruntime_ENABLE_WEBASSEMBLY_THREADS)
203
          list(APPEND TEST_NODE_FLAGS "--experimental-wasm-threads")
204
        endif()
205
        if (onnxruntime_ENABLE_WEBASSEMBLY_SIMD)
206
          list(APPEND TEST_NODE_FLAGS "--experimental-wasm-simd")
207
        endif()
208

209
        # prefer Node from emsdk so the version is more deterministic
210
        if (DEFINED ENV{EMSDK_NODE})
211
          set(NODE_EXECUTABLE $ENV{EMSDK_NODE})
212
        else()
213
          # warning as we don't know what node version is being used and whether things like the TEST_NODE_FLAGS
214
          # will be valid. e.g. "--experimental-wasm-simd" is not valid with node v20 or later.
215
          message(WARNING "EMSDK_NODE environment variable was not set. Falling back to system `node`.")
216
          set(NODE_EXECUTABLE node)
217
        endif()
218

219
        add_test(NAME ${_UT_TARGET}
220
          COMMAND ${NODE_EXECUTABLE} ${TEST_NODE_FLAGS} ${_UT_TARGET}.js ${TEST_ARGS}
221
          WORKING_DIRECTORY $<TARGET_FILE_DIR:${_UT_TARGET}>
222
        )
223
      endif()
224
      # Set test timeout to 3 hours.
225
      set_tests_properties(${_UT_TARGET} PROPERTIES TIMEOUT 7200)
226
    else()
227
      add_test(NAME ${_UT_TARGET}
228
        COMMAND ${_UT_TARGET} ${TEST_ARGS}
229
        WORKING_DIRECTORY $<TARGET_FILE_DIR:${_UT_TARGET}>
230
      )
231
      # Set test timeout to 3 hours.
232
      set_tests_properties(${_UT_TARGET} PROPERTIES TIMEOUT 7200)
233
    endif()
234
  endif()
235
endfunction(AddTest)
236

237
# general program entrypoint for C++ unit tests
238
set(onnxruntime_unittest_main_src "${TEST_SRC_DIR}/unittest_main/test_main.cc")
239

240
#Do not add '${TEST_SRC_DIR}/util/include' to your include directories directly
241
#Use onnxruntime_add_include_to_target or target_link_libraries, so that compile definitions
242
#can propagate correctly.
243

244
file(GLOB onnxruntime_test_utils_src CONFIGURE_DEPENDS
245
  "${TEST_SRC_DIR}/util/include/*.h"
246
  "${TEST_SRC_DIR}/util/*.cc"
247
)
248

249
file(GLOB onnxruntime_test_common_src CONFIGURE_DEPENDS
250
  "${TEST_SRC_DIR}/common/*.cc"
251
  "${TEST_SRC_DIR}/common/*.h"
252
  "${TEST_SRC_DIR}/common/logging/*.cc"
253
  "${TEST_SRC_DIR}/common/logging/*.h"
254
)
255

256
file(GLOB onnxruntime_test_quantization_src CONFIGURE_DEPENDS
257
  "${TEST_SRC_DIR}/quantization/*.cc"
258
  "${TEST_SRC_DIR}/quantization/*.h"
259
)
260

261
file(GLOB onnxruntime_test_flatbuffers_src CONFIGURE_DEPENDS
262
  "${TEST_SRC_DIR}/flatbuffers/*.cc"
263
  "${TEST_SRC_DIR}/flatbuffers/*.h"
264
)
265

266
if(NOT onnxruntime_MINIMAL_BUILD AND NOT onnxruntime_REDUCED_OPS_BUILD)
267

268
  file(GLOB onnxruntime_test_ir_src CONFIGURE_DEPENDS
269
    "${TEST_SRC_DIR}/ir/*.cc"
270
    "${TEST_SRC_DIR}/ir/*.h"
271
    )
272

273
  file(GLOB onnxruntime_test_optimizer_src CONFIGURE_DEPENDS
274
    "${TEST_SRC_DIR}/optimizer/*.cc"
275
    "${TEST_SRC_DIR}/optimizer/*.h"
276
    )
277

278
  set(onnxruntime_test_framework_src_patterns
279
    "${TEST_SRC_DIR}/framework/*.cc"
280
    "${TEST_SRC_DIR}/framework/*.h"
281
    "${TEST_SRC_DIR}/platform/*.cc"
282
    )
283

284
else()  # minimal and/or reduced ops build
285

286
  set(onnxruntime_test_framework_src_patterns
287
    "${TEST_SRC_DIR}/platform/*.cc"
288
    )
289

290
  if (onnxruntime_MINIMAL_BUILD AND NOT onnxruntime_REDUCED_OPS_BUILD)
291
    list(APPEND onnxruntime_test_framework_src_patterns
292
      "${TEST_SRC_DIR}/framework/ort_model_only_test.cc"
293
    )
294
  endif()
295

296
  if (NOT onnxruntime_MINIMAL_BUILD)
297
    file(GLOB onnxruntime_test_ir_src CONFIGURE_DEPENDS
298
      "${TEST_SRC_DIR}/ir/*.cc"
299
      "${TEST_SRC_DIR}/ir/*.h"
300
      )
301
  endif()
302
endif()
303

304
if((NOT onnxruntime_MINIMAL_BUILD OR onnxruntime_EXTENDED_MINIMAL_BUILD)
305
   AND NOT onnxruntime_REDUCED_OPS_BUILD)
306
  list(APPEND onnxruntime_test_optimizer_src
307
       "${TEST_SRC_DIR}/optimizer/runtime_optimization/graph_runtime_optimization_test.cc")
308
endif()
309

310
file(GLOB onnxruntime_test_training_src
311
  "${ORTTRAINING_SOURCE_DIR}/test/model/*.h"
312
  "${ORTTRAINING_SOURCE_DIR}/test/model/*.cc"
313
  "${ORTTRAINING_SOURCE_DIR}/test/gradient/*.h"
314
  "${ORTTRAINING_SOURCE_DIR}/test/gradient/*.cc"
315
  "${ORTTRAINING_SOURCE_DIR}/test/graph/*.h"
316
  "${ORTTRAINING_SOURCE_DIR}/test/graph/*.cc"
317
  "${ORTTRAINING_SOURCE_DIR}/test/session/*.h"
318
  "${ORTTRAINING_SOURCE_DIR}/test/session/*.cc"
319
  "${ORTTRAINING_SOURCE_DIR}/test/optimizer/*.h"
320
  "${ORTTRAINING_SOURCE_DIR}/test/optimizer/*.cc"
321
  "${ORTTRAINING_SOURCE_DIR}/test/framework/*.cc"
322
  "${ORTTRAINING_SOURCE_DIR}/test/distributed/*.h"
323
  "${ORTTRAINING_SOURCE_DIR}/test/distributed/*.cc"
324
  )
325

326
# TODO (baijumeswani): Remove the minimal build check here.
327
#                      The training api tests should be runnable even on a minimal build.
328
#                      This requires converting all the *.onnx files to ort format.
329
if (NOT onnxruntime_MINIMAL_BUILD)
330
  if (onnxruntime_ENABLE_TRAINING_APIS)
331
    file(GLOB onnxruntime_test_training_api_src
332
      "${ORTTRAINING_SOURCE_DIR}/test/training_api/common/*.cc"
333
      "${ORTTRAINING_SOURCE_DIR}/test/training_api/common/*.h"
334
      "${ORTTRAINING_SOURCE_DIR}/test/training_api/core/*.cc"
335
      "${ORTTRAINING_SOURCE_DIR}/test/training_api/core/*.h"
336
      )
337
  endif()
338
endif()
339

340
if(WIN32)
341
  list(APPEND onnxruntime_test_framework_src_patterns
342
    "${TEST_SRC_DIR}/platform/windows/*.cc"
343
    "${TEST_SRC_DIR}/platform/windows/logging/*.cc" )
344
endif()
345

346
if(NOT onnxruntime_MINIMAL_BUILD AND NOT onnxruntime_REDUCED_OPS_BUILD)
347

348
  if(onnxruntime_USE_CUDA)
349
    list(APPEND onnxruntime_test_framework_src_patterns  ${TEST_SRC_DIR}/framework/cuda/*)
350
  endif()
351

352
  set(onnxruntime_test_providers_src_patterns
353
    "${TEST_SRC_DIR}/providers/*.h"
354
    "${TEST_SRC_DIR}/providers/*.cc"
355
    "${TEST_SRC_DIR}/opaque_api/test_opaque_api.cc"
356
    "${TEST_SRC_DIR}/framework/TestAllocatorManager.cc"
357
    "${TEST_SRC_DIR}/framework/TestAllocatorManager.h"
358
    "${TEST_SRC_DIR}/framework/test_utils.cc"
359
    "${TEST_SRC_DIR}/framework/test_utils.h"
360
  )
361

362
  if(NOT onnxruntime_DISABLE_CONTRIB_OPS)
363
    list(APPEND onnxruntime_test_providers_src_patterns
364
      "${TEST_SRC_DIR}/contrib_ops/*.h"
365
      "${TEST_SRC_DIR}/contrib_ops/*.cc"
366
      "${TEST_SRC_DIR}/contrib_ops/math/*.h"
367
      "${TEST_SRC_DIR}/contrib_ops/math/*.cc")
368
  endif()
369

370
else()
371
  set(onnxruntime_test_providers_src_patterns
372
    "${TEST_SRC_DIR}/framework/test_utils.cc"
373
    "${TEST_SRC_DIR}/framework/test_utils.h"
374
    # TODO: Add anything that is needed for testing a minimal build
375
  )
376
endif()
377

378
file(GLOB onnxruntime_test_providers_src CONFIGURE_DEPENDS ${onnxruntime_test_providers_src_patterns})
379

380
if(NOT onnxruntime_MINIMAL_BUILD AND NOT onnxruntime_REDUCED_OPS_BUILD)
381
  file(GLOB_RECURSE onnxruntime_test_providers_cpu_src CONFIGURE_DEPENDS
382
    "${TEST_SRC_DIR}/providers/cpu/*"
383
    )
384
endif()
385

386
if(onnxruntime_DISABLE_ML_OPS)
387
  list(FILTER onnxruntime_test_providers_cpu_src EXCLUDE REGEX ".*/ml/.*")
388
endif()
389

390
list(APPEND onnxruntime_test_providers_src ${onnxruntime_test_providers_cpu_src})
391

392
if (onnxruntime_USE_CUDA AND NOT onnxruntime_MINIMAL_BUILD AND NOT onnxruntime_REDUCED_OPS_BUILD)
393
  file(GLOB onnxruntime_test_providers_cuda_src CONFIGURE_DEPENDS
394
    "${TEST_SRC_DIR}/providers/cuda/*"
395
    )
396
  list(APPEND onnxruntime_test_providers_src ${onnxruntime_test_providers_cuda_src})
397

398
  if (onnxruntime_USE_CUDA_NHWC_OPS AND CUDNN_MAJOR_VERSION GREATER 8)
399
    file(GLOB onnxruntime_test_providers_cuda_nhwc_src CONFIGURE_DEPENDS
400
      "${TEST_SRC_DIR}/providers/cuda/nhwc/*.cc"
401
    )
402
    list(APPEND onnxruntime_test_providers_src ${onnxruntime_test_providers_cuda_nhwc_src})
403
  endif()
404
endif()
405

406
if (onnxruntime_USE_CANN)
407
  file(GLOB_RECURSE onnxruntime_test_providers_cann_src CONFIGURE_DEPENDS
408
    "${TEST_SRC_DIR}/providers/cann/*"
409
    )
410
  list(APPEND onnxruntime_test_providers_src ${onnxruntime_test_providers_cann_src})
411
endif()
412

413
# Disable training ops test for minimal build as a lot of these depend on loading an onnx model.
414
if (NOT onnxruntime_MINIMAL_BUILD)
415
  if (onnxruntime_ENABLE_TRAINING_OPS)
416
    file(GLOB_RECURSE orttraining_test_trainingops_cpu_src CONFIGURE_DEPENDS
417
      "${ORTTRAINING_SOURCE_DIR}/test/training_ops/compare_provider_test_utils.cc"
418
      "${ORTTRAINING_SOURCE_DIR}/test/training_ops/function_op_test_utils.cc"
419
      "${ORTTRAINING_SOURCE_DIR}/test/training_ops/cpu/*"
420
      )
421

422
    if (NOT onnxruntime_ENABLE_TRAINING)
423
      list(REMOVE_ITEM orttraining_test_trainingops_cpu_src
424
        "${ORTTRAINING_SOURCE_DIR}/test/training_ops/cpu/tensorboard/summary_op_test.cc"
425
        )
426
    endif()
427

428
    list(APPEND onnxruntime_test_providers_src ${orttraining_test_trainingops_cpu_src})
429

430
    if (onnxruntime_USE_CUDA OR onnxruntime_USE_ROCM)
431
      file(GLOB_RECURSE orttraining_test_trainingops_cuda_src CONFIGURE_DEPENDS
432
        "${ORTTRAINING_SOURCE_DIR}/test/training_ops/cuda/*"
433
        )
434
      list(APPEND onnxruntime_test_providers_src ${orttraining_test_trainingops_cuda_src})
435
    endif()
436
  endif()
437
endif()
438

439
if (onnxruntime_USE_DNNL)
440
  file(GLOB_RECURSE onnxruntime_test_providers_dnnl_src CONFIGURE_DEPENDS
441
    "${TEST_SRC_DIR}/providers/dnnl/*"
442
    )
443
  list(APPEND onnxruntime_test_providers_src ${onnxruntime_test_providers_dnnl_src})
444
endif()
445

446
if (onnxruntime_USE_NNAPI_BUILTIN)
447
  file(GLOB_RECURSE onnxruntime_test_providers_nnapi_src CONFIGURE_DEPENDS
448
    "${TEST_SRC_DIR}/providers/nnapi/*"
449
    )
450
  list(APPEND onnxruntime_test_providers_src ${onnxruntime_test_providers_nnapi_src})
451
endif()
452

453
if (onnxruntime_USE_RKNPU)
454
  file(GLOB_RECURSE onnxruntime_test_providers_rknpu_src CONFIGURE_DEPENDS
455
    "${TEST_SRC_DIR}/providers/rknpu/*"
456
    )
457
  list(APPEND onnxruntime_test_providers_src ${onnxruntime_test_providers_rknpu_src})
458
endif()
459

460
if (NOT onnxruntime_MINIMAL_BUILD OR onnxruntime_EXTENDED_MINIMAL_BUILD)
461
  file(GLOB_RECURSE onnxruntime_test_providers_internal_testing_src CONFIGURE_DEPENDS
462
    "${TEST_SRC_DIR}/providers/internal_testing/*"
463
    )
464
  list(APPEND onnxruntime_test_providers_src ${onnxruntime_test_providers_internal_testing_src})
465
endif()
466

467
set (ONNXRUNTIME_SHARED_LIB_TEST_SRC_DIR "${TEST_SRC_DIR}/shared_lib")
468
set (ONNXRUNTIME_GLOBAL_THREAD_POOLS_TEST_SRC_DIR "${TEST_SRC_DIR}/global_thread_pools")
469
set (ONNXRUNTIME_CUSTOM_OP_REGISTRATION_TEST_SRC_DIR "${TEST_SRC_DIR}/custom_op_registration")
470
set (ONNXRUNTIME_LOGGING_APIS_TEST_SRC_DIR "${TEST_SRC_DIR}/logging_apis")
471

472
set (onnxruntime_shared_lib_test_SRC
473
          ${ONNXRUNTIME_SHARED_LIB_TEST_SRC_DIR}/test_fixture.h
474
          ${ONNXRUNTIME_SHARED_LIB_TEST_SRC_DIR}/test_session_options.cc
475
          ${ONNXRUNTIME_SHARED_LIB_TEST_SRC_DIR}/test_run_options.cc
476
          ${ONNXRUNTIME_SHARED_LIB_TEST_SRC_DIR}/test_allocator.cc
477
          ${ONNXRUNTIME_SHARED_LIB_TEST_SRC_DIR}/test_nontensor_types.cc
478
          ${ONNXRUNTIME_SHARED_LIB_TEST_SRC_DIR}/test_model_loading.cc
479
          ${ONNXRUNTIME_SHARED_LIB_TEST_SRC_DIR}/test_ort_format_models.cc
480
          ${ONNXRUNTIME_SHARED_LIB_TEST_SRC_DIR}/utils.h
481
          ${ONNXRUNTIME_SHARED_LIB_TEST_SRC_DIR}/utils.cc
482
          ${ONNXRUNTIME_SHARED_LIB_TEST_SRC_DIR}/custom_op_utils.h
483
          ${ONNXRUNTIME_SHARED_LIB_TEST_SRC_DIR}/custom_op_utils.cc)
484

485
if (NOT onnxruntime_MINIMAL_BUILD)
486
  list(APPEND onnxruntime_shared_lib_test_SRC ${ONNXRUNTIME_SHARED_LIB_TEST_SRC_DIR}/test_inference.cc)
487
endif()
488

489
if(onnxruntime_RUN_ONNX_TESTS)
490
  list(APPEND onnxruntime_shared_lib_test_SRC ${ONNXRUNTIME_SHARED_LIB_TEST_SRC_DIR}/test_io_types.cc)
491
endif()
492

493
set (onnxruntime_global_thread_pools_test_SRC
494
          ${ONNXRUNTIME_SHARED_LIB_TEST_SRC_DIR}/test_fixture.h
495
          ${ONNXRUNTIME_GLOBAL_THREAD_POOLS_TEST_SRC_DIR}/test_main.cc
496
          ${ONNXRUNTIME_GLOBAL_THREAD_POOLS_TEST_SRC_DIR}/test_inference.cc)
497

498
# tests from lowest level library up.
499
# the order of libraries should be maintained, with higher libraries being added first in the list
500

501
set(onnxruntime_test_common_libs
502
  onnxruntime_test_utils
503
  onnxruntime_common
504
)
505

506
set(onnxruntime_test_ir_libs
507
  onnxruntime_test_utils
508
  onnxruntime_graph
509
  onnxruntime_common
510
)
511

512
set(onnxruntime_test_optimizer_libs
513
  onnxruntime_test_utils
514
  onnxruntime_framework
515
  onnxruntime_util
516
  onnxruntime_graph
517
  onnxruntime_common
518
)
519

520
set(onnxruntime_test_framework_libs
521
  onnxruntime_test_utils
522
  onnxruntime_framework
523
  onnxruntime_util
524
  onnxruntime_graph
525
  ${ONNXRUNTIME_MLAS_LIBS}
526
  onnxruntime_common
527
  )
528

529
set(onnxruntime_test_server_libs
530
  onnxruntime_test_utils
531
  onnxruntime_test_utils_for_server
532
)
533

534
if(WIN32)
535
    list(APPEND onnxruntime_test_framework_libs Advapi32)
536
endif()
537

538
set (onnxruntime_test_providers_dependencies ${onnxruntime_EXTERNAL_DEPENDENCIES})
539

540
if(onnxruntime_USE_CUDA)
541
  list(APPEND onnxruntime_test_providers_dependencies onnxruntime_providers_cuda)
542
endif()
543

544
if(onnxruntime_USE_CANN)
545
  list(APPEND onnxruntime_test_providers_dependencies onnxruntime_providers_cann)
546
endif()
547

548
if(onnxruntime_USE_NNAPI_BUILTIN)
549
  list(APPEND onnxruntime_test_providers_dependencies onnxruntime_providers_nnapi)
550
endif()
551

552
if(onnxruntime_USE_VSINPU)
553
  list(APPEND onnxruntime_test_providers_dependencies onnxruntime_providers_vsinpu)
554
endif()
555

556
if(onnxruntime_USE_JSEP)
557
  list(APPEND onnxruntime_test_providers_dependencies onnxruntime_providers_js)
558
endif()
559

560
if(onnxruntime_USE_RKNPU)
561
  list(APPEND onnxruntime_test_providers_dependencies onnxruntime_providers_rknpu)
562
endif()
563

564
if(onnxruntime_USE_DML)
565
  list(APPEND onnxruntime_test_providers_dependencies onnxruntime_providers_dml)
566
endif()
567

568
if(onnxruntime_USE_DNNL)
569
  list(APPEND onnxruntime_test_providers_dependencies onnxruntime_providers_dnnl)
570
endif()
571

572
if(onnxruntime_USE_MIGRAPHX)
573
  list(APPEND onnxruntime_test_framework_libs onnxruntime_providers_migraphx)
574
  list(APPEND onnxruntime_test_providers_dependencies onnxruntime_providers_migraphx onnxruntime_providers_shared)
575
endif()
576

577
if(onnxruntime_USE_ROCM)
578
  list(APPEND onnxruntime_test_providers_dependencies onnxruntime_providers_rocm)
579
endif()
580

581
if(onnxruntime_USE_COREML)
582
  list(APPEND onnxruntime_test_providers_dependencies onnxruntime_providers_coreml coreml_proto)
583
endif()
584

585
if(onnxruntime_USE_ACL)
586
  list(APPEND onnxruntime_test_providers_dependencies onnxruntime_providers_acl)
587
endif()
588

589
if(onnxruntime_USE_ARMNN)
590
  list(APPEND onnxruntime_test_providers_dependencies onnxruntime_providers_armnn)
591
endif()
592

593
set(ONNXRUNTIME_TEST_LIBS
594
    onnxruntime_session
595
    ${ONNXRUNTIME_INTEROP_TEST_LIBS}
596
    ${onnxruntime_libs}
597
    # CUDA, ROCM, TENSORRT, MIGRAPHX, DNNL, and OpenVINO are dynamically loaded at runtime
598
    ${PROVIDERS_NNAPI}
599
    ${PROVIDERS_VSINPU}
600
    ${PROVIDERS_JS}
601
    ${PROVIDERS_QNN}
602
    ${PROVIDERS_SNPE}
603
    ${PROVIDERS_RKNPU}
604
    ${PROVIDERS_DML}
605
    ${PROVIDERS_ACL}
606
    ${PROVIDERS_ARMNN}
607
    ${PROVIDERS_COREML}
608
    # ${PROVIDERS_TVM}
609
    ${PROVIDERS_XNNPACK}
610
    ${PROVIDERS_AZURE}
611
    onnxruntime_optimizer
612
    onnxruntime_providers
613
    onnxruntime_util
614
    ${onnxruntime_tvm_libs}
615
    onnxruntime_framework
616
    onnxruntime_util
617
    onnxruntime_graph
618
    ${ONNXRUNTIME_MLAS_LIBS}
619
    onnxruntime_common
620
    onnxruntime_flatbuffers
621
)
622

623
if (onnxruntime_ENABLE_TRAINING)
624
  set(ONNXRUNTIME_TEST_LIBS onnxruntime_training_runner onnxruntime_training ${ONNXRUNTIME_TEST_LIBS})
625
endif()
626

627
set(onnxruntime_test_providers_libs
628
    onnxruntime_test_utils
629
    ${ONNXRUNTIME_TEST_LIBS}
630
  )
631

632
if(onnxruntime_USE_TENSORRT)
633
  list(APPEND onnxruntime_test_framework_src_patterns  ${TEST_SRC_DIR}/providers/tensorrt/*)
634
  list(APPEND onnxruntime_test_framework_src_patterns  "${ONNXRUNTIME_ROOT}/core/providers/tensorrt/tensorrt_execution_provider_utils.h")
635
  list(APPEND onnxruntime_test_framework_libs onnxruntime_providers_tensorrt)
636
  list(APPEND onnxruntime_test_providers_dependencies onnxruntime_providers_tensorrt onnxruntime_providers_shared)
637
  list(APPEND onnxruntime_test_providers_libs ${TENSORRT_LIBRARY_INFER})
638
endif()
639

640
if(onnxruntime_USE_MIGRAPHX)
641
  list(APPEND onnxruntime_test_framework_src_patterns  ${TEST_SRC_DIR}/providers/migraphx/*)
642
  list(APPEND onnxruntime_test_framework_src_patterns  "${ONNXRUNTIME_ROOT}/core/providers/migraphx/migraphx_execution_provider_utils.h")
643
  list(APPEND onnxruntime_test_framework_libs onnxruntime_providers_migraphx)
644
  list(APPEND onnxruntime_test_providers_dependencies onnxruntime_providers_migraphx onnxruntime_providers_shared)
645
endif()
646

647
if(onnxruntime_USE_NNAPI_BUILTIN)
648
  list(APPEND onnxruntime_test_framework_src_patterns  ${TEST_SRC_DIR}/providers/nnapi/*)
649
  list(APPEND onnxruntime_test_framework_libs onnxruntime_providers_nnapi)
650
  list(APPEND onnxruntime_test_providers_dependencies onnxruntime_providers_nnapi)
651
  list(APPEND onnxruntime_test_providers_libs onnxruntime_providers_nnapi)
652
endif()
653

654
if(onnxruntime_USE_JSEP)
655
  list(APPEND onnxruntime_test_framework_src_patterns  ${TEST_SRC_DIR}/providers/js/*)
656
  list(APPEND onnxruntime_test_framework_libs onnxruntime_providers_js)
657
  list(APPEND onnxruntime_test_providers_dependencies onnxruntime_providers_js)
658
  list(APPEND onnxruntime_test_providers_libs onnxruntime_providers_js)
659
endif()
660

661
# QNN EP tests require CPU EP op implementations for accuracy evaluation, so disable on minimal
662
# or reduced op builds.
663
if(onnxruntime_USE_QNN AND NOT onnxruntime_MINIMAL_BUILD AND NOT onnxruntime_REDUCED_OPS_BUILD)
664
  list(APPEND onnxruntime_test_framework_src_patterns ${TEST_SRC_DIR}/providers/qnn/*)
665
  list(APPEND onnxruntime_test_framework_libs onnxruntime_providers_qnn)
666
  list(APPEND onnxruntime_test_providers_dependencies onnxruntime_providers_qnn)
667
  list(APPEND onnxruntime_test_providers_libs onnxruntime_providers_qnn)
668
endif()
669

670
if(onnxruntime_USE_SNPE)
671
  list(APPEND onnxruntime_test_framework_src_patterns  ${TEST_SRC_DIR}/providers/snpe/*)
672
  list(APPEND onnxruntime_test_framework_libs onnxruntime_providers_snpe)
673
  list(APPEND onnxruntime_test_providers_dependencies onnxruntime_providers_snpe)
674
  list(APPEND onnxruntime_test_providers_libs onnxruntime_providers_snpe)
675
endif()
676

677
if(onnxruntime_USE_RKNPU)
678
  list(APPEND onnxruntime_test_framework_src_patterns  ${TEST_SRC_DIR}/providers/rknpu/*)
679
  list(APPEND onnxruntime_test_framework_libs onnxruntime_providers_rknpu)
680
  list(APPEND onnxruntime_test_providers_dependencies onnxruntime_providers_rknpu)
681
  list(APPEND onnxruntime_test_providers_libs onnxruntime_providers_rknpu)
682
endif()
683

684
if(onnxruntime_USE_COREML)
685
  list(APPEND onnxruntime_test_framework_src_patterns ${TEST_SRC_DIR}/providers/coreml/*.cc)
686
  if(APPLE)
687
    list(APPEND onnxruntime_test_framework_src_patterns ${TEST_SRC_DIR}/providers/coreml/*.mm)
688
  endif()
689
  list(APPEND onnxruntime_test_framework_libs onnxruntime_providers_coreml coreml_proto)
690
  list(APPEND onnxruntime_test_providers_dependencies onnxruntime_providers_coreml coreml_proto)
691
  list(APPEND onnxruntime_test_providers_libs onnxruntime_providers_coreml coreml_proto)
692
endif()
693

694
if(onnxruntime_USE_XNNPACK)
695
  list(APPEND onnxruntime_test_framework_src_patterns  ${TEST_SRC_DIR}/providers/xnnpack/*)
696
  list(APPEND onnxruntime_test_framework_libs onnxruntime_providers_xnnpack)
697
  list(APPEND onnxruntime_test_providers_dependencies onnxruntime_providers_xnnpack)
698
  list(APPEND onnxruntime_test_providers_libs onnxruntime_providers_xnnpack)
699
endif()
700

701
if(onnxruntime_USE_AZURE)
702
  list(APPEND onnxruntime_test_framework_src_patterns  ${TEST_SRC_DIR}/providers/azure/*)
703
  list(APPEND onnxruntime_test_framework_libs onnxruntime_providers_azure)
704
  list(APPEND onnxruntime_test_providers_dependencies onnxruntime_providers_azure)
705
  list(APPEND onnxruntime_test_providers_libs onnxruntime_providers_azure)
706
endif()
707

708
if(WIN32)
709
  if (onnxruntime_USE_TVM)
710
    list(APPEND disabled_warnings ${DISABLED_WARNINGS_FOR_TVM})
711
  endif()
712
endif()
713

714
file(GLOB onnxruntime_test_framework_src CONFIGURE_DEPENDS
715
  ${onnxruntime_test_framework_src_patterns}
716
  )
717

718
#This is a small wrapper library that shouldn't use any onnxruntime internal symbols(except onnxruntime_common).
719
#Because it could dynamically link to onnxruntime. Otherwise you will have two copies of onnxruntime in the same
720
#process and you won't know which one you are testing.
721
onnxruntime_add_static_library(onnxruntime_test_utils ${onnxruntime_test_utils_src})
722
if(MSVC)
723
  target_compile_options(onnxruntime_test_utils PRIVATE "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:--compiler-options /utf-8>"
724
          "$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:/utf-8>")
725
  target_compile_options(onnxruntime_test_utils PRIVATE "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:--compiler-options /wd6326>"
726
                "$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:/wd6326>")
727
else()
728
  target_compile_definitions(onnxruntime_test_utils PUBLIC -DNSYNC_ATOMIC_CPP11)
729
  target_include_directories(onnxruntime_test_utils PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${ONNXRUNTIME_ROOT})
730
  onnxruntime_add_include_to_target(onnxruntime_test_utils nsync::nsync_cpp)
731
endif()
732
if (onnxruntime_USE_NCCL)
733
  target_include_directories(onnxruntime_test_utils PRIVATE ${NCCL_INCLUDE_DIRS})
734
endif()
735
if (onnxruntime_USE_ROCM)
736
  target_include_directories(onnxruntime_test_utils PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/amdgpu/onnxruntime ${CMAKE_CURRENT_BINARY_DIR}/amdgpu/orttraining)
737
endif()
738
onnxruntime_add_include_to_target(onnxruntime_test_utils onnxruntime_common onnxruntime_framework onnxruntime_session GTest::gtest GTest::gmock onnx onnx_proto flatbuffers::flatbuffers nlohmann_json::nlohmann_json Boost::mp11 safeint_interface)
739

740

741

742
if (onnxruntime_USE_DML)
743
  target_add_dml(onnxruntime_test_utils)
744
endif()
745
add_dependencies(onnxruntime_test_utils ${onnxruntime_EXTERNAL_DEPENDENCIES})
746
target_include_directories(onnxruntime_test_utils PUBLIC "${TEST_SRC_DIR}/util/include" PRIVATE
747
        ${eigen_INCLUDE_DIRS} ${ONNXRUNTIME_ROOT})
748
set_target_properties(onnxruntime_test_utils PROPERTIES FOLDER "ONNXRuntimeTest")
749
source_group(TREE ${TEST_SRC_DIR} FILES ${onnxruntime_test_utils_src})
750

751
if(NOT IOS)
752
    set(onnx_test_runner_src_dir ${TEST_SRC_DIR}/onnx)
753
    file(GLOB onnx_test_runner_common_srcs CONFIGURE_DEPENDS
754
        ${onnx_test_runner_src_dir}/*.h
755
        ${onnx_test_runner_src_dir}/*.cc)
756

757
    list(REMOVE_ITEM onnx_test_runner_common_srcs ${onnx_test_runner_src_dir}/main.cc)
758

759
    onnxruntime_add_static_library(onnx_test_runner_common ${onnx_test_runner_common_srcs})
760
    if(MSVC)
761
      target_compile_options(onnx_test_runner_common PRIVATE "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:--compiler-options /utf-8>"
762
              "$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:/utf-8>")
763
    else()
764
      target_compile_definitions(onnx_test_runner_common PUBLIC -DNSYNC_ATOMIC_CPP11)
765
      target_include_directories(onnx_test_runner_common PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${ONNXRUNTIME_ROOT})
766
      onnxruntime_add_include_to_target(onnx_test_runner_common nsync::nsync_cpp)
767
    endif()
768
    if (MSVC AND NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
769
      #TODO: fix the warnings, they are dangerous
770
      target_compile_options(onnx_test_runner_common PRIVATE "/wd4244")
771
    endif()
772
    onnxruntime_add_include_to_target(onnx_test_runner_common onnxruntime_common onnxruntime_framework
773
            onnxruntime_test_utils onnx onnx_proto re2::re2 flatbuffers::flatbuffers Boost::mp11 safeint_interface)
774

775
    add_dependencies(onnx_test_runner_common onnx_test_data_proto ${onnxruntime_EXTERNAL_DEPENDENCIES})
776
    target_include_directories(onnx_test_runner_common PRIVATE ${eigen_INCLUDE_DIRS}
777
            ${CMAKE_CURRENT_BINARY_DIR} ${ONNXRUNTIME_ROOT})
778

779
    set_target_properties(onnx_test_runner_common PROPERTIES FOLDER "ONNXRuntimeTest")
780
    set(onnx_test_runner_common_lib onnx_test_runner_common)
781
endif()
782

783
set(all_tests ${onnxruntime_test_common_src} ${onnxruntime_test_ir_src} ${onnxruntime_test_optimizer_src}
784
        ${onnxruntime_test_framework_src} ${onnxruntime_test_providers_src} ${onnxruntime_test_quantization_src}
785
        ${onnxruntime_test_flatbuffers_src})
786

787
if (onnxruntime_ENABLE_CUDA_EP_INTERNAL_TESTS)
788
  file(GLOB onnxruntime_test_providers_cuda_ut_src CONFIGURE_DEPENDS
789
    "${TEST_SRC_DIR}/providers/cuda/test_cases/*"
790
  )
791
  # onnxruntime_providers_cuda_ut is only for unittests.
792
  onnxruntime_add_shared_library_module(onnxruntime_providers_cuda_ut ${onnxruntime_test_providers_cuda_ut_src} $<TARGET_OBJECTS:onnxruntime_providers_cuda_obj>)
793
  config_cuda_provider_shared_module(onnxruntime_providers_cuda_ut)
794
  onnxruntime_add_include_to_target(onnxruntime_providers_cuda_ut GTest::gtest GTest::gmock)
795
  add_dependencies(onnxruntime_providers_cuda_ut onnxruntime_test_utils onnxruntime_common)
796
  target_include_directories(onnxruntime_providers_cuda_ut PRIVATE ${ONNXRUNTIME_ROOT}/core/mickey)
797
  target_link_libraries(onnxruntime_providers_cuda_ut PRIVATE GTest::gtest GTest::gmock ${ONNXRUNTIME_MLAS_LIBS} onnxruntime_test_utils onnxruntime_common)
798
  if (MSVC)
799
    # Cutlass code has an issue with the following:
800
    # warning C4100: 'magic': unreferenced formal parameter
801
    target_compile_options(onnxruntime_providers_cuda_ut PRIVATE "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:--compiler-options /wd4100>"
802
                  "$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:/wd4100>")
803
  endif()
804

805
  list(APPEND onnxruntime_test_providers_dependencies onnxruntime_providers_cuda_ut)
806
endif()
807

808
set(all_dependencies ${onnxruntime_test_providers_dependencies} )
809

810
if (onnxruntime_ENABLE_TRAINING)
811
  list(APPEND all_tests ${onnxruntime_test_training_src})
812
endif()
813

814
if (onnxruntime_ENABLE_TRAINING_APIS)
815
    list(APPEND all_tests ${onnxruntime_test_training_api_src})
816
endif()
817

818
if (onnxruntime_USE_TVM)
819
    list(APPEND all_tests ${onnxruntime_test_tvm_src})
820
endif()
821

822
if (onnxruntime_USE_OPENVINO)
823
  list(APPEND all_tests ${onnxruntime_test_openvino_src})
824
endif()
825

826
# this is only added to onnxruntime_test_framework_libs above, but we use onnxruntime_test_providers_libs for the onnxruntime_test_all target.
827
# for now, add it here. better is probably to have onnxruntime_test_providers_libs use the full onnxruntime_test_framework_libs
828
# list given it's built on top of that library and needs all the same dependencies.
829
if(WIN32)
830
  list(APPEND onnxruntime_test_providers_libs Advapi32)
831
endif()
832

833
if (CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
834
  if (NOT onnxruntime_ENABLE_WEBASSEMBLY_THREADS)
835
    list(REMOVE_ITEM all_tests
836
      "${TEST_SRC_DIR}/framework/execution_frame_test.cc"
837
      "${TEST_SRC_DIR}/framework/inference_session_test.cc"
838
      "${TEST_SRC_DIR}/platform/barrier_test.cc"
839
      "${TEST_SRC_DIR}/platform/threadpool_test.cc"
840
      "${TEST_SRC_DIR}/providers/cpu/controlflow/loop_test.cc"
841
      "${TEST_SRC_DIR}/providers/cpu/nn/string_normalizer_test.cc"
842
      "${TEST_SRC_DIR}/providers/memcpy_test.cc"
843
    )
844
  endif()
845
  list(REMOVE_ITEM all_tests "${TEST_SRC_DIR}/providers/cpu/reduction/reduction_ops_test.cc"
846
      "${TEST_SRC_DIR}/providers/cpu/tensor/grid_sample_test.cc")
847
endif()
848

849
if (CMAKE_SYSTEM_NAME STREQUAL "Emscripten" OR IOS)
850
   # Because we do not run these model tests in our web or iOS CI build pipelines, and some test code uses C++17
851
   # filesystem functions that are not available in the iOS version we target.
852
   message("Disable model tests in onnxruntime_test_all")
853
   list(REMOVE_ITEM all_tests
854
      "${TEST_SRC_DIR}/providers/cpu/model_tests.cc"
855
    )
856
endif()
857

858
set(test_all_args)
859
if (onnxruntime_USE_TENSORRT)
860
  # TRT EP CI takes much longer time when updating to TRT 8.2
861
  # So, we only run trt ep and exclude other eps to reduce CI test time.
862
  #
863
  # The test names of model tests were using sequential number in the past.
864
  # This PR https://github.com/microsoft/onnxruntime/pull/10220 (Please see ExpandModelName function in model_tests.cc for more details)
865
  # made test name contain the "ep" and "model path" information, so we can easily filter the tests using cuda ep or other ep with *cpu_* or *xxx_*.
866
  list(APPEND test_all_args "--gtest_filter=-*cpu_*:*cuda_*" )
867
endif ()
868
if(NOT onnxruntime_ENABLE_CUDA_EP_INTERNAL_TESTS)
869
  list(REMOVE_ITEM all_tests ${TEST_SRC_DIR}/providers/cuda/cuda_provider_test.cc)
870
endif()
871
AddTest(
872
  TARGET onnxruntime_test_all
873
  SOURCES ${all_tests} ${onnxruntime_unittest_main_src}
874
  LIBS
875
    ${onnx_test_runner_common_lib} ${onnxruntime_test_providers_libs} ${onnxruntime_test_common_libs}
876
    onnx_test_data_proto
877
  DEPENDS ${all_dependencies}
878
  TEST_ARGS ${test_all_args}
879
)
880

881
if (MSVC)
882
  # The warning means the type of two integral values around a binary operator is narrow than their result.
883
  # If we promote the two input values first, it could be more tolerant to integer overflow.
884
  # However, this is test code. We are less concerned.
885
  target_compile_options(onnxruntime_test_all PRIVATE "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:--compiler-options /wd26451>"
886
                "$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:/wd26451>")
887
  target_compile_options(onnxruntime_test_all PRIVATE "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:--compiler-options /wd4244>"
888
                "$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:/wd4244>")
889

890
  # Avoid this compile error in graph_transform_test.cc and qdq_transformer_test.cc:
891
  # fatal error C1128: number of sections exceeded object file format limit: compile with /bigobj
892
  set_property(SOURCE "${TEST_SRC_DIR}/optimizer/graph_transform_test.cc"
893
                      "${TEST_SRC_DIR}/optimizer/qdq_transformer_test.cc"
894
               APPEND PROPERTY COMPILE_OPTIONS "/bigobj")
895
  set_property(SOURCE "${TEST_SRC_DIR}/optimizer/qdq_transformer_test.cc"
896
               APPEND PROPERTY COMPILE_OPTIONS "/bigobj")
897
else()
898
  target_compile_options(onnxruntime_test_all PRIVATE "-Wno-parentheses")
899
endif()
900

901
# TODO fix shorten-64-to-32 warnings
902
# there are some in builds where sizeof(size_t) != sizeof(int64_t), e.g., in 'ONNX Runtime Web CI Pipeline'
903
if (HAS_SHORTEN_64_TO_32 AND NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
904
  target_compile_options(onnxruntime_test_all PRIVATE -Wno-error=shorten-64-to-32)
905
endif()
906

907
if (UNIX AND onnxruntime_USE_TENSORRT)
908
    # The test_main.cc includes NvInfer.h where it has many deprecated declarations
909
    # simply ignore them for TensorRT EP build
910
    set_property(TARGET onnxruntime_test_all APPEND_STRING PROPERTY COMPILE_FLAGS "-Wno-deprecated-declarations")
911
endif()
912

913
if (MSVC AND onnxruntime_ENABLE_STATIC_ANALYSIS)
914
# attention_op_test.cc: Function uses '49152' bytes of stack:  exceeds /analyze:stacksize '16384'..
915
target_compile_options(onnxruntime_test_all PRIVATE  "/analyze:stacksize 131072")
916
endif()
917

918
#In AIX + gcc compiler ,crash is observed with the usage of googletest EXPECT_THROW,
919
#because some needed symbol is garbaged out by linker.
920
#So, fix is to exports the symbols from executable.
921
#Another way is to use -Wl,-bkeepfile for each object file where EXPECT_THROW is used like below
922
#target_link_options(onnxruntime_test_all PRIVATE "-Wl,-bkeepfile:CMakeFiles/onnxruntime_test_all.dir${TEST_SRC_DIR}/framework/tensor_test.cc.o")
923
if (CMAKE_SYSTEM_NAME MATCHES "AIX" AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
924
  set_target_properties(onnxruntime_test_all PROPERTIES ENABLE_EXPORTS 1)
925
endif()
926

927
# the default logger tests conflict with the need to have an overall default logger
928
# so skip in this type of
929
target_compile_definitions(onnxruntime_test_all PUBLIC -DSKIP_DEFAULT_LOGGER_TESTS)
930
if (IOS)
931
  target_compile_definitions(onnxruntime_test_all_xc PUBLIC -DSKIP_DEFAULT_LOGGER_TESTS)
932
endif()
933
if(onnxruntime_RUN_MODELTEST_IN_DEBUG_MODE)
934
  target_compile_definitions(onnxruntime_test_all PUBLIC -DRUN_MODELTEST_IN_DEBUG_MODE)
935
endif()
936
if (onnxruntime_DEBUG_NODE_INPUTS_OUTPUTS)
937
  target_compile_definitions(onnxruntime_test_all PRIVATE DEBUG_NODE_INPUTS_OUTPUTS)
938
endif()
939
if (onnxruntime_USE_ROCM)
940
  if (onnxruntime_USE_COMPOSABLE_KERNEL)
941
    target_compile_definitions(onnxruntime_test_all PRIVATE USE_COMPOSABLE_KERNEL)
942
    if (onnxruntime_USE_COMPOSABLE_KERNEL_CK_TILE)
943
      target_compile_definitions(onnxruntime_test_all PRIVATE USE_COMPOSABLE_KERNEL_CK_TILE)
944
    endif()
945
  endif()
946
  target_compile_options(onnxruntime_test_all PRIVATE -D__HIP_PLATFORM_AMD__=1 -D__HIP_PLATFORM_HCC__=1)
947
  target_include_directories(onnxruntime_test_all PRIVATE  ${onnxruntime_ROCM_HOME}/hipfft/include ${onnxruntime_ROCM_HOME}/include ${onnxruntime_ROCM_HOME}/hiprand/include ${onnxruntime_ROCM_HOME}/rocrand/include ${CMAKE_CURRENT_BINARY_DIR}/amdgpu/onnxruntime ${CMAKE_CURRENT_BINARY_DIR}/amdgpu/orttraining)
948
endif()
949
if (onnxruntime_ENABLE_TRAINING_TORCH_INTEROP)
950
  target_link_libraries(onnxruntime_test_all PRIVATE Python::Python)
951
endif()
952
if (CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
953
  set_target_properties(onnxruntime_test_all PROPERTIES LINK_DEPENDS ${TEST_SRC_DIR}/wasm/onnxruntime_test_all_adapter.js)
954
  set_target_properties(onnxruntime_test_all PROPERTIES LINK_DEPENDS ${ONNXRUNTIME_ROOT}/wasm/pre.js)
955
  set_target_properties(onnxruntime_test_all PROPERTIES LINK_FLAGS "-s STACK_SIZE=5242880 -s INITIAL_MEMORY=536870912 -s ALLOW_MEMORY_GROWTH=1 -s MAXIMUM_MEMORY=4294967296 -s INCOMING_MODULE_JS_API=[preRun,locateFile,arguments,onExit,wasmMemory,buffer,instantiateWasm] --pre-js \"${TEST_SRC_DIR}/wasm/onnxruntime_test_all_adapter.js\" --pre-js \"${ONNXRUNTIME_ROOT}/wasm/pre.js\" -s \"EXPORTED_RUNTIME_METHODS=['FS']\" --preload-file ${CMAKE_CURRENT_BINARY_DIR}/testdata@/testdata -s EXIT_RUNTIME=1")
956
  if (onnxruntime_ENABLE_WEBASSEMBLY_THREADS)
957
    set_property(TARGET onnxruntime_test_all APPEND_STRING PROPERTY LINK_FLAGS " -s DEFAULT_PTHREAD_STACK_SIZE=131072 -s PROXY_TO_PTHREAD=1")
958
  endif()
959
  if (onnxruntime_USE_JSEP)
960
    set_target_properties(onnxruntime_test_all PROPERTIES LINK_DEPENDS ${ONNXRUNTIME_ROOT}/wasm/pre-jsep.js)
961
    set_property(TARGET onnxruntime_test_all APPEND_STRING PROPERTY LINK_FLAGS " --pre-js \"${ONNXRUNTIME_ROOT}/wasm/pre-jsep.js\"")
962
  endif()
963

964
  ###
965
  ### if you want to investigate or debug a test failure in onnxruntime_test_all, replace the following line.
966
  ### those flags slow down the CI test significantly, so we don't use them by default.
967
  ###
968
  #   set_property(TARGET onnxruntime_test_all APPEND_STRING PROPERTY LINK_FLAGS " -s ASSERTIONS=2 -s SAFE_HEAP=1 -s STACK_OVERFLOW_CHECK=2")
969
  set_property(TARGET onnxruntime_test_all APPEND_STRING PROPERTY LINK_FLAGS " -s ASSERTIONS=0 -s SAFE_HEAP=0 -s STACK_OVERFLOW_CHECK=1")
970
endif()
971

972
if (onnxruntime_ENABLE_ATEN)
973
  target_compile_definitions(onnxruntime_test_all PRIVATE ENABLE_ATEN)
974
endif()
975

976
set(test_data_target onnxruntime_test_all)
977

978
onnxruntime_add_static_library(onnx_test_data_proto ${TEST_SRC_DIR}/proto/tml.proto)
979
add_dependencies(onnx_test_data_proto onnx_proto ${onnxruntime_EXTERNAL_DEPENDENCIES})
980
#onnx_proto target should mark this definition as public, instead of private
981
target_compile_definitions(onnx_test_data_proto PRIVATE "-DONNX_API=")
982
onnxruntime_add_include_to_target(onnx_test_data_proto onnx_proto)
983
target_include_directories(onnx_test_data_proto PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
984
set_target_properties(onnx_test_data_proto PROPERTIES FOLDER "ONNXRuntimeTest")
985
onnxruntime_protobuf_generate(APPEND_PATH IMPORT_DIRS ${onnx_SOURCE_DIR} TARGET onnx_test_data_proto)
986

987
#
988
# onnxruntime_ir_graph test data
989
#
990
set(TEST_DATA_SRC ${TEST_SRC_DIR}/testdata)
991
set(TEST_DATA_DES $<TARGET_FILE_DIR:${test_data_target}>/testdata)
992

993
set(TEST_SAMPLES_SRC ${REPO_ROOT}/samples)
994
set(TEST_SAMPLES_DES $<TARGET_FILE_DIR:${test_data_target}>/samples)
995

996
# Copy test data from source to destination.
997
add_custom_command(
998
  TARGET ${test_data_target} PRE_BUILD
999
  COMMAND ${CMAKE_COMMAND} -E copy_directory
1000
  ${TEST_DATA_SRC}
1001
  ${TEST_DATA_DES})
1002

1003
# Copy test samples from source to destination.
1004
add_custom_command(
1005
  TARGET ${test_data_target} PRE_BUILD
1006
  COMMAND ${CMAKE_COMMAND} -E copy_directory
1007
  ${TEST_SAMPLES_SRC}
1008
  ${TEST_SAMPLES_DES})
1009

1010
if (NOT onnxruntime_ENABLE_TRAINING_TORCH_INTEROP)
1011
  if (onnxruntime_USE_SNPE)
1012
    add_custom_command(
1013
      TARGET ${test_data_target} POST_BUILD
1014
      COMMAND ${CMAKE_COMMAND} -E copy ${SNPE_SO_FILES} $<TARGET_FILE_DIR:${test_data_target}>
1015
      )
1016
  endif()
1017

1018
  if (onnxruntime_USE_QNN)
1019
    if (MSVC OR ${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
1020
      add_custom_command(
1021
        TARGET ${test_data_target} POST_BUILD
1022
        COMMAND ${CMAKE_COMMAND} -E copy ${QNN_LIB_FILES} $<TARGET_FILE_DIR:${test_data_target}>
1023
        )
1024
    endif()
1025
    if (EXISTS "${onnxruntime_QNN_HOME}/Qualcomm AI Hub Proprietary License.pdf")
1026
      add_custom_command(
1027
        TARGET ${test_data_target} POST_BUILD
1028
        COMMAND ${CMAKE_COMMAND} -E copy "${onnxruntime_QNN_HOME}/Qualcomm AI Hub Proprietary License.pdf" $<TARGET_FILE_DIR:${test_data_target}>
1029
        )
1030
    endif()
1031
  endif()
1032

1033
  if (onnxruntime_USE_DNNL)
1034
    if(onnxruntime_DNNL_GPU_RUNTIME STREQUAL "ocl" AND onnxruntime_DNNL_OPENCL_ROOT STREQUAL "")
1035
      message(FATAL_ERROR "--dnnl_opencl_root required")
1036
    elseif(onnxruntime_DNNL_GPU_RUNTIME STREQUAL "" AND NOT (onnxruntime_DNNL_OPENCL_ROOT STREQUAL ""))
1037
      message(FATAL_ERROR "--dnnl_gpu_runtime required")
1038
    elseif(onnxruntime_DNNL_GPU_RUNTIME STREQUAL "ocl" AND NOT (onnxruntime_DNNL_OPENCL_ROOT STREQUAL ""))
1039
      #file(TO_CMAKE_PATH ${onnxruntime_DNNL_OPENCL_ROOT} onnxruntime_DNNL_OPENCL_ROOT)
1040
      #set(DNNL_OCL_INCLUDE_DIR ${onnxruntime_DNNL_OPENCL_ROOT}/include)
1041
      #set(DNNL_GPU_CMAKE_ARGS "-DDNNL_GPU_RUNTIME=OCL " "-DOPENCLROOT=${onnxruntime_DNNL_OPENCL_ROOT}")
1042
      target_compile_definitions(onnxruntime_test_all PUBLIC -DDNNL_GPU_RUNTIME=OCL)
1043
    endif()
1044
    list(APPEND onnx_test_libs dnnl)
1045
    add_custom_command(
1046
      TARGET ${test_data_target} POST_BUILD
1047
      COMMAND ${CMAKE_COMMAND} -E copy ${DNNL_DLL_PATH} $<TARGET_FILE_DIR:${test_data_target}>
1048
      )
1049
  endif()
1050
  if(WIN32)
1051
    if (onnxruntime_USE_TVM)
1052
      add_custom_command(
1053
        TARGET ${test_data_target} POST_BUILD
1054
        COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:tvm> $<TARGET_FILE_DIR:${test_data_target}>
1055
        )
1056
    endif()
1057
  endif()
1058

1059
  if(WIN32)
1060
    set(wide_get_opt_src_dir ${TEST_SRC_DIR}/win_getopt/wide)
1061
    onnxruntime_add_static_library(win_getopt_wide ${wide_get_opt_src_dir}/getopt.cc ${wide_get_opt_src_dir}/include/getopt.h)
1062
    target_include_directories(win_getopt_wide INTERFACE ${wide_get_opt_src_dir}/include)
1063
    set_target_properties(win_getopt_wide PROPERTIES FOLDER "ONNXRuntimeTest")
1064
    set(onnx_test_runner_common_srcs ${onnx_test_runner_common_srcs})
1065
    set(GETOPT_LIB_WIDE win_getopt_wide)
1066
  endif()
1067
endif()
1068

1069

1070
set(onnx_test_libs
1071
  onnxruntime_test_utils
1072
  ${ONNXRUNTIME_TEST_LIBS}
1073
  onnx_test_data_proto
1074
  ${onnxruntime_EXTERNAL_LIBRARIES})
1075

1076
if (NOT IOS)
1077
    onnxruntime_add_executable(onnx_test_runner ${onnx_test_runner_src_dir}/main.cc)
1078
    if(MSVC)
1079
      target_compile_options(onnx_test_runner PRIVATE "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:--compiler-options /utf-8>"
1080
              "$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:/utf-8>")
1081
    endif()
1082
    if (CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
1083
      if (onnxruntime_ENABLE_WEBASSEMBLY_THREADS)
1084
        set_target_properties(onnx_test_runner PROPERTIES LINK_FLAGS "-s NODERAWFS=1 -s ALLOW_MEMORY_GROWTH=1 -s PROXY_TO_PTHREAD=1 -s EXIT_RUNTIME=1")
1085
      else()
1086
        set_target_properties(onnx_test_runner PROPERTIES LINK_FLAGS "-s NODERAWFS=1 -s ALLOW_MEMORY_GROWTH=1")
1087
      endif()
1088
    endif()
1089

1090
    target_link_libraries(onnx_test_runner PRIVATE onnx_test_runner_common ${GETOPT_LIB_WIDE} ${onnx_test_libs} nlohmann_json::nlohmann_json)
1091
    target_include_directories(onnx_test_runner PRIVATE ${ONNXRUNTIME_ROOT})
1092
    if (onnxruntime_USE_ROCM)
1093
      target_include_directories(onnx_test_runner PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/amdgpu/onnxruntime ${CMAKE_CURRENT_BINARY_DIR}/amdgpu/orttraining)
1094
    endif()
1095
    if (onnxruntime_ENABLE_TRAINING_TORCH_INTEROP)
1096
      target_link_libraries(onnx_test_runner PRIVATE Python::Python)
1097
    endif()
1098
    set_target_properties(onnx_test_runner PROPERTIES FOLDER "ONNXRuntimeTest")
1099

1100
    if (onnxruntime_USE_TVM)
1101
      if (WIN32)
1102
        target_link_options(onnx_test_runner PRIVATE "/STACK:4000000")
1103
      endif()
1104
    endif()
1105

1106
    install(TARGETS onnx_test_runner
1107
            ARCHIVE  DESTINATION ${CMAKE_INSTALL_LIBDIR}
1108
            LIBRARY  DESTINATION ${CMAKE_INSTALL_LIBDIR}
1109
            BUNDLE   DESTINATION ${CMAKE_INSTALL_LIBDIR}
1110
            RUNTIME  DESTINATION ${CMAKE_INSTALL_BINDIR})
1111
endif()
1112

1113
if (NOT onnxruntime_ENABLE_TRAINING_TORCH_INTEROP)
1114
  if(onnxruntime_BUILD_BENCHMARKS)
1115
    SET(BENCHMARK_DIR ${TEST_SRC_DIR}/onnx/microbenchmark)
1116
    onnxruntime_add_executable(onnxruntime_benchmark
1117
      ${BENCHMARK_DIR}/main.cc
1118
      ${BENCHMARK_DIR}/modeltest.cc
1119
      ${BENCHMARK_DIR}/pooling.cc
1120
      ${BENCHMARK_DIR}/resize.cc
1121
      ${BENCHMARK_DIR}/batchnorm.cc
1122
      ${BENCHMARK_DIR}/batchnorm2.cc
1123
      ${BENCHMARK_DIR}/tptest.cc
1124
      ${BENCHMARK_DIR}/eigen.cc
1125
      ${BENCHMARK_DIR}/copy.cc
1126
      ${BENCHMARK_DIR}/gelu.cc
1127
      ${BENCHMARK_DIR}/activation.cc
1128
      ${BENCHMARK_DIR}/quantize.cc
1129
      ${BENCHMARK_DIR}/reduceminmax.cc)
1130
    target_include_directories(onnxruntime_benchmark PRIVATE ${ONNXRUNTIME_ROOT} ${onnxruntime_graph_header} ${ONNXRUNTIME_ROOT}/core/mlas/inc)
1131
    target_compile_definitions(onnxruntime_benchmark PRIVATE BENCHMARK_STATIC_DEFINE)
1132
    if(WIN32)
1133
      target_compile_options(onnxruntime_benchmark PRIVATE "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:--compiler-options /wd4141>"
1134
                        "$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:/wd4141>")
1135
      # Avoid using new and delete. But this is a benchmark program, it's ok if it has a chance to leak.
1136
      target_compile_options(onnxruntime_benchmark PRIVATE "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:--compiler-options /wd26409>"
1137
                        "$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:/wd26409>")
1138
      target_compile_options(onnxruntime_benchmark PRIVATE "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:--compiler-options /wd26400>"
1139
                        "$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:/wd26400>")
1140
      target_compile_options(onnxruntime_benchmark PRIVATE "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:--compiler-options /wd26814>"
1141
                        "$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:/wd26814>")
1142
      target_compile_options(onnxruntime_benchmark PRIVATE "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:--compiler-options /wd26814>"
1143
                        "$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:/wd26497>")
1144
      target_compile_options(onnxruntime_benchmark PRIVATE "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:--compiler-options /wd26426>"
1145
                        "$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:/wd26426>")
1146
      target_compile_options(onnxruntime_benchmark PRIVATE "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:--compiler-options /utf-8>"
1147
              "$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:/utf-8>")
1148
    endif()
1149
    target_link_libraries(onnxruntime_benchmark PRIVATE onnx_test_runner_common benchmark::benchmark ${onnx_test_libs})
1150
    add_dependencies(onnxruntime_benchmark ${onnxruntime_EXTERNAL_DEPENDENCIES})
1151
    set_target_properties(onnxruntime_benchmark PROPERTIES FOLDER "ONNXRuntimeTest")
1152

1153
    SET(MLAS_BENCH_DIR ${TEST_SRC_DIR}/mlas/bench)
1154
    file(GLOB_RECURSE MLAS_BENCH_SOURCE_FILES "${MLAS_BENCH_DIR}/*.cpp" "${MLAS_BENCH_DIR}/*.h")
1155
    onnxruntime_add_executable(onnxruntime_mlas_benchmark ${MLAS_BENCH_SOURCE_FILES})
1156
    target_include_directories(onnxruntime_mlas_benchmark PRIVATE ${ONNXRUNTIME_ROOT}/core/mlas/inc)
1157
    target_link_libraries(onnxruntime_mlas_benchmark PRIVATE benchmark::benchmark onnxruntime_util onnxruntime_framework ${ONNXRUNTIME_MLAS_LIBS} onnxruntime_common ${CMAKE_DL_LIBS})
1158
    target_compile_definitions(onnxruntime_mlas_benchmark PRIVATE BENCHMARK_STATIC_DEFINE)
1159
    if(WIN32)
1160
      target_link_libraries(onnxruntime_mlas_benchmark PRIVATE debug Dbghelp)
1161
      # Avoid using new and delete. But this is a benchmark program, it's ok if it has a chance to leak.
1162
      target_compile_options(onnxruntime_mlas_benchmark PRIVATE /wd26409)
1163
      # "Global initializer calls a non-constexpr function." BENCHMARK_CAPTURE macro needs this.
1164
      target_compile_options(onnxruntime_mlas_benchmark PRIVATE /wd26426)
1165
    else()
1166
      target_link_libraries(onnxruntime_mlas_benchmark PRIVATE nsync::nsync_cpp ${CMAKE_DL_LIBS})
1167
    endif()
1168
    if (CPUINFO_SUPPORTED AND NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
1169
      target_link_libraries(onnxruntime_mlas_benchmark PRIVATE cpuinfo)
1170
    endif()
1171
    set_target_properties(onnxruntime_mlas_benchmark PROPERTIES FOLDER "ONNXRuntimeTest")
1172
  endif()
1173

1174
  if(WIN32)
1175
    target_compile_options(onnx_test_runner_common PRIVATE -D_CRT_SECURE_NO_WARNINGS)
1176
  endif()
1177

1178
  if (NOT onnxruntime_REDUCED_OPS_BUILD AND NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
1179
    add_test(NAME onnx_test_pytorch_converted
1180
      COMMAND onnx_test_runner ${onnx_SOURCE_DIR}/onnx/backend/test/data/pytorch-converted)
1181
    add_test(NAME onnx_test_pytorch_operator
1182
      COMMAND onnx_test_runner ${onnx_SOURCE_DIR}/onnx/backend/test/data/pytorch-operator)
1183
  endif()
1184

1185
  if (CMAKE_SYSTEM_NAME STREQUAL "Android")
1186
      list(APPEND android_shared_libs log android)
1187
  endif()
1188
endif()
1189

1190

1191
if (NOT onnxruntime_ENABLE_TRAINING_TORCH_INTEROP)
1192
  if(NOT IOS)
1193
    #perf test runner
1194
    set(onnxruntime_perf_test_src_dir ${TEST_SRC_DIR}/perftest)
1195
    set(onnxruntime_perf_test_src_patterns
1196
    "${onnxruntime_perf_test_src_dir}/*.cc"
1197
    "${onnxruntime_perf_test_src_dir}/*.h")
1198

1199
    if(WIN32)
1200
      list(APPEND onnxruntime_perf_test_src_patterns
1201
        "${onnxruntime_perf_test_src_dir}/windows/*.cc"
1202
        "${onnxruntime_perf_test_src_dir}/windows/*.h" )
1203
    else ()
1204
      list(APPEND onnxruntime_perf_test_src_patterns
1205
        "${onnxruntime_perf_test_src_dir}/posix/*.cc"
1206
        "${onnxruntime_perf_test_src_dir}/posix/*.h" )
1207
    endif()
1208

1209
    file(GLOB onnxruntime_perf_test_src CONFIGURE_DEPENDS
1210
      ${onnxruntime_perf_test_src_patterns}
1211
      )
1212
    onnxruntime_add_executable(onnxruntime_perf_test ${onnxruntime_perf_test_src} ${ONNXRUNTIME_ROOT}/core/platform/path_lib.cc)
1213
    if(MSVC)
1214
      target_compile_options(onnxruntime_perf_test PRIVATE "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:--compiler-options /utf-8>"
1215
            "$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:/utf-8>")
1216
    endif()
1217
    target_include_directories(onnxruntime_perf_test PRIVATE   ${onnx_test_runner_src_dir} ${ONNXRUNTIME_ROOT}
1218
          ${eigen_INCLUDE_DIRS} ${onnxruntime_graph_header} ${onnxruntime_exec_src_dir}
1219
          ${CMAKE_CURRENT_BINARY_DIR})
1220
    if (onnxruntime_USE_ROCM)
1221
      target_include_directories(onnxruntime_perf_test PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/amdgpu/onnxruntime ${CMAKE_CURRENT_BINARY_DIR}/amdgpu/orttraining)
1222
    endif()
1223
    if (WIN32)
1224
      target_compile_options(onnxruntime_perf_test PRIVATE ${disabled_warnings})
1225
      if (NOT DEFINED SYS_PATH_LIB)
1226
        set(SYS_PATH_LIB shlwapi)
1227
      endif()
1228
    endif()
1229

1230
    if (onnxruntime_BUILD_SHARED_LIB)
1231
      #It will dynamically link to onnxruntime. So please don't add onxruntime_graph/onxruntime_framework/... here.
1232
      #onnxruntime_common is kind of ok because it is thin, tiny and totally stateless.
1233
      set(onnxruntime_perf_test_libs
1234
            onnx_test_runner_common onnxruntime_test_utils onnxruntime_common
1235
            onnxruntime onnxruntime_flatbuffers onnx_test_data_proto
1236
            ${onnxruntime_EXTERNAL_LIBRARIES}
1237
            ${GETOPT_LIB_WIDE} ${SYS_PATH_LIB} ${CMAKE_DL_LIBS})
1238
      if(NOT WIN32)
1239
        list(APPEND onnxruntime_perf_test_libs nsync::nsync_cpp)
1240
        if(onnxruntime_USE_SNPE)
1241
          list(APPEND onnxruntime_perf_test_libs onnxruntime_providers_snpe)
1242
        endif()
1243
      endif()
1244
      if (CMAKE_SYSTEM_NAME STREQUAL "Android")
1245
        list(APPEND onnxruntime_perf_test_libs ${android_shared_libs})
1246
      endif()
1247
      if (${CMAKE_SYSTEM_NAME} MATCHES "AIX")
1248
        list(APPEND onnxruntime_perf_test_libs onnxruntime_graph onnxruntime_session onnxruntime_providers onnxruntime_framework onnxruntime_util onnxruntime_mlas onnxruntime_optimizer onnxruntime_flatbuffers iconv re2 gtest absl_failure_signal_handler absl_examine_stack absl_flags_parse  absl_flags_usage absl_flags_usage_internal)
1249
    endif()
1250
      target_link_libraries(onnxruntime_perf_test PRIVATE ${onnxruntime_perf_test_libs} Threads::Threads)
1251
      if(WIN32)
1252
        target_link_libraries(onnxruntime_perf_test PRIVATE debug dbghelp advapi32)
1253
      endif()
1254
    else()
1255
      target_link_libraries(onnxruntime_perf_test PRIVATE onnx_test_runner_common ${GETOPT_LIB_WIDE} ${onnx_test_libs})
1256
    endif()
1257
    set_target_properties(onnxruntime_perf_test PROPERTIES FOLDER "ONNXRuntimeTest")
1258

1259
    if (onnxruntime_USE_TVM)
1260
      if (WIN32)
1261
        target_link_options(onnxruntime_perf_test PRIVATE "/STACK:4000000")
1262
      endif()
1263
    endif()
1264
  endif()
1265
  # shared lib
1266
  if (onnxruntime_BUILD_SHARED_LIB)
1267
    onnxruntime_add_static_library(onnxruntime_mocked_allocator ${TEST_SRC_DIR}/util/test_allocator.cc)
1268
    target_include_directories(onnxruntime_mocked_allocator PUBLIC ${TEST_SRC_DIR}/util/include)
1269
    target_link_libraries(onnxruntime_mocked_allocator PRIVATE ${GSL_TARGET})
1270
    set_target_properties(onnxruntime_mocked_allocator PROPERTIES FOLDER "ONNXRuntimeTest")
1271

1272
    #################################################################
1273
    # test inference using shared lib
1274
    set(onnxruntime_shared_lib_test_LIBS onnxruntime_mocked_allocator onnxruntime_test_utils onnxruntime_common onnx_proto)
1275
    if(NOT WIN32)
1276
      list(APPEND onnxruntime_shared_lib_test_LIBS nsync::nsync_cpp)
1277
      if(onnxruntime_USE_SNPE)
1278
        list(APPEND onnxruntime_shared_lib_test_LIBS onnxruntime_providers_snpe)
1279
      endif()
1280
    endif()
1281
    if (CPUINFO_SUPPORTED AND NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
1282
      list(APPEND onnxruntime_shared_lib_test_LIBS cpuinfo)
1283
    endif()
1284
    if (onnxruntime_USE_CUDA)
1285
      list(APPEND onnxruntime_shared_lib_test_LIBS CUDA::cudart)
1286
    endif()
1287
    if (onnxruntime_USE_ROCM)
1288
      list(APPEND onnxruntime_shared_lib_test_LIBS hip::host)
1289
    endif()
1290
    if (onnxruntime_USE_TENSORRT)
1291
      list(APPEND onnxruntime_shared_lib_test_LIBS ${TENSORRT_LIBRARY_INFER})
1292
    endif()
1293
    if (onnxruntime_USE_DML)
1294
      list(APPEND onnxruntime_shared_lib_test_LIBS d3d12.lib)
1295
    endif()
1296
    if (CMAKE_SYSTEM_NAME STREQUAL "Android")
1297
      list(APPEND onnxruntime_shared_lib_test_LIBS ${android_shared_libs})
1298
    endif()
1299

1300
    if (${CMAKE_SYSTEM_NAME} MATCHES "AIX")
1301
      list(APPEND onnxruntime_shared_lib_test_LIBS onnxruntime_graph onnxruntime_session onnxruntime_providers onnxruntime_framework onnxruntime_util onnxruntime_mlas onnxruntime_optimizer onnxruntime_flatbuffers iconv re2)
1302
    endif()
1303

1304
    AddTest(DYN
1305
            TARGET onnxruntime_shared_lib_test
1306
            SOURCES ${onnxruntime_shared_lib_test_SRC} ${onnxruntime_unittest_main_src}
1307
            LIBS ${onnxruntime_shared_lib_test_LIBS}
1308
            DEPENDS ${all_dependencies}
1309
    )
1310
    if (onnxruntime_USE_CUDA)
1311
      target_include_directories(onnxruntime_shared_lib_test PRIVATE ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
1312
      target_sources(onnxruntime_shared_lib_test PRIVATE ${ONNXRUNTIME_SHARED_LIB_TEST_SRC_DIR}/cuda_ops.cu)
1313
    endif()
1314
    if (onnxruntime_USE_ROCM)
1315
      target_include_directories(onnxruntime_shared_lib_test PRIVATE ${onnxruntime_ROCM_HOME}/include)
1316
      target_compile_definitions(onnxruntime_shared_lib_test PRIVATE __HIP_PLATFORM_AMD__)
1317
    endif()
1318
    if (CMAKE_SYSTEM_NAME STREQUAL "Android")
1319
      target_sources(onnxruntime_shared_lib_test PRIVATE
1320
        "${ONNXRUNTIME_ROOT}/core/platform/android/cxa_demangle.cc"
1321
        "${TEST_SRC_DIR}/platform/android/cxa_demangle_test.cc"
1322
      )
1323
      target_compile_definitions(onnxruntime_shared_lib_test PRIVATE USE_DUMMY_EXA_DEMANGLE=1)
1324
    endif()
1325

1326
    if (IOS)
1327
      add_custom_command(
1328
        TARGET onnxruntime_shared_lib_test POST_BUILD
1329
        COMMAND ${CMAKE_COMMAND} -E copy_directory
1330
        ${TEST_DATA_SRC}
1331
        $<TARGET_FILE_DIR:onnxruntime_shared_lib_test>/testdata)
1332
    endif()
1333

1334
    if (UNIX AND onnxruntime_USE_TENSORRT)
1335
        # The test_main.cc includes NvInfer.h where it has many deprecated declarations
1336
        # simply ignore them for TensorRT EP build
1337
        set_property(TARGET onnxruntime_shared_lib_test APPEND_STRING PROPERTY COMPILE_FLAGS "-Wno-deprecated-declarations")
1338
    endif()
1339

1340
    # test inference using global threadpools
1341
    if (NOT CMAKE_SYSTEM_NAME MATCHES "Android|iOS" AND NOT onnxruntime_MINIMAL_BUILD)
1342
      AddTest(DYN
1343
              TARGET onnxruntime_global_thread_pools_test
1344
              SOURCES ${onnxruntime_global_thread_pools_test_SRC}
1345
              LIBS ${onnxruntime_shared_lib_test_LIBS}
1346
              DEPENDS ${all_dependencies}
1347
      )
1348
    endif()
1349
  endif()
1350

1351
  # the debug node IO functionality uses static variables, so it is best tested
1352
  # in its own process
1353
  if(onnxruntime_DEBUG_NODE_INPUTS_OUTPUTS)
1354
    AddTest(
1355
      TARGET onnxruntime_test_debug_node_inputs_outputs
1356
      SOURCES
1357
        "${TEST_SRC_DIR}/debug_node_inputs_outputs/debug_node_inputs_outputs_utils_test.cc"
1358
        "${TEST_SRC_DIR}/framework/TestAllocatorManager.cc"
1359
        "${TEST_SRC_DIR}/framework/test_utils.cc"
1360
        "${TEST_SRC_DIR}/providers/base_tester.h"
1361
        "${TEST_SRC_DIR}/providers/base_tester.cc"
1362
        "${TEST_SRC_DIR}/providers/checkers.h"
1363
        "${TEST_SRC_DIR}/providers/checkers.cc"
1364
        "${TEST_SRC_DIR}/providers/op_tester.h"
1365
        "${TEST_SRC_DIR}/providers/op_tester.cc"
1366
        "${TEST_SRC_DIR}/providers/provider_test_utils.h"
1367
        "${TEST_SRC_DIR}/providers/tester_types.h"
1368
        ${onnxruntime_unittest_main_src}
1369
      LIBS ${onnxruntime_test_providers_libs} ${onnxruntime_test_common_libs}
1370
      DEPENDS ${all_dependencies}
1371
    )
1372

1373
    if (onnxruntime_USE_ROCM)
1374
      target_include_directories(onnxruntime_test_debug_node_inputs_outputs PRIVATE ${onnxruntime_ROCM_HOME}/hipfft/include ${onnxruntime_ROCM_HOME}/include ${onnxruntime_ROCM_HOME}/hipcub/include ${onnxruntime_ROCM_HOME}/hiprand/include ${onnxruntime_ROCM_HOME}/rocrand/include)
1375
      target_include_directories(onnxruntime_test_debug_node_inputs_outputs PRIVATE ${ONNXRUNTIME_ROOT} ${CMAKE_CURRENT_BINARY_DIR}/amdgpu/onnxruntime)
1376
    endif(onnxruntime_USE_ROCM)
1377

1378
    target_compile_definitions(onnxruntime_test_debug_node_inputs_outputs
1379
      PRIVATE DEBUG_NODE_INPUTS_OUTPUTS)
1380
  endif(onnxruntime_DEBUG_NODE_INPUTS_OUTPUTS)
1381

1382
  #some ETW tools
1383
  if(WIN32 AND onnxruntime_ENABLE_INSTRUMENT)
1384
    onnxruntime_add_executable(generate_perf_report_from_etl ${ONNXRUNTIME_ROOT}/tool/etw/main.cc
1385
            ${ONNXRUNTIME_ROOT}/tool/etw/eparser.h ${ONNXRUNTIME_ROOT}/tool/etw/eparser.cc
1386
            ${ONNXRUNTIME_ROOT}/tool/etw/TraceSession.h ${ONNXRUNTIME_ROOT}/tool/etw/TraceSession.cc)
1387
    target_compile_definitions(generate_perf_report_from_etl PRIVATE "_CONSOLE" "_UNICODE" "UNICODE")
1388
    target_link_libraries(generate_perf_report_from_etl PRIVATE tdh Advapi32)
1389

1390
    onnxruntime_add_executable(compare_two_sessions ${ONNXRUNTIME_ROOT}/tool/etw/compare_two_sessions.cc
1391
            ${ONNXRUNTIME_ROOT}/tool/etw/eparser.h ${ONNXRUNTIME_ROOT}/tool/etw/eparser.cc
1392
            ${ONNXRUNTIME_ROOT}/tool/etw/TraceSession.h ${ONNXRUNTIME_ROOT}/tool/etw/TraceSession.cc)
1393
    target_compile_definitions(compare_two_sessions PRIVATE "_CONSOLE" "_UNICODE" "UNICODE")
1394
    target_link_libraries(compare_two_sessions PRIVATE ${GETOPT_LIB_WIDE} tdh Advapi32)
1395
  endif()
1396

1397
  if(NOT onnxruntime_target_platform STREQUAL "ARM64EC")
1398
    file(GLOB onnxruntime_mlas_test_src CONFIGURE_DEPENDS
1399
      "${TEST_SRC_DIR}/mlas/unittest/*.h"
1400
      "${TEST_SRC_DIR}/mlas/unittest/*.cpp"
1401
    )
1402
    onnxruntime_add_executable(onnxruntime_mlas_test ${onnxruntime_mlas_test_src})
1403
    if(MSVC)
1404
      target_compile_options(onnxruntime_mlas_test PRIVATE "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:--compiler-options /wd26409>"
1405
                  "$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:/wd26409>")
1406
      target_compile_options(onnxruntime_mlas_test PRIVATE "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:--compiler-options /utf-8>"
1407
              "$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:/utf-8>")
1408
      target_compile_options(onnxruntime_mlas_test PRIVATE "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:--compiler-options /wd6326>"
1409
                  "$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:/wd6326>")
1410
      target_compile_options(onnxruntime_mlas_test PRIVATE "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:--compiler-options /wd26426>"
1411
                  "$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:/wd26426>")
1412
    endif()
1413
    if(IOS)
1414
      set_target_properties(onnxruntime_mlas_test PROPERTIES
1415
        XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO"
1416
      )
1417
    endif()
1418
    target_include_directories(onnxruntime_mlas_test PRIVATE ${ONNXRUNTIME_ROOT}/core/mlas/inc ${ONNXRUNTIME_ROOT}
1419
            ${CMAKE_CURRENT_BINARY_DIR})
1420
    target_link_libraries(onnxruntime_mlas_test PRIVATE GTest::gtest GTest::gmock ${ONNXRUNTIME_MLAS_LIBS} onnxruntime_common)
1421
    if (CPUINFO_SUPPORTED AND NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
1422
      target_link_libraries(onnxruntime_mlas_test PRIVATE cpuinfo)
1423
    endif()
1424
    if(NOT WIN32)
1425
      target_link_libraries(onnxruntime_mlas_test PRIVATE nsync::nsync_cpp ${CMAKE_DL_LIBS})
1426
    endif()
1427
    if (CMAKE_SYSTEM_NAME STREQUAL "Android")
1428
      target_link_libraries(onnxruntime_mlas_test PRIVATE ${android_shared_libs})
1429
    endif()
1430
    if(WIN32)
1431
      target_link_libraries(onnxruntime_mlas_test PRIVATE debug Dbghelp Advapi32)
1432
    endif()
1433
    if (onnxruntime_LINK_LIBATOMIC)
1434
      target_link_libraries(onnxruntime_mlas_test PRIVATE atomic)
1435
    endif()
1436
    target_link_libraries(onnxruntime_mlas_test PRIVATE Threads::Threads)
1437
    set_target_properties(onnxruntime_mlas_test PROPERTIES FOLDER "ONNXRuntimeTest")
1438
    if (CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
1439
      if (onnxruntime_ENABLE_WEBASSEMBLY_THREADS)
1440
        set_target_properties(onnxruntime_mlas_test PROPERTIES LINK_FLAGS "-s ALLOW_MEMORY_GROWTH=1 -s PROXY_TO_PTHREAD=1 -s EXIT_RUNTIME=1")
1441
      else()
1442
        set_target_properties(onnxruntime_mlas_test PROPERTIES LINK_FLAGS "-s ALLOW_MEMORY_GROWTH=1")
1443
      endif()
1444
    endif()
1445
endif()
1446
  # Training API Tests
1447
  # Disabling training_api_test_trainer. CXXOPT generates a ton of warnings because of which nuget pipeline is failing.
1448
  # TODO(askhade): Fix the warnings.
1449
  # This has no impact on the release as the release package and the pipeline, both do not use this.
1450
  # This is used by devs for testing training apis.
1451
  #if (onnxruntime_ENABLE_TRAINING_APIS)
1452
  if (0)
1453
    # Only files in the trainer and common folder will be compiled into test trainer.
1454
    file(GLOB training_api_test_trainer_src
1455
      "${ORTTRAINING_SOURCE_DIR}/test/training_api/common/*.cc"
1456
      "${ORTTRAINING_SOURCE_DIR}/test/training_api/common/*.h"
1457
      "${ORTTRAINING_SOURCE_DIR}/test/training_api/trainer/*.cc"
1458
      "${ORTTRAINING_SOURCE_DIR}/test/training_api/trainer/*.h"
1459
    )
1460
    onnxruntime_add_executable(onnxruntime_test_trainer ${training_api_test_trainer_src})
1461

1462
    onnxruntime_add_include_to_target(onnxruntime_test_trainer onnxruntime_session
1463
      onnxruntime_framework onnxruntime_common onnx onnx_proto ${PROTOBUF_LIB} flatbuffers::flatbuffers)
1464

1465
    set(CXXOPTS ${cxxopts_SOURCE_DIR}/include)
1466
    target_include_directories(onnxruntime_test_trainer PRIVATE
1467
      ${CMAKE_CURRENT_BINARY_DIR}
1468
      ${ONNXRUNTIME_ROOT}
1469
      ${ORTTRAINING_ROOT}
1470
      ${eigen_INCLUDE_DIRS}
1471
      ${CXXOPTS}
1472
      ${extra_includes}
1473
      ${onnxruntime_graph_header}
1474
      ${onnxruntime_exec_src_dir}
1475
    )
1476

1477
    set(ONNXRUNTIME_TEST_LIBS
1478
      onnxruntime_session
1479
      ${onnxruntime_libs}
1480
      # CUDA is dynamically loaded at runtime
1481
      onnxruntime_optimizer
1482
      onnxruntime_providers
1483
      onnxruntime_util
1484
      onnxruntime_framework
1485
      onnxruntime_util
1486
      onnxruntime_graph
1487
      ${ONNXRUNTIME_MLAS_LIBS}
1488
      onnxruntime_common
1489
      onnxruntime_flatbuffers
1490
    )
1491

1492
    target_link_libraries(onnxruntime_test_trainer PRIVATE
1493
      ${ONNXRUNTIME_TEST_LIBS}
1494
      ${onnxruntime_EXTERNAL_LIBRARIES}
1495
    )
1496
    set_target_properties(onnxruntime_test_trainer PROPERTIES FOLDER "ONNXRuntimeTest")
1497
  endif()
1498
endif()
1499

1500
if (NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
1501

1502
  set(custom_op_src_patterns
1503
    "${TEST_SRC_DIR}/testdata/custom_op_library/*.h"
1504
    "${TEST_SRC_DIR}/testdata/custom_op_library/*.cc"
1505
    "${TEST_SRC_DIR}/testdata/custom_op_library/cpu/cpu_ops.*"
1506
  )
1507

1508
  set(custom_op_lib_include ${REPO_ROOT}/include)
1509
  set(custom_op_lib_option)
1510
  set(custom_op_lib_link ${GSL_TARGET})
1511

1512
  if (onnxruntime_USE_CUDA)
1513
    list(APPEND custom_op_src_patterns
1514
        "${ONNXRUNTIME_SHARED_LIB_TEST_SRC_DIR}/cuda_ops.cu"
1515
        "${TEST_SRC_DIR}/testdata/custom_op_library/cuda/cuda_ops.*")
1516
    list(APPEND custom_op_lib_include ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES} ${CUDNN_INCLUDE_DIR})
1517
    if (HAS_QSPECTRE)
1518
      list(APPEND custom_op_lib_option "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:--compiler-options /Qspectre>")
1519
    endif()
1520
  endif()
1521

1522
  if (onnxruntime_USE_ROCM)
1523
    list(APPEND custom_op_src_patterns
1524
        "${ONNXRUNTIME_SHARED_LIB_TEST_SRC_DIR}/rocm_ops.hip"
1525
        "${TEST_SRC_DIR}/testdata/custom_op_library/rocm/rocm_ops.*")
1526
    list(APPEND custom_op_lib_include ${onnxruntime_ROCM_HOME}/include)
1527
    list(APPEND custom_op_lib_option "-D__HIP_PLATFORM_AMD__=1 -D__HIP_PLATFORM_HCC__=1")
1528
  endif()
1529

1530
  file(GLOB custom_op_src ${custom_op_src_patterns})
1531
  onnxruntime_add_shared_library(custom_op_library ${custom_op_src})
1532
  target_compile_options(custom_op_library PRIVATE ${custom_op_lib_option})
1533
  target_include_directories(custom_op_library PRIVATE ${REPO_ROOT}/include ${custom_op_lib_include})
1534
  target_link_libraries(custom_op_library PRIVATE ${GSL_TARGET} ${custom_op_lib_link})
1535

1536
  if(UNIX)
1537
    if (APPLE)
1538
      set(ONNXRUNTIME_CUSTOM_OP_LIB_LINK_FLAG "-Xlinker -dead_strip")
1539
    elseif(NOT ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
1540
      set(ONNXRUNTIME_CUSTOM_OP_LIB_LINK_FLAG "-Xlinker --version-script=${TEST_SRC_DIR}/testdata/custom_op_library/custom_op_library.lds -Xlinker --no-undefined -Xlinker --gc-sections -z noexecstack")
1541
    endif()
1542
  else()
1543
    set(ONNXRUNTIME_CUSTOM_OP_LIB_LINK_FLAG "-DEF:${TEST_SRC_DIR}/testdata/custom_op_library/custom_op_library.def")
1544
    if (NOT onnxruntime_USE_CUDA)
1545
      target_compile_options(custom_op_library PRIVATE "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:--compiler-options /wd26409>"
1546
                    "$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:/wd26409>")
1547
    endif()
1548
  endif()
1549
  set_property(TARGET custom_op_library APPEND_STRING PROPERTY LINK_FLAGS ${ONNXRUNTIME_CUSTOM_OP_LIB_LINK_FLAG})
1550

1551
  if (NOT onnxruntime_ENABLE_TRAINING_TORCH_INTEROP)
1552
    if (onnxruntime_BUILD_JAVA AND NOT onnxruntime_ENABLE_STATIC_ANALYSIS)
1553
        message(STATUS "Running Java tests")
1554
        # native-test is added to resources so custom_op_lib can be loaded
1555
        # and we want to symlink it there
1556
        set(JAVA_NATIVE_TEST_DIR ${JAVA_OUTPUT_DIR}/native-test)
1557
        file(MAKE_DIRECTORY ${JAVA_NATIVE_TEST_DIR})
1558

1559
        # delegate to gradle's test runner
1560
        if(WIN32)
1561
          add_custom_command(TARGET custom_op_library POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:custom_op_library>
1562
                          ${JAVA_NATIVE_TEST_DIR}/$<TARGET_FILE_NAME:custom_op_library>)
1563
          # On windows ctest requires a test to be an .exe(.com) file
1564
          # With gradle wrapper we get gradlew.bat. We delegate execution to a separate .cmake file
1565
          # That can handle both .exe and .bat
1566
          add_test(NAME onnxruntime4j_test COMMAND ${CMAKE_COMMAND}
1567
            -DGRADLE_EXECUTABLE=${GRADLE_EXECUTABLE}
1568
            -DBIN_DIR=${CMAKE_CURRENT_BINARY_DIR}
1569
            -DREPO_ROOT=${REPO_ROOT}
1570
            ${ORT_PROVIDER_FLAGS}
1571
            -P ${CMAKE_CURRENT_SOURCE_DIR}/onnxruntime_java_unittests.cmake)
1572
        else()
1573
          add_custom_command(TARGET custom_op_library POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:custom_op_library>
1574
                          ${JAVA_NATIVE_TEST_DIR}/$<TARGET_LINKER_FILE_NAME:custom_op_library>)
1575
          if (onnxruntime_ENABLE_TRAINING_APIS)
1576
            message(STATUS "Running Java inference and training tests")
1577
            add_test(NAME onnxruntime4j_test COMMAND ${GRADLE_EXECUTABLE} cmakeCheck -DcmakeBuildDir=${CMAKE_CURRENT_BINARY_DIR} ${ORT_PROVIDER_FLAGS} -DENABLE_TRAINING_APIS=1
1578
                          WORKING_DIRECTORY ${REPO_ROOT}/java)
1579
          else()
1580
            message(STATUS "Running Java inference tests only")
1581
            add_test(NAME onnxruntime4j_test COMMAND ${GRADLE_EXECUTABLE} cmakeCheck -DcmakeBuildDir=${CMAKE_CURRENT_BINARY_DIR} ${ORT_PROVIDER_FLAGS}
1582
                          WORKING_DIRECTORY ${REPO_ROOT}/java)
1583
          endif()
1584
        endif()
1585
        set_property(TEST onnxruntime4j_test APPEND PROPERTY DEPENDS onnxruntime4j_jni)
1586
    endif()
1587
  endif()
1588

1589
  if (onnxruntime_BUILD_SHARED_LIB AND (NOT onnxruntime_MINIMAL_BUILD OR onnxruntime_MINIMAL_BUILD_CUSTOM_OPS))
1590
    set (onnxruntime_customopregistration_test_SRC
1591
            ${ONNXRUNTIME_CUSTOM_OP_REGISTRATION_TEST_SRC_DIR}/test_registercustomops.cc)
1592

1593
    set(onnxruntime_customopregistration_test_LIBS custom_op_library onnxruntime_common onnxruntime_test_utils)
1594
    if (NOT WIN32)
1595
      list(APPEND onnxruntime_customopregistration_test_LIBS nsync::nsync_cpp)
1596
    endif()
1597
    if (CPUINFO_SUPPORTED AND NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
1598
      list(APPEND onnxruntime_customopregistration_test_LIBS cpuinfo)
1599
    endif()
1600
    if (onnxruntime_USE_TENSORRT)
1601
      list(APPEND onnxruntime_customopregistration_test_LIBS ${TENSORRT_LIBRARY_INFER})
1602
    endif()
1603
    if (${CMAKE_SYSTEM_NAME} MATCHES "AIX")
1604
      list(APPEND onnxruntime_customopregistration_test_LIBS onnxruntime_graph onnxruntime_session onnxruntime_providers onnxruntime_framework onnxruntime_util onnxruntime_mlas onnxruntime_optimizer onnxruntime_flatbuffers iconv re2 libprotobuf-lite onnx_proto nsync_cpp)
1605
    endif()
1606
    AddTest(DYN
1607
            TARGET onnxruntime_customopregistration_test
1608
            SOURCES ${onnxruntime_customopregistration_test_SRC} ${onnxruntime_unittest_main_src}
1609
            LIBS ${onnxruntime_customopregistration_test_LIBS}
1610
            DEPENDS ${all_dependencies}
1611
    )
1612

1613
    if (IOS)
1614
      add_custom_command(
1615
        TARGET onnxruntime_customopregistration_test POST_BUILD
1616
        COMMAND ${CMAKE_COMMAND} -E copy_directory
1617
        ${TEST_DATA_SRC}
1618
        $<TARGET_FILE_DIR:onnxruntime_customopregistration_test>/testdata)
1619
    endif()
1620

1621
    if (UNIX AND onnxruntime_USE_TENSORRT)
1622
        # The test_main.cc includes NvInfer.h where it has many deprecated declarations
1623
        # simply ignore them for TensorRT EP build
1624
        set_property(TARGET onnxruntime_customopregistration_test APPEND_STRING PROPERTY COMPILE_FLAGS "-Wno-deprecated-declarations")
1625
    endif()
1626

1627
  endif()
1628
endif()
1629

1630
# Build custom op library that returns an error OrtStatus when the exported RegisterCustomOps function is called.
1631
if (NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten" AND (NOT onnxruntime_MINIMAL_BUILD OR onnxruntime_MINIMAL_BUILD_CUSTOM_OPS))
1632
  onnxruntime_add_shared_library_module(custom_op_invalid_library
1633
                                        ${TEST_SRC_DIR}/testdata/custom_op_invalid_library/custom_op_library.h
1634
                                        ${TEST_SRC_DIR}/testdata/custom_op_invalid_library/custom_op_library.cc)
1635
  target_include_directories(custom_op_invalid_library PRIVATE ${REPO_ROOT}/include/onnxruntime/core/session)
1636

1637
  if(UNIX)
1638
    if (APPLE)
1639
      set(ONNXRUNTIME_CUSTOM_OP_INVALID_LIB_LINK_FLAG "-Xlinker -dead_strip")
1640
    elseif (NOT ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
1641
      string(CONCAT ONNXRUNTIME_CUSTOM_OP_INVALID_LIB_LINK_FLAG
1642
             "-Xlinker --version-script=${TEST_SRC_DIR}/testdata/custom_op_invalid_library/custom_op_library.lds "
1643
             "-Xlinker --no-undefined -Xlinker --gc-sections -z noexecstack")
1644
    endif()
1645
  else()
1646
    set(ONNXRUNTIME_CUSTOM_OP_INVALID_LIB_LINK_FLAG
1647
        "-DEF:${TEST_SRC_DIR}/testdata/custom_op_invalid_library/custom_op_library.def")
1648
  endif()
1649

1650
  set_property(TARGET custom_op_invalid_library APPEND_STRING PROPERTY LINK_FLAGS
1651
               ${ONNXRUNTIME_CUSTOM_OP_INVALID_LIB_LINK_FLAG})
1652
endif()
1653

1654
if (NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten" AND (NOT onnxruntime_MINIMAL_BUILD OR onnxruntime_MINIMAL_BUILD_CUSTOM_OPS))
1655

1656
  file(GLOB_RECURSE custom_op_get_const_input_test_library_src
1657
        "${TEST_SRC_DIR}/testdata/custom_op_get_const_input_test_library/custom_op_lib.cc"
1658
        "${TEST_SRC_DIR}/testdata/custom_op_get_const_input_test_library/custom_op.h"
1659
        "${TEST_SRC_DIR}/testdata/custom_op_get_const_input_test_library/custom_op.cc"
1660
  )
1661

1662
  onnxruntime_add_shared_library_module(custom_op_get_const_input_test_library ${custom_op_get_const_input_test_library_src})
1663

1664
  onnxruntime_add_include_to_target(custom_op_get_const_input_test_library onnxruntime_common GTest::gtest GTest::gmock)
1665
  target_include_directories(custom_op_get_const_input_test_library PRIVATE ${REPO_ROOT}/include/onnxruntime/core/session
1666
                                                                            ${REPO_ROOT}/include/onnxruntime/core/common)
1667

1668
  if(UNIX)
1669
    if (APPLE)
1670
      set(ONNXRUNTIME_CUSTOM_OP_GET_CONST_INPUT_TEST_LIB_LINK_FLAG "-Xlinker -dead_strip")
1671
    elseif(NOT ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
1672
      string(CONCAT ONNXRUNTIME_CUSTOM_OP_GET_CONST_INPUT_TEST_LIB_LINK_FLAG
1673
             "-Xlinker --version-script=${TEST_SRC_DIR}/testdata/custom_op_get_const_input_test_library/custom_op_lib.lds "
1674
             "-Xlinker --no-undefined -Xlinker --gc-sections -z noexecstack")
1675
    endif()
1676
  else()
1677
    set(ONNXRUNTIME_CUSTOM_OP_GET_CONST_INPUT_TEST_LIB_LINK_FLAG
1678
        "-DEF:${TEST_SRC_DIR}/testdata/custom_op_get_const_input_test_library/custom_op_lib.def")
1679
  endif()
1680

1681
  set_property(TARGET custom_op_get_const_input_test_library APPEND_STRING PROPERTY LINK_FLAGS
1682
               ${ONNXRUNTIME_CUSTOM_OP_GET_CONST_INPUT_TEST_LIB_LINK_FLAG})
1683
endif()
1684

1685
if (NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten" AND (NOT onnxruntime_MINIMAL_BUILD OR onnxruntime_MINIMAL_BUILD_CUSTOM_OPS))
1686

1687
  file(GLOB_RECURSE custom_op_local_function_test_library_src
1688
        "${TEST_SRC_DIR}/testdata/custom_op_local_function/custom_op_local_function.cc"
1689
        "${TEST_SRC_DIR}/testdata/custom_op_local_function/custom_op_local_function.h"
1690
        "${TEST_SRC_DIR}/testdata/custom_op_local_function/dummy_gemm.cc"
1691
        "${TEST_SRC_DIR}/testdata/custom_op_local_function/dummy_gemm.h"
1692
  )
1693

1694
  onnxruntime_add_shared_library_module(custom_op_local_function ${custom_op_local_function_test_library_src})
1695

1696
  onnxruntime_add_include_to_target(custom_op_local_function onnxruntime_common GTest::gtest GTest::gmock)
1697
  target_include_directories(custom_op_local_function PRIVATE ${REPO_ROOT}/include/onnxruntime/core/session
1698
                                                                            ${REPO_ROOT}/include/onnxruntime/core/common)
1699

1700
  if(UNIX)
1701
    if (APPLE)
1702
      set(ONNXRUNTIME_CUSTOM_OP_lOCAL_FUNCTION_TEST_LIB_LINK_FLAG "-Xlinker -dead_strip")
1703
    elseif(NOT ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
1704
      string(CONCAT ONNXRUNTIME_CUSTOM_OP_lOCAL_FUNCTION_TEST_LIB_LINK_FLAG
1705
             "-Xlinker --version-script=${TEST_SRC_DIR}/testdata/custom_op_local_function/custom_op_local_function.lds "
1706
             "-Xlinker --no-undefined -Xlinker --gc-sections -z noexecstack")
1707
    endif()
1708
  else()
1709
    set(ONNXRUNTIME_CUSTOM_OP_lOCAL_FUNCTION_TEST_LIB_LINK_FLAG
1710
        "-DEF:${TEST_SRC_DIR}/testdata/custom_op_local_function/custom_op_local_function.def")
1711
  endif()
1712

1713
  set_property(TARGET custom_op_local_function APPEND_STRING PROPERTY LINK_FLAGS
1714
               ${ONNXRUNTIME_CUSTOM_OP_lOCAL_FUNCTION_TEST_LIB_LINK_FLAG})
1715
endif()
1716

1717
if (onnxruntime_BUILD_SHARED_LIB AND NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten" AND NOT onnxruntime_MINIMAL_BUILD)
1718
  set (onnxruntime_logging_apis_test_SRC
1719
       ${ONNXRUNTIME_LOGGING_APIS_TEST_SRC_DIR}/test_logging_apis.cc)
1720

1721
  set(onnxruntime_logging_apis_test_LIBS onnxruntime_common onnxruntime_test_utils)
1722
  if (${CMAKE_SYSTEM_NAME} MATCHES "AIX")
1723
    list(APPEND onnxruntime_logging_apis_test_LIBS onnxruntime_session onnxruntime_util onnxruntime_framework onnxruntime_common onnxruntime_graph  onnxruntime_providers onnxruntime_mlas onnxruntime_optimizer onnxruntime_flatbuffers iconv re2 libprotobuf-lite onnx_proto nsync_cpp)
1724
     endif()
1725

1726
  if(NOT WIN32)
1727
    list(APPEND onnxruntime_logging_apis_test_LIBS nsync::nsync_cpp ${CMAKE_DL_LIBS})
1728
  endif()
1729

1730
  AddTest(DYN
1731
          TARGET onnxruntime_logging_apis_test
1732
          SOURCES ${onnxruntime_logging_apis_test_SRC}
1733
          LIBS ${onnxruntime_logging_apis_test_LIBS}
1734
          DEPENDS ${all_dependencies}
1735
  )
1736
endif()
1737

1738
if (NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten" AND onnxruntime_USE_OPENVINO AND (NOT onnxruntime_MINIMAL_BUILD OR
1739
                                                                        onnxruntime_MINIMAL_BUILD_CUSTOM_OPS))
1740
  onnxruntime_add_shared_library_module(custom_op_openvino_wrapper_library
1741
                                        ${TEST_SRC_DIR}/testdata/custom_op_openvino_wrapper_library/custom_op_lib.cc
1742
                                        ${TEST_SRC_DIR}/testdata/custom_op_openvino_wrapper_library/openvino_wrapper.cc)
1743
  target_include_directories(custom_op_openvino_wrapper_library PRIVATE ${REPO_ROOT}/include/onnxruntime/core/session)
1744
  target_link_libraries(custom_op_openvino_wrapper_library PRIVATE openvino::runtime)
1745

1746
  if(UNIX)
1747
    if (APPLE)
1748
      set(ONNXRUNTIME_CUSTOM_OP_OPENVINO_WRAPPER_LIB_LINK_FLAG "-Xlinker -dead_strip")
1749
    else()
1750
      string(CONCAT ONNXRUNTIME_CUSTOM_OP_OPENVINO_WRAPPER_LIB_LINK_FLAG
1751
             "-Xlinker --version-script=${TEST_SRC_DIR}/testdata/custom_op_openvino_wrapper_library/custom_op_lib.lds "
1752
             "-Xlinker --no-undefined -Xlinker --gc-sections -z noexecstack")
1753
    endif()
1754
  else()
1755
    set(ONNXRUNTIME_CUSTOM_OP_OPENVINO_WRAPPER_LIB_LINK_FLAG
1756
        "-DEF:${TEST_SRC_DIR}/testdata/custom_op_openvino_wrapper_library/custom_op_lib.def")
1757
  endif()
1758

1759
  set_property(TARGET custom_op_openvino_wrapper_library APPEND_STRING PROPERTY LINK_FLAGS
1760
               ${ONNXRUNTIME_CUSTOM_OP_OPENVINO_WRAPPER_LIB_LINK_FLAG})
1761
endif()
1762

1763
# limit to only test on windows first, due to a runtime path issue on linux
1764
if (NOT onnxruntime_MINIMAL_BUILD AND NOT onnxruntime_EXTENDED_MINIMAL_BUILD
1765
                                  AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin|iOS|visionOS"
1766
                                  AND NOT CMAKE_SYSTEM_NAME STREQUAL "Android"
1767
                                  AND NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten"
1768
                                  AND NOT onnxruntime_USE_ROCM)
1769
  file(GLOB_RECURSE test_execution_provider_srcs
1770
    "${REPO_ROOT}/onnxruntime/test/testdata/custom_execution_provider_library/*.h"
1771
    "${REPO_ROOT}/onnxruntime/test/testdata/custom_execution_provider_library/*.cc"
1772
    "${ONNXRUNTIME_ROOT}/core/providers/shared_library/*.h"
1773
    "${ONNXRUNTIME_ROOT}/core/providers/shared_library/*.cc"
1774
  )
1775

1776
  onnxruntime_add_shared_library_module(test_execution_provider ${test_execution_provider_srcs})
1777
  add_dependencies(test_execution_provider onnxruntime_providers_shared onnx ${ABSEIL_LIBS})
1778
  if (CMAKE_SYSTEM_NAME MATCHES "AIX")
1779
    target_link_options(test_execution_provider PRIVATE -Wl,-brtl -lonnxruntime_providers_shared)
1780
    target_link_libraries(test_execution_provider PRIVATE ${ABSEIL_LIBS} Boost::mp11)
1781
  else()
1782
    target_link_libraries(test_execution_provider PRIVATE onnxruntime_providers_shared ${ABSEIL_LIBS} Boost::mp11)
1783
  endif()
1784
  target_include_directories(test_execution_provider PRIVATE $<TARGET_PROPERTY:onnx,INTERFACE_INCLUDE_DIRECTORIES>)
1785
  target_include_directories(test_execution_provider PRIVATE $<TARGET_PROPERTY:onnxruntime_common,INTERFACE_INCLUDE_DIRECTORIES>)
1786
  target_include_directories(test_execution_provider PRIVATE ${ONNXRUNTIME_ROOT} ${CMAKE_CURRENT_BINARY_DIR} ${ORTTRAINING_ROOT})
1787
  if (onnxruntime_ENABLE_TRAINING_TORCH_INTEROP)
1788
    target_link_libraries(test_execution_provider PRIVATE Python::Python)
1789
  endif()
1790
  if(APPLE)
1791
    set_property(TARGET test_execution_provider APPEND_STRING PROPERTY LINK_FLAGS "-Xlinker -exported_symbols_list ${REPO_ROOT}/onnxruntime/test/testdata/custom_execution_provider_library/exported_symbols.lst")
1792
  elseif(UNIX)
1793
    if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
1794
      set_property(TARGET test_execution_provider APPEND_STRING PROPERTY LINK_FLAGS "-Xlinker --version-script=${REPO_ROOT}/onnxruntime/test/testdata/custom_execution_provider_library/version_script.lds -Xlinker --gc-sections -Xlinker -rpath=\\$ORIGIN")
1795
     endif()
1796
  elseif(WIN32)
1797
    set_property(TARGET test_execution_provider APPEND_STRING PROPERTY LINK_FLAGS "-DEF:${REPO_ROOT}/onnxruntime/test/testdata/custom_execution_provider_library/symbols.def")
1798
  else()
1799
    message(FATAL_ERROR "test_execution_provider unknown platform, need to specify shared library exports for it")
1800
  endif()
1801
endif()
1802

1803
include(onnxruntime_fuzz_test.cmake)
1804

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.