CMakeLists.txt 5.5 KB
Newer Older
Paul's avatar
Paul committed
1
2
3
4

list(APPEND CMAKE_PREFIX_PATH /opt/rocm /opt/rocm/hip /opt/rocm/hcc)
find_package(miopen)

5
6
7
8
# rocblas
find_package(rocblas REQUIRED PATHS /opt/rocm)
message(STATUS "Build with rocblas")

Paul's avatar
Paul committed
9
10
11
12
if(NOT TARGET MIOpen)
    message(SEND_ERROR "Cant find miopen")
endif()

Paul's avatar
Paul committed
13
add_library(migraphx_device
14
    device/acos.cpp
15
    device/acosh.cpp
Paul's avatar
Paul committed
16
    device/add.cpp
17
18
19
20
    device/add_clip.cpp
    device/add_relu.cpp
    device/add_sigmoid.cpp
    device/add_tanh.cpp
Shucai Xiao's avatar
Shucai Xiao committed
21
22
    device/argmax.cpp
    device/argmin.cpp
23
    device/asin.cpp
24
    device/asinh.cpp
25
    device/atan.cpp
26
    device/atanh.cpp
27
28
29
    device/ceil.cpp
    device/clip.cpp
    device/concat.cpp
30
    device/contiguous.cpp
31
    device/convert.cpp
32
33
34
35
36
37
    device/cos.cpp
    device/cosh.cpp
    device/div.cpp
    device/erf.cpp
    device/exp.cpp
    device/floor.cpp
38
    device/gather.cpp
kahmed10's avatar
kahmed10 committed
39
    device/gelu.cpp
40
    device/int8_gemm_pack.cpp
kahmed10's avatar
kahmed10 committed
41
    device/layernorm.cpp
42
43
44
45
46
47
48
49
50
    device/log.cpp
    device/logsoftmax.cpp
    device/max.cpp
    device/min.cpp
    device/mul.cpp
    device/mul_add.cpp
    device/mul_add_relu.cpp
    device/pad.cpp
    device/pow.cpp
Shucai Xiao's avatar
Shucai Xiao committed
51
    device/prelu.cpp
kahmed10's avatar
kahmed10 committed
52
    device/recip.cpp
53
    device/reduce_max.cpp
54
    device/reduce_mean.cpp
Shucai Xiao's avatar
Shucai Xiao committed
55
    device/reduce_min.cpp
56
    device/reduce_sum.cpp
Shucai Xiao's avatar
Shucai Xiao committed
57
    device/reduce_prod.cpp
58
59
60
61
    device/relu.cpp
    device/round.cpp
    device/rsqrt.cpp
    device/sigmoid.cpp
Shucai Xiao's avatar
Shucai Xiao committed
62
    device/sign.cpp
63
64
65
66
67
68
69
70
    device/sin.cpp
    device/sinh.cpp
    device/softmax.cpp
    device/sqdiff.cpp
    device/sqrt.cpp
    device/sub.cpp
    device/tan.cpp
    device/tanh.cpp
Shucai Xiao's avatar
Shucai Xiao committed
71
    device/rnn_variable_seq_lens.cpp
72
)
Paul's avatar
Paul committed
73
set_target_properties(migraphx_device PROPERTIES EXPORT_NAME device)
Paul's avatar
Paul committed
74
rocm_set_soversion(migraphx_device ${MIGRAPHX_SO_VERSION})
Paul's avatar
Paul committed
75
rocm_clang_tidy_check(migraphx_device)
Paul's avatar
Paul committed
76
target_compile_options(migraphx_device PRIVATE -std=c++17 -fno-gpu-rdc -Wno-unused-command-line-argument -Xclang -fallow-half-arguments-and-returns)
Paul Fultz II's avatar
Paul Fultz II committed
77
78
79
80
81
82
83
target_link_libraries(migraphx_device migraphx hip::device -fno-gpu-rdc -Wno-invalid-command-line-argument -Wno-unused-command-line-argument)
if(CMAKE_CXX_COMPILER MATCHES ".*hcc")
    set(AMDGPU_TARGETS "gfx803;gfx900;gfx906" CACHE STRING "")
    foreach(AMDGPU_TARGET ${AMDGPU_TARGETS})
        target_compile_options(migraphx_device PRIVATE -amdgpu-target=${AMDGPU_TARGET})
        target_link_libraries(migraphx_device -amdgpu-target=${AMDGPU_TARGET})
    endforeach()
Paul's avatar
Paul committed
84
85
else()
    target_compile_options(migraphx_device PRIVATE -Wno-cuda-compat)
Paul Fultz II's avatar
Paul Fultz II committed
86
endif()
87
88
89
90
91
check_cxx_compiler_flag("--cuda-host-only -fhip-lambda-host-device -x hip" HAS_HIP_LAMBDA_HOST_DEVICE)
if(HAS_HIP_LAMBDA_HOST_DEVICE)
  message(STATUS "Enable -fhip-lambda-host-device")
  target_compile_options(migraphx_device PRIVATE -fhip-lambda-host-device)
endif()
Paul's avatar
Paul committed
92
93
target_include_directories(migraphx_device PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)
target_include_directories(migraphx_device PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/device/include>)
94

Paul's avatar
Paul committed
95
add_library(migraphx_gpu
Shucai Xiao's avatar
Shucai Xiao committed
96
97
    argmax.cpp
    argmin.cpp
98
    eliminate_workspace.cpp
Paul's avatar
Paul committed
99
    fuse_ops.cpp
Paul's avatar
Paul committed
100
    hip.cpp
Paul's avatar
Paul committed
101
    target.cpp
Paul's avatar
Paul committed
102
    lowering.cpp
wsttiger's avatar
wsttiger committed
103
104
    pooling.cpp
    convolution.cpp
kahmed10's avatar
kahmed10 committed
105
    deconvolution.cpp
106
    quant_convolution.cpp
107
    softmax.cpp
108
    logsoftmax.cpp
109
    concat.cpp
Khalique's avatar
Khalique committed
110
    leaky_relu.cpp
111
    batch_norm_inference.cpp
Paul's avatar
Paul committed
112
    write_literals.cpp
113
    rocblas.cpp
Khalique's avatar
Khalique committed
114
    abs.cpp
Khalique's avatar
Khalique committed
115
    elu.cpp
116
    pad.cpp
117
    gather.cpp
Shucai Xiao's avatar
Shucai Xiao committed
118
    convert.cpp
Khalique's avatar
Khalique committed
119
    lrn.cpp
Paul's avatar
Paul committed
120
    schedule_model.cpp
121
    adjust_allocation.cpp
122
    pack_int8_args.cpp
Khalique's avatar
Khalique committed
123
    clip.cpp
124
125
    int8_gemm_pack.cpp
    int8_conv_pack.cpp
126
    gemm_impl.cpp
127
    preallocate_param.cpp
Shucai Xiao's avatar
Shucai Xiao committed
128
    rnn_variable_seq_lens.cpp
129
    sync_device.cpp
Paul's avatar
Paul committed
130
)
Paul's avatar
Paul committed
131
set_target_properties(migraphx_gpu PROPERTIES EXPORT_NAME gpu)
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
function(register_migraphx_gpu_ops PREFIX)
    foreach(OP ${ARGN})
        register_op(migraphx_gpu HEADER migraphx/gpu/${OP}.hpp OPERATORS gpu::${PREFIX}${OP} INCLUDES migraphx/gpu/context.hpp)
    endforeach()
endfunction()
register_migraphx_gpu_ops(hip_
    acosh
    acos
    add
    argmax
    argmin
    asinh
    asin
    atanh
    atan
    ceil
    clip
    concat
    convert
    cosh
    cos
    div
    erf
    exp
    floor
    gather
    log
    logsoftmax
    max
    min
    mul
    pad
    pow
    prelu
    recip
    reduce_max
    reduce_mean
    reduce_min
    reduce_prod
    reduce_sum
    relu
    round
    rsqrt
    sigmoid
    sign
    sinh
    sin
    softmax
    sqdiff
    sqrt
    sub
    tanh
    tan
)
register_migraphx_gpu_ops(miopen_
    abs
    batch_norm_inference
    contiguous
    convolution
    deconvolution
    elu
    int8_conv_pack
    leaky_relu
    lrn
    pooling
    quant_convolution
)
register_op(migraphx_gpu 
    HEADER migraphx/gpu/rnn_variable_seq_lens.hpp 
    OPERATORS gpu::hip_rnn_var_sl_shift_sequence gpu::hip_rnn_var_sl_shift_output gpu::hip_rnn_var_sl_last_output
    INCLUDES migraphx/gpu/context.hpp)
register_op(migraphx_gpu 
    HEADER migraphx/gpu/int8_gemm_pack.hpp 
    OPERATORS gpu::hip_int8_gemm_pack_a gpu::hip_int8_gemm_pack_b
    INCLUDES migraphx/gpu/context.hpp)
register_op(migraphx_gpu 
    HEADER migraphx/gpu/gemm.hpp 
    OPERATORS gpu::rocblas_gemm<op::dot> gpu::rocblas_gemm<op::quant_dot>
    INCLUDES migraphx/gpu/context.hpp)
Paul's avatar
Paul committed
211
rocm_set_soversion(migraphx_gpu ${MIGRAPHX_SO_VERSION})
Paul's avatar
Paul committed
212
rocm_clang_tidy_check(migraphx_gpu)
Paul Fultz II's avatar
Paul Fultz II committed
213
214
# Workaround broken rocblas headers
target_compile_definitions(migraphx_gpu PUBLIC -D__HIP_PLATFORM_HCC__=1)
Paul's avatar
Paul committed
215
216
target_link_libraries(migraphx_gpu PUBLIC migraphx MIOpen roc::rocblas)
target_link_libraries(migraphx_gpu PRIVATE migraphx_device)
mei-ye's avatar
mei-ye committed
217

Paul's avatar
Paul committed
218
rocm_install_targets(
Paul's avatar
Paul committed
219
  TARGETS migraphx_gpu migraphx_device
Paul's avatar
Paul committed
220
221
222
  INCLUDE
    ${CMAKE_CURRENT_SOURCE_DIR}/include
)
mei-ye's avatar
mei-ye committed
223