|
| 1 | +# ExecuTorch Program Data Separation Demo C++. |
| 2 | + |
| 3 | +This directory contains the C++ code to run the examples generated in [program-data-separation](../program-data-separation/README.md). |
| 4 | + |
| 5 | + |
| 6 | +## Virtual environment setup. |
| 7 | +Create and activate a Python virtual environment: |
| 8 | +```bash |
| 9 | +python3 -m venv .venv && source .venv/bin/activate && pip install --upgrade pip |
| 10 | +``` |
| 11 | +Or alternatively, [install conda on your machine](https://conda.io/projects/conda/en/latest/user-guide/install/index.html) |
| 12 | +```bash |
| 13 | +conda create -yn executorch-ptd python=3.10.0 && conda activate executorch-ptd |
| 14 | +``` |
| 15 | + |
| 16 | +Install dependencies: |
| 17 | +```bash |
| 18 | +pip install executorch==0.7.0 |
| 19 | +``` |
| 20 | + |
| 21 | +## Export the model/s. |
| 22 | + |
| 23 | +Change into the program-data-separation directory and create a directory to hold exported artifacts. |
| 24 | +```bash |
| 25 | +cd ~/executorch-examples/program-data-separation |
| 26 | +mkdir models |
| 27 | +``` |
| 28 | + |
| 29 | +Export models into the `models` directory. The first command will generated undelegated model/data files, and the second will generate XNNPACK-delegated model/data files. |
| 30 | +```bash |
| 31 | +./export_lora.sh |
| 32 | +``` |
| 33 | +Expect the files `lora.pte` and `lora.ptd`. |
| 34 | + |
| 35 | +Note: |
| 36 | +- PTE: contains the program execution logic. |
| 37 | +- PTD: contains the constant tensors used by the PTE. |
| 38 | + |
| 39 | +See [program-data-separation](../../program-data-separation/README.md) for instructions. |
| 40 | + |
| 41 | +## Install runtime dependencies. |
| 42 | +The ExecuTorch repository is configured as a git submodule at `~/executorch-examples/program-data-separation/cpp/executorch`. To initialize it: |
| 43 | +```bash |
| 44 | +cd ~/executorch-examples/ |
| 45 | +git submodule sync |
| 46 | +git submodule update --init --recursive |
| 47 | +``` |
| 48 | +Install dev requirements for ExecuTorch |
| 49 | + |
| 50 | +```bash |
| 51 | +cd ~/executorch-examples/program-data-separation/cpp/executorch |
| 52 | +pip install -r requirements-dev.txt |
| 53 | +``` |
| 54 | + |
| 55 | +## Build the runtime. |
| 56 | +Build the executable: |
| 57 | +```bash |
| 58 | +cd ~/executorch-examples/program-data-separation/cpp/lora_example |
| 59 | +chmod +x build_example.sh |
| 60 | +./build_example.sh |
| 61 | +``` |
| 62 | + |
| 63 | +## Run the executable. |
| 64 | +``` |
| 65 | +./build/bin/executorch_program_data_separation --model-path ../../models/linear.pte --data-path ../../models/linear.ptd |
| 66 | +
|
| 67 | +./build/bin/executorch_program_data_separation --model-path ../../models/linear_xnnpack.pte --data-path ../../models/linear_xnnpack.ptd |
| 68 | +``` |
| 69 | + |
| 70 | +## Clean up. |
| 71 | +rm -rf build |
| 72 | +cd ~/executorch-examples/program-data-separation |
| 73 | +rm -rf models |
0 commit comments