Skip to content

Commit 1c72e0e

Browse files
authored
Arm backend: Introduce support for a VGF runtime backend. (#12426)
This is a first version of a VGF runtime with spport for simple VGF files containing inputs and outputs (no weights) and will prepare the appropriate Vulkan structures and dispatch the workload following the normal backend delegate interfaces. It's intended to be extended to take advantage of the existing Vulkan delegate by replacing the basic object creation, and by re-using the VgfRepr in the appropriate way in either a "direct" Arm backend for testing and simple deployment, or integrated with the Vulkan backend to have good memory, sync and performance interop with existing Vulkan delegate operators. It re-uses the build-setup (headers, volk, etc) and vulkan_executor_runner and has been tested on linux only. This was on the simple S32 add kernel from the aot_arm_compiler, and a quantized and non-quantized mv2. It depends on a number of components which are not yet released, and the script for these is not included, as our third party dependencies are still evolving. Details: * Minor build fix for vulkan runtime. * Bump vulkan and volk headers to get tensor and graph extensions * First version of VGFBackend, dispatching on a vulkan layer driver * Will process the examples/models mv2 model and constants ### Testing This change currently requires internal dependencies while a few pieces are upstreamed. The following is reproducable for those with full access to the ML SDK for Vulkan (https://github.com/arm/ai-ml-sdk-model-converter) ``` # test models python3 -m examples.arm.aot_arm_compiler -t vgf --delegate --model_name="add" -i ./out_add -o out_add.pte python3 -m examples.arm.aot_arm_compiler -t vgf --delegate --model_name="mv2" -i ./out_mv2 -o out_mv2.pte #quantized test models python3 -m examples.arm.aot_arm_compiler -t vgf --delegate --quantize --model_name=add -i ./out_add_quant -o out_add_quant.pte python3 -m examples.arm.aot_arm_compiler --model_name=mv2 --target=vgf --quantize --delegate -i ./out_mv2_quant -o out_mv2_quant.pte # commands to execute them using the vulkan executor runner ./cmake-out/backends/vulkan/vulkan_executor_runner -model_path out_add.pte ./cmake-out/backends/vulkan/vulkan_executor_runner -model_path out_mv2.pte ./cmake-out/backends/vulkan/vulkan_executor_runner -model_path out_add_quant.pte ./cmake-out/backends/vulkan/vulkan_executor_runner -model_path out_mv2_quant.pte ``` Signed-off-by: Rob Elliott <[email protected]>
1 parent de0554d commit 1c72e0e

File tree

10 files changed

+1329
-4
lines changed

10 files changed

+1329
-4
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,10 @@ endif()
817817
if(EXECUTORCH_BUILD_VULKAN)
818818
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/vulkan)
819819
endif()
820+
if(EXECUTORCH_BUILD_VGF)
821+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/arm)
822+
endif()
823+
820824

821825
if(EXECUTORCH_BUILD_ANDROID_JNI)
822826
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/android)

backends/arm/CMakeLists.txt

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,17 @@ if(NOT EXECUTORCH_ROOT)
1212
set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../..)
1313
endif()
1414

15-
add_compile_options("-Wall" "-Werror")
16-
1715
include(${EXECUTORCH_ROOT}/tools/cmake/Utils.cmake)
1816

1917
set(_common_include_directories ${EXECUTORCH_ROOT}/.. ${EXECUTORCH_ROOT}/runtime/core/portable_type/c10)
2018
add_compile_definitions(C10_USING_CUSTOM_GENERATED_MACROS)
2119

20+
21+
# bare metal backend builds
22+
if(EXECUTORCH_BUILD_ARM_BAREMETAL)
23+
24+
add_compile_options("-Wall" "-Werror")
25+
2226
# Third-party folder and Ethos-U driver inclued
2327
set(THIRD_PARTY_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/third-party")
2428
set(DRIVER_ETHOSU_INCLUDE_DIR "${THIRD_PARTY_ROOT}/ethos-u-core-driver/include")
@@ -36,3 +40,47 @@ target_include_directories(
3640
target_include_directories(
3741
executorch_delegate_ethos_u PUBLIC ${DRIVER_ETHOSU_INCLUDE_DIR}
3842
)
43+
44+
# end config for bare metal builds
45+
endif()
46+
47+
48+
# VGF backend builds
49+
if(EXECUTORCH_BUILD_VGF)
50+
51+
# include libvgf
52+
set(LIBVGF_PATH "${EXECUTORCH_ROOT}/examples/arm/ethos-u-scratch/ml-sdk-for-vulkan-manifest/sw/vgf-lib/")
53+
54+
set(VULKAN_THIRD_PARTY_PATH ${EXECUTORCH_ROOT}/backends/vulkan/third-party)
55+
set(VULKAN_HEADERS_PATH ${VULKAN_THIRD_PARTY_PATH}/Vulkan-Headers/include)
56+
set(VOLK_HEADERS_PATH ${VULKAN_THIRD_PARTY_PATH}/volk)
57+
58+
set(LIBVGF_STATIC "${LIBVGF_PATH}/build/src/libvgf.a")
59+
set(LIBVGF_INCLUDE "${LIBVGF_PATH}/include/")
60+
61+
add_library(vgf STATIC IMPORTED)
62+
set_property( TARGET vgf PROPERTY IMPORTED_LOCATION "${LIBVGF_STATIC}" )
63+
target_include_directories(vgf INTERFACE "${LIBVGF_INCLUDE}")
64+
65+
# Add backend delegate for VGF
66+
set(_vgf_backend_sources backends/arm/runtime/VGFBackend.cpp
67+
backends/arm/runtime/VGFSetup.cpp )
68+
69+
# vgf backend
70+
list(TRANSFORM _vgf_backend_sources PREPEND "${EXECUTORCH_ROOT}/")
71+
add_library(vgf_backend ${_vgf_backend_sources})
72+
target_include_directories(
73+
vgf_backend PUBLIC
74+
${_common_include_directories}
75+
${VULKAN_HEADERS_PATH}
76+
${VOLK_HEADERS_PATH}
77+
)
78+
target_compile_options(vgf_backend PRIVATE -DUSE_VULKAN_WRAPPER -DUSE_VULKAN_VOLK)
79+
80+
81+
target_link_libraries(vgf_backend PRIVATE executorch_core)
82+
target_link_libraries(vgf_backend PRIVATE vgf)
83+
executorch_target_link_options_shared_lib(vgf_backend)
84+
85+
# end config for VGF builds
86+
endif()

0 commit comments

Comments
 (0)