Skip to content

Commit 5b765c5

Browse files
Update on "[ExecuTorch][#10375] Add extension.BundledModule to Wrap extension.Module with Bundled Program Logic"
#10375 # Context This issue is a step of #9638. In #9638, we want to have `extension.Module` as the single source of implementation in `pybindings`, which means that `pybindings.PyModule` should use `extension.Module` rather than its own `pybindings.Module`. The issue is that `pybindings.PyModule` is dependent on the `method` getter from `pybindings.Module`, which `extension.Module` do not have. Since we don't want to expose `method` getter in `extension.Module`, we have to protect the getter, wrap the functions that is dependent on it and use the protected getter there, ultimately decouple `pybindings` from a `method` getter. # Proposal Now that we have a protected `method` getter, we can introduce a `extension.BundledModule`, a child class inheriting `extension.Module` which wraps up bundled program logic that is dependent on the `method` getter. Differential Revision: [D73564125](https://our.internmc.facebook.com/intern/diff/D73564125/) [ghstack-poisoned]
2 parents 2a71451 + fb5ce4b commit 5b765c5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

extension/module/test/resources/gen_bundled_program.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from executorch.exir import to_edge_transform_and_lower
1111
from torch.export import export, export_for_training
1212

13+
1314
# Step 1: ExecuTorch Program Export
1415
class SampleModel(torch.nn.Module):
1516
"""An example model with multi-methods. Each method has multiple input and single output"""
@@ -27,6 +28,7 @@ def forward(self, x: torch.Tensor, q: torch.Tensor) -> torch.Tensor:
2728
torch.add(y, q, out=y)
2829
return y
2930

31+
3032
def main() -> None:
3133
"""Sample code to generate bundled program and save it to file. It is the same as in https://pytorch.org/executorch/0.6/bundled-io.html#emit-example"""
3234
# Inference method name of SampleModel we want to bundle testcases to.
@@ -46,7 +48,6 @@ def main() -> None:
4648
capture_input,
4749
)
4850

49-
5051
# Emit the traced method into ET Program.
5152
et_program = to_edge_transform_and_lower(method_graph).to_executorch()
5253

0 commit comments

Comments
 (0)