@@ -115,6 +115,11 @@ endmacro()
115115
116116# hipdnn_frontend
117117#
118+ # NOTE: we currently build hipDNN as a CMake source dependency (via
119+ # FetchContent) rather than using find_package() to locate an installed version.
120+ # The hipDNN build automatically handles transitive dependencies, which is
121+ # quite convenient.
122+ #
118123# HIP_DNN_HASH
119124# Git commit hash or tag to fetch
120125macro (_fetch_hipdnn_frontend)
@@ -133,46 +138,37 @@ macro(_fetch_hipdnn_frontend)
133138 message (FATAL_ERROR "Argument error: passing both LOCAL_PATH and HIP_DNN_HASH is ambiguous." )
134139 endif ()
135140
136- # We would normally check for, and preferentially use, an installed config
137- # package using FIND_PACKAGE_ARGS CONFIG on FetchContent_Declare. But, CMake
138- # throws an error if both FIND_PACKAGE_ARGS and DOWNLOAD_COMMAND arguments
139- # are passed, it's one or the other.
140- find_package (
141- hipdnn_frontend QUIET ${PARSE_FIND_PACKAGE_ARGS}
142- )
143- if (NOT hipdnn_frontend_FOUND) # we can't early return in a macro
144- if (DEFINED ARG_HIP_DNN_HASH)
145- FetchContent_Declare(
146- hipdnn_frontend
147- # location of hipdnn CMakeLists.txt in rocm-libraries
148- SOURCE_SUBDIR projects/hipdnn
149- # rocm-libraries takes 10+ min to fetch without sparse checkout
150- # (even with a shallow clone). We provide a custom
151- # DOWNLOAD_COMMAND until such time as CMAKE natively supports
152- # sparse checkouts.
153- DOWNLOAD_COMMAND
154- git clone --no -checkout --filter =blob:none https://github.com/ROCm/rocm-libraries.git <SOURCE_DIR> &&
155- cd <SOURCE_DIR> &&
156- git sparse-checkout init --cone &&
157- git sparse-checkout set projects/hipdnn &&
158- git checkout ${ARG_HIP_DNN_HASH}
159- )
160- else ()
161- FetchContent_Declare(
162- hipdnn_frontend
163- SOURCE_DIR ${ARG_LOCAL_PATH}
164- )
165- endif ()
166-
167- set (HIP_DNN_BUILD_BACKEND ON )
168- set (HIP_DNN_BUILD_FRONTEND ON )
169- set (HIP_DNN_SKIP_TESTS ON )
170- set (HIP_DNN_BUILD_PLUGINS OFF )
171- set (ENABLE_CLANG_TIDY OFF )
172- # PIC required to link static library into shared object.
173- set (CMAKE_POSITION_INDEPENDENT_CODE ON )
174- FetchContent_MakeAvailable(hipdnn_frontend)
141+ if (DEFINED ARG_HIP_DNN_HASH)
142+ FetchContent_Declare(
143+ hipdnn_frontend
144+ # location of hipdnn CMakeLists.txt in rocm-libraries
145+ SOURCE_SUBDIR projects/hipdnn
146+ # rocm-libraries takes 10+ min to fetch without sparse checkout
147+ # (even with a shallow clone). We provide a custom
148+ # DOWNLOAD_COMMAND until such time as CMAKE natively supports
149+ # sparse checkouts.
150+ DOWNLOAD_COMMAND
151+ git clone --no -checkout --filter =blob:none https://github.com/ROCm/rocm-libraries.git <SOURCE_DIR> &&
152+ cd <SOURCE_DIR> &&
153+ git sparse-checkout init --cone &&
154+ git sparse-checkout set projects/hipdnn &&
155+ git checkout ${ARG_HIP_DNN_HASH}
156+ )
157+ else ()
158+ FetchContent_Declare(
159+ hipdnn_frontend
160+ SOURCE_DIR ${ARG_LOCAL_PATH}
161+ )
175162 endif ()
163+
164+ set (HIP_DNN_BUILD_BACKEND ON )
165+ set (HIP_DNN_BUILD_FRONTEND ON )
166+ set (HIP_DNN_SKIP_TESTS ON )
167+ set (HIP_DNN_BUILD_PLUGINS OFF )
168+ set (ENABLE_CLANG_TIDY OFF )
169+ # PIC required to link static library into shared object.
170+ set (CMAKE_POSITION_INDEPENDENT_CODE ON )
171+ FetchContent_MakeAvailable(hipdnn_frontend)
176172endmacro ()
177173
178174# IREERuntime
0 commit comments