Skip to content

Commit

Permalink
Merge pull request PaddlePaddle#1223 from reyoung/feature/remove_unus…
Browse files Browse the repository at this point in the history
…ed_clean_method

Removed unused GradientMachine::create
  • Loading branch information
wangkuiyi authored Jan 30, 2017
2 parents a78b653 + 5b1f66f commit dac4a59
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 264 deletions.
49 changes: 0 additions & 49 deletions paddle/gserver/gradientmachines/GradientMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,55 +60,6 @@ GradientMachine* GradientMachine::create(
return nullptr;
}

GradientMachine* GradientMachine::create(const std::string& modelFile,
DataConfig* dataConfig) {
std::ifstream is(modelFile);
CHECK(is) << "Fail to open " << modelFile;
return create(is, dataConfig);
}

GradientMachine* GradientMachine::create(std::istream& is,
DataConfig* dataConfig) {
TrainerConfig trainerConfig;
GradientMachine* ret = create(is, &trainerConfig);
if (dataConfig && trainerConfig.has_data_config()) {
*dataConfig = trainerConfig.data_config();
}
return ret;
}

GradientMachine* GradientMachine::create(const std::string& modelFile,
TrainerConfig* trainerConfig) {
std::ifstream is(modelFile);
CHECK(is) << "Fail to open " << modelFile;
return create(is, trainerConfig);
}

GradientMachine* GradientMachine::create(std::istream& is,
TrainerConfig* trainerConfig) {
TrainerConfig trainerConfigTemp;
int64_t size;
CHECK(is.read((char*)&size, sizeof(size))) << "Fail to read ";
std::string buf;
buf.resize(size);
CHECK(is.read(&buf[0], size)) << "Fail to read ";
CHECK(trainerConfigTemp.ParseFromString(buf)) << "Fail to parse config";
std::unique_ptr<GradientMachine> machine(
create(trainerConfigTemp.model_config()));
std::vector<ParameterPtr>& parameters = machine->getParameters();
for (auto& para : parameters) {
para->load(is);
}

machine->onLoadParameter();

if (trainerConfig) {
*trainerConfig = trainerConfigTemp;
}

return machine.release();
}

void GradientMachine::saveParameters(const std::string& dir) const {
LOG(INFO) << "Saving parameters to " << dir;

Expand Down
33 changes: 0 additions & 33 deletions paddle/gserver/gradientmachines/GradientMachine.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,39 +89,6 @@ class GradientMachine {
std::vector<ParameterType>{
PARAMETER_VALUE, PARAMETER_GRADIENT, PARAMETER_MOMENTUM});

/**
* Create a gradient machine from the merged model file.
* The merged model file can be generated using tools/merge_model
* If dataConfig is not null, it will be filled with the DataConfig
* from the TrainerConfig
*/
static GradientMachine* create(const std::string& modelFile,
DataConfig* dataConfig);

/**
* Create a gradient machine from a stream which contains the merged
* model file. The merged model file can be generated using tools/merge_model
* If dataConfig is not null, it will be filled with the DataConfig
* from the TrainerConfig
*/
static GradientMachine* create(std::istream& is, DataConfig* dataConfig);

/**
* Create a gradient machine from the merged model file.
* The merged model file can be generated using tools/merge_model
* If trainerConfig is not null, it will be filled with the TrainerConfig
*/
static GradientMachine* create(const std::string& modelFile,
TrainerConfig* trainerConfig);

/**
* Create a gradient machine from a stream which contains the merged
* model file. The merged model file can be generated using tools/merge_model
* If trainerConfig is not null, it will be filled with the TrainerConfig
*/
static GradientMachine* create(std::istream& is,
TrainerConfig* trainerConfig);

virtual ~GradientMachine() {}

/**
Expand Down
8 changes: 0 additions & 8 deletions paddle/trainer/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
################# test_Prediction ######################
add_unittest_without_exec(test_Prediction
test_Prediction.cpp)
add_test(NAME test_Prediction
COMMAND ${PROJ_ROOT}/paddle/.set_python_path.sh -d ${PROJ_ROOT}/python
${CMAKE_CURRENT_BINARY_DIR}/test_Prediction --merger=${CMAKE_CURRENT_BINARY_DIR}/../paddle_merge_model
WORKING_DIRECTORY ${PROJ_ROOT}/paddle/)

################# test_Compare ############################
add_unittest_without_exec(test_Compare
test_Compare.cpp)
Expand Down
174 changes: 0 additions & 174 deletions paddle/trainer/tests/test_Prediction.cpp

This file was deleted.

0 comments on commit dac4a59

Please sign in to comment.