Fix compilation for Tensorflow code

Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
Stefan Weil 2021-03-29 16:13:26 +02:00
parent 3c03d70e64
commit 2e349dbba5
2 changed files with 5 additions and 6 deletions

View File

@ -1117,6 +1117,7 @@ unittest_CPPFLAGS += -I$(top_srcdir)/src/wordrec
unittest_CPPFLAGS += -I$(top_srcdir)/abseil
if TENSORFLOW
unittest_CPPFLAGS += -DINCLUDE_TENSORFLOW
unittest_CPPFLAGS += -I$(top_srcdir)/unittest
unittest_CPPFLAGS += -I/usr/include/tensorflow
endif # TENSORFLOW

View File

@ -44,19 +44,17 @@ bool TFNetwork::Serialize(TFile *fp) const {
return false;
std::string proto_str;
model_proto_.SerializeToString(&proto_str);
std::vector<char> data;
data.resize_no_init(proto_str.size());
// TODO: optimize and avoid copy from proto_str to data.
std::vector<char> data(proto_str.size());
memcpy(&data[0], proto_str.data(), proto_str.size());
if (!data.Serialize(fp))
return false;
return true;
return fp->Serialize(data);
}
// Reads from the given file. Returns false in case of error.
// Should be overridden by subclasses, but NOT called by their DeSerialize.
bool TFNetwork::DeSerialize(TFile *fp) {
std::vector<char> data;
if (!data.DeSerialize(fp))
if (!fp->DeSerialize(data))
return false;
if (!model_proto_.ParseFromArray(&data[0], data.size())) {
return false;