Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions runtime/backend/backend_init_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class BackendInitContext final {
public:
explicit BackendInitContext(
MemoryAllocator* runtime_allocator,
EventTracer* event_tracer = nullptr,
const char* method_name = nullptr)
: runtime_allocator_(runtime_allocator), method_name_(method_name) {}

Expand All @@ -31,6 +32,15 @@ class BackendInitContext final {
return runtime_allocator_;
}

/**
* Returns a pointer (null if not installed) to an instance of EventTracer to
* do profiling/debugging logging inside the delegate backend. Users will need
* access to this pointer to use any of the event tracer APIs.
*/
EventTracer* event_tracer() {
return event_tracer_;
}

/** Get the loaded method name from ExecuTorch runtime. Usually it's
* "forward", however, if there are multiple methods in the .pte file, it can
* be different. One example is that we may have prefill and decode methods in
Expand All @@ -44,6 +54,7 @@ class BackendInitContext final {

private:
MemoryAllocator* runtime_allocator_ = nullptr;
EventTracer* event_tracer_ = nullptr;
const char* method_name_ = nullptr;
};

Expand Down
1 change: 1 addition & 0 deletions runtime/executor/method.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,7 @@ Error Method::init(executorch_flatbuffer::ExecutionPlan* s_plan) {
const auto& delegate = *delegates->Get(i);
BackendInitContext backend_init_context(
method_allocator,
/*event_tracer=*/event_tracer_,
/*method_name=*/serialization_plan_->name()->c_str());
Error err = BackendDelegate::Init(
delegate, program_, backend_init_context, &delegates_[i]);
Expand Down