我正在尝试使用以下代码从.proto文件动态生成protobuf消息:
MyMultiFileErrorCollector error_collector;
google::protobuf::compiler::DiskSourceTree source_tree;
source_tree.MapPath("", "../protofiles/");
data_proto_.importer = new (std::nothrow)
google::protobuf::compiler::Importer(&source_tree,
&error_collector);
if (data_proto_.importer == nullptr) {
LOG(ERROR) << "Create data proto import failed";
return false;
}
data_proto_.file_dscrptr = data_proto_.importer->Import(
"thirdparty/tensorflow_serving-
1.5.0/tensorflow_serving/apis/model.proto");
if (data_proto_.file_dscrptr == nullptr) {
LOG(ERROR) << "Import proto["
<< data_proto_.proto_root
<< "][" << data_proto_.proto_path << "] failed";
return false;
}
原始文件的定义如下:
syntax = "proto3";
package tensorflow.serving;
// option cc_enable_arenas = true;
import "google/protobuf/wrappers.proto";
// Metadata for an inference request such as the model name and version.
message ModelSpec {
// Required servable name.
string name = 1;
// Optional version. If unspecified, will use the latest (numerical) version.
// Typically not needed unless coordinating across multiple models that were co-trained and/or have inter-dependencies on the versions used at inference time.
google.protobuf.Int64Value version = 2;
// A named signature to evaluate. If unspecified, the default signature will
// be used.
string signature_name = 3;
}
错误如下:
E1210 13:23:00.616284 187180
test/beijing/module/datahub/datahub_regression/down_stream.cc:126]
Import[thirdparty/tensorflow_serving1.5.0/tensorflow_serving/
apis/model.proto]
line[3] column[7] error: Option "cc_enable_arenas" unknown.
如果我从原始文件中删除此句子“ option cc_enable_arenas = true”,那没关系。 我想进口商不支持选项,但是我不知道如何解决这个问题。