From 21549d55bc901ca965c571e80e2debb5b65b8f24 Mon Sep 17 00:00:00 2001 From: dolphin8 Date: Thu, 11 Oct 2018 21:01:04 +0800 Subject: [PATCH] web-export --- tools/web-exporter/export-scope.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/web-exporter/export-scope.cpp b/tools/web-exporter/export-scope.cpp index 62a47e8c7f..d5c2492ac7 100644 --- a/tools/web-exporter/export-scope.cpp +++ b/tools/web-exporter/export-scope.cpp @@ -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(); int count = 1; for (auto n: var->Tensor_desc().Dims()) { count *= n; } + + auto* tensor = v->GetMutable(); + const float * p = tensor->mutable_data(); + 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"; } } } -- GitLab