Skip to content

Commit a815591

Browse files
committed
Update on "[ExecuTorch][Weight Sharing] Track Named Data Store in EdgeProgramManager"
We enable Backends to return Named Data by adding NamedDataStoreOutput to the preprocess result. This is a completely BC change, as no backends with an implemented preprocess will see any change if nothing is explicitly implemented. For backend developers to leverage the new NamedDataStore, they can initialize a new NamedDataStore() within preprocess, add_named_data to the data store, and return the NamedDataStore.get_named_data_store_output() in the preprocess result like such: ``` def preprocess(ExportedProgram, List[CompileSpecs]) -> PreprocessResult: named_data_store = NamedDataStore() for node in exported_program.graph.nodes: named_data_store.add_named_data("name", bytes) return PreprocessResult( processed_bytes=bytes, debug_handle_map={}, data_store_output= named_data_store.get_named_data_store_output() ) ``` Under the hood, the data store output is embedded in the loweredbackendmodule, (serializing loweredbackendmodule by itself with the a named_data_store_output is still a todo). But via the EdgeProgramManager path, we add the named_data_store_outputs to the edge_program_manger's named data store to keep track of all the named data returned by backends. Differential Revision: [D70451660](https://our.internmc.facebook.com/intern/diff/D70451660/) [ghstack-poisoned]
2 parents cb99857 + a7c6115 commit a815591

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

exir/backend/test/test_backend_with_named_data_map.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def false_branch(self, x):
6767

6868
def forward(self, x, y):
6969
z = x / y
70-
z = torch.cond(z > 1, self.true_branch, self.false_branch, [x])
70+
z = torch.cond(z.sum() > 0, self.true_branch, self.false_branch, [x])
7171
return z - z
7272

7373
ep = to_edge(torch.export.export(M(), (torch.randn(1, 2), torch.randn(1, 2))))

0 commit comments

Comments
 (0)