Skip to content

Commit 9352502

Browse files
authored
Arm backend: Enable C++ tests for VGF runtime. (pytorch#23238)
Enable C++ runtime tests for VGF backend. cc @digantdesai @freddan80 @per @zingo @oscarandersson8218 @mansnils @Sebastian-Larsson @robell @rascani Signed-off-by: Elena Zhelezina <elena.zhelezina@arm.com>
1 parent e937cd7 commit 9352502

4 files changed

Lines changed: 76 additions & 29 deletions

File tree

‎.github/workflows/pull.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,7 @@ jobs:
905905
include:
906906
- test_arm_backend: test_pytest_ops_vkml
907907
- test_arm_backend: test_ootb_tests_vgf
908+
- test_arm_backend: test_runtime_vgf
908909
fail-fast: false
909910
with:
910911
runner: linux.2xlarge.memory

‎.github/workflows/trunk.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ jobs:
328328
- test_arm_backend: test_pytest_models_vkml
329329
- test_arm_backend: test_run_vkml
330330
- test_arm_backend: test_ootb_tests_vgf
331+
- test_arm_backend: test_runtime_vgf
331332
- test_arm_backend: test_smaller_stories_llama_vkml
332333
fail-fast: false
333334
with:

‎backends/arm/CMakeLists.txt‎

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -251,35 +251,6 @@ if(EXECUTORCH_BUILD_VGF)
251251
NO_DEFAULT_PATH
252252
)
253253

254-
if(EXECUTORCH_BUILD_TESTS)
255-
add_executable(
256-
vgf_neural_statistics_test
257-
${EXECUTORCH_ROOT}/backends/arm/test/vgf_neural_statistics_test.cpp
258-
${EXECUTORCH_ROOT}/backends/arm/runtime/VGFNeuralStatistics.cpp
259-
)
260-
target_include_directories(
261-
vgf_neural_statistics_test
262-
PRIVATE ${_common_include_directories} ${VULKAN_HEADERS_PATH}
263-
${VOLK_HEADERS_PATH}
264-
)
265-
target_compile_options(
266-
vgf_neural_statistics_test PRIVATE -DUSE_VULKAN_WRAPPER
267-
-DUSE_VULKAN_VOLK
268-
)
269-
target_link_libraries(vgf_neural_statistics_test PRIVATE executorch_core)
270-
if(TARGET GTest::gtest_main)
271-
target_link_libraries(
272-
vgf_neural_statistics_test PRIVATE GTest::gtest_main
273-
)
274-
else()
275-
target_link_libraries(
276-
vgf_neural_statistics_test PRIVATE gtest gtest_main
277-
)
278-
endif()
279-
add_test(NAME vgf_neural_statistics_test
280-
COMMAND vgf_neural_statistics_test
281-
)
282-
endif()
283254
endif()
284255

285256
if(TARGET VGF::vgf)
@@ -322,6 +293,32 @@ if(EXECUTORCH_BUILD_VGF)
322293
executorch_target_link_options_shared_lib(vgf_backend)
323294

324295
if(EXECUTORCH_BUILD_TESTS)
296+
add_executable(
297+
vgf_neural_statistics_test
298+
${EXECUTORCH_ROOT}/backends/arm/test/vgf_neural_statistics_test.cpp
299+
${EXECUTORCH_ROOT}/backends/arm/runtime/VGFNeuralStatistics.cpp
300+
${EXECUTORCH_ROOT}/backends/vulkan/third-party/volk/volk.c
301+
)
302+
target_include_directories(
303+
vgf_neural_statistics_test
304+
PRIVATE ${_common_include_directories} ${VULKAN_HEADERS_PATH}
305+
${VOLK_HEADERS_PATH}
306+
)
307+
target_compile_options(
308+
vgf_neural_statistics_test PRIVATE -DUSE_VULKAN_WRAPPER -DUSE_VULKAN_VOLK
309+
)
310+
target_link_libraries(
311+
vgf_neural_statistics_test PRIVATE executorch_core ${CMAKE_DL_LIBS}
312+
)
313+
if(TARGET GTest::gtest_main)
314+
target_link_libraries(
315+
vgf_neural_statistics_test PRIVATE GTest::gtest_main
316+
)
317+
else()
318+
target_link_libraries(vgf_neural_statistics_test PRIVATE gtest gtest_main)
319+
endif()
320+
add_test(NAME vgf_neural_statistics_test COMMAND vgf_neural_statistics_test)
321+
325322
add_executable(
326323
vgf_vulkan_features_test
327324
${EXECUTORCH_ROOT}/backends/arm/test/vgf_vulkan_features_test.cpp

‎backends/arm/test/test_arm_backend.sh‎

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,54 @@ test_pytest_vgf_smoke() {
454454
echo "${TEST_SUITE_NAME}: PASS"
455455
}
456456

457+
test_runtime_vgf() {
458+
echo "${TEST_SUITE_NAME}: Run VGF C++ unit tests"
459+
460+
# Keep this separate from the executor_runner build. The normal VKML runner
461+
# intentionally does not enable EXECUTORCH_BUILD_TESTS.
462+
local ctest_build_dir="${et_root_dir}/arm_test/vgf_runtime_tests"
463+
local python_executable="${PYTHON_EXECUTABLE:-}"
464+
465+
if [[ -z "${python_executable}" ]]; then
466+
if command -v python3 >/dev/null 2>&1; then
467+
python_executable="$(command -v python3)"
468+
elif command -v python >/dev/null 2>&1; then
469+
python_executable="$(command -v python)"
470+
else
471+
echo "Python is required to configure the VGF build."
472+
return 1
473+
fi
474+
fi
475+
476+
# Always configure a clean tree so stale CMake cache values cannot make CI
477+
# silently skip EXECUTORCH_BUILD_TESTS or EXECUTORCH_BUILD_VGF.
478+
rm -rf "${ctest_build_dir}"
479+
480+
cmake \
481+
-S "${et_root_dir}" \
482+
-B "${ctest_build_dir}" \
483+
-DCMAKE_BUILD_TYPE=Debug \
484+
-DEXECUTORCH_BUILD_TESTS=ON \
485+
-DEXECUTORCH_BUILD_VGF=ON \
486+
-DEXECUTORCH_BUILD_VULKAN=OFF \
487+
-DPYTHON_EXECUTABLE="${python_executable}" -DPython3_EXECUTABLE="${python_executable}"
488+
489+
# Build the VGF tests explicitly. This makes a missing/renamed target fail
490+
# the job instead of being hidden among unrelated C++ tests.
491+
cmake --build "${ctest_build_dir}" \
492+
--target vgf_neural_statistics_test vgf_vulkan_features_test \
493+
--parallel
494+
495+
# --no-tests=error is intentional: discovering zero VGF tests must fail CI.
496+
ctest \
497+
--test-dir "${ctest_build_dir}" \
498+
--output-on-failure \
499+
--no-tests=error \
500+
-R '^vgf_'
501+
502+
echo "${TEST_SUITE_NAME}: PASS"
503+
}
504+
457505
# --------------------------------------
458506
# -------- Out-of-the-box tests --------
459507
# --------------------------------------

0 commit comments

Comments
 (0)