[mlpack-svn] r16322 - mlpack/trunk/src/mlpack/core/data
fastlab-svn at coffeetalk-1.cc.gatech.edu
fastlab-svn at coffeetalk-1.cc.gatech.edu
Thu Feb 20 09:53:07 EST 2014
Author: rcurtin
Date: Thu Feb 20 09:53:07 2014
New Revision: 16322
Log:
Stop timers correctly when Log::Fatal is called (or when Load() or Save() return
early).
Modified:
mlpack/trunk/src/mlpack/core/data/load_impl.hpp
mlpack/trunk/src/mlpack/core/data/save_impl.hpp
Modified: mlpack/trunk/src/mlpack/core/data/load_impl.hpp
==============================================================================
--- mlpack/trunk/src/mlpack/core/data/load_impl.hpp (original)
+++ mlpack/trunk/src/mlpack/core/data/load_impl.hpp Thu Feb 20 09:53:07 2014
@@ -28,6 +28,7 @@
size_t ext = filename.rfind('.');
if (ext == std::string::npos)
{
+ Timer::Stop("loading_data");
if (fatal)
Log::Fatal << "Cannot determine type of file '" << filename << "'; "
<< "no extension is present." << std::endl;
@@ -35,7 +36,6 @@
Log::Warn << "Cannot determine type of file '" << filename << "'; "
<< "no extension is present. Load failed." << std::endl;
- Timer::Stop("loading_data");
return false;
}
@@ -50,13 +50,13 @@
if (!stream.is_open())
{
+ Timer::Stop("loading_data");
if (fatal)
Log::Fatal << "Cannot open file '" << filename << "'. " << std::endl;
else
Log::Warn << "Cannot open file '" << filename << "'; load failed."
<< std::endl;
- Timer::Stop("loading_data");
return false;
}
@@ -143,6 +143,7 @@
loadType = arma::hdf5_binary;
stringType = "HDF5 data";
#else
+ Timer::Stop("loading_data");
if (fatal)
Log::Fatal << "Attempted to load '" << filename << "' as HDF5 data, but "
<< "Armadillo was compiled without HDF5 support. Load failed."
@@ -152,7 +153,6 @@
<< "Armadillo was compiled without HDF5 support. Load failed."
<< std::endl;
- Timer::Stop("loading_data");
return false;
#endif
}
@@ -166,6 +166,7 @@
// Provide error if we don't know the type.
if (unknownType)
{
+ Timer::Stop("loading_data");
if (fatal)
Log::Fatal << "Unable to detect type of '" << filename << "'; "
<< "incorrect extension?" << std::endl;
@@ -173,7 +174,6 @@
Log::Warn << "Unable to detect type of '" << filename << "'; load failed."
<< " Incorrect extension?" << std::endl;
- Timer::Stop("loading_data");
return false;
}
@@ -190,10 +190,13 @@
if (!success)
{
Log::Info << std::endl;
+ Timer::Stop("loading_data");
if (fatal)
Log::Fatal << "Loading from '" << filename << "' failed." << std::endl;
else
Log::Warn << "Loading from '" << filename << "' failed." << std::endl;
+
+ return false;
}
else
Log::Info << "Size is " << (transpose ? matrix.n_cols : matrix.n_rows)
Modified: mlpack/trunk/src/mlpack/core/data/save_impl.hpp
==============================================================================
--- mlpack/trunk/src/mlpack/core/data/save_impl.hpp (original)
+++ mlpack/trunk/src/mlpack/core/data/save_impl.hpp Thu Feb 20 09:53:07 2014
@@ -25,6 +25,7 @@
size_t ext = filename.rfind('.');
if (ext == std::string::npos)
{
+ Timer::Stop("saving_data");
if (fatal)
Log::Fatal << "No extension given with filename '" << filename << "'; "
<< "type unknown. Save failed." << std::endl;
@@ -44,6 +45,7 @@
if (!stream.is_open())
{
+ Timer::Stop("saving_data");
if (fatal)
Log::Fatal << "Cannot open file '" << filename << "' for writing. "
<< "Save failed." << std::endl;
@@ -51,7 +53,6 @@
Log::Warn << "Cannot open file '" << filename << "' for writing; save "
<< "failed." << std::endl;
- Timer::Stop("saving_data");
return false;
}
@@ -86,6 +87,7 @@
saveType = arma::hdf5_binary;
stringType = "HDF5 data";
#else
+ Timer::Stop("saving_data");
if (fatal)
Log::Fatal << "Attempted to save HDF5 data to '" << filename << "', but "
<< "Armadillo was compiled without HDF5 support. Save failed."
@@ -95,7 +97,6 @@
<< "Armadillo was compiled without HDF5 support. Save failed."
<< std::endl;
- Timer::Stop("saving_data");
return false;
#endif
}
@@ -109,12 +110,15 @@
// Provide error if we don't know the type.
if (unknownType)
{
+ Timer::Stop("saving_data");
if (fatal)
Log::Fatal << "Unable to determine format to save to from filename '"
<< filename << "'. Save failed." << std::endl;
else
Log::Warn << "Unable to determine format to save to from filename '"
<< filename << "'. Save failed." << std::endl;
+
+ return false;
}
// Try to save the file.
@@ -128,12 +132,12 @@
if (!tmp.quiet_save(stream, saveType))
{
+ Timer::Stop("saving_data");
if (fatal)
Log::Fatal << "Save to '" << filename << "' failed." << std::endl;
else
Log::Warn << "Save to '" << filename << "' failed." << std::endl;
- Timer::Stop("saving_data");
return false;
}
}
@@ -141,12 +145,12 @@
{
if (!matrix.quiet_save(stream, saveType))
{
+ Timer::Stop("saving_data");
if (fatal)
Log::Fatal << "Save to '" << filename << "' failed." << std::endl;
else
Log::Warn << "Save to '" << filename << "' failed." << std::endl;
- Timer::Stop("saving_data");
return false;
}
}
More information about the mlpack-svn
mailing list