Skip to content

Commit b831dbe

Browse files
authored
Revert "Give backends the method's metadata at init (#24220)" (#24259)
Reverts #24220
1 parent bf9bef3 commit b831dbe

6 files changed

Lines changed: 4 additions & 85 deletions

File tree

‎runtime/backend/backend_init_context.h‎

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@
2525

2626
namespace executorch {
2727
namespace ET_RUNTIME_NAMESPACE {
28-
29-
class MethodMeta;
30-
3128
/**
3229
* BackendInitContext will be used to inject runtime info for to initialize
3330
* delegate.
@@ -39,8 +36,7 @@ class BackendInitContext final {
3936
EventTracer* event_tracer = nullptr,
4037
const char* method_name = nullptr,
4138
const NamedDataMap* named_data_map = nullptr,
42-
Span<const BackendOption> runtime_specs = {},
43-
const MethodMeta* method_meta = nullptr)
39+
Span<const BackendOption> runtime_specs = {})
4440
: runtime_allocator_(runtime_allocator),
4541
#ifdef ET_EVENT_TRACER_ENABLED
4642
event_tracer_(event_tracer),
@@ -49,8 +45,7 @@ class BackendInitContext final {
4945
#endif
5046
method_name_(method_name),
5147
named_data_map_(named_data_map),
52-
runtime_specs_(runtime_specs),
53-
method_meta_(method_meta) {
48+
runtime_specs_(runtime_specs) {
5449
}
5550

5651
/** Get the runtime allocator passed from Method. It's the same runtime
@@ -99,16 +94,6 @@ class BackendInitContext final {
9994
return runtime_specs_;
10095
}
10196

102-
/**
103-
* Returns metadata for the enclosing method, or nullptr if not supplied.
104-
* The runtime provides a borrowed view valid during backend initialization.
105-
* Other callers must keep the view and its backing program alive for the
106-
* lifetime of this context.
107-
*/
108-
const MethodMeta* method_meta() const {
109-
return method_meta_;
110-
}
111-
11297
/**
11398
* Get a runtime spec value by key and type.
11499
*
@@ -150,7 +135,6 @@ class BackendInitContext final {
150135
const char* method_name_ = nullptr;
151136
const NamedDataMap* named_data_map_ = nullptr;
152137
Span<const BackendOption> runtime_specs_;
153-
const MethodMeta* method_meta_ = nullptr;
154138
};
155139

156140
} // namespace ET_RUNTIME_NAMESPACE

‎runtime/backend/test/backend_init_context_test.cpp‎

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,7 @@
88

99
#include <executorch/runtime/backend/backend_init_context.h>
1010
#include <executorch/runtime/backend/options.h>
11-
#include <executorch/runtime/executor/method_meta.h>
1211
#include <executorch/runtime/platform/runtime.h>
13-
#include <executorch/schema/program_generated.h>
14-
15-
#include <cstdint>
16-
#include <vector>
1712

1813
#include <gtest/gtest.h>
1914

@@ -22,7 +17,6 @@ using executorch::runtime::BackendInitContext;
2217
using executorch::runtime::BackendOption;
2318
using executorch::runtime::BackendOptions;
2419
using executorch::runtime::Error;
25-
using executorch::runtime::MethodMeta;
2620
using executorch::runtime::Span;
2721

2822
class BackendInitContextTest : public ::testing::Test {
@@ -38,32 +32,6 @@ TEST_F(BackendInitContextTest, DefaultConstructorNoRuntimeSpecs) {
3832

3933
auto specs = context.runtime_specs();
4034
EXPECT_EQ(specs.size(), 0);
41-
EXPECT_EQ(context.method_meta(), nullptr);
42-
}
43-
44-
TEST_F(BackendInitContextTest, ConstructorPreservesMethodMeta) {
45-
namespace fb = executorch_flatbuffer;
46-
flatbuffers::FlatBufferBuilder builder;
47-
const auto plan = fb::CreateExecutionPlan(
48-
builder,
49-
builder.CreateString("forward"),
50-
/*container_meta_type=*/0,
51-
builder.CreateVector(std::vector<flatbuffers::Offset<fb::EValue>>{}),
52-
builder.CreateVector(std::vector<int32_t>{}),
53-
builder.CreateVector(std::vector<int32_t>{}),
54-
/*chains=*/0,
55-
/*operators=*/0,
56-
builder.CreateVector(
57-
std::vector<flatbuffers::Offset<fb::BackendDelegate>>{}));
58-
builder.Finish(plan);
59-
const auto meta = MethodMeta::from_serialized_execution_plan(
60-
builder.GetBufferPointer(), builder.GetSize());
61-
ASSERT_TRUE(meta.ok());
62-
63-
BackendInitContext context(
64-
nullptr, nullptr, "forward", nullptr, {}, &meta.get());
65-
66-
EXPECT_EQ(context.method_meta(), &meta.get());
6735
}
6836

6937
// Test constructor with runtime specs

‎runtime/backend/test/targets.bzl‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ def define_common_targets():
3131
deps = [
3232
"//executorch/runtime/core:core",
3333
"//executorch/runtime/backend:interface",
34-
"//executorch/runtime/executor:program",
35-
"//executorch/schema:program",
3634
],
3735
)
3836

‎runtime/executor/method.cpp‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,7 +1022,6 @@ Error Method::init(
10221022
// makes it safe for errors to return without updating any state.
10231023
n_delegate_ = 0;
10241024

1025-
const auto method_meta = this->method_meta();
10261025
for (size_t i = 0; i < n_delegate; ++i) {
10271026
const auto& delegate = *delegates->Get(i);
10281027

@@ -1039,8 +1038,7 @@ Error Method::init(
10391038
/*event_tracer=*/event_tracer_,
10401039
/*method_name=*/serialization_plan_->name()->c_str(),
10411040
/*named_data_map=*/named_data_map,
1042-
/*runtime_specs=*/delegate_runtime_specs,
1043-
/*method_meta=*/&method_meta);
1041+
/*runtime_specs=*/delegate_runtime_specs);
10441042
Error err = BackendDelegate::Init(
10451043
delegate, program_, backend_init_context, &delegates_[i]);
10461044
if (err != Error::Ok) {

‎runtime/executor/test/backend_integration_test.cpp‎

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -610,34 +610,6 @@ TEST_P(BackendIntegrationTest, GetMethodNameDuringInitSuccess) {
610610
ASSERT_EQ(program.error(), Error::Ok);
611611
}
612612

613-
TEST_P(BackendIntegrationTest, MethodMetaPassedToBackendInitContext) {
614-
Result<FileDataLoader> loader = FileDataLoader::from(program_path());
615-
ASSERT_EQ(loader.error(), Error::Ok);
616-
Result<Program> program = Program::load(&loader.get());
617-
ASSERT_EQ(program.error(), Error::Ok);
618-
619-
bool init_called = false;
620-
StubBackend::singleton().install_init(
621-
[&](FreeableBuffer* processed,
622-
ET_UNUSED ArrayRef<CompileSpec> compile_specs,
623-
BackendInitContext& context) -> Result<DelegateHandle*> {
624-
init_called = true;
625-
const auto* meta = context.method_meta();
626-
EXPECT_NE(meta, nullptr);
627-
if (meta != nullptr) {
628-
EXPECT_STREQ(meta->name(), "forward");
629-
EXPECT_TRUE(meta->uses_backend(StubBackend::kName));
630-
}
631-
processed->Free();
632-
return nullptr;
633-
});
634-
635-
ManagedMemoryManager mmm(kDefaultNonConstMemBytes, kDefaultRuntimeMemBytes);
636-
Result<Method> method = program->load_method("forward", &mmm.get());
637-
EXPECT_TRUE(method.ok());
638-
EXPECT_TRUE(init_called);
639-
}
640-
641613
TEST_P(BackendIntegrationTest, GetMethodNameDuringExecuteSuccess) {
642614
Result<FileDataLoader> loader = FileDataLoader::from(program_path());
643615
ASSERT_EQ(loader.error(), Error::Ok);

‎schema/targets.bzl‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,9 @@ def define_common_targets():
8080
"//executorch/runtime/executor/...",
8181
"//executorch/backends/native/extension/module/...",
8282
# Tests have a set up which uses raw flatbuffer.
83-
# TODO will refactor these setup steps into
83+
# TODO will refactor these setup steps into
8484
# testing utils in runtime/executor/... path
8585
"//executorch/backends/xnnpack/test/...",
86-
"//executorch/runtime/backend/test/...",
8786
],
8887
exported_headers = {
8988
OUTPUT_PROGRAM_HEADER: ":{}[{}]".format(PROGRAM_GEN_RULE_NAME, OUTPUT_PROGRAM_HEADER),

0 commit comments

Comments
 (0)