You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
Copy file name to clipboardExpand all lines: docs/source/sdk-bundled-io.md
+22-3Lines changed: 22 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,27 +17,34 @@ This stage mainly focuses on the creation of a `BundledProgram` and dumping it o
17
17
18
18
### Step 1: Create a Model and Emit its ExecuTorch Program.
19
19
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).
22
21
23
22
### Step 2: Construct `BundledConfig`
24
23
24
+
25
25
`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`:
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:
35
39
40
+
:::{dropdown} `BundledProgram`
41
+
36
42
```{eval-rst}
37
43
.. currentmodule:: bundled_program.core
38
44
.. autofunction:: create_bundled_program
39
45
:noindex:
40
46
```
47
+
:::
41
48
42
49
`create_bundled_program` will do sannity check internally to see if the given BundledConfig matches the given Program's requirements. Specifically:
43
50
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
47
54
48
55
To serialize `BundledProgram` to make runtime APIs use it, we provide two APIs, both under `executorch/bundled_program/serialize/__init__.py`.
49
56
57
+
:::{dropdown} Serialize and Deserialize
50
58
51
59
```{eval-rst}
52
60
.. currentmodule:: bundled_program.serialize
@@ -59,6 +67,7 @@ To serialize `BundledProgram` to make runtime APIs use it, we provide two APIs,
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.
185
194
195
+
186
196
### Get ExecuTorch Program Pointer from `BundledProgram` Buffer
187
197
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:
Here's an example of how to use the `GetProgramData` API:
194
207
```c++
@@ -216,21 +229,27 @@ ET_CHECK_MSG(
216
229
### Load Bundled Input to Method
217
230
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`:
We call `torch::executor::util::VerifyResultWithBundledExpectedOutput` to verify the method's output with bundled expected outputs. Here's the details of this API:
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:
234
253
235
254
```c++
236
255
// method_name is the name for the method we want to test
0 commit comments