Skip to content

Commit 7e95015

Browse files
limintangfacebook-github-bot
authored andcommitted
Measure model latency when input list is not provided
Summary: As title. Differential Revision: D82280438
1 parent 35c1f52 commit 7e95015

File tree

1 file changed

+31
-5
lines changed

1 file changed

+31
-5
lines changed

examples/qualcomm/executor_runner/qnn_executor_runner.cpp

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -568,13 +568,39 @@ int main(int argc, char** argv) {
568568
ET_LOG(
569569
Info,
570570
"Input list not provided. Inputs prepared with default values set.");
571+
572+
// Run the method
571573
Error status = method->execute();
572574
ET_CHECK_MSG(
573-
status == Error::Ok,
574-
"Execution of method %s failed with status 0x%" PRIx32,
575-
method_name,
576-
(int)status);
577-
ET_LOG(Info, "Model executed successfully.");
575+
status == Error::Ok,
576+
"Execution of method %s failed with status 0x%" PRIx32,
577+
method_name,
578+
(int)status);
579+
580+
// Warm up
581+
ET_LOG(Info, "Perform %d inference for warming up", FLAGS_warm_up);
582+
for (int i = 0; i < FLAGS_warm_up; ++i) {
583+
status = method->execute();
584+
}
585+
586+
// Inference with designated iterations
587+
auto before_exec = std::chrono::high_resolution_clock::now();
588+
for (int i = 0; i < FLAGS_iteration; ++i) {
589+
status = method->execute();
590+
}
591+
auto after_exec = std::chrono::high_resolution_clock::now();
592+
double interval_infs =
593+
std::chrono::duration_cast<std::chrono::microseconds>(
594+
after_exec - before_exec)
595+
.count() /
596+
1000.0;
597+
598+
ET_LOG(
599+
Info,
600+
"%d inferences took %f ms, avg %f ms",
601+
FLAGS_iteration,
602+
interval_infs,
603+
interval_infs / (float)FLAGS_iteration);
578604
}
579605

580606
// Dump the etdump data containing profiling/debugging data to the specified

0 commit comments

Comments
 (0)