Skip to content

Commit 65646eb

Browse files
Olivia-liufacebook-github-bot
authored andcommitted
Add a null check for tracer in the Module::load_method (#6298)
Summary: When testing the [LLM Manual](https://pytorch.org/executorch/0.4/llm/getting-started.html#profiling-and-debugging), I found etdump is not generated :(. It seems to be a bug introduced in D62520386 when a `tracer` parameter was added to `Module::load_method`. It overrides the `event_tracer_.get()`, resulting `tracer` being null `program_->load_method` is called and thus etdump is not generated. This diff just adds a check: it `tracer` is not null, use it; otherwise use the tracer get from class member event_tracer_. Differential Revision: D64481537
1 parent 50aa517 commit 65646eb

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

extension/module/module.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,11 @@ runtime::Error Module::load_method(
151151
method_holder.memory_manager = std::make_unique<runtime::MemoryManager>(
152152
memory_allocator_.get(),
153153
method_holder.planned_memory.get(),
154-
temp_allocator_.get());
154+
temp_allocator_.get());
155+
// Use class member event_tracer_ when the tracer function parameter is null
156+
if (tracer == nullptr && event_tracer_ != nullptr) {
157+
tracer = event_tracer_.get();
158+
}
155159
method_holder.method = ET_UNWRAP_UNIQUE(program_->load_method(
156160
method_name.c_str(), method_holder.memory_manager.get(), tracer));
157161
method_holder.inputs.resize(method_holder.method->inputs_size());

0 commit comments

Comments
 (0)