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
Copy file name to clipboardExpand all lines: docs/source/bundled-io.md
+18-93
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ 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. Follow the [Generate Sample ExecuTorch program](./getting-started-setup.md) or [Exporting to ExecuTorch tutorial](./tutorials/export-to-executorch-tutorial).
20
+
ExecuTorch Program can be emitted from user's model by using ExecuTorch APIs. Follow the [Generate and emit sample ExecuTorch program](./getting-started.md#exporting) or [Exporting to ExecuTorch tutorial](./tutorials/export-to-executorch-tutorial).
21
21
22
22
### Step 2: Construct `List[MethodTestSuite]` to hold test info
23
23
@@ -89,7 +89,7 @@ Here is a flow highlighting how to generate a `BundledProgram` given a PyTorch m
89
89
```python
90
90
import torch
91
91
92
-
from executorch.exir importto_edge
92
+
from executorch.exir importto_edge_transform_and_lower
93
93
from executorch.devtools import BundledProgram
94
94
95
95
from executorch.devtools.bundled_program.config import MethodTestCase, MethodTestSuite
@@ -105,8 +105,8 @@ class SampleModel(torch.nn.Module):
We can also regenerate `BundledProgram` from flatbuffer file if needed:
@@ -199,103 +198,29 @@ This stage mainly focuses on executing the model with the bundled inputs and and
199
198
200
199
201
200
### Get ExecuTorch Program Pointer from `BundledProgram` Buffer
202
-
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:
"get_program_data() failed with status 0x%" PRIx32,
229
-
status);
230
-
```
201
+
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 for this
202
+
`executorch::bundled_program::get_program_data`. Check out an [example usage](https://github.com/pytorch/executorch/blob/release/0.6/examples/devtools/example_runner/example_runner.cpp#L128-L137) of this API.
231
203
232
204
### Load Bundled Input to Method
233
-
To execute the program on the bundled input, we need to load the bundled input into the method. Here we provided an API called `executorch::bundled_program::load_bundled_input`:
To execute the program on the bundled input, we need to load the bundled input into the method. Here we provided an API called `executorch::bundled_program::load_bundled_input`. Check out an [example usage](https://github.com/pytorch/executorch/blob/release/0.6/examples/devtools/example_runner/example_runner.cpp#L253-L259) of this API.
241
206
242
207
### Verify the Method's Output.
243
-
We call `executorch::bundled_program::verify_method_outputs` to verify the method's output with bundled expected outputs. Here's the details of this API:
We call `executorch::bundled_program::verify_method_outputs` to verify the method's output with bundled expected outputs. Check out an [example usage](https://github.com/pytorch/executorch/blob/release/0.6/examples/devtools/example_runner/example_runner.cpp#L300-L311) of this API.
252
209
253
210
### Runtime Example
254
211
255
-
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/devtools/example_runner/example_runner.cpp), and please review that file if you need more info and context:
256
-
257
-
```c++
258
-
// method_name is the name for the method we want to test
259
-
// memory_manager is the executor::MemoryManager variable for executor memory allocation.
// Load testset_idx-th input in the buffer to plan
269
-
status = executorch::bundled_program::load_bundled_input(
270
-
*method,
271
-
program_data.bundled_program_data(),
272
-
FLAGS_testset_idx);
273
-
ET_CHECK_MSG(
274
-
status == Error::Ok,
275
-
"load_bundled_input failed with status 0x%" PRIx32,
276
-
status);
277
-
278
-
// Execute the plan
279
-
status = method->execute();
280
-
ET_CHECK_MSG(
281
-
status == Error::Ok,
282
-
"method->execute() failed with status 0x%" PRIx32,
283
-
status);
284
-
285
-
// Verify the result.
286
-
status = executorch::bundled_program::verify_method_outputs(
287
-
*method,
288
-
program_data.bundled_program_data(),
289
-
FLAGS_testset_idx,
290
-
FLAGS_rtol,
291
-
FLAGS_atol);
292
-
ET_CHECK_MSG(
293
-
status == Error::Ok,
294
-
"Bundle verification failed with status 0x%" PRIx32,
295
-
status);
212
+
Please checkout our [example runner](https://github.com/pytorch/executorch/blob/release/0.6/examples/devtools/README.md#bundledprogram) for a bundled program. You could run these commands to test with the BundledProgram binary (`.bpte`) file you generated in the previous step:
It is expected to see no output from running the above mentioned snippet.
221
+
222
+
For a detailed example of how the runner should be like, please refer to our [example runner](https://github.com/pytorch/executorch/blob/release/0.6/examples/devtools/example_runner/example_runner.cpp).
223
+
299
224
## Common Errors
300
225
301
226
Errors will be raised if `List[MethodTestSuites]` doesn't match the `Program`. Here're two common situations:
0 commit comments