|
|
|
@ -39,11 +39,11 @@ bool HasDependentVar(const OpDesc& op_desc,
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Prune(const ProgramDesc& input, ProgramDesc& output, int id) {
|
|
|
|
|
void Prune(const ProgramDesc& input, ProgramDesc& output, int block_id) {
|
|
|
|
|
// TODO(tonyyang-svail):
|
|
|
|
|
// - will change to use multiple blocks for RNN op and Cond Op
|
|
|
|
|
|
|
|
|
|
auto& block = input.blocks(id);
|
|
|
|
|
auto& block = input.blocks(block_id);
|
|
|
|
|
auto& ops = block.ops();
|
|
|
|
|
|
|
|
|
|
bool expect_feed = true;
|
|
|
|
@ -85,11 +85,11 @@ void Prune(const ProgramDesc& input, ProgramDesc& output, int id) {
|
|
|
|
|
std::reverse(should_run.begin(), should_run.end());
|
|
|
|
|
|
|
|
|
|
output = input;
|
|
|
|
|
auto* op_field = output.mutable_blocks(id)->mutable_ops();
|
|
|
|
|
auto* op_field = output.mutable_blocks(block_id)->mutable_ops();
|
|
|
|
|
op_field->Clear();
|
|
|
|
|
for (size_t i = 0; i < should_run.size(); ++i) {
|
|
|
|
|
if (should_run[i]) {
|
|
|
|
|
*op_field->Add() = input.blocks(id).ops(i);
|
|
|
|
|
*op_field->Add() = input.blocks(block_id).ops(i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|