提交 f9135aea 编写于 作者: X xzl

change back to original

上级 c6355444
...@@ -73,6 +73,7 @@ Trainer* Trainer::create(TrainerConfig* config, ...@@ -73,6 +73,7 @@ Trainer* Trainer::create(TrainerConfig* config,
if (retv->m->getConfig().IsInitialized()) { if (retv->m->getConfig().IsInitialized()) {
return retv; return retv;
} else { } else {
retv->m->getConfig().CheckInitialized();
throw IOError(); throw IOError();
} }
} }
......
...@@ -12,21 +12,19 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ...@@ -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 See the License for the specific language governing permissions and
limitations under the License. */ limitations under the License. */
#include <google/protobuf/text_format.h>
#include <google/protobuf/util/message_differencer.h> #include <google/protobuf/util/message_differencer.h>
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include "TrainerConfig.pb.h" #include "TrainerConfig.pb.h"
using google::protobuf::MessageLite; bool loadPb(google::protobuf::Message* conf, const std::string& filename) {
using google::protobuf::Message;
bool loadPb(MessageLite* conf, const std::string& filename) {
std::ifstream fin; std::ifstream fin;
fin.open(filename.c_str()); fin.open(filename.c_str());
if (fin.is_open()) { if (fin.is_open()) {
std::string str((std::istreambuf_iterator<char>(fin)), std::string str((std::istreambuf_iterator<char>(fin)),
std::istreambuf_iterator<char>()); std::istreambuf_iterator<char>());
bool ok = conf->ParseFromString(str); bool ok = google::protobuf::TextFormat::ParseFromString(str, conf);
fin.close(); fin.close();
return ok; return ok;
} else { } else {
...@@ -35,8 +33,8 @@ bool loadPb(MessageLite* conf, const std::string& filename) { ...@@ -35,8 +33,8 @@ bool loadPb(MessageLite* conf, const std::string& filename) {
} }
int main(int argc, char** argv) { int main(int argc, char** argv) {
std::unique_ptr<MessageLite> config1; std::unique_ptr<google::protobuf::Message> config1;
std::unique_ptr<MessageLite> config2; std::unique_ptr<google::protobuf::Message> config2;
if (argc == 3) { if (argc == 3) {
config1.reset(new paddle::ModelConfig()); config1.reset(new paddle::ModelConfig());
config2.reset(new paddle::ModelConfig()); config2.reset(new paddle::ModelConfig());
...@@ -52,8 +50,7 @@ int main(int argc, char** argv) { ...@@ -52,8 +50,7 @@ int main(int argc, char** argv) {
return 3; return 3;
} else { } else {
if (google::protobuf::util::MessageDifferencer::ApproximatelyEquals( if (google::protobuf::util::MessageDifferencer::ApproximatelyEquals(
*reinterpret_cast<Message*>(config1.get()), *config1, *config2)) {
*reinterpret_cast<Message*>(config2.get()))) {
return 0; return 0;
} else { } else {
return 4; return 4;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册