|
137 | 137 | "metadata": {}, |
138 | 138 | "outputs": [], |
139 | 139 | "source": [ |
| 140 | + "import os\n", |
140 | 141 | "from executorch.backends.arm.ethosu_partitioner import EthosUPartitioner\n", |
141 | 142 | "from executorch.exir import (\n", |
142 | 143 | " EdgeCompileConfig,\n", |
143 | 144 | " ExecutorchBackendConfig,\n", |
144 | 145 | " to_edge_transform_and_lower,\n", |
145 | 146 | ")\n", |
146 | 147 | "from executorch.extension.export_util.utils import save_pte_program\n", |
147 | | - "import platform\n", |
148 | 148 | "\n", |
149 | 149 | "# Create partitioner from compile spec\n", |
150 | 150 | "partitioner = EthosUPartitioner(compile_spec)\n", |
|
158 | 158 | " ),\n", |
159 | 159 | " )\n", |
160 | 160 | "\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", |
170 | 161 | "# Convert edge program to executorch\n", |
171 | 162 | "executorch_program_manager = edge_program_manager.to_executorch(\n", |
172 | 163 | " config=ExecutorchBackendConfig(extract_delegate_segments=False)\n", |
|
175 | 166 | "executorch_program_manager.exported_program().module().print_readable()\n", |
176 | 167 | "\n", |
177 | 168 | "# Save pte file\n", |
| 169 | + "cwd_dir = os.getcwd()\n", |
178 | 170 | "pte_base_name = \"simple_example\"\n", |
179 | 171 | "pte_name = pte_base_name + \".pte\"\n", |
180 | 172 | "pte_path = os.path.join(cwd_dir, pte_name)\n", |
|
200 | 192 | "metadata": {}, |
201 | 193 | "outputs": [], |
202 | 194 | "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", |
204 | 203 | "subprocess.run(os.path.join(script_dir, \"build_executorch.sh\"), shell=True, cwd=et_dir)\n", |
205 | 204 | "\n", |
206 | | - "# Build portable kernels\n", |
| 205 | + "# Cross-compile portable kernels\n", |
207 | 206 | "subprocess.run(os.path.join(script_dir, \"build_portable_kernels.sh\"), shell=True, cwd=et_dir)\n", |
208 | 207 | "\n", |
209 | | - "# Build executorch runner\n", |
| 208 | + "# Cross-compile executorch runner\n", |
210 | 209 | "args = f\"--pte={pte_path} --target={target}\"\n", |
211 | 210 | "subprocess.run(os.path.join(script_dir, \"build_executor_runner.sh\") + \" \" + args, shell=True, cwd=et_dir)\n", |
212 | 211 | "\n", |
|
236 | 235 | ], |
237 | 236 | "metadata": { |
238 | 237 | "kernelspec": { |
239 | | - "display_name": "venv", |
| 238 | + "display_name": ".venv", |
240 | 239 | "language": "python", |
241 | 240 | "name": "python3" |
242 | 241 | }, |
|
0 commit comments