From 8b80cf898917066daf12900473a832268a2e965e Mon Sep 17 00:00:00 2001 From: dongzhihong Date: Tue, 18 Jul 2017 21:03:52 +0800 Subject: [PATCH] "add net op testing" --- paddle/framework/net_op_test.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/paddle/framework/net_op_test.cc b/paddle/framework/net_op_test.cc index d61233a8b40..814f397c7da 100644 --- a/paddle/framework/net_op_test.cc +++ b/paddle/framework/net_op_test.cc @@ -32,6 +32,7 @@ void AssertSameVectorWithoutOrder(const std::vector& expected, } class PlainNetTest : public testing::Test { + public: virtual void SetUp() { net_ = std::make_shared(); ASSERT_NE(net_, nullptr); @@ -50,6 +51,8 @@ class PlainNetTest : public testing::Test { virtual void TearDown() {} + virtual void TestBody() {} + void TestOpKernel() { AssertSameVectorWithoutOrder({"x", "w1", "b1", "w2", "b2"}, net_->inputs_); AssertSameVectorWithoutOrder({"y", "z"}, net_->outputs_); @@ -67,6 +70,7 @@ class PlainNetTest : public testing::Test { ASSERT_EQ(2, infer_shape_cnt); ASSERT_EQ(2, run_cnt); + auto op2 = std::make_shared(); ASSERT_THROW(net_->AddOp(op2), EnforceNotMet); } @@ -83,12 +87,12 @@ class PlainNetTest : public testing::Test { TEST(OpKernel, all) { PlainNetTest net; - net->TestOpKernel(); + net.TestOpKernel(); } TEST(AddBackwardOp, TestAddBackwardOp) { PlainNetTest net; - net->TestAddBackwardOp(); + net.TestAddBackwardOp(); } } // namespace framework -- GitLab