|
|
|
@ -68,11 +68,11 @@ TEST(Prune, one_operator) {
|
|
|
|
|
f::ProgramDesc *pdesc = program.Proto();
|
|
|
|
|
f::ProgramDesc pruned;
|
|
|
|
|
|
|
|
|
|
Prune(*pdesc, pruned, 0);
|
|
|
|
|
Prune(*pdesc, pruned);
|
|
|
|
|
PADDLE_ENFORCE_EQ(pruned.blocks(0).ops_size(), 0);
|
|
|
|
|
|
|
|
|
|
pdesc->mutable_blocks(0)->mutable_ops(0)->set_is_target(true);
|
|
|
|
|
Prune(*pdesc, pruned, 0);
|
|
|
|
|
Prune(*pdesc, pruned);
|
|
|
|
|
PADDLE_ENFORCE_EQ(pruned.blocks(0).ops_size(), 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -91,7 +91,7 @@ TEST(Prune, forward) {
|
|
|
|
|
for (int i = 0; i < pdesc->blocks(0).ops_size(); ++i) {
|
|
|
|
|
f::ProgramDesc pruned;
|
|
|
|
|
pdesc->mutable_blocks(0)->mutable_ops(i)->set_is_target(true);
|
|
|
|
|
Prune(*pdesc, pruned, 0);
|
|
|
|
|
Prune(*pdesc, pruned);
|
|
|
|
|
PADDLE_ENFORCE_EQ(pruned.blocks(0).ops_size(), i + 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -111,7 +111,7 @@ TEST(Prune, multi_input_op) {
|
|
|
|
|
pdesc->mutable_blocks(0)->mutable_ops(3)->set_is_target(true);
|
|
|
|
|
|
|
|
|
|
f::ProgramDesc pruned;
|
|
|
|
|
Prune(*pdesc, pruned, 0);
|
|
|
|
|
Prune(*pdesc, pruned);
|
|
|
|
|
PADDLE_ENFORCE_EQ(pruned.blocks(0).ops_size(), 4);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -128,7 +128,7 @@ TEST(Prune, multi_output_op) {
|
|
|
|
|
pdesc->mutable_blocks(0)->mutable_ops(2)->set_is_target(true);
|
|
|
|
|
|
|
|
|
|
f::ProgramDesc pruned;
|
|
|
|
|
Prune(*pdesc, pruned, 0);
|
|
|
|
|
Prune(*pdesc, pruned);
|
|
|
|
|
PADDLE_ENFORCE_EQ(pruned.blocks(0).ops_size(), 2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -146,6 +146,6 @@ TEST(Prune, multi_target) {
|
|
|
|
|
pdesc->mutable_blocks(0)->mutable_ops(2)->set_is_target(true);
|
|
|
|
|
|
|
|
|
|
f::ProgramDesc pruned;
|
|
|
|
|
Prune(*pdesc, pruned, 0);
|
|
|
|
|
Prune(*pdesc, pruned);
|
|
|
|
|
PADDLE_ENFORCE_EQ(pruned.blocks(0).ops_size(), 3);
|
|
|
|
|
}
|
|
|
|
|