1 // Copyright Yangqing Jia 2013
3 #ifndef CAFFE_UTIL_IO_H_
4 #define CAFFE_UTIL_IO_H_
6 #include <google/protobuf/message.h>
10 #include "caffe/blob.hpp"
11 #include "caffe/proto/caffe.pb.h"
14 using ::google::protobuf::Message;
18 void ReadProtoFromTextFile(const char* filename,
20 inline void ReadProtoFromTextFile(const string& filename,
22 ReadProtoFromTextFile(filename.c_str(), proto);
25 void WriteProtoToTextFile(const Message& proto, const char* filename);
26 inline void WriteProtoToTextFile(const Message& proto, const string& filename) {
27 WriteProtoToTextFile(proto, filename.c_str());
30 void ReadProtoFromBinaryFile(const char* filename,
32 inline void ReadProtoFromBinaryFile(const string& filename,
34 ReadProtoFromBinaryFile(filename.c_str(), proto);
37 void WriteProtoToBinaryFile(const Message& proto, const char* filename);
38 inline void WriteProtoToBinaryFile(
39 const Message& proto, const string& filename) {
40 WriteProtoToBinaryFile(proto, filename.c_str());
46 #endif // CAFFE_UTIL_IO_H_