Skip to content
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
12 changes: 10 additions & 2 deletions torch/csrc/jit/mobile/profiler_edge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,23 @@ KinetoEdgeCPUProfiler::KinetoEdgeCPUProfiler(
const bool profile_memory,
const bool with_stack,
const bool with_flops,
const bool with_modules)
const bool with_modules,
std::vector<std::string> events)
: m_(m), trace_file_name_(fname) {
torch::profiler::impl::ExperimentalConfig experimental_config;
// Enable hardware counters
if (events.size()) {
experimental_config.performance_events = std::move(events);
}

torch::profiler::impl::ProfilerConfig config(
torch::profiler::impl::ProfilerState::KINETO,
report_input_shapes,
profile_memory,
with_stack,
with_flops,
with_modules);
with_modules,
experimental_config);
torch::autograd::profiler::prepareProfiler(
config, {torch::autograd::profiler::ActivityType::CPU});
if (with_modules || with_stack) {
Expand Down
3 changes: 2 additions & 1 deletion torch/csrc/jit/mobile/profiler_edge.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ class TORCH_API KinetoEdgeCPUProfiler {
const bool profile_memory = false,
const bool with_stack = false,
const bool with_flops = false,
const bool with_modules = false);
const bool with_modules = false,
std::vector<std::string> events = {});

const std::unique_ptr<torch::autograd::profiler::ProfilerResult>&
disableProfiler();
Expand Down