Skip to content

Commit d5763c3

Browse files
tarun292facebook-github-bot
authored andcommitted
Add event_tracer pointer to delegate backend context
Summary: Adding `event_tracer` pointer to delegate backend context which backend authors can access for logging/profiling in their backend. Reviewed By: cccclai Differential Revision: D49422536 fbshipit-source-id: 22e52b71cc38a7a26fdd5e1afdbc24c43491baae
1 parent 5aaf289 commit d5763c3

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
@@ -950,7 +950,7 @@ Error Method::execute_instruction() {
950950
delegate_idx,
951951
n_delegate_,
952952
step_state_.instr_idx);
953-
BackendExecutionContext backend_execution_context;
953+
BackendExecutionContext backend_execution_context(event_tracer_);
954954
Error err = delegates_[delegate_idx].Execute(
955955
backend_execution_context,
956956
chain.argument_lists_[step_state_.instr_idx].data());

0 commit comments

Comments
 (0)