Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 13 additions & 14 deletions examples/arm/ethos_u_minimal_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,14 @@
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"from executorch.backends.arm.ethosu_partitioner import EthosUPartitioner\n",
"from executorch.exir import (\n",
" EdgeCompileConfig,\n",
" ExecutorchBackendConfig,\n",
" to_edge_transform_and_lower,\n",
")\n",
"from executorch.extension.export_util.utils import save_pte_program\n",
"import platform\n",
"\n",
"# Create partitioner from compile spec\n",
"partitioner = EthosUPartitioner(compile_spec)\n",
Expand All @@ -158,15 +158,6 @@
" ),\n",
" )\n",
"\n",
"# Load quantization ops library\n",
"os_aot_lib_names = {\"Darwin\" : \"libquantized_ops_aot_lib.dylib\",\n",
" \"Linux\" : \"libquantized_ops_aot_lib.so\",\n",
" \"Windows\": \"libquantized_ops_aot_lib.dll\"}\n",
"aot_lib_name = os_aot_lib_names[platform.system()]\n",
"\n",
"libquantized_ops_aot_lib_path = os.path.join(et_dir, \"cmake-out-aot-lib\", \"kernels\", \"quantized\", aot_lib_name)\n",
"torch.ops.load_library(libquantized_ops_aot_lib_path)\n",
"\n",
"# Convert edge program to executorch\n",
"executorch_program_manager = edge_program_manager.to_executorch(\n",
" config=ExecutorchBackendConfig(extract_delegate_segments=False)\n",
Expand All @@ -175,6 +166,7 @@
"executorch_program_manager.exported_program().module().print_readable()\n",
"\n",
"# Save pte file\n",
"cwd_dir = os.getcwd()\n",
"pte_base_name = \"simple_example\"\n",
"pte_name = pte_base_name + \".pte\"\n",
"pte_path = os.path.join(cwd_dir, pte_name)\n",
Expand All @@ -200,13 +192,20 @@
"metadata": {},
"outputs": [],
"source": [
"# Build executorch\n",
"import subprocess\n",
"\n",
"# Setup paths\n",
"et_dir = os.path.join(cwd_dir, \"..\", \"..\")\n",
"et_dir = os.path.abspath(et_dir)\n",
"script_dir = os.path.join(et_dir, \"backends\", \"arm\", \"scripts\")\n",
"\n",
"# Cross-compile executorch \n",
"subprocess.run(os.path.join(script_dir, \"build_executorch.sh\"), shell=True, cwd=et_dir)\n",
"\n",
"# Build portable kernels\n",
"# Cross-compile portable kernels\n",
"subprocess.run(os.path.join(script_dir, \"build_portable_kernels.sh\"), shell=True, cwd=et_dir)\n",
"\n",
"# Build executorch runner\n",
"# Cross-compile executorch runner\n",
"args = f\"--pte={pte_path} --target={target}\"\n",
"subprocess.run(os.path.join(script_dir, \"build_executor_runner.sh\") + \" \" + args, shell=True, cwd=et_dir)\n",
"\n",
Expand Down Expand Up @@ -236,7 +235,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "venv",
"display_name": ".venv",
"language": "python",
"name": "python3"
},
Expand Down
Loading