提交 a6718797 编写于 作者: K Kexin Zhao

remove unreferenced vars

上级 6592ea15
...@@ -17,6 +17,7 @@ limitations under the License. */ ...@@ -17,6 +17,7 @@ limitations under the License. */
#include <algorithm> #include <algorithm>
#include <set> #include <set>
#include <string> #include <string>
#include <unordered_map>
#include <vector> #include <vector>
#include <glog/logging.h> #include <glog/logging.h>
...@@ -103,33 +104,31 @@ void prune_impl(const proto::ProgramDesc& input, proto::ProgramDesc* output, ...@@ -103,33 +104,31 @@ void prune_impl(const proto::ProgramDesc& input, proto::ProgramDesc* output,
} }
} }
// remove the vars in ProgramDesc that are not referenced in // remove the VarDescs in BlockDesc that are not referenced in
// the pruned ops // the pruned OpDescs
std::unordered_map<std::string name, proto::VarDesc> var_map; std::unordered_map<std::string, proto::VarDesc> var_map;
auto* var_field = output->mutable_blocks(block_id)->mutable_vars(); auto* var_field = output->mutable_blocks(block_id)->mutable_vars();
for (auto* var : *var_field) { for (const auto& var : *var_field) {
var_map[var->name()] = *var; var_map[var.name()] = var;
} }
// for (size_t i = 0; i < var_field->size(); ++i) { var_field->Clear();
// auto* var = (*var_field)[i]; for (const auto& op : *op_field) {
// var_map[var->name()] = *var; // add VarDescs of all input arguments for each OpDesc
// } auto& input_field = op.inputs();
for (auto& input : input_field) {
// var_field->Clear(); for (auto& arg : input.arguments()) {
// for (size_t i = 0; i < op_field->size(); ++i) { *var_field->Add() = var_map[arg];
// auto* op = (*op_field)[i]; }
}
// auto* input_field = op->mutable_inputs(); // add VarDescs of all output arguments for each OpDesc
// for (size_t j = 0; j < input_field->size(); ++j) { auto& output_field = op.outputs();
// auto* input_names = (*input_field)[j]->arguments(); for (auto& output : output_field) {
// for () for (auto& arg : output.arguments()) {
// *var_field->Add() = var_map[] *var_field->Add() = var_map[arg];
// } }
// auto* ouput_field = op->mutable_outputs(); }
// for (size_t k = 0; k < output_field->size(); ++k) { }
// }
// }
} }
// TODO(fengjiayi): Prune() could be inplaced to avoid unnecessary copies // TODO(fengjiayi): Prune() could be inplaced to avoid unnecessary copies
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册