|
13 | 13 | * [Error during torch.export.export](#error-during-torchexportexport) |
14 | 14 | * [Error during ExportedProgram to edge model lowering](#error-during-exportedprogram-to-edge-model-lowering) |
15 | 15 | * [Visualization](#visualization) |
16 | | -* [Use ODML Torch Conversion Backend (Experimental)](#use-odml-torch-conversion-backend-experimental) |
| 16 | +* [Use Torch XLA Conversion Backend (Legacy)](#use-torch-xla-conversion-backend-legacy) |
| 17 | + * [Update LD_LIBRARY_PATH if necessary](#update-ld_library_path-if-necessary) |
17 | 18 |
|
18 | 19 | <!-- Created by https://github.com/ekalinin/github-markdown-toc --> |
19 | | -<!-- Added by: cnchan, at: Wed Jul 24 09:51:17 PM PDT 2024 --> |
20 | 20 |
|
21 | 21 | <!--te--> |
22 | 22 |
|
@@ -327,19 +327,26 @@ pip install ai-edge-model-explorer |
327 | 327 | model-explorer 'resnet.tflite' |
328 | 328 | ``` |
329 | 329 |
|
330 | | -# Use ODML Torch Conversion Backend (Experimental) |
| 330 | +# Use Torch XLA Conversion Backend (Legacy) |
331 | 331 |
|
332 | | -ODML Torch is an experimental conversion backend for AI Edge Torch, which enables |
333 | | -conversion on macOS and generates TFLite Flatbuffer with higher quality and better |
334 | | -performance. To use AI Edge Torch with ODML Torch, setup your environment these |
335 | | -commands: |
| 332 | +AI Edge Torch has been switched to a modern conversion backend for better |
| 333 | +on-device compatibility and performance. However, if you encounter compatibility |
| 334 | +issues, you can optionally switch to the legacy Torch XLA backend: |
336 | 335 |
|
337 | 336 | ```bash |
338 | | -# Install ODML Torch backend dependencies |
339 | | -pip install -r https://raw.githubusercontent.com/google-ai-edge/ai-edge-torch/main/odmltorch-requirements.txt |
340 | | -# Install ai-edge-torch with no default backend (Torch XLA) dependencies |
341 | | -pip install ai-edge-torch-nightly --no-deps |
342 | | - |
343 | | -# Disable default AI Edge Torch backend (Torch XLA) |
344 | | -export USE_TORCH_XLA=0 |
345 | | -``` |
| 337 | +# Install ai-edge-torch with torch-xla dependency |
| 338 | +pip install ai-edge-torch-nightly[torch-xla] |
| 339 | + |
| 340 | +# Enable torch-xla as the AI Edge Torch backend |
| 341 | +export USE_TORCH_XLA=1 |
| 342 | +``` |
| 343 | + |
| 344 | +## Update LD_LIBRARY_PATH if necessary |
| 345 | + |
| 346 | +Torch XLA builds a shared library, `_XLAC.so` that needs to link to the version of Python |
| 347 | +it was built with (currently 3.10 or 3.11). In order to ensure that `import _XLAC` can succeed, |
| 348 | +update the LD_LIBRARY_PATH to the lib directory of your Python environment: |
| 349 | + |
| 350 | +```bash |
| 351 | +export LD_LIBRARY_PATH=<path to Python installation>/lib:$LD_LIBRARY_PATH |
| 352 | +``` |
0 commit comments