提交 9fc3e2e1 编写于 作者: 刘琦

Merge branch 'mace_run' into 'master'

Update gcn script and mace_run

See merge request !174
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
* --output_file=mace.out \ * --output_file=mace.out \
* --device=NEON * --device=NEON
*/ */
#include <sys/time.h>
#include <fstream> #include <fstream>
#include <numeric> #include <numeric>
#include <iostream> #include <iostream>
...@@ -99,7 +98,7 @@ int main(int argc, char **argv) { ...@@ -99,7 +98,7 @@ int main(int argc, char **argv) {
int64_t t0 = utils::NowMicros(); int64_t t0 = utils::NowMicros();
NetDef net_def = mace::MACE_MODEL_FUNCTION(); NetDef net_def = mace::MACE_MODEL_FUNCTION();
int64_t t1 = utils::NowMicros(); 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; int64_t init_micros = t1 - t0;
DeviceType device_type = ParseDeviceType(device); DeviceType device_type = ParseDeviceType(device);
...@@ -119,29 +118,26 @@ int main(int argc, char **argv) { ...@@ -119,29 +118,26 @@ int main(int argc, char **argv) {
mace::MaceEngine engine(&net_def, device_type); mace::MaceEngine engine(&net_def, device_type);
t1 = utils::NowMicros(); t1 = utils::NowMicros();
init_micros += t1 - t0; 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<int64_t> output_shape; std::vector<int64_t> output_shape;
VLOG(0) << "warm up"; VLOG(0) << "Warm up";
// warm up t0 = utils::NowMicros();
for (int i = 0; i < 1; ++i) { engine.Run(input_data.get(), shape, output_shape);
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"; if (round > 0) {
timeval tv1, tv2; VLOG(0) << "Run model";
gettimeofday(&tv1, NULL); t0 = utils::NowMicros();
for (int i = 0; i < round; ++i) { for (int i = 0; i < round; ++i) {
engine.Run(input_data.get(), shape, output_shape); 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); const float *output = engine.Run(input_data.get(), shape, output_shape);
if (output != nullptr) { if (output != nullptr) {
...@@ -159,4 +155,4 @@ int main(int argc, char **argv) { ...@@ -159,4 +155,4 @@ int main(int argc, char **argv) {
ss << "]"; ss << "]";
VLOG(0) << ss.str(); VLOG(0) << ss.str();
} }
} }
\ No newline at end of file
...@@ -53,8 +53,10 @@ build_and_run() ...@@ -53,8 +53,10 @@ build_and_run()
num_threads=${1:-4} num_threads=${1:-4}
if [[ "${TUNING_OR_NOT}" != "0" && "$EMBED_OPENCL_BINARY" != true ]];then if [[ "${TUNING_OR_NOT}" != "0" && "$EMBED_OPENCL_BINARY" != true ]];then
tuning_flag=1 tuning_flag=1
round=0 # only warm up
else else
tuning_flag=0 tuning_flag=0
round=2
fi fi
adb </dev/null shell MACE_TUNING=${tuning_flag} \ adb </dev/null shell MACE_TUNING=${tuning_flag} \
...@@ -70,7 +72,7 @@ build_and_run() ...@@ -70,7 +72,7 @@ build_and_run()
--input_file=${PHONE_DATA_DIR}/${INPUT_FILE_NAME} \ --input_file=${PHONE_DATA_DIR}/${INPUT_FILE_NAME} \
--output_file=${PHONE_DATA_DIR}/${OUTPUT_FILE_NAME} \ --output_file=${PHONE_DATA_DIR}/${OUTPUT_FILE_NAME} \
--device=OPENCL \ --device=OPENCL \
--round=2 --round=$round
} }
echo "Step 1: Generate input data" echo "Step 1: Generate input data"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册