Skip to content

Commit 3d4be1d

Browse files
authored
Arm backend: Install TOSA and VGF tooling from pip (#18840)
Install tosa-tools and the ML SDK model-converter/VGF packages from pip instead of cloning tosa-tools from source. Update the VGF runtime to the 0.9 decoder API and export VK_LAYER_PATH for the pip-installed emulation layer so the Vulkan ML layers are discovered at runtime. Signed-off-by: per.held@arm.com
1 parent 65db2ac commit 3d4be1d

7 files changed

Lines changed: 41 additions & 46 deletions

File tree

backends/arm/requirements-arm-tosa.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,5 @@ ml_dtypes == 0.5.1
77
flatbuffers == 24.3.25
88
tosa-adapter-model-explorer == 0.1.0
99
ai-edge-model-explorer >= 0.1.16
10-
# NOTE: Will be removed when tosa-tools is installed via pypi
11-
pybind11 == 2.10.4
12-
pytest-timeout == 2.4.0
10+
pytest-timeout == 2.4.0
11+
tosa-tools == 2026.2.1

backends/arm/requirements-arm-vgf.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
# This source code is licensed under the BSD-style license found in the
44
# LICENSE file in the root directory of this source tree.
55

6-
ai_ml_emulation_layer_for_vulkan == 0.8.0
7-
ai_ml_sdk_model_converter == 0.8.0
8-
ai_ml_sdk_vgf_library == 0.8.0
6+
ai_ml_emulation_layer_for_vulkan == 0.9.0
7+
ai_ml_sdk_model_converter == 0.9.0
8+
ai_ml_sdk_vgf_library == 0.9.0

backends/arm/runtime/VGFBackend.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ class VGFBackend final : public ::executorch::runtime::BackendInterface {
157157
new (repr) VgfRepr(
158158
vk_instance, vk_physical_device, vk_device, vk_queue, vk_command_pool);
159159

160-
auto valid_vgf = repr->process_vgf(vgf_data, compile_specs);
160+
auto valid_vgf =
161+
repr->process_vgf(vgf_data, processed->size(), compile_specs);
161162
if (!valid_vgf) {
162163
ET_LOG(Error, "Failed to process VGF blob.");
163164
return Error::Internal;

backends/arm/runtime/VGFSetup.cpp

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2025 Arm Limited and/or its affiliates.
2+
* Copyright 2025-2026 Arm Limited and/or its affiliates.
33
*
44
* This source code is licensed under the BSD-style license found in the
55
* LICENSE file in the root directory of this source tree.
@@ -324,26 +324,38 @@ static void debug_print_modules(
324324
}
325325
}
326326

327-
bool VgfRepr::process_vgf(const char* vgf_data, ArrayRef<CompileSpec> specs) {
327+
bool VgfRepr::process_vgf(
328+
const char* vgf_data,
329+
size_t vgf_size,
330+
ArrayRef<CompileSpec> specs) {
328331
ET_LOG(Info, "Preparing VGF as Vulkan objects");
329332

330333
VkResult result;
331334

332335
// Prepare temporary decoders
333336
unique_ptr<vgflib::HeaderDecoder> header_decoder =
334-
vgflib::CreateHeaderDecoder(vgf_data);
337+
vgflib::CreateHeaderDecoder(vgf_data, vgflib::HeaderSize(), vgf_size);
338+
if (!header_decoder) {
339+
ET_LOG(Error, "Failed to create VGF header decoder");
340+
return false;
341+
}
342+
335343
unique_ptr<vgflib::ModelSequenceTableDecoder> sequence_decoder =
336344
vgflib::CreateModelSequenceTableDecoder(
337-
vgf_data + header_decoder->GetModelSequenceTableOffset());
345+
vgf_data + header_decoder->GetModelSequenceTableOffset(),
346+
header_decoder->GetModelSequenceTableSize());
338347
unique_ptr<vgflib::ModuleTableDecoder> module_decoder =
339348
vgflib::CreateModuleTableDecoder(
340-
vgf_data + header_decoder->GetModuleTableOffset());
349+
vgf_data + header_decoder->GetModuleTableOffset(),
350+
header_decoder->GetModuleTableSize());
341351
unique_ptr<vgflib::ModelResourceTableDecoder> resource_decoder =
342352
vgflib::CreateModelResourceTableDecoder(
343-
vgf_data + header_decoder->GetModelResourceTableOffset());
353+
vgf_data + header_decoder->GetModelResourceTableOffset(),
354+
header_decoder->GetModelResourceTableSize());
344355
unique_ptr<vgflib::ConstantDecoder> constant_decoder =
345356
vgflib::CreateConstantDecoder(
346-
vgf_data + header_decoder->GetConstantsOffset());
357+
vgf_data + header_decoder->GetConstantsOffset(),
358+
header_decoder->GetConstantsSize());
347359
// Check the VGF decoders
348360
if (not(header_decoder && module_decoder && sequence_decoder &&
349361
resource_decoder && constant_decoder && header_decoder->IsValid() &&

backends/arm/runtime/VGFSetup.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2025 Arm Limited and/or its affiliates.
2+
* Copyright 2025-2026 Arm Limited and/or its affiliates.
33
*
44
* This source code is licensed under the BSD-style license found in the
55
* LICENSE file in the root directory of this source tree.
@@ -58,7 +58,10 @@ class VgfRepr {
5858
/*
5959
* Process a VGF ready for execution, allocate necessary Vulkan objects.
6060
*/
61-
bool process_vgf(const char* vgf_data, ArrayRef<CompileSpec> specs);
61+
bool process_vgf(
62+
const char* vgf_data,
63+
size_t vgf_size,
64+
ArrayRef<CompileSpec> specs);
6265

6366
/*
6467
* Execute the VGF we've previously processed.

backends/arm/scripts/mlsdk_utils.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,16 @@ PY
291291
fi
292292
fi
293293

294+
local vk_layer_line
295+
vk_layer_line=$(echo "$exports" | grep 'VK_LAYER_PATH=' || true)
296+
if [[ -n "${vk_layer_line}" ]]; then
297+
local vk_layer_value=${vk_layer_line#export VK_LAYER_PATH=}
298+
vk_layer_value=${vk_layer_value%%:\$VK_LAYER_PATH*}
299+
if [[ -n "${vk_layer_value}" ]]; then
300+
prepend_env_in_setup_path VK_LAYER_PATH "${vk_layer_value}"
301+
fi
302+
fi
303+
294304
local vk_add_line
295305
vk_add_line=$(echo "$exports" | grep 'VK_ADD_LAYER_PATH=' || true)
296306
if [[ -n "${vk_add_line}" ]]; then

examples/arm/setup.sh

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -335,36 +335,6 @@ if [[ $is_script_sourced -eq 0 ]]; then
335335
CMAKE_POLICY_VERSION_MINIMUM=3.5 \
336336
pip install --no-dependencies -r "$et_dir/backends/arm/requirements-arm-tosa.txt"
337337

338-
pushd "$root_dir"
339-
if [[ ! -d "tosa-tools" ]]; then
340-
git clone https://git.gitlab.arm.com/tosa/tosa-tools.git
341-
fi
342-
343-
pushd tosa-tools
344-
git checkout v2025.11.2
345-
346-
if [[ ! -d "reference_model" ]]; then
347-
log_step "main" "[error] Missing reference_model directory in tosa-tools repo."
348-
exit 1
349-
fi
350-
if [[ ! -d "serialization" ]]; then
351-
log_step "main" "[error] Missing serialization directory in tosa-tools repo."
352-
exit 1
353-
fi
354-
355-
export CMAKE_BUILD_PARALLEL_LEVEL="$(get_parallel_jobs)"
356-
357-
CMAKE_POLICY_VERSION_MINIMUM=3.5 \
358-
BUILD_PYBIND=1 \
359-
BUILD_TOSA_REFERENCE_MODEL_TESTS=0 \
360-
pip install --no-dependencies ./reference_model
361-
362-
CMAKE_POLICY_VERSION_MINIMUM=3.5 \
363-
BUILD_PYBIND=1 \
364-
pip install --no-dependencies ./serialization
365-
popd
366-
popd
367-
368338
if [[ "${enable_vela}" -eq 1 ]]; then
369339
log_step "deps" "Installing Ethos-U Vela compiler"
370340
setup_ethos_u_tools

0 commit comments

Comments
 (0)