Skip to content

Commit b9308bb

Browse files
committed
Update
1 parent 4bb3267 commit b9308bb

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

backends/xnnpack/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ if(NOT CMAKE_TOOLCHAIN_FILE MATCHES ".*(iOS|ios\.toolchain)\.cmake$")
141141
target_link_libraries(
142142
xnn_executor_runner gflags portable_ops_lib ${xnn_executor_runner_libs}
143143
)
144-
target_compile_options(xnn_executor_runner PUBLIC ${_common_compile_options})
144+
target_compile_options(xnn_executor_runner PUBLIC ${_common_compile_options} "-DPROFILING_ENABLED")
145145
endif()
146146

147147
install(

examples/portable/executor_runner/executor_runner.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ DEFINE_string(
4444
"model.pte",
4545
"Model serialized in flatbuffer format.");
4646

47+
DEFINE_string(
48+
prof_result_path,
49+
"prof_result.bin",
50+
"ExecuTorch profiler output path.");
51+
4752
DEFINE_int32(
4853
num_warmup_iters,
4954
0,
@@ -245,9 +250,14 @@ int main(int argc, char** argv) {
245250
(uint32_t)inputs.error());
246251
ET_LOG(Info, "Inputs prepared.");
247252

248-
// Run the model.
249253
for (uint32_t i = 0; i < FLAGS_num_warmup_iters; i++) {
250254
Error status = method->execute();
255+
}
256+
ET_LOG(Info, "Warm up complete.");
257+
258+
// Run the model.
259+
for (uint32_t i = 0; i < FLAGS_num_iters; i++) {
260+
Error status = method->execute();
251261
ET_CHECK_MSG(
252262
status == Error::Ok,
253263
"Execution of method %s failed with status 0x%" PRIx32,
@@ -288,5 +298,13 @@ int main(int argc, char** argv) {
288298
ET_CHECK_MSG(status == Error::Ok, "Failed to save ETDump file.");
289299
}
290300

301+
executorch::runtime::prof_result_t prof_result;
302+
EXECUTORCH_DUMP_PROFILE_RESULTS(&prof_result);
303+
if (prof_result.num_bytes != 0) {
304+
FILE* ptr = fopen(FLAGS_prof_result_path.c_str(), "w+");
305+
fwrite(prof_result.prof_data, 1, prof_result.num_bytes, ptr);
306+
fclose(ptr);
307+
}
308+
291309
return 0;
292310
}

0 commit comments

Comments
 (0)