@@ -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+
4752DEFINE_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