Skip to content

Commit b07c2d5

Browse files
committed
Update on "Backend data separation test"
Add backend data separation test with demo ExecutorBackend. Note: ExecutorBackend is a wrapper around a portable PTE file. It doesn't support delegated program-data separation in the sense of tagging tensors as external and placing them into the named data store as such. Rather, this test: 1. Creates a linear PTE file with data removed, using the portable flow. 2. Packages (1) into preprocessed blob as a delegate, using ExecutorBackend. Note: this discards the PTD portion. 3. Re-create the PTD portion via export_program (portable flow again). 4. Runs the delegated ExecutorBackend linear with portable linear.ptd file. Caveat: this means that LinearModule definition in export_program and export_delegated_program must stay in sync, as we get the PTE artifact from export_delegated_program (wrapped in ExecutorBackend), and the PTD artifact from export_program. Differential Revision: [D73679733](https://our.internmc.facebook.com/intern/diff/D73679733/) [ghstack-poisoned]
2 parents 521dc07 + 806dfe3 commit b07c2d5

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

runtime/executor/method.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,8 @@ Result<size_t> Method::get_num_external_constants() {
329329
}
330330

331331
Error Method::parse_external_constants(const NamedDataMap* named_data_map) {
332-
ET_CHECK_OR_RETURN_ERROR(named_data_map != nullptr, InvalidState, "named_data_map is null");
332+
ET_CHECK_OR_RETURN_ERROR(
333+
named_data_map != nullptr, InvalidState, "named_data_map is null");
333334
auto flatbuffer_values = serialization_plan_->values();
334335
size_t n_value = flatbuffer_values->size();
335336

runtime/executor/test/backend_data_separation_test.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,11 @@ class BackendDataSeparationTest : public ::testing::Test {
7070
EXPECT_EQ(linear_data_map.error(), Error::Ok);
7171
linear_data_map_ =
7272
std::make_unique<FlatTensorDataMap>(std::move(linear_data_map.get()));
73-
74-
ET_LOG(Info, "setup done, named_data_map_ = %lu", linear_data_map_->get_num_keys().get());
73+
74+
ET_LOG(
75+
Info,
76+
"setup done, named_data_map_ = %lu",
77+
linear_data_map_->get_num_keys().get());
7578
}
7679

7780
private:
@@ -86,7 +89,10 @@ class BackendDataSeparationTest : public ::testing::Test {
8689
TEST_F(BackendDataSeparationTest, TestSeparation) {
8790
ManagedMemoryManager mmm(kDefaultNonConstMemBytes, kDefaultRuntimeMemBytes);
8891
Result<Method> method = linear_program_->load_method(
89-
"forward", &mmm.get(), /*event_tracer=*/nullptr, /*named_data_map=*/linear_data_map_.get());
92+
"forward",
93+
&mmm.get(),
94+
/*event_tracer=*/nullptr,
95+
/*named_data_map=*/linear_data_map_.get());
9096
ASSERT_EQ(method.error(), Error::Ok);
9197

9298
// Can execute the method.

test/models/export_delegated_program.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@
2626
)
2727
from executorch.exir.passes.external_constants_pass import (
2828
delegate_external_constants_pass,
29-
)
30-
from executorch.exir.backend.test.demos.rpc.executor_backend_preprocess import (
31-
ExecutorBackend,
3229
)
3330
from executorch.exir.program import ExecutorchProgramManager
3431
from torch import nn

0 commit comments

Comments
 (0)