Skip to content

Commit 1b4afed

Browse files
tarun292facebook-github-bot
authored andcommitted
Add event_tracer pointer to delegate backend context (#409)
Summary: Pull Request resolved: #409 Adding `event_tracer` pointer to delegate backend context which backend authors can access for logging/profiling in their backend. Reviewed By: chakriu, cccclai Differential Revision: D49422536 fbshipit-source-id: 7f3399e1078826032d087a1d19e83360ef43e4de
1 parent c15495e commit 1b4afed

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

runtime/backend/backend_execution_context.h

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
#pragma once
1010

11+
#include <executorch/runtime/core/event_tracer.h>
12+
1113
namespace torch {
1214
namespace executor {
1315

@@ -16,7 +18,23 @@ namespace executor {
1618
* The current plan is to add temp allocator and event tracer (for profiling) as
1719
* part of the runtime context.
1820
*/
19-
class BackendExecutionContext final {};
21+
class BackendExecutionContext final {
22+
public:
23+
BackendExecutionContext(EventTracer* event_tracer = nullptr)
24+
: event_tracer_(event_tracer) {}
25+
26+
/**
27+
* Returns a pointer to an instance of EventTracer to do profiling/debugging
28+
* logging inside the delegate backend. Users will need access to this pointer
29+
* to use any of the event tracer APIs.
30+
*/
31+
EventTracer* event_tracer() {
32+
return event_tracer_;
33+
}
34+
35+
private:
36+
EventTracer* event_tracer_;
37+
};
2038

2139
} // namespace executor
2240
} // namespace torch

runtime/executor/method.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,7 @@ Error Method::execute_instruction() {
951951
delegate_idx,
952952
n_delegate_,
953953
step_state_.instr_idx);
954-
BackendExecutionContext backend_execution_context;
954+
BackendExecutionContext backend_execution_context(event_tracer_);
955955
Error err = delegates_[delegate_idx].Execute(
956956
backend_execution_context,
957957
chain.argument_lists_[step_state_.instr_idx].data());

0 commit comments

Comments
 (0)