CMakeLists.txt 3.17 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#####################################################################################
# The MIT License (MIT)
#
# Copyright (c) 2015-2022 Advanced Micro Devices, Inc. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#####################################################################################
kahmed10's avatar
kahmed10 committed
24
function(add_api_test TEST_NAME TEST_SRC TEST_DIR)
Paul Fultz II's avatar
Paul Fultz II committed
25
26
27
    set(NAME test_api_${TEST_NAME})
    add_executable(${NAME} EXCLUDE_FROM_ALL ${TEST_SRC})
    rocm_clang_tidy_check(${NAME})
28
    target_link_libraries(${NAME} migraphx_c migraphx)
Paul Fultz II's avatar
Paul Fultz II committed
29
    target_include_directories(${NAME} PUBLIC ../include)
kahmed10's avatar
kahmed10 committed
30
    add_test(NAME ${NAME} COMMAND $<TARGET_FILE:${NAME}> WORKING_DIRECTORY ${TEST_DIR}) 
Paul Fultz II's avatar
Paul Fultz II committed
31
32
33
34
    add_dependencies(tests ${NAME})
    add_dependencies(check ${NAME})
endfunction()

Paul Fultz II's avatar
Paul Fultz II committed
35
36
37
38
39
40
41
42
43
44
45
# Workaround: C file dont work with clang-tidy right now, need a fix in rocm-cmake
function(add_c_api_test TEST_NAME TEST_SRC TEST_DIR)
    set(NAME test_api_${TEST_NAME})
    add_executable(${NAME} EXCLUDE_FROM_ALL ${TEST_SRC})
    target_link_libraries(${NAME} migraphx_c migraphx)
    target_include_directories(${NAME} PUBLIC ../include)
    add_test(NAME ${NAME} COMMAND $<TARGET_FILE:${NAME}> WORKING_DIRECTORY ${TEST_DIR}) 
    add_dependencies(tests ${NAME})
    add_dependencies(check ${NAME})
endfunction()

46
add_api_test(array_base test_array_base.cpp ${TEST_ONNX_DIR})
47
add_api_test(assign test_assign.cpp ${TEST_ONNX_DIR})
48
add_api_test(compile_options test_compile_options.cpp ${TEST_ONNX_DIR})
49
add_api_test(lookup test_lookup.cpp ${TEST_ONNX_DIR})
50
add_api_test(module_construct test_module_construct.cpp ${TEST_ONNX_DIR})
kahmed10's avatar
kahmed10 committed
51
52
53
add_api_test(ref test_cpu.cpp ${TEST_ONNX_DIR})
add_api_test(save_load test_save_load.cpp ${TEST_ONNX_DIR})
add_api_test(op test_op_construct.cpp ${TEST_ONNX_DIR})
Paul Fultz II's avatar
Paul Fultz II committed
54
add_c_api_test(c_op test_c_op_construct.c ${TEST_ONNX_DIR})
55
add_api_test(custom_op test_custom_op.cpp ${TEST_ONNX_DIR})
kahmed10's avatar
kahmed10 committed
56
add_api_test(tf_parser test_tf_parser.cpp ${TEST_TF_DIR})
57
# GPU-based tests
Paul Fultz II's avatar
Paul Fultz II committed
58
if(MIGRAPHX_ENABLE_GPU)
kahmed10's avatar
kahmed10 committed
59
add_api_test(gpu test_gpu.cpp ${TEST_ONNX_DIR})
60
target_link_libraries(test_api_gpu migraphx_gpu)
61
62
add_api_test(custom_op_gpu test_custom_op_gpu.cpp ${TEST_ONNX_DIR})
target_link_libraries(test_api_custom_op_gpu migraphx_gpu)
Paul Fultz II's avatar
Paul Fultz II committed
63
endif()