Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Neural Network Extension - find/link MIOpenGEMM only for OCL GPU backend #617

Merged
merged 1 commit into from
Sep 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions amd_openvx_extensions/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ if(GPU_SUPPORT)
find_package(OpenCL QUIET)
if(OpenCL_FOUND)
SET(BUILD_OPENCL True)
find_package(miopengemm PATHS ${ROCM_PATH} QUIET)
else()
set(GPU_SUPPORT OFF)
set(BUILD_OPENCL False)
Expand All @@ -52,7 +53,6 @@ if(GPU_SUPPORT)
list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH} ${ROCM_PATH}/llvm ${ROCM_PATH}/hip)
endif()

find_package(miopengemm PATHS ${ROCM_PATH} QUIET)
find_package(miopen PATHS ${ROCM_PATH} QUIET)
if (miopen_FOUND)
#find the MIOPEN backend type
Expand Down Expand Up @@ -93,8 +93,8 @@ if(GPU_SUPPORT)
endif(GPU_SUPPORT)

if (NEURAL_NET)
if(GPU_SUPPORT AND miopengemm_FOUND AND miopen_FOUND)
if ("${BACKEND}" STREQUAL "OPENCL" AND OpenCL_FOUND)
if(GPU_SUPPORT AND miopen_FOUND)
if ("${BACKEND}" STREQUAL "OPENCL" AND OpenCL_FOUND AND miopengemm_FOUND)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asalmanp can we keep the check for MIOpenGEMM, if not found, not required to add the vx_nn lib?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kiritigowda the previous outer check for MIOpenGEMM was used for both OCL and HIP backends.
in the new code, the miopengemm is only checked if the backend is OCL.

For OCL backend, the vx_nn lib won't be added if GPU_SUPPORT/MIOpen with OCL backend/MIOpenGEMM is not found.
FOR HIP backend, the vx_nn lib won't be added if GPU_SUPPORT/MIOpen with the HIP backend is not found.

if (MIOPEN_BACKEND_OPENCL_FOUND)
add_subdirectory(amd_nn)
message("-- ${Green}AMD OpenVX Neural Network Extension -- amd_nn module added with OpenCL backend${ColourReset}")
Expand All @@ -109,10 +109,10 @@ if (NEURAL_NET)
message("-- ${Red}WARNING: MIOPEN with HIP backend Not Found -- amd_nn module excluded${ColourReset}")
endif()
else()
message("-- ${Red}WARNING:GPU support with OpenCL/HIP Not Found -- amd_nn module excluded${ColourReset}")
message("-- ${Red}WARNING:GPU support with OpenCL/MIOpenGEMM(for OpenCL)/HIP Not Found -- amd_nn module excluded${ColourReset}")
endif()
else()
message("-- ${Red}WARNING:GPU_SUPPORT/MIOpen/MIOpenGEMM Not Found -- amd_nn module excluded${ColourReset}")
message("-- ${Red}WARNING:GPU_SUPPORT/MIOpen Not Found -- amd_nn module excluded${ColourReset}")
endif()
else()
message("-- ${Cyan}Neural Net Modules turned OFF by user option -D NEURAL_NET=OFF ${ColourReset}")
Expand Down
4 changes: 2 additions & 2 deletions amd_openvx_extensions/amd_nn/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ project(amd_nn)
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../../amd_openvx/cmake)
set(CMAKE_CXX_STANDARD 11)

find_package(miopengemm PATHS ${ROCM_PATH} REQUIRED)
find_package(miopen PATHS ${ROCM_PATH} REQUIRED)
find_package(Protobuf QUIET)

if(GPU_SUPPORT AND "${BACKEND}" STREQUAL "OPENCL")
find_package(miopengemm PATHS ${ROCM_PATH} REQUIRED)
find_package(OpenCL REQUIRED)
list(APPEND PACKAGE_DEPENDS PACKAGE OpenCL)
elseif(GPU_SUPPORT AND "${BACKEND}" STREQUAL "HIP")
Expand Down Expand Up @@ -124,7 +124,7 @@ elseif (GPU_SUPPORT AND "${BACKEND}" STREQUAL "HIP" AND HIP_FOUND)
add_library(vx_nn SHARED ${SOURCES})
set_target_properties(openvx PROPERTIES LINKER_LANGUAGE CXX)
set_target_properties(openvx PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_link_libraries(vx_nn openvx openvx_hip nn_hip MIOpen miopengemm ${HIP_LIBRARY})
target_link_libraries(vx_nn openvx openvx_hip nn_hip MIOpen ${HIP_LIBRARY})
else()
message("-- ${Red}WARNING:OpenCL/HIP Not Found -- amd_nn module excluded${ColourReset}")
endif()
Expand Down
2 changes: 1 addition & 1 deletion apps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../amd_openvx/cmake)

if(GPU_SUPPORT)
find_package(OpenCV QUIET)
find_package(miopengemm PATHS ${ROCM_PATH} QUIET)
find_package(miopen PATHS ${ROCM_PATH} QUIET)

if("${BACKEND}" STREQUAL "OPENCL")
find_package(miopengemm PATHS ${ROCM_PATH} QUIET)
find_package(OpenCL QUIET)
if (OpenCL_FOUND)
set(BUILD_OPENCL True)
Expand Down