Skip to content

Commit 1454743

Browse files
authored
Measure model latency when input list is not provided
Differential Revision: D82280438 Pull Request resolved: #14247
1 parent ed0ab94 commit 1454743

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

examples/qualcomm/executor_runner/qnn_executor_runner.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,13 +568,40 @@ 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(
573575
status == Error::Ok,
574576
"Execution of method %s failed with status 0x%" PRIx32,
575577
method_name,
576578
(int)status);
577579
ET_LOG(Info, "Model executed successfully.");
580+
581+
// Warm up
582+
ET_LOG(Info, "Perform %d inferences for warming up", FLAGS_warm_up);
583+
for (int i = 0; i < FLAGS_warm_up; ++i) {
584+
status = method->execute();
585+
}
586+
587+
// Inference with designated iterations
588+
auto before_exec = std::chrono::high_resolution_clock::now();
589+
for (int i = 0; i < FLAGS_iteration; ++i) {
590+
status = method->execute();
591+
}
592+
auto after_exec = std::chrono::high_resolution_clock::now();
593+
double interval_infs =
594+
std::chrono::duration_cast<std::chrono::microseconds>(
595+
after_exec - before_exec)
596+
.count() /
597+
1000.0;
598+
599+
ET_LOG(
600+
Info,
601+
"%d inferences took %f ms, avg %f ms",
602+
FLAGS_iteration,
603+
interval_infs,
604+
interval_infs / (float)FLAGS_iteration);
578605
}
579606

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

0 commit comments

Comments
 (0)