Skip to content

Commit fde5862

Browse files
committed
Small fix for use of flag FLAGS_etdump
Change-Id: I0ebb22636cdd64aea24bcee51cba05496ed78b1f
1 parent b36d5b4 commit fde5862

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

examples/portable/executor_runner/executor_runner.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,18 @@ class EventTraceManager {
7272
return event_tracer_ptr_.get();
7373
};
7474

75-
Error write_etdump_to_file(const char* filename) const {
75+
Error write_etdump_to_file() const {
7676
torch::executor::ETDumpGen* const etdump_ptr =
7777
static_cast<torch::executor::ETDumpGen*>(get_event_tracer());
7878
if (!etdump_ptr) {
7979
return Error::NotSupported;
8080
}
8181

82+
const char* filename = nullptr;
83+
#ifdef ET_EVENT_TRACER_ENABLED
84+
filename = FLAGS_etdump_path.c_str();
85+
#endif // ET_EVENT_TRACER_ENABLED
86+
8287
std::unique_ptr<FILE, decltype(&fclose)> etdump_file(
8388
fopen(filename, "w+"), fclose);
8489
if (!etdump_file) {
@@ -251,12 +256,10 @@ int main(int argc, char** argv) {
251256
}
252257

253258
if (tracer.get_event_tracer()) {
254-
// Dump ETDump data containing profiling/debugging data to specified file.
255-
Error status = tracer.write_etdump_to_file(FLAGS_etdump_path.c_str());
256-
ET_CHECK_MSG(
257-
status == Error::Ok,
258-
"Failed to save ETDump file at %s.",
259-
FLAGS_etdump_path.c_str());
259+
// Dump ETDump data containing profiling/debugging data to file specified in
260+
// command line flag.
261+
Error status = tracer.write_etdump_to_file();
262+
ET_CHECK_MSG(status == Error::Ok, "Failed to save ETDump file.");
260263
}
261264

262265
return 0;

0 commit comments

Comments
 (0)