Skip to content

Add event_tracer pointer to delegate backend context #409

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
20 changes: 19 additions & 1 deletion runtime/backend/backend_execution_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#pragma once

#include <executorch/runtime/core/event_tracer.h>

namespace torch {
namespace executor {

Expand All @@ -16,7 +18,23 @@ namespace executor {
* The current plan is to add temp allocator and event tracer (for profiling) as
* part of the runtime context.
*/
class BackendExecutionContext final {};
class BackendExecutionContext final {
public:
BackendExecutionContext(EventTracer* event_tracer = nullptr)
: event_tracer_(event_tracer) {}

/**
* Returns a pointer 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_;
}

private:
EventTracer* event_tracer_ = nullptr;
};

} // namespace executor
} // namespace torch
2 changes: 1 addition & 1 deletion runtime/executor/method.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,7 @@ Error Method::execute_instruction() {
delegate_idx,
n_delegate_,
step_state_.instr_idx);
BackendExecutionContext backend_execution_context;
BackendExecutionContext backend_execution_context(event_tracer_);
Error err = delegates_[delegate_idx].Execute(
backend_execution_context,
chain.argument_lists_[step_state_.instr_idx].data());
Expand Down
2 changes: 1 addition & 1 deletion runtime/kernel/kernel_runtime_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class KernelRuntimeContext {
// TODO(T147221312): Add a way to resize a tensor.

private:
EventTracer* event_tracer_;
EventTracer* event_tracer_ = nullptr;
Error failure_state_ = Error::Ok;
};

Expand Down