@@ -43,7 +43,14 @@ DEFINE_string(
43
43
model_path,
44
44
" model.pte" ,
45
45
" 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
+
47
54
#ifdef ET_EVENT_TRACER_ENABLED
48
55
DEFINE_string (etdump_path, " model.etdump" , " Write ETDump data to this path." );
49
56
#endif // ET_EVENT_TRACER_ENABLED
@@ -239,8 +246,19 @@ int main(int argc, char** argv) {
239
246
ET_LOG (Info, " Inputs prepared." );
240
247
241
248
// 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" );
243
260
Error status = method->execute ();
261
+ EXECUTORCH_END_PROF (prof_tok);
244
262
ET_CHECK_MSG (
245
263
status == Error::Ok,
246
264
" Execution of method %s failed with status 0x%" PRIx32,
@@ -250,7 +268,7 @@ int main(int argc, char** argv) {
250
268
ET_LOG (
251
269
Info,
252
270
" Model executed successfully %" PRIu32 " time(s)." ,
253
- FLAGS_num_executions );
271
+ FLAGS_num_iters );
254
272
255
273
// Print the outputs.
256
274
std::vector<EValue> outputs (method->outputs_size ());
0 commit comments