mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
print average duration for caffe2 benchmark
Summary: print average duration for caffe2 benchmark Test Plan: buck run //xplat/caffe2:caffe2_benchmarkAppleMac -- --init_net ~/track_init_net.pb --net ~/track_predict_net.pb --warmup 10 --input 'data' --input_dims '1,4,128,256' --input_type float --iter 20 Using additional configuration options from .buckconfig.local Building: finished in 0.6 sec (100%) 247/2137 jobs, 0 updated Total time: 0.6 sec Average Duration: 18111 us Reviewed By: larryliu0820 Differential Revision: D27745416 fbshipit-source-id: a5d20b8ef0ba4a9547d396738d5ddd1aca57684d
This commit is contained in:
committed by
Facebook GitHub Bot
parent
d1fac54f13
commit
6dd1978d4b
@ -281,13 +281,18 @@ void runNetwork(
|
||||
iter,
|
||||
".");
|
||||
LOG(INFO) << "net runs.";
|
||||
long long duration_sum = 0;
|
||||
for (int i = 0; i < iter; ++i) {
|
||||
caffe2::ObserverConfig::initSampleRate(1, 1, 1, 0, warmup);
|
||||
fillInputBlob(workspace, tensor_protos_map, i);
|
||||
if (wipe_cache) {
|
||||
caffe2::wipe_cache();
|
||||
}
|
||||
auto start = std::chrono::high_resolution_clock::now();
|
||||
CAFFE_ENFORCE(net->Run(), "Main run ", i, " has failed.");
|
||||
auto stop = std::chrono::high_resolution_clock::now();
|
||||
auto duration = std::chrono::duration_cast<std::chrono::microseconds>(stop - start);
|
||||
duration_sum += duration.count();
|
||||
// Write the output for the first num_blobs times
|
||||
writeOutput(
|
||||
workspace,
|
||||
@ -305,6 +310,7 @@ void runNetwork(
|
||||
std::chrono::seconds(sleep_between_iteration));
|
||||
}
|
||||
}
|
||||
std::cout << "Average Duration: " << (duration_sum/iter) << " us" << std::endl;
|
||||
if (run_individual) {
|
||||
LOG(INFO) << "operator runs.";
|
||||
if (sleep_between_net_and_operator > 0) {
|
||||
|
Reference in New Issue
Block a user