Skip to content
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: 6 additions & 4 deletions backends/vulkan/cmake/ShaderLibrary.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ if(ANDROID)
message(FATAL_ERROR "ANDROID_NDK not set")
endif()

set(GLSLC_PATH
"${ANDROID_NDK}/shader-tools/${ANDROID_NDK_HOST_SYSTEM_NAME}/glslc"
)
if(NOT GLSLC_PATH)
set(GLSLC_PATH
"${ANDROID_NDK}/shader-tools/${ANDROID_NDK_HOST_SYSTEM_NAME}/glslc"
)
endif()
else()
find_program(GLSLC_PATH glslc PATHS $ENV{PATH})

Expand All @@ -56,7 +58,7 @@ function(gen_vulkan_shader_lib_cpp shaders_path)
${shaders_path} --output-path ${VULKAN_SHADERGEN_OUT_PATH}
--glslc-path=${GLSLC_PATH}
--tmp-dir-path=${VULKAN_SHADERGEN_OUT_PATH}/shader_cache/ --env
${VULKAN_GEN_ARG_ENV}
${VULKAN_GEN_ARG_ENV} --optimize
DEPENDS ${shaders_path}/*
${EXECUTORCH_ROOT}/backends/vulkan/runtime/gen_vulkan_spv.py
)
Expand Down
10 changes: 6 additions & 4 deletions backends/vulkan/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@
cmake_minimum_required(VERSION 3.19)
project(executorch)

if(ANDROID)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH)
endif()

find_package(executorch CONFIG REQUIRED COMPONENTS vulkan_backend)
find_package(GTest CONFIG REQUIRED)

# Only build tests if Vulkan was compiled
find_library(LIB_VULKAN_BACKEND vulkan_backend)

if(LIB_VULKAN_BACKEND)

if(TARGET vulkan_backend)
if(NOT EXECUTORCH_ROOT)
set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../..)
endif()
Expand Down
23 changes: 13 additions & 10 deletions backends/vulkan/test/op_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
cmake_minimum_required(VERSION 3.19)
project(executorch)

if(ANDROID)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH)
endif()

find_package(executorch CONFIG REQUIRED COMPONENTS vulkan_backend)
find_package(GTest CONFIG REQUIRED)

Expand All @@ -31,16 +36,14 @@ endif()
include(${EXECUTORCH_ROOT}/tools/cmake/Utils.cmake)

get_torch_base_path(TORCH_BASE_PATH)
message(STATUS "torch base path: ${TORCH_BASE_PATH}")

# Only build tests if Vulkan was compiled
find_library(LIB_VULKAN_BACKEND vulkan_backend)
find_library(LIB_TORCH torch ${TORCH_BASE_PATH}/lib)
find_library(LIB_TORCH_CPU torch_cpu ${TORCH_BASE_PATH}/lib)
find_library(LIB_C10 c10 ${TORCH_BASE_PATH}/lib)
if(NOT TORCH_INSTALL_PREFIX)
set(TORCH_INSTALL_PREFIX ${TORCH_BASE_PATH})
endif()

message(STATUS "Vulkan backend lib ${LIB_VULKAN_BACKEND}")
message(STATUS "Torch ${LIB_TORCH}")
# libtorch is needed for Vulkan correctness tests
find_library(LIB_TORCH torch HINTS ${TORCH_INSTALL_PREFIX}/lib)
find_library(LIB_TORCH_CPU torch_cpu HINTS ${TORCH_INSTALL_PREFIX}/lib)
find_library(LIB_C10 c10 HINTS ${TORCH_INSTALL_PREFIX}/lib)

if(NOT PYTHON_EXECUTABLE)
set(PYTHON_EXECUTABLE python3)
Expand Down Expand Up @@ -88,7 +91,7 @@ function(vulkan_op_test test_name test_src)
add_test(${test_name} ${test_name})
endfunction()

if(LIB_VULKAN_BACKEND AND LIB_TORCH)
if(TARGET vulkan_backend AND LIB_TORCH)
find_library(
CUSTOM_OPS_LIB custom_ops_aot_lib
HINTS ${CMAKE_INSTALL_PREFIX}/executorch/extension/llm/custom_ops
Expand Down
Loading