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

print data according to its type (#1738)

上级 acfb2469
......@@ -176,19 +176,35 @@ void test(int argc, char *argv[]) {
if (out->memory_size() == 0) {
continue;
}
auto data = out->data<float>();
std::string sample = "";
if (!is_sample_step) {
sample_step = len / sample_num;
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>();
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;
}
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;
}
std::cout << std::endl;
}
......
......@@ -382,11 +382,6 @@ def main():
feed_kv = gen_feed_kv()
save_feed_kv(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")
outputs = run_model(feed_kv=feed_kv)
......@@ -397,6 +392,11 @@ def main():
# 输出所有中间结果
pp_yellow(dot + dot + " checking output result of every op")
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的正确性
print("")
print("==================================================")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册