Skip to content

Commit

Permalink
Add global boolean for controlling whether to record concrete shapes …
Browse files Browse the repository at this point in the history
…or not (pytorch#101043)

Summary:
Pull Request resolved: pytorch#101043

We don't think the performance impact of recording concrete shapes is significant; but it's good to have a knob for turning it off quickly in case it has a large performance impact.

Test Plan:
Ran D45681838. It prints the state of that "concrete inputs" boolean. I ran it before and after canarying a change to `pytorch/kineto:pytorch_record_concrete_inputs`; before, it returns true; after, it returns false.

Note that D45681838 had to add `service` on the main function. That's because we need to `initFacebook` in order to use jks.

Reviewed By: aaronenyeshi

Differential Revision: D45680162

fbshipit-source-id: 680780ad9c947c0c60d09b3ba9904490730e96cb
  • Loading branch information
davidberard98 authored and facebook-github-bot committed May 11, 2023
1 parent 3271413 commit 776908b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
15 changes: 15 additions & 0 deletions torch/csrc/profiler/collection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1213,6 +1213,21 @@ RecordQueue::getRecords(
return {out, std::move(trace)};
}

namespace {
std::atomic<bool>& record_concrete_inputs_enabled() {
static std::atomic<bool> val{true};
return val;
}
} // namespace

bool get_record_concrete_inputs_enabled() {
return record_concrete_inputs_enabled();
}

void set_record_concrete_inputs_enabled(bool val) {
record_concrete_inputs_enabled() = val;
}

} // namespace impl
} // namespace profiler
} // namespace torch
3 changes: 3 additions & 0 deletions torch/csrc/profiler/collection.h
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,9 @@ class TORCH_API RecordQueue {
std::unique_ptr<python_tracer::PythonTracerBase> python_tracer_;
};

TORCH_API bool get_record_concrete_inputs_enabled();
TORCH_API void set_record_concrete_inputs_enabled(bool);

} // namespace impl
} // namespace profiler
} // namespace torch

0 comments on commit 776908b

Please sign in to comment.