@@ -285,6 +285,8 @@ void SGDSolver<Dtype>::SnapshotSolverStateToBinaryProto(
285
285
template <typename Dtype>
286
286
void SGDSolver<Dtype>::SnapshotSolverStateToHDF5(
287
287
const string& model_filename) {
288
+ // This code is taken from https://github.com/sh1r0/caffe-android-lib
289
+ #ifdef USE_HDF5
288
290
string snapshot_filename =
289
291
Solver<Dtype>::SnapshotFilename (" .solverstate.h5" );
290
292
LOG (INFO) << " Snapshotting solver state to HDF5 file " << snapshot_filename;
@@ -306,6 +308,11 @@ void SGDSolver<Dtype>::SnapshotSolverStateToHDF5(
306
308
}
307
309
H5Gclose (history_hid);
308
310
H5Fclose (file_hid);
311
+ // This code is taken from https://github.com/sh1r0/caffe-android-lib
312
+ #else
313
+ LOG (FATAL) << " SnapshotSolverStateToHDF5 requires hdf5;"
314
+ << " compile with USE_HDF5." ;
315
+ #endif // USE_HDF5
309
316
}
310
317
311
318
template <typename Dtype>
@@ -330,6 +337,7 @@ void SGDSolver<Dtype>::RestoreSolverStateFromBinaryProto(
330
337
331
338
template <typename Dtype>
332
339
void SGDSolver<Dtype>::RestoreSolverStateFromHDF5(const string& state_file) {
340
+ #ifdef USE_HDF5
333
341
hid_t file_hid = H5Fopen (state_file.c_str (), H5F_ACC_RDONLY, H5P_DEFAULT);
334
342
CHECK_GE (file_hid, 0 ) << " Couldn't open solver state file " << state_file;
335
343
this ->iter_ = hdf5_load_int (file_hid, " iter" );
@@ -351,6 +359,10 @@ void SGDSolver<Dtype>::RestoreSolverStateFromHDF5(const string& state_file) {
351
359
}
352
360
H5Gclose (history_hid);
353
361
H5Fclose (file_hid);
362
+ #else
363
+ LOG (FATAL) << " RestoreSolverStateFromHDF5 requires hdf5;"
364
+ << " compile with USE_HDF5." ;
365
+ #endif // USE_HDF5
354
366
}
355
367
356
368
INSTANTIATE_CLASS (SGDSolver);
0 commit comments