提交 d0b5d2c2 编写于 作者: Y Yanzhan Yang 提交者: zp7

print data according to its type (#1738)

上级 acfb2469
...@@ -176,6 +176,21 @@ void test(int argc, char *argv[]) { ...@@ -176,6 +176,21 @@ void test(int argc, char *argv[]) {
if (out->memory_size() == 0) { if (out->memory_size() == 0) {
continue; continue;
} }
if (out->type() == type_id<int>()) {
auto data = out->data<int>();
std::string sample = "";
if (!is_sample_step) {
sample_step = len / sample_num;
}
if (sample_step <= 0) {
sample_step = 1;
}
for (int i = 0; i < len; i += sample_step) {
sample += " " + std::to_string(data[i]);
}
std::cout << "auto-test"
<< " var " << var_name << sample << std::endl;
} else if (out->type() == type_id<float>()) {
auto data = out->data<float>(); auto data = out->data<float>();
std::string sample = ""; std::string sample = "";
if (!is_sample_step) { if (!is_sample_step) {
...@@ -190,6 +205,7 @@ void test(int argc, char *argv[]) { ...@@ -190,6 +205,7 @@ void test(int argc, char *argv[]) {
std::cout << "auto-test" std::cout << "auto-test"
<< " var " << var_name << sample << std::endl; << " var " << var_name << sample << std::endl;
} }
}
std::cout << std::endl; std::cout << std::endl;
} }
} }
...@@ -382,11 +382,6 @@ def main(): ...@@ -382,11 +382,6 @@ def main():
feed_kv = gen_feed_kv() feed_kv = gen_feed_kv()
save_feed_kv(feed_kv) save_feed_kv(feed_kv)
feed_kv = load_feed_kv() feed_kv = load_feed_kv()
pp_yellow(dot + dot + " checking fetch info")
for fetch in fetches:
fetch_name = fetch.name
fetch_shape = get_var_shape(fetch_name)
pp_tab("fetch var name : {}; fetch var shape : {}".format(fetch_name, fetch_shape), 1)
# 预测 # 预测
pp_yellow(dot + dot + " checking inference") pp_yellow(dot + dot + " checking inference")
outputs = run_model(feed_kv=feed_kv) outputs = run_model(feed_kv=feed_kv)
...@@ -397,6 +392,11 @@ def main(): ...@@ -397,6 +392,11 @@ def main():
# 输出所有中间结果 # 输出所有中间结果
pp_yellow(dot + dot + " checking output result of every op") pp_yellow(dot + dot + " checking output result of every op")
save_all_op_output(feed_kv=feed_kv) save_all_op_output(feed_kv=feed_kv)
pp_yellow(dot + dot + " checking fetch info")
for fetch in fetches:
fetch_name = fetch.name
fetch_shape = get_var_shape(fetch_name)
pp_tab("fetch var name : {}; fetch var shape : {}".format(fetch_name, fetch_shape), 1)
# 开始检查mobile的正确性 # 开始检查mobile的正确性
print("") print("")
print("==================================================") print("==================================================")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册