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/sdk-bundled-io.md
+66-73
Original file line number
Diff line number
Diff line change
@@ -23,6 +23,8 @@ ExecuTorch Program can be emitted from user's model by using ExecuTorch APIs. Fo
23
23
24
24
In `BundledProgram`, we create two new classes, `MethodTestCase` and `MethodTestSuite`, to hold essential info for ExecuTorch program verification.
25
25
26
+
`MethodTestCase` represents a single testcase. Each `MethodTestCase` contains inputs and expected outputs for a single execution.
27
+
26
28
:::{dropdown} `MethodTestCase`
27
29
28
30
```{eval-rst}
@@ -31,6 +33,8 @@ In `BundledProgram`, we create two new classes, `MethodTestCase` and `MethodTest
31
33
```
32
34
:::
33
35
36
+
`MethodTestSuite` contains all testing info for single method, including a str representing method name, and a `List[MethodTestCase]` for all testcases:
37
+
34
38
:::{dropdown} `MethodTestSuite`
35
39
36
40
```{eval-rst}
@@ -44,18 +48,18 @@ Since each model may have multiple inference methods, we need to generate `List[
44
48
45
49
### Step 3: Generate `BundledProgram`
46
50
47
-
We provide `create_bundled_program` API under `executorch/sdk/bundled_program/core.py` to generate `BundledProgram` by bundling the emitted ExecuTorch program with the `List[MethodTestSuite]`:
51
+
We provide `BundledProgram` class under `executorch/sdk/bundled_program/core.py` to bundled the `ExecutorchProgram`-like variable, including
52
+
`ExecutorchProgram`, `MultiMethodExecutorchProgram` or `ExecutorchProgramManager`, with the `List[MethodTestSuite]`:
`create_bundled_program`will do sannity check internally to see if the given `List[MethodTestSuite]` matches the given Program's requirements. Specifically:
62
+
Construtor of `BundledProgram `will do sannity check internally to see if the given `List[MethodTestSuite]` matches the given Program's requirements. Specifically:
59
63
1. The method_names of each `MethodTestSuite` in `List[MethodTestSuite]` for should be also in program. Please notice that it is no need to set testcases for every method in the Program.
60
64
2. The metadata of each testcase should meet the requirement of the coresponding inference methods input.
61
65
@@ -83,20 +87,20 @@ To serialize `BundledProgram` to make runtime APIs use it, we provide two APIs,
83
87
Here is a flow highlighting how to generate a `BundledProgram` given a PyTorch model and the representative inputs we want to test it along with.
84
88
85
89
```python
86
-
87
90
import torch
88
91
92
+
from executorch.exir import to_edge
93
+
from executorch.sdk import BundledProgram
94
+
89
95
from executorch.sdk.bundled_program.config import MethodTestCase, MethodTestSuite
90
-
from executorch.sdk.bundled_program.core import create_bundled_program
91
96
from executorch.sdk.bundled_program.serialize import (
92
97
serialize_from_bundled_program_to_flatbuffer,
93
98
)
94
-
95
-
from executorch.exir import to_edge
99
+
from torch._export import capture_pre_autograd_graph
96
100
from torch.export import export
97
101
98
-
# Step 1: ExecuTorch Program Export
99
102
103
+
# Step 1: ExecuTorch Program Export
100
104
classSampleModel(torch.nn.Module):
101
105
"""An example model with multi-methods. Each method has multiple input and single output"""
102
106
@@ -105,82 +109,70 @@ class SampleModel(torch.nn.Module):
0 commit comments