Revert "solver: check and set type to reconcile class and proto"
authorEvan Shelhamer <shelhamer@imaginarynumber.net>
Fri, 25 Nov 2016 20:49:53 +0000 (12:49 -0800)
committerEvan Shelhamer <shelhamer@imaginarynumber.net>
Fri, 25 Nov 2016 20:49:53 +0000 (12:49 -0800)
as pointed out by #5028 this does not achieve what it intended, and
furthermore causes trouble with direct solver instantiation.

revert commit e52451de914312b80a83459cb160c2f72a5b4fea

include/caffe/solver.hpp
src/caffe/solver.cpp
src/caffe/test/test_gradient_based_solver.cpp

index ef38d6e..eafcee3 100644 (file)
@@ -108,8 +108,6 @@ class Solver {
   virtual void RestoreSolverStateFromBinaryProto(const string& state_file) = 0;
   void DisplayOutputBlobs(const int net_id);
   void UpdateSmoothedLoss(Dtype loss, int start_iter, int average_loss);
-  /// Harmonize solver class type with configured proto type.
-  void CheckType(SolverParameter* param);
 
   SolverParameter param_;
   int iter_;
index ae6a5a3..ece3913 100644 (file)
@@ -38,22 +38,10 @@ Solver<Dtype>::Solver(const string& param_file, const Solver* root_solver)
       requested_early_exit_(false) {
   SolverParameter param;
   ReadSolverParamsFromTextFileOrDie(param_file, &param);
-  CheckType(&param);
   Init(param);
 }
 
 template <typename Dtype>
-void Solver<Dtype>::CheckType(SolverParameter* param) {
-  // Harmonize solver class type with configured type to avoid confusion.
-  if (param->has_type()) {
-    CHECK_EQ(param->type(), this->type())
-        << "Solver type must agree with instantiated solver class.";
-  } else {
-    param->set_type(this->type());
-  }
-}
-
-template <typename Dtype>
 void Solver<Dtype>::Init(const SolverParameter& param) {
   CHECK(Caffe::root_solver() || root_solver_)
       << "root_solver_ needs to be set for all non-root solvers";
index e81caea..975a8f0 100644 (file)
@@ -694,11 +694,6 @@ TYPED_TEST(SGDSolverTest, TestSnapshotShare) {
   }
 }
 
-TYPED_TEST(SGDSolverTest, TestSolverType) {
-  this->TestLeastSquaresUpdate();
-  EXPECT_NE(this->solver_->type(), string(""));
-  EXPECT_EQ(this->solver_->type(), this->solver_->param().type());
-}
 
 template <typename TypeParam>
 class AdaGradSolverTest : public GradientBasedSolverTest<TypeParam> {