Skip to content

Commit

Permalink
fix examples/xnnpack/README (#3317)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #3317

Updating XNNPACK's README

- Clean up directory structure by removing xnn_executor_runner
- Add commands for running examples via cmake

Reviewed By: cccclai

Differential Revision: D56524907

fbshipit-source-id: 70e1ccded923cf66f3dbca2574dab766207401cc
  • Loading branch information
mcr229 authored and facebook-github-bot committed May 2, 2024
1 parent 9371c16 commit 74538f8
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
2 changes: 1 addition & 1 deletion backends/xnnpack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ cmake \
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
-DEXECUTORCH_BUILD_XNNPACK=ON \
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
-DEXECUTORCH_ENABLE_LOGGING=1 \
-DEXECUTORCH_ENABLE_LOGGING=ON \
-DPYTHON_EXECUTABLE=python \
-Bcmake-out .
```
Expand Down
35 changes: 34 additions & 1 deletion examples/xnnpack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ examples/xnnpack
├── quantization # Scripts to illustrate PyTorch 2 Export Quantization workflow with XNNPACKQuantizer
│ └── example.py
├── aot_compiler.py # The main script to illustrate the full AOT (export, quantization, delegation) workflow with XNNPACK delegate
├── xnn_executor_runner # ExecuTorch runtime application for XNNPACK delegate examples
└── README.md # This file
```

Expand All @@ -31,6 +30,40 @@ Once we have the model binary (pte) file, then let's run it with ExecuTorch runt
buck2 run examples/xnnpack:xnn_executor_runner -- --model_path ./mv2_xnnpack_fp32.pte
```

For cmake, you first configure your cmake with the following:

```bash
# cd to the root of executorch repo
cd executorch

# Get a clean cmake-out directory
rm- -rf cmake-out
mkdir cmake-out

# Configure cmake
cmake \
-DCMAKE_INSTALL_PREFIX=cmake-out \
-DCMAKE_BUILD_TYPE=Release \
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
-DEXECUTORCH_BUILD_XNNPACK=ON \
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
-DEXECUTORCH_ENABLE_LOGGING=ON \
-DPYTHON_EXECUTABLE=python \
-Bcmake-out .
```

Then you can build the runtime components with

```bash
cmake --build cmake-out -j9 --target install --config Release
```

Now finally you should be able to run this model with the following command

```bash
./cmake-out/backends/xnnpack/xnn_executor_runner --model_path ./mv2_xnnpack_fp32.pte
```

## Quantization
First, learn more about the generic PyTorch 2 Export Quantization workflow in the [Quantization Flow Docs](https://pytorch.org/executorch/stable/quantization-overview.html), if you are not familiar already.

Expand Down

0 comments on commit 74538f8

Please sign in to comment.