29 #ifndef LBANN_IO_PERSIST_IMPL_H 30 #define LBANN_IO_PERSIST_IMPL_H 90 template <
class Archive>
99 std::ofstream os(filename);
103 #ifdef LBANN_HAS_CEREAL_XML_ARCHIVES 104 cereal::XMLOutputArchive archive(os);
105 #else // defined LBANN_HAS_CEREAL_BINARY_ARCHIVES 106 cereal::BinaryOutputArchive archive(os);
107 #endif // LBANN_HAS_CEREAL_XML_ARCHIVES 111 template <
typename C>
117 template <
typename C>
121 const std::string& suffix)
123 write_cereal_archive<C>(obj, p.
get_filename(pt) + suffix);
126 template <
typename C>
130 const std::string& suffix)
133 write_cereal_archive<C>(obj, p, pt, suffix);
136 template <
typename C>
139 std::ifstream is(filename);
143 #ifdef LBANN_HAS_CEREAL_XML_ARCHIVES 144 cereal::XMLInputArchive archive(is);
145 #else // defined LBANN_HAS_CEREAL_BINARY_ARCHIVES 146 cereal::BinaryInputArchive archive(is);
147 #endif // LBANN_HAS_CEREAL_XML_ARCHIVES 151 template <
typename C>
157 template <
typename C>
161 const std::string& suffix)
166 template <
typename C>
170 const std::string& suffix)
173 read_cereal_archive<C>(obj, p, pt, suffix);
176 template <
typename C>
179 std::ostringstream ss;
181 cereal::BinaryOutputArchive archive(ss);
187 template <
typename C>
190 std::istringstream ss(buf);
192 cereal::BinaryInputArchive archive(ss);
197 template <
typename C>
200 const std::string& filename)
204 read_cereal_archive<C>(obj, filename);
205 buf = create_cereal_archive_binary_string<C>(obj);
209 std::ifstream is(filename);
220 unpack_cereal_archive_binary_string<C>(obj, buf);
224 template <
typename C>
228 const std::string& filename)
233 template <
typename C>
238 const std::string& suffix)
243 template <
typename C>
248 const std::string& suffix)
251 load_from_shared_cereal_archive<C>(obj, p, pt, comm, suffix);
255 #endif // LBANN_IO_PERSIST_IMPL_H
void trainer_broadcast(int root, T &val) const
Within-trainer broadcast of a scalar.
void serialize(Archive &ar)
persist_type execution_mode_to_persist_type(execution_mode m)
const std::string & get_checkpoint_dir() const
void read_cereal_archive(C &obj, const std::string &filename)
std::string to_string(El::Device const &d)
void load_from_shared_cereal_archive(C &obj, lbann_comm &comm, const std::string &filename)
std::string create_cereal_archive_binary_string(C &obj)
execution_mode
Neural network execution mode.
bool am_trainer_master() const noexcept
void write_cereal_archive(C &obj, const std::string &filename)
std::string get_filename(persist_type type) const
void unpack_cereal_archive_binary_string(C &obj, const std::string &buf)