File tree Expand file tree Collapse file tree 4 files changed +53
-1
lines changed Expand file tree Collapse file tree 4 files changed +53
-1
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ install_swiftshader() {
2323
2424 export VK_ICD_FILENAMES=" ${_swiftshader_dir} /swiftshader/build/Linux/vk_swiftshader_icd.json"
2525 export LD_LIBRARY_PATH=" ${_swiftshader_dir} /swiftshader/build/Linux/"
26+ export ETVK_USING_SWIFTSHADER=1
2627}
2728
2829install_vulkan_sdk () {
Original file line number Diff line number Diff line change @@ -864,6 +864,43 @@ jobs:
864864 PYTHON_EXECUTABLE=python bash examples/nxp/run_aot_example.sh
865865
866866
867+ test-vulkan-models-linux :
868+ name : test-vulkan-models-linux
869+ uses : pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
870+ permissions :
871+ id-token : write
872+ contents : read
873+ with :
874+ runner : linux.2xlarge
875+ docker-image : ci-image:executorch-ubuntu-22.04-clang12
876+ submodules : ' recursive'
877+ ref : ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
878+ timeout : 90
879+ script : |
880+ set -eux
881+
882+ # The generic Linux job chooses to use base env, not the one setup by the image
883+ CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
884+ conda activate "${CONDA_ENV}"
885+
886+ # Setup swiftshader and Vulkan SDK which are required to build the Vulkan delegate
887+ source .ci/scripts/setup-vulkan-linux-deps.sh
888+
889+ # Setup python
890+ PYTHON_EXECUTABLE=python \
891+ CMAKE_ARGS="-DEXECUTORCH_BUILD_VULKAN=ON" \
892+ .ci/scripts/setup-linux.sh --build-tool "cmake"
893+
894+ PYTHON_EXECUTABLE=python bash backends/vulkan/test/scripts/test_model.sh --build
895+
896+ # Test models serially
897+ models="mv2 mv3 edsr resnet18 resnet50 dl3"
898+ for model in $models; do
899+ python -m examples.vulkan.export --model_name=$model --test
900+ done
901+
902+
903+
867904 nxp-build-test :
868905 name : nxp-build-test
869906 uses : pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
Original file line number Diff line number Diff line change @@ -49,6 +49,15 @@ function(gen_vulkan_shader_lib_cpp shaders_path)
4949 set (VULKAN_SHADERGEN_ENV "" )
5050 set (VULKAN_SHADERGEN_OUT_PATH ${CMAKE_BINARY_DIR} /vulkan_compute_shaders)
5151
52+ set (GEN_SPV_ARGS "--optimize" )
53+ if (DEFINED ENV{ETVK_USING_SWIFTSHADER})
54+ if ("$ENV{ETVK_USING_SWIFTSHADER} " STREQUAL "1"
55+ OR "$ENV{ETVK_USING_SWIFTSHADER} " STREQUAL "True"
56+ )
57+ list (APPEND GEN_SPV_ARGS "--replace-u16vecn" )
58+ endif ()
59+ endif ()
60+
5261 add_custom_command (
5362 COMMENT "Generating Vulkan Compute Shaders"
5463 OUTPUT ${VULKAN_SHADERGEN_OUT_PATH} /spv.cpp
@@ -58,7 +67,7 @@ function(gen_vulkan_shader_lib_cpp shaders_path)
5867 ${shaders_path} --output -path ${VULKAN_SHADERGEN_OUT_PATH}
5968 --glslc-path =${GLSLC_PATH}
6069 --tmp-dir-path =${VULKAN_SHADERGEN_OUT_PATH} /shader_cache/ --env
61- ${VULKAN_GEN_ARG_ENV} --optimize
70+ ${VULKAN_GEN_ARG_ENV} ${GEN_SPV_ARGS}
6271 DEPENDS ${shaders_path} /*
6372 ${EXECUTORCH_ROOT} /backends/vulkan/runtime/gen_vulkan_spv.py
6473 )
Original file line number Diff line number Diff line change 66
77
88import logging
9+ from collections import OrderedDict
910from typing import List , Optional , Tuple
1011
1112import executorch .backends .vulkan .utils as utils
@@ -114,6 +115,10 @@ def check_outputs_equal(
114115 Helper function that checks if model output and reference output are equal with some tolerance.
115116 Returns True if equal, False otherwise.
116117 """
118+ # Convert OrderedDict to list if needed
119+ if isinstance (ref_output , OrderedDict ):
120+ ref_output = list (ref_output .values ())
121+
117122 # Compare the result from executor and eager mode directly
118123 if isinstance (ref_output , tuple ) or isinstance (ref_output , list ):
119124 # Multiple outputs executor always returns tuple, even if there is one output
You can’t perform that action at this time.
0 commit comments