From e3987f2dec053bc361c17e0db112db0ebfdcee14 Mon Sep 17 00:00:00 2001 From: xzl Date: Mon, 9 Oct 2017 20:12:33 +0800 Subject: [PATCH] modify Message to MessageLite --- .../tests/ProtobufEqualMain.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/python/paddle/trainer_config_helpers/tests/ProtobufEqualMain.cpp b/python/paddle/trainer_config_helpers/tests/ProtobufEqualMain.cpp index fc53422afd4..ec19e74cf95 100644 --- a/python/paddle/trainer_config_helpers/tests/ProtobufEqualMain.cpp +++ b/python/paddle/trainer_config_helpers/tests/ProtobufEqualMain.cpp @@ -12,19 +12,21 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include #include #include #include #include "TrainerConfig.pb.h" -bool loadPb(google::protobuf::Message* conf, const std::string& filename) { +using google::protobuf::MessageLite; +using google::protobuf::Message; + +bool loadPb(MessageLite* conf, const std::string& filename) { std::ifstream fin; fin.open(filename.c_str()); if (fin.is_open()) { std::string str((std::istreambuf_iterator(fin)), std::istreambuf_iterator()); - bool ok = google::protobuf::TextFormat::ParseFromString(str, conf); + bool ok = conf->ParseFromString(str); fin.close(); return ok; } else { @@ -33,8 +35,8 @@ bool loadPb(google::protobuf::Message* conf, const std::string& filename) { } int main(int argc, char** argv) { - std::unique_ptr config1; - std::unique_ptr config2; + std::unique_ptr config1; + std::unique_ptr config2; if (argc == 3) { config1.reset(new paddle::ModelConfig()); config2.reset(new paddle::ModelConfig()); @@ -50,7 +52,8 @@ int main(int argc, char** argv) { return 3; } else { if (google::protobuf::util::MessageDifferencer::ApproximatelyEquals( - *config1, *config2)) { + *reinterpret_cast(config1.get()), + *reinterpret_cast(config2.get()))) { return 0; } else { return 4; -- GitLab