CMakeLists.txt 3.25 KB
Newer Older
Li Zhang's avatar
Li Zhang committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# Copyright (c) 2021-2023, NVIDIA CORPORATION.  All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# GoogleTest Preparation - Code block copied from
#   https://google.github.io/googletest/quickstart-cmake.html
include(FetchContent)
FetchContent_Declare(
  googletest
20
21
22
  URL ../../../3rdparty/googletest-release-1.12.1
  #GIT_REPOSITORY https://github.com/google/googletest.git
  #GIT_TAG release-1.12.1
Li Zhang's avatar
Li Zhang committed
23
)
Chen Xin's avatar
Chen Xin committed
24

25
26
# find_package(CUDAToolkit REQUIRED)
find_package(CUDA REQUIRED)
Chen Xin's avatar
Chen Xin committed
27
28
29
30

if (NOT MSVC)
  add_definitions(-DTORCH_CUDA=1)
endif()
Li Zhang's avatar
Li Zhang committed
31
32
33
34
35

# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)

36
37
include_directories(../../../3rdparty/googletest-release-1.12.1/googletest/include)

Li Zhang's avatar
Li Zhang committed
38
39
40
41
42
add_executable(unittest
    test_attention_kernels.cu
    test_logprob_kernels.cu
    test_penalty_kernels.cu
    test_sampling_kernels.cu
43
#    test_sampling_layer.cu
Li Zhang's avatar
Li Zhang committed
44
45
46
47
48
49
50
51
52
    test_tensor.cu)

# automatic discovery of unit tests
target_link_libraries(unittest PUBLIC "${TORCH_LIBRARIES}" gtest_main)
target_compile_features(unittest PRIVATE cxx_std_14)

# Sorted by alphabetical order of test name.
target_link_libraries(  # Libs for test_attention_kernels
  unittest PUBLIC
53
    cudart curand
54
    gpt_kernels gtest memory_utils tensor unfused_attention_kernels cuda_utils logger)
Li Zhang's avatar
Li Zhang committed
55
56
target_link_libraries(  # Libs for test_logprob_kernels
  unittest PUBLIC
57
    cudart
Li Zhang's avatar
Li Zhang committed
58
59
60
    logprob_kernels memory_utils cuda_utils logger)
target_link_libraries(  # Libs for test_penalty_kernels
  unittest PUBLIC
61
    cublas  cudart
62
    sampling_penalty_kernels memory_utils cuda_utils logger)
Li Zhang's avatar
Li Zhang committed
63
64
target_link_libraries(  # Libs for test_sampling_kernel
  unittest PUBLIC
65
    cudart
Li Zhang's avatar
Li Zhang committed
66
67
68
    sampling_topk_kernels sampling_topp_kernels memory_utils tensor cuda_utils logger)
target_link_libraries(  # Libs for test_sampling_layer
  unittest PUBLIC
69
    cublas  cudart
Li Zhang's avatar
Li Zhang committed
70
71
72
    cublasMMWrapper memory_utils
    DynamicDecodeLayer TopKSamplingLayer TopPSamplingLayer tensor cuda_utils logger)
target_link_libraries(  # Libs for test_tensor
73
  unittest PUBLIC -lrocblas tensor cuda_utils logger)
Li Zhang's avatar
Li Zhang committed
74
75
76

remove_definitions(-DTORCH_CUDA=1)
add_executable(test_gemm test_gemm.cu)
77
target_link_libraries(test_gemm PUBLIC -lrocblas cublas cudart curand gemm cublasMMWrapper tensor cuda_utils logger)
Li Zhang's avatar
Li Zhang committed
78
79
80
81
82

add_executable(test_gpt_kernels test_gpt_kernels.cu)
target_link_libraries(test_gpt_kernels PUBLIC
                      gpt_kernels memory_utils tensor cuda_utils logger)

83
84
85
86
87
#add_executable(test_context_attention_layer test_context_attention_layer.cu)
#target_link_libraries(test_context_attention_layer PUBLIC
#                      Llama cublas  cudart
#                      unfused_attention_kernels
#                      memory_utils tensor cublasMMWrapper cuda_utils logger)