From f9135aeabfc35226f4b34702d86f26dd609b80f7 Mon Sep 17 00:00:00 2001 From: xzl Date: Wed, 11 Oct 2017 14:13:33 +0800 Subject: [PATCH] change back to original --- paddle/api/Trainer.cpp | 1 + .../tests/ProtobufEqualMain.cpp | 15 ++++++--------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/paddle/api/Trainer.cpp b/paddle/api/Trainer.cpp index 8a4b79a51..84e4ca054 100644 --- a/paddle/api/Trainer.cpp +++ b/paddle/api/Trainer.cpp @@ -73,6 +73,7 @@ Trainer* Trainer::create(TrainerConfig* config, if (retv->m->getConfig().IsInitialized()) { return retv; } else { + retv->m->getConfig().CheckInitialized(); throw IOError(); } } diff --git a/python/paddle/trainer_config_helpers/tests/ProtobufEqualMain.cpp b/python/paddle/trainer_config_helpers/tests/ProtobufEqualMain.cpp index ec19e74cf..fc53422af 100644 --- a/python/paddle/trainer_config_helpers/tests/ProtobufEqualMain.cpp +++ b/python/paddle/trainer_config_helpers/tests/ProtobufEqualMain.cpp @@ -12,21 +12,19 @@ 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" -using google::protobuf::MessageLite; -using google::protobuf::Message; - -bool loadPb(MessageLite* conf, const std::string& filename) { +bool loadPb(google::protobuf::Message* 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 = conf->ParseFromString(str); + bool ok = google::protobuf::TextFormat::ParseFromString(str, conf); fin.close(); return ok; } else { @@ -35,8 +33,8 @@ bool loadPb(MessageLite* 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()); @@ -52,8 +50,7 @@ int main(int argc, char** argv) { return 3; } else { if (google::protobuf::util::MessageDifferencer::ApproximatelyEquals( - *reinterpret_cast(config1.get()), - *reinterpret_cast(config2.get()))) { + *config1, *config2)) { return 0; } else { return 4; -- GitLab