@@ -43,7 +43,14 @@ DEFINE_string(
4343 model_path,
4444 " model.pte" ,
4545 " Model serialized in flatbuffer format." );
46- DEFINE_uint32 (num_executions, 1 , " Number of times to run the model." );
46+
47+ DEFINE_int32 (
48+ num_warmup_iters,
49+ 0 ,
50+ " Number of warmup inference iterations (doesn't count to benchmark)." );
51+
52+ DEFINE_int32 (num_iters, 1 , " Number of inference iterations to run." );
53+
4754#ifdef ET_EVENT_TRACER_ENABLED
4855DEFINE_string (etdump_path, " model.etdump" , " Write ETDump data to this path." );
4956#endif // ET_EVENT_TRACER_ENABLED
@@ -239,8 +246,19 @@ int main(int argc, char** argv) {
239246 ET_LOG (Info, " Inputs prepared." );
240247
241248 // Run the model.
242- for (uint32_t i = 0 ; i < FLAGS_num_executions; i++) {
249+ for (uint32_t i = 0 ; i < FLAGS_num_warmup_iters; i++) {
250+ Error status = method->execute ();
251+ ET_CHECK_MSG (
252+ status == Error::Ok,
253+ " Execution of method %s failed with status 0x%" PRIx32,
254+ method_name,
255+ (uint32_t )status);
256+ }
257+ for (uint32_t i = 0 ; i < FLAGS_num_iters; i++) {
258+ EXECUTORCH_PROFILE_CREATE_BLOCK (" inference loop" );
259+ uint32_t prof_tok = EXECUTORCH_BEGIN_PROF (" run model" );
243260 Error status = method->execute ();
261+ EXECUTORCH_END_PROF (prof_tok);
244262 ET_CHECK_MSG (
245263 status == Error::Ok,
246264 " Execution of method %s failed with status 0x%" PRIx32,
@@ -250,7 +268,7 @@ int main(int argc, char** argv) {
250268 ET_LOG (
251269 Info,
252270 " Model executed successfully %" PRIu32 " time(s)." ,
253- FLAGS_num_executions );
271+ FLAGS_num_iters );
254272
255273 // Print the outputs.
256274 std::vector<EValue> outputs (method->outputs_size ());
0 commit comments