提交 3b41d716 编写于 作者: D dolphin8

web-export

上级 3cb591a8
......@@ -10,17 +10,24 @@ void export_scope(ProgramPtr program, ScopePtr scope, const std::string & dirnam
if (var->Persistable()) {
auto* v = scope->FindVar(var->Name());
assert(v != nullptr);
const float * p = v->Get<float>();
int count = 1;
for (auto n: var->Tensor_desc().Dims()) {
count *= n;
}
auto* tensor = v->GetMutable<paddle_mobile::framework::LoDTensor>();
const float * p = tensor->mutable_data<float>();
std::string para_file_name = dirname + '/' + var->Name();
FILE *para_file = fopen(para_file_name.c_str(), "w");
assert(p != nullptr);
// std::cout << var->Name() << " " << count << "\n";
fwrite(p, sizeof(float), count, para_file);
fclose(para_file);
// std::cout << "==> " << var->Name() << " " << count << "\n";
// for (int i = 0; i < count; i++) {
// std::cout << p[i] << ", ";
// }
// std::cout << "\n";
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册