Save external constant tensors to custom filename#15862
Save external constant tensors to custom filename#15862meta-codesync[bot] merged 1 commit intopytorch:mainfrom
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/15862
Note: Links to docs will display an error until the docs builds have been completed. ❌ 3 New Failures, 1 Cancelled Job, 3 Unrelated FailuresAs of commit 96efb61 with merge base d2c011e ( NEW FAILURES - The following jobs have failed:
CANCELLED JOB - The following job was cancelled. Please retry:
FLAKY - The following jobs failed but were likely due to flakiness present on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for customizing external constant tensor storage by allowing a Callable option in the ExecutorchBackendConfig.external_constants field. Previously, this field only accepted a boolean value to determine whether all constants should be externalized. Now it can also accept a function that determines which constants to externalize and which filename to use for storage.
Key changes:
- Extended
external_constantsto accept eitherboolorCallable[[torch.fx.Node], Optional[str]] - Updated the conditional logic in
to_executorch()to handle both bool and callable cases - Added test coverage for the custom callable scenario
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| exir/capture/_config.py | Extended type annotation and documentation for external_constants to support Callable option |
| exir/program/_program.py | Updated conditional logic to handle both bool and callable external_constants values |
| exir/emit/test/test_emit.py | Added test case for custom callable external_constants behavior |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary: Adding a Callable option in the config, so we can customize the nodes to save, and the filenames to save to. The pass is applied in _program.py, it's hard to do this on the eager model (like we do with delegates) as we have to run the pass after SpecPropPass. Differential Revision: D87280747
5b8b7a1 to
5781904
Compare
Summary: Adding a Callable option in the config, so we can customize the nodes to save, and the filenames to save to. The pass is applied in _program.py, it's hard to do this on the eager model (like we do with delegates) as we have to run the pass after SpecPropPass. Differential Revision: D87280747
5781904 to
3c0743f
Compare
Summary: Adding a Callable option in the config, so we can customize the nodes to save, and the filenames to save to. The pass is applied in _program.py, it's hard to do this on the eager model (like we do with delegates) as we have to run the pass after SpecPropPass. Reviewed By: ethansfng Differential Revision: D87280747
3c0743f to
96efb61
Compare
Summary: Adding a Callable option in the config, so we can customize the nodes to save, and the filenames to save to. The pass is applied in _program.py, it's hard to do this on the eager model (like we do with delegates) as we have to run the pass after SpecPropPass. Reviewed By: ethansfng Differential Revision: D87280747
Summary: Adding a Callable option in the config, so we can customize the nodes to save, and the filenames to save to. The pass is applied in _program.py, it's hard to do this on the eager model (like we do with delegates) as we have to run the pass after SpecPropPass. Reviewed By: ethansfng Differential Revision: D87280747
JacobSzwejbka
left a comment
There was a problem hiding this comment.
Review automatically exported from Phabricator review in Meta.
Differential Revision: D87280747 Pull Request resolved: pytorch#15862
Summary: Adding a Callable option in the config, so we can customize the nodes to save, and the filenames to save to.
The pass is applied in _program.py, it's hard to do this on the eager model (like we do with delegates) as we have to run the pass after SpecPropPass.
Differential Revision: D87280747