@@ -19,8 +19,6 @@ limitations under the License. */
1919#include " paddle/fluid/framework/op_registry.h"
2020#include " paddle/fluid/platform/init.h"
2121
22- PD_DECLARE_bool (enable_unused_var_check);
23-
2422namespace paddle {
2523namespace framework {
2624
@@ -612,35 +610,7 @@ REGISTER_OP_WITHOUT_GRADIENT(
612610REGISTER_OP_CPU_KERNEL (op_without_unused_var,
613611 paddle::framework::OpWithoutUnusedVarKernelTest<float >);
614612
615- // test with single input
616- TEST (OpWithUnusedVar, all) {
617- // enable the unused_var_check
618- FLAGS_enable_unused_var_check = true ;
619- paddle::framework::InitDevices ();
620- paddle::framework::proto::OpDesc op_desc;
621- op_desc.set_type (" op_with_unused_var" );
622- BuildVar (" X" , {" X" }, op_desc.add_inputs ());
623- BuildVar (" Y" , {" Y" }, op_desc.add_outputs ());
624-
625- phi::CPUPlace cpu_place;
626- paddle::framework::Scope scope;
627- auto * x = scope.Var (" X" )->GetMutable <phi::DenseTensor>();
628- auto * y = scope.Var (" Y" )->GetMutable <phi::DenseTensor>();
629- x->Resize ({32 , 64 });
630- y->Resize ({32 , 64 });
631- x->mutable_data <float >(cpu_place);
632- y->mutable_data <float >(cpu_place);
633-
634- auto op = paddle::framework::OpRegistry::CreateOp (op_desc);
635- // should throw exception
636- ASSERT_THROW (op->Run (scope, cpu_place), paddle::platform::EnforceNotMet);
637- FLAGS_enable_unused_var_check = false ;
638- }
639-
640613TEST (OpWithoutUnusedVar, all) {
641- // enable the unused_var_check
642- FLAGS_enable_unused_var_check = true ;
643-
644614 paddle::framework::InitDevices ();
645615 paddle::framework::proto::OpDesc op_desc;
646616 op_desc.set_type (" op_without_unused_var" );
@@ -659,5 +629,4 @@ TEST(OpWithoutUnusedVar, all) {
659629 auto op = paddle::framework::OpRegistry::CreateOp (op_desc);
660630 // should not throw exception
661631 ASSERT_NO_THROW (op->Run (scope, cpu_place));
662- FLAGS_enable_unused_var_check = false ;
663632}
0 commit comments