Skip to content

Commit c0d007f

Browse files
pytorchbotbyjlw
andauthored
Make getting started clearer and reduce formatting bugs (#6071)
Make getting started clearer and reduce formatting bugs (#5954) Summary: Giving the user specific instructions on where to create the new file and how to use it so they don't have to think as much or fall into a common issue. Pull Request resolved: #5954 Test Plan: Went through the instructions in the readme manually Reviewed By: dbort Differential Revision: D64053565 Pulled By: byjlw fbshipit-source-id: 5fb5cda2497e77c727ac99f17d7b1ec13e0b0941 (cherry picked from commit 2e64e62) Co-authored-by: Jesse <[email protected]>
1 parent 4f4dc0b commit c0d007f

File tree

1 file changed

+25
-19
lines changed

1 file changed

+25
-19
lines changed

docs/source/getting-started-setup.md

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<!---- DO NOT MODIFY Progress Bar Start --->
2-
32
<div class="progress-bar-wrapper">
43
<div class="progress-bar-item">
54
<div class="step-number" id="step-1">1</div>
@@ -18,11 +17,7 @@
1817
<span class="step-caption" id="caption-4"></span>
1918
</div>
2019
</div>
21-
2220
<!---- DO NOT MODIFY Progress Bar End--->
23-
```{note}
24-
Before diving in, make sure you understand the concepts in the [ExecuTorch Overview](intro-overview.md)
25-
```
2621

2722
# Setting Up ExecuTorch
2823
In this section, we'll learn how to
@@ -37,22 +32,16 @@ We've tested these instructions on the following systems, although they should
3732
also work in similar environments.
3833

3934

40-
::::{grid} 3
41-
:::{grid-item-card} Linux (x86_64)
42-
:class-card: card-prerequisites
35+
Linux (x86_64)
4336
- CentOS 8+
4437
- Ubuntu 20.04.6 LTS+
4538
- RHEL 8+
46-
:::
47-
:::{grid-item-card} macOS (x86_64/M1/M2)
48-
:class-card: card-prerequisites
39+
40+
macOS (x86_64/M1/M2)
4941
- Big Sur (11.0)+
50-
:::
51-
:::{grid-item-card} Windows (x86_64)
52-
:class-card: card-prerequisites
42+
43+
Windows (x86_64)
5344
- Windows Subsystem for Linux (WSL) with any of the Linux options
54-
:::
55-
::::
5645

5746
### Software
5847
* `conda` or another virtual environment manager
@@ -140,7 +129,19 @@ ExecuTorch provides APIs to compile a PyTorch [`nn.Module`](https://pytorch.org/
140129
1. Save the result as a [`.pte` binary](pte-file-format.md) to be consumed by the ExecuTorch runtime.
141130
142131
143-
Let's try this using with a simple PyTorch model that adds its inputs. Create a file called `export_add.py` with the following code:
132+
Let's try this using with a simple PyTorch model that adds its inputs.
133+
134+
Create `export_add.py` in a new directory outside of the ExecuTorch repo.
135+
136+
**Note: It's important that this file does does not live in the directory that's a parent of the `executorch` directory. We need python to import from site-packages, not from the repo itself.**
137+
138+
```
139+
mkdir -p ../example_files
140+
cd ../example_files
141+
touch export_add.py
142+
```
143+
144+
Add the following code to `export_add.py`:
144145
```python
145146
import torch
146147
from torch.export import export
@@ -174,12 +175,17 @@ Then, execute it from your terminal.
174175
python3 export_add.py
175176
```
176177
178+
If it worked you'll see `add.pte` in that directory
179+
177180
See the [ExecuTorch export tutorial](tutorials_source/export-to-executorch-tutorial.py) to learn more about the export process.
178181
179182
180183
## Build & Run
181184
182-
After creating a program, we can use the ExecuTorch runtime to execute it.
185+
After creating a program go back to the executorch directory to execute it using the ExecuTorch runtime.
186+
```
187+
cd ../executorch
188+
```
183189
184190
For now, let's use [`executor_runner`](https://github.com/pytorch/executorch/blob/main/examples/portable/executor_runner/executor_runner.cpp), an example that runs the `forward` method on your program using the ExecuTorch runtime.
185191

@@ -215,7 +221,7 @@ The ExecuTorch repo uses CMake to build its C++ code. Here, we'll configure it t
215221
Now that we've exported a program and built the runtime, let's execute it!
216222
217223
```bash
218-
./cmake-out/executor_runner --model_path add.pte
224+
./cmake-out/executor_runner --model_path ../example_files/add.pte
219225
```
220226
Our output is a `torch.Tensor` with a size of 1. The `executor_runner` sets all input values to a [`torch.ones`](https://pytorch.org/docs/stable/generated/torch.ones.html) tensor, so when `x=[1]` and `y=[1]`, we get `[1]+[1]=[2]`
221227
:::{dropdown} Sample Output

0 commit comments

Comments
 (0)