Skip to content

Commit dc23eb6

Browse files
committed
Arm backend: Install TOSA reference model with local patches
In preparation to move to TOSA 1.0 release the 0.80 package is moved to it's own namespace to be able to handle both versions during the transition period. Signed-off-by: Per Åstrand <per.astrand@arm.com> Change-Id: Ib653ae81125052f5105ff124b59155018c98aef5
1 parent a6cd1dc commit dc23eb6

File tree

5 files changed

+488
-14
lines changed

5 files changed

+488
-14
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/usr/bin/env bash
2+
# Copyright 2025 Arm Limited and/or its affiliates.
3+
#
4+
# This source code is licensed under the BSD-style license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
7+
set -euo pipefail
8+
9+
# Installation script to manage transition to 1.0
10+
11+
# TOSA reference model
12+
tosa_reference_model_url="https://review.mlplatform.org/tosa/reference_model"
13+
tosa_reference_model_0_80_branch="v0.80"
14+
tosa_reference_model_0_80_rev="70ed0b40fa831387e36abdb4f7fb9670a3464f5a"
15+
tosa_serialization_lib_0_80_rev="v0.80.1"
16+
tosa_reference_model_1_0_rev="v1.0"
17+
18+
script_dir=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)
19+
20+
source ${script_dir}/utils.sh
21+
22+
23+
function setup_tosa_reference_model() {
24+
local work_dir="$1"
25+
26+
if [[ -z "$work_dir" ]]; then
27+
echo "Error: work_dir parameter is required."
28+
return 1
29+
fi
30+
31+
mkdir -p "$work_dir"
32+
pushd "$work_dir" || exit 1
33+
34+
# Install a patched version of TOSA reference model v0.80.1 to make it co-exist with 1.0 during the transition period
35+
if [[ ! -d "reference_model" ]]; then
36+
git clone --recurse-submodules --branch ${tosa_reference_model_0_80_branch} --depth 1 "$tosa_reference_model_url" reference_model
37+
fi
38+
39+
patches_dir=${script_dir}/../third-party/reference_model/patches/v0.80
40+
patch_repo reference_model ${tosa_reference_model_0_80_rev} ${patches_dir}
41+
patch_repo reference_model/thirdparty/serialization_lib ${tosa_serialization_lib_0_80_rev} ${patches_dir}
42+
43+
pushd reference_model
44+
pip install . --no-dependencies flatbuffers
45+
popd
46+
}
47+
48+
setup_tosa_reference_model $1

backends/arm/scripts/utils.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,13 @@ function patch_repo() {
4646
local patch_dir="${3}/$name"
4747

4848
echo -e "[${FUNCNAME[0]}] Patching ${name} repo_dir:${repo_dir} base_rev:${base_rev} patch_dir:${patch_dir}"
49-
cd $repo_dir
49+
pushd $repo_dir
5050
git fetch
5151
git reset --hard ${base_rev}
5252

5353
[[ -e ${patch_dir} && $(ls -A ${patch_dir}) ]] && \
5454
git am -3 ${patch_dir}/*.patch
5555

5656
echo -e "[${FUNCNAME[0]}] Patched ${name} @ $(git describe --all --long 2> /dev/null) in ${repo_dir} dir.\n"
57+
popd
5758
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
From 20c2059723d5c6952cecfb7fcde92601639ef825 Mon Sep 17 00:00:00 2001
2+
From: =?UTF-8?q?Per=20=C3=85strand?= <per.astrand@arm.com>
3+
Date: Wed, 5 Feb 2025 12:31:47 +0100
4+
Subject: [PATCH 1/2] Move tosa-tools to be namespaced into tosa-tools.v0_80
5+
6+
---
7+
CMakeLists.txt | 4 ++-
8+
pyproject.toml | 3 ++-
9+
setup.cfg | 70 +++++++++++++++++++++++++-------------------------
10+
setup.py | 3 ++-
11+
4 files changed, 42 insertions(+), 38 deletions(-)
12+
13+
diff --git a/CMakeLists.txt b/CMakeLists.txt
14+
index 68e8d8a..34becd0 100644
15+
--- a/CMakeLists.txt
16+
+++ b/CMakeLists.txt
17+
@@ -1,4 +1,6 @@
18+
-cmake_minimum_required (VERSION 3.4)
19+
+cmake_minimum_required (VERSION 3.19)
20+
+
21+
+cmake_policy(SET CMP0077 NEW)
22+
23+
set(CMAKE_INSTALL_PREFIX ".")
24+
project(tosa_tools LANGUAGES CXX)
25+
diff --git a/pyproject.toml b/pyproject.toml
26+
index 7565f93..60448e7 100644
27+
--- a/pyproject.toml
28+
+++ b/pyproject.toml
29+
@@ -6,7 +6,8 @@ requires = [
30+
"setuptools>=42",
31+
"wheel",
32+
"setuptools_scm[toml]>=6.0",
33+
- "cmake"
34+
+ "cmake",
35+
+ "ninja",
36+
]
37+
build-backend = "setuptools.build_meta"
38+
39+
diff --git a/setup.cfg b/setup.cfg
40+
index 82ec9b8..c1bd1a8 100644
41+
--- a/setup.cfg
42+
+++ b/setup.cfg
43+
@@ -2,7 +2,7 @@
44+
# SPDX-License-Identifier: Apache-2.0
45+
46+
[metadata]
47+
-name = tosa-tools
48+
+name = tosa-tools-v0.80
49+
# version = done by setuptools_scm in pyproject.toml
50+
author = Arm Limited
51+
#author_email =
52+
@@ -25,44 +25,44 @@ install_requires =
53+
python_requires = >=3.6
54+
include_package_data = True
55+
packages =
56+
- runner
57+
- generator
58+
- checker
59+
- frameworks
60+
- tests
61+
- conformance
62+
- xunit
63+
- json2fbbin
64+
- json2numpy
65+
- schemavalidation
66+
- convert2conformance
67+
- tosa
68+
- serializer
69+
- tosa_reference_model
70+
+ tosa_tools.v0_80.verif.runner
71+
+ tosa_tools.v0_80.verif.generator
72+
+ tosa_tools.v0_80.verif.checker
73+
+ tosa_tools.v0_80.verif.frameworks
74+
+ tosa_tools.v0_80.verif.tests
75+
+ tosa_tools.v0_80.verif.conformance
76+
+ tosa_tools.v0_80.xunit
77+
+ tosa_tools.v0_80.json2fbbin
78+
+ tosa_tools.v0_80.json2numpy
79+
+ tosa_tools.v0_80.schemavalidation
80+
+ tosa_tools.v0_80.convert2conformance
81+
+ tosa_tools.v0_80.tosa
82+
+ tosa_tools.v0_80.serializer
83+
+ tosa_tools.v0_80.tosa_reference_model
84+
package_dir =
85+
- = verif
86+
- xunit = scripts/xunit
87+
- json2fbbin = scripts/json2fbbin
88+
- json2numpy = scripts/json2numpy
89+
- convert2conformance = scripts/convert2conformance
90+
- tosa = thirdparty/serialization_lib/python/tosa
91+
- serializer = thirdparty/serialization_lib/python/serializer
92+
- tosa_reference_model = py_package
93+
- schemavalidation = scripts/schemavalidation
94+
+ tosa_tools.v0_80.verif = verif
95+
+ tosa_tools.v0_80.xunit = scripts/xunit
96+
+ tosa_tools.v0_80.json2fbbin = scripts/json2fbbin
97+
+ tosa_tools.v0_80.json2numpy = scripts/json2numpy
98+
+ tosa_tools.v0_80.convert2conformance = scripts/convert2conformance
99+
+ tosa_tools.v0_80.tosa = thirdparty/serialization_lib/python/tosa
100+
+ tosa_tools.v0_80.serializer = thirdparty/serialization_lib/python/serializer
101+
+ tosa_tools.v0_80.tosa_reference_model = py_package
102+
+ tosa_tools.v0_80.schemavalidation = scripts/schemavalidation
103+
104+
[options.entry_points]
105+
console_scripts =
106+
- tosa_verif_run_ref = runner.tosa_verif_run_tests:main
107+
- tosa_verif_run_tests = runner.tosa_verif_run_tests:main
108+
- tosa_verif_build_tests = generator.tosa_verif_build_tests:main
109+
- tosa_json2numpy = json2numpy.json2numpy:main
110+
- tosa_json2fbbin = json2fbbin.json2fbbin:main
111+
- tosa_verif_result_check = checker.tosa_result_checker:main
112+
- tosa_convert2conformance = convert2conformance.convert2conformance:main
113+
- tosa_verif_framework_generator = frameworks.tosa_verif_framework_generator:main
114+
- tosa_verif_framework_compiler_runner = frameworks.tosa_verif_framework_compiler_runner:main
115+
- tosa_verif_conformance_generator = conformance.tosa_verif_conformance_generator:main
116+
- tosa_schemavalidation = schemavalidation.schemavalidation:main
117+
+ tosa_verif_run_ref = tosa_tools.v0_80.verif.runner.tosa_verif_run_tests:main
118+
+ tosa_verif_run_tests = tosa_tools.v0_80.verif.runner.tosa_verif_run_tests:main
119+
+ tosa_verif_build_tests = tosa_tools.v0_80.verif.generator.tosa_verif_build_tests:main
120+
+ tosa_json2numpy = tosa_tools.v0_80.verif.json2numpy.json2numpy:main
121+
+ tosa_json2fbbin = tosa_tools.v0_80.verif.json2fbbin.json2fbbin:main
122+
+ tosa_verif_result_check = tosa_tools.v0_80.verif.checker.tosa_result_checker:main
123+
+ tosa_convert2conformance = tosa_tools.v0_80.verif.convert2conformance.convert2conformance:main
124+
+ tosa_verif_framework_generator = tosa_tools.v0_80.verif.frameworks.tosa_verif_framework_generator:main
125+
+ tosa_verif_framework_compiler_runner = tosa_tools.v0_80.verif.frameworks.tosa_verif_framework_compiler_runner:main
126+
+ tosa_verif_conformance_generator = tosa_tools.v0_80.verif.conformance.tosa_verif_conformance_generator:main
127+
+ tosa_schemavalidation = tosa_tools.v0_80.verif.schemavalidation.schemavalidation:main
128+
129+
[options.package_data]
130+
schemavalidation=
131+
diff --git a/setup.py b/setup.py
132+
index 8c6b4cd..95896ad 100644
133+
--- a/setup.py
134+
+++ b/setup.py
135+
@@ -20,7 +20,7 @@ class CMakeBuild(build_py):
136+
root_dir = Path(__file__).parent
137+
build_dir = root_dir / "build"
138+
build_dir.mkdir(exist_ok=True)
139+
- package_dir = root_dir / "py_package"
140+
+ package_dir = root_dir / "build/lib/tosa_tools/v0_80/tosa_reference_model/"
141+
142+
cmake_cmd = [
143+
"cmake",
144+
@@ -90,6 +90,7 @@ class CMakeBuild(build_py):
145+
# Python will know which one to import
146+
copied_so = False
147+
so_dir = build_dir / "reference_model"
148+
+ package_dir.mkdir(parents=True, exist_ok=True)
149+
print(f"copying .so files from '{so_dir}' to '{package_dir}'")
150+
for so_file in so_dir.glob("tosa_reference_model.*.so"):
151+
shutil.copy(so_file, package_dir)
152+
--
153+
2.39.5 (Apple Git-154)
154+

0 commit comments

Comments
 (0)