From bcdb302611f50ef8d896db5efddff59e7808969a Mon Sep 17 00:00:00 2001 From: Liangliang He Date: Wed, 20 Dec 2017 20:34:45 +0800 Subject: [PATCH] Update gcn script and mace_run --- mace/examples/mace_run.cc | 38 +++++++++++++++++--------------------- tools/validate_gcn.sh | 4 +++- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/mace/examples/mace_run.cc b/mace/examples/mace_run.cc index 1e3834f9..09146737 100644 --- a/mace/examples/mace_run.cc +++ b/mace/examples/mace_run.cc @@ -12,7 +12,6 @@ * --output_file=mace.out \ * --device=NEON */ -#include #include #include #include @@ -99,7 +98,7 @@ int main(int argc, char **argv) { int64_t t0 = utils::NowMicros(); NetDef net_def = mace::MACE_MODEL_FUNCTION(); int64_t t1 = utils::NowMicros(); - LOG(INFO) << "CreateNetDef duration: " << t1 - t0 << "us"; + LOG(INFO) << "CreateNetDef duration: " << t1 - t0 << " us"; int64_t init_micros = t1 - t0; DeviceType device_type = ParseDeviceType(device); @@ -119,29 +118,26 @@ int main(int argc, char **argv) { mace::MaceEngine engine(&net_def, device_type); t1 = utils::NowMicros(); init_micros += t1 - t0; - LOG(INFO) << "Net init duration: " << t1 - t0 << "us"; + LOG(INFO) << "Net init duration: " << t1 - t0 << " us"; - LOG(INFO) << "Total init duration: " << init_micros << "us"; + LOG(INFO) << "Total init duration: " << init_micros << " us"; std::vector output_shape; - VLOG(0) << "warm up"; - // warm up - for (int i = 0; i < 1; ++i) { - engine.Run(input_data.get(), shape, output_shape); - } + VLOG(0) << "Warm up"; + t0 = utils::NowMicros(); + engine.Run(input_data.get(), shape, output_shape); + t1 = utils::NowMicros(); + LOG(INFO) << "1st warm up run duration: " << t1 - t0 << " us"; - VLOG(0) << "Run model"; - timeval tv1, tv2; - gettimeofday(&tv1, NULL); - for (int i = 0; i < round; ++i) { - engine.Run(input_data.get(), shape, output_shape); + if (round > 0) { + VLOG(0) << "Run model"; + t0 = utils::NowMicros(); + for (int i = 0; i < round; ++i) { + engine.Run(input_data.get(), shape, output_shape); + } + t1 = utils::NowMicros(); + LOG(INFO) << "Avg duration: " << (t1 - t0) / (double)round << " us"; } - gettimeofday(&tv2, NULL); - std::cout << "avg duration: " - << ((tv2.tv_sec - tv1.tv_sec) * 1000 + - (tv2.tv_usec - tv1.tv_usec) / 1000) / - round - << endl; const float *output = engine.Run(input_data.get(), shape, output_shape); if (output != nullptr) { @@ -159,4 +155,4 @@ int main(int argc, char **argv) { ss << "]"; VLOG(0) << ss.str(); } -} \ No newline at end of file +} diff --git a/tools/validate_gcn.sh b/tools/validate_gcn.sh index bd0cb6b3..d97f7056 100644 --- a/tools/validate_gcn.sh +++ b/tools/validate_gcn.sh @@ -53,8 +53,10 @@ build_and_run() num_threads=${1:-4} if [[ "${TUNING_OR_NOT}" != "0" && "$EMBED_OPENCL_BINARY" != true ]];then tuning_flag=1 + round=0 # only warm up else tuning_flag=0 + round=2 fi adb