@@ -289,6 +289,8 @@ void SGDSolver<Dtype>::SnapshotSolverStateToBinaryProto(
289
289
template <typename Dtype>
290
290
void SGDSolver<Dtype>::SnapshotSolverStateToHDF5(
291
291
const string& model_filename) {
292
+ // This code is taken from https://github.com/sh1r0/caffe-android-lib
293
+ #ifdef USE_HDF5
292
294
string snapshot_filename =
293
295
Solver<Dtype>::SnapshotFilename (" .solverstate.h5" );
294
296
LOG (INFO) << " Snapshotting solver state to HDF5 file " << snapshot_filename;
@@ -310,6 +312,11 @@ void SGDSolver<Dtype>::SnapshotSolverStateToHDF5(
310
312
}
311
313
H5Gclose (history_hid);
312
314
H5Fclose (file_hid);
315
+ // This code is taken from https://github.com/sh1r0/caffe-android-lib
316
+ #else
317
+ LOG (FATAL) << " SnapshotSolverStateToHDF5 requires hdf5;"
318
+ << " compile with USE_HDF5." ;
319
+ #endif // USE_HDF5
313
320
}
314
321
315
322
template <typename Dtype>
@@ -334,6 +341,7 @@ void SGDSolver<Dtype>::RestoreSolverStateFromBinaryProto(
334
341
335
342
template <typename Dtype>
336
343
void SGDSolver<Dtype>::RestoreSolverStateFromHDF5(const string& state_file) {
344
+ #ifdef USE_HDF5
337
345
hid_t file_hid = H5Fopen (state_file.c_str (), H5F_ACC_RDONLY, H5P_DEFAULT);
338
346
CHECK_GE (file_hid, 0 ) << " Couldn't open solver state file " << state_file;
339
347
this ->iter_ = hdf5_load_int (file_hid, " iter" );
@@ -355,6 +363,10 @@ void SGDSolver<Dtype>::RestoreSolverStateFromHDF5(const string& state_file) {
355
363
}
356
364
H5Gclose (history_hid);
357
365
H5Fclose (file_hid);
366
+ #else
367
+ LOG (FATAL) << " RestoreSolverStateFromHDF5 requires hdf5;"
368
+ << " compile with USE_HDF5." ;
369
+ #endif // USE_HDF5
358
370
}
359
371
360
372
INSTANTIATE_CLASS (SGDSolver);
0 commit comments