Skip to content

Commit 0cf2d53

Browse files
Arm backend: Update minimal example notebook (#11149)
cc @digantdesai @freddan80 @per @zingo @oscarandersson8218 Signed-off-by: Adrian Lundell <adrian.lundell@arm.com>
1 parent e022e34 commit 0cf2d53

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

examples/arm/ethos_u_minimal_example.ipynb

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,14 @@
137137
"metadata": {},
138138
"outputs": [],
139139
"source": [
140+
"import os\n",
140141
"from executorch.backends.arm.ethosu_partitioner import EthosUPartitioner\n",
141142
"from executorch.exir import (\n",
142143
" EdgeCompileConfig,\n",
143144
" ExecutorchBackendConfig,\n",
144145
" to_edge_transform_and_lower,\n",
145146
")\n",
146147
"from executorch.extension.export_util.utils import save_pte_program\n",
147-
"import platform\n",
148148
"\n",
149149
"# Create partitioner from compile spec\n",
150150
"partitioner = EthosUPartitioner(compile_spec)\n",
@@ -158,15 +158,6 @@
158158
" ),\n",
159159
" )\n",
160160
"\n",
161-
"# Load quantization ops library\n",
162-
"os_aot_lib_names = {\"Darwin\" : \"libquantized_ops_aot_lib.dylib\",\n",
163-
" \"Linux\" : \"libquantized_ops_aot_lib.so\",\n",
164-
" \"Windows\": \"libquantized_ops_aot_lib.dll\"}\n",
165-
"aot_lib_name = os_aot_lib_names[platform.system()]\n",
166-
"\n",
167-
"libquantized_ops_aot_lib_path = os.path.join(et_dir, \"cmake-out-aot-lib\", \"kernels\", \"quantized\", aot_lib_name)\n",
168-
"torch.ops.load_library(libquantized_ops_aot_lib_path)\n",
169-
"\n",
170161
"# Convert edge program to executorch\n",
171162
"executorch_program_manager = edge_program_manager.to_executorch(\n",
172163
" config=ExecutorchBackendConfig(extract_delegate_segments=False)\n",
@@ -175,6 +166,7 @@
175166
"executorch_program_manager.exported_program().module().print_readable()\n",
176167
"\n",
177168
"# Save pte file\n",
169+
"cwd_dir = os.getcwd()\n",
178170
"pte_base_name = \"simple_example\"\n",
179171
"pte_name = pte_base_name + \".pte\"\n",
180172
"pte_path = os.path.join(cwd_dir, pte_name)\n",
@@ -200,13 +192,20 @@
200192
"metadata": {},
201193
"outputs": [],
202194
"source": [
203-
"# Build executorch\n",
195+
"import subprocess\n",
196+
"\n",
197+
"# Setup paths\n",
198+
"et_dir = os.path.join(cwd_dir, \"..\", \"..\")\n",
199+
"et_dir = os.path.abspath(et_dir)\n",
200+
"script_dir = os.path.join(et_dir, \"backends\", \"arm\", \"scripts\")\n",
201+
"\n",
202+
"# Cross-compile executorch \n",
204203
"subprocess.run(os.path.join(script_dir, \"build_executorch.sh\"), shell=True, cwd=et_dir)\n",
205204
"\n",
206-
"# Build portable kernels\n",
205+
"# Cross-compile portable kernels\n",
207206
"subprocess.run(os.path.join(script_dir, \"build_portable_kernels.sh\"), shell=True, cwd=et_dir)\n",
208207
"\n",
209-
"# Build executorch runner\n",
208+
"# Cross-compile executorch runner\n",
210209
"args = f\"--pte={pte_path} --target={target}\"\n",
211210
"subprocess.run(os.path.join(script_dir, \"build_executor_runner.sh\") + \" \" + args, shell=True, cwd=et_dir)\n",
212211
"\n",
@@ -236,7 +235,7 @@
236235
],
237236
"metadata": {
238237
"kernelspec": {
239-
"display_name": "venv",
238+
"display_name": ".venv",
240239
"language": "python",
241240
"name": "python3"
242241
},

0 commit comments

Comments
 (0)