Skip to content

Add a null check for tracer in the Module::load_method #6298

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
6 changes: 4 additions & 2 deletions extension/module/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ runtime::Result<std::unordered_set<std::string>> Module::method_names() {

runtime::Error Module::load_method(
const std::string& method_name,
torch::executor::EventTracer* tracer) {
torch::executor::EventTracer* event_tracer) {
if (!is_method_loaded(method_name)) {
ET_CHECK_OK_OR_RETURN_ERROR(load());

Expand Down Expand Up @@ -153,7 +153,9 @@ runtime::Error Module::load_method(
method_holder.planned_memory.get(),
temp_allocator_.get());
method_holder.method = ET_UNWRAP_UNIQUE(program_->load_method(
method_name.c_str(), method_holder.memory_manager.get(), tracer));
method_name.c_str(),
method_holder.memory_manager.get(),
event_tracer ? event_tracer : this->event_tracer()));
method_holder.inputs.resize(method_holder.method->inputs_size());
methods_.emplace(method_name, std::move(method_holder));
}
Expand Down
5 changes: 4 additions & 1 deletion extension/module/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,10 @@ class Module {
* needed. The loaded method is cached to reuse the next time it's executed.
*
* @param[in] method_name The name of the method to load.
* @param[in] event_tracer A EventTracer used for tracking and logging events.
* @param[in] event_tracer Per-method event tracer to profile/trace methods
* individually. When not given, the event tracer passed to the Module
* constructor is used. Otherwise, this per-method event tracer takes
* precedence.
*
* @returns An Error to indicate success or failure.
*/
Expand Down
Loading