Skip to content

Commit af726cd

Browse files
committed
Pass one NDM to backend init
Take external NDM if it exists, otherwise internal. Note: by default, xnnpack uses the named_data_map. Constants are not stored with the delegated blob anymore. Differential Revision: [D73679710](https://our.internmc.facebook.com/intern/diff/D73679710/) ghstack-source-id: 280710106 Pull Request resolved: #10528
1 parent 1432bfb commit af726cd

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

runtime/executor/method.cpp

+16-1
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,21 @@ Error Method::init(
805805
pte_data_map = pte_data_map_res.get();
806806
}
807807

808+
int named_data_map_items =
809+
(named_data_map != nullptr) ? named_data_map->get_num_keys().get() : 0;
810+
int pte_map_items =
811+
(pte_data_map != nullptr) ? pte_data_map->get_num_keys().get() : 0;
812+
813+
// TODO: implement ndm merge.
814+
ET_CHECK_OR_RETURN_ERROR(
815+
(pte_map_items == 0 || named_data_map_items == 0),
816+
NotImplemented,
817+
"NamedDataMap merge not supported. Both pte_data_map and named_data_map are non-empty, don't know what to do.");
818+
819+
if (named_data_map_items == 0) {
820+
named_data_map = pte_data_map;
821+
}
822+
808823
// n_delegate_ counts the number of successfully-initialized delegates for
809824
// ~Method() to clean up, and is incremented at the bottom of the loop. This
810825
// makes it safe for errors to return without updating any state.
@@ -816,7 +831,7 @@ Error Method::init(
816831
method_allocator,
817832
/*event_tracer=*/event_tracer_,
818833
/*method_name=*/serialization_plan_->name()->c_str(),
819-
/*named_data_map=*/pte_data_map);
834+
/*named_data_map=*/named_data_map);
820835
Error err = BackendDelegate::Init(
821836
delegate, program_, backend_init_context, &delegates_[i]);
822837
if (err != Error::Ok) {

0 commit comments

Comments
 (0)