Skip to content

Commit fc518e7

Browse files
committed
QA fixes for "BUNDLED PROGRAM" page (#942)
Summary: Pull Request resolved: #942 - Fix links - Currently the page is hard to read because API references are directly in it, which makes it hard to follow. Let's make API definitions expandable instead. Reviewed By: tarun292 Differential Revision: D50314611 fbshipit-source-id: 02b510273bd9ffee66b5ca55452f4362a60638ab
1 parent 838453f commit fc518e7

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

docs/source/sdk-bundled-io.md

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,34 @@ This stage mainly focuses on the creation of a `BundledProgram` and dumping it o
1717

1818
### Step 1: Create a Model and Emit its ExecuTorch Program.
1919

20-
ExecuTorch Program can be emitted from user's model by using ExecuTorch APIs. [Here](https://github.com/pytorch/executorch/blob/main/docs/website/docs/tutorials/exporting_to_executorch.md) is the tutorial for ExecuTorch Program exporting.
21-
20+
ExecuTorch Program can be emitted from user's model by using ExecuTorch APIs. Follow the [Generate Sample ExecuTorch program](./getting-started-setup.md) or [Exporting to ExecuTorch tutorial](./tutorials/export-to-executorch-tutorial).
2221

2322
### Step 2: Construct `BundledConfig`
2423

24+
2525
`BundledConfig` is a class under `executorch/bundled_program/config.py` that contains all information to be bundled for model verification. Here's the constructor api to create `BundledConfig`:
2626

27+
:::{dropdown} `BundledConfig`
28+
2729
```{eval-rst}
2830
.. autofunction:: bundled_program.config.BundledConfig.__init__
2931
:noindex:
3032
```
33+
:::
34+
3135

3236
### Step 3: Generate `BundledProgram`
3337

3438
We provide `create_bundled_program` API under `executorch/bundled_program/core.py` to generate `BundledProgram` by bundling the emitted ExecuTorch program with the bundled_config:
3539

40+
:::{dropdown} `BundledProgram`
41+
3642
```{eval-rst}
3743
.. currentmodule:: bundled_program.core
3844
.. autofunction:: create_bundled_program
3945
:noindex:
4046
```
47+
:::
4148

4249
`create_bundled_program` will do sannity check internally to see if the given BundledConfig matches the given Program's requirements. Specifically:
4350
1. The name of methods we create BundledConfig for should be also in program. Please notice that it is no need to set testcases for every method in the Program.
@@ -47,6 +54,7 @@ We provide `create_bundled_program` API under `executorch/bundled_program/core.p
4754

4855
To serialize `BundledProgram` to make runtime APIs use it, we provide two APIs, both under `executorch/bundled_program/serialize/__init__.py`.
4956

57+
:::{dropdown} Serialize and Deserialize
5058

5159
```{eval-rst}
5260
.. currentmodule:: bundled_program.serialize
@@ -59,6 +67,7 @@ To serialize `BundledProgram` to make runtime APIs use it, we provide two APIs,
5967
.. autofunction:: deserialize_from_flatbuffer_to_bundled_program
6068
:noindex:
6169
```
70+
:::
6271

6372
### Emit Example
6473

@@ -183,12 +192,16 @@ regenerate_bundled_program = deserialize_from_flatbuffer_to_bundled_program(seri
183192
## Runtime Stage
184193
This stage mainly focuses on executing the model with the bundled inputs and and comparing the model's output with the bundled expected output. We provide multiple APIs to handle the key parts of it.
185194

195+
186196
### Get ExecuTorch Program Pointer from `BundledProgram` Buffer
187197
We need the pointer to ExecuTorch program to do the execution. To unify the process of loading and executing `BundledProgram` and Program flatbuffer, we create an API:
188198

199+
:::{dropdown} `GetProgramData`
200+
189201
```{eval-rst}
190202
.. doxygenfunction:: torch::executor::util::GetProgramData
191203
```
204+
:::
192205

193206
Here's an example of how to use the `GetProgramData` API:
194207
```c++
@@ -216,21 +229,27 @@ ET_CHECK_MSG(
216229
### Load Bundled Input to Method
217230
To execute the program on the bundled input, we need to load the bundled input into the method. Here we provided an API called `torch::executor::util::LoadBundledInput`:
218231
232+
:::{dropdown} `LoadBundledInput`
233+
219234
```{eval-rst}
220235
.. doxygenfunction:: torch::executor::util::LoadBundledInput
221236
```
237+
:::
222238

223239
### Verify the Method's Output.
224240
We call `torch::executor::util::VerifyResultWithBundledExpectedOutput` to verify the method's output with bundled expected outputs. Here's the details of this API:
225241

242+
:::{dropdown} `VerifyResultWithBundledExpectedOutput`
243+
226244
```{eval-rst}
227245
.. doxygenfunction:: torch::executor::util::VerifyResultWithBundledExpectedOutput
228246
```
247+
:::
229248

230249

231250
### Runtime Example
232251

233-
Here we provide an example about how to run the bundled program step by step. Most of the code is borrowed from [executor_runner](https://github.com/pytorch/executorch/blob/main/sdk/runners/executor_runner.cpp), and please review that file if you need more info and context:
252+
Here we provide an example about how to run the bundled program step by step. Most of the code is borrowed from [executor_runner](https://github.com/pytorch/executorch/blob/main/examples/sdk/sdk_example_runner/sdk_example_runner.cpp), and please review that file if you need more info and context:
234253

235254
```c++
236255
// method_name is the name for the method we want to test

0 commit comments

Comments
 (0)