From e42cafb24f3868713958213777d798cd54140b40 Mon Sep 17 00:00:00 2001 From: qijun Date: Fri, 29 Sep 2017 22:50:40 -0700 Subject: [PATCH] add executor unittest --- paddle/framework/CMakeLists.txt | 1 + paddle/framework/executor.cc | 6 +++--- paddle/framework/executor.h | 2 +- paddle/framework/executor_test.cc | 10 +++++++++- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/paddle/framework/CMakeLists.txt b/paddle/framework/CMakeLists.txt index 3ee721ac9..2cad2e54f 100644 --- a/paddle/framework/CMakeLists.txt +++ b/paddle/framework/CMakeLists.txt @@ -45,3 +45,4 @@ cc_library(backward SRCS backward.cc DEPS net_op) cc_test(backward_test SRCS backward_test.cc DEPS backward recurrent_op device_context) cc_library(executor SRCS executor.cc DEPS device_context framework_proto) +cc_test(executor_test SRCS executor_test.cc DEPS executor) diff --git a/paddle/framework/executor.cc b/paddle/framework/executor.cc index 8534e70f4..7fda2332b 100644 --- a/paddle/framework/executor.cc +++ b/paddle/framework/executor.cc @@ -40,7 +40,7 @@ class GraphView : public ProgramDescView { void Initialize(const ProgramDesc*) override; }; -static ProgramDescView* Create(bool is_linear) { +ProgramDescView* ProgramDescView::Create(bool is_linear) { if (is_linear) { return new LinearListView(); } else { @@ -91,8 +91,8 @@ static std::unique_ptr g_cuda_device_context = make_unique(platform::GPUPlace(0)); #endif -static Executor* NewLocalExecutor(const platform::Place& place, - const ProgramDesc& pdesc, bool is_linear) { +Executor* NewLocalExecutor(const platform::Place& place, + const ProgramDesc& pdesc, bool is_linear) { platform::DeviceContext* device_context = nullptr; if (platform::is_cpu_place(place)) { device_context = g_cpu_device_context.get(); diff --git a/paddle/framework/executor.h b/paddle/framework/executor.h index 69f0e3f18..25ef2d4d4 100644 --- a/paddle/framework/executor.h +++ b/paddle/framework/executor.h @@ -26,7 +26,7 @@ class Executor { virtual void Run() = 0; }; -static Executor* NewLocalExecutor(const platform::Place&, const ProgramDesc&); +Executor* NewLocalExecutor(const platform::Place&, const ProgramDesc&, bool); } // namespace framework } // namespace paddle diff --git a/paddle/framework/executor_test.cc b/paddle/framework/executor_test.cc index f8a41b12a..c046ae315 100644 --- a/paddle/framework/executor_test.cc +++ b/paddle/framework/executor_test.cc @@ -15,4 +15,12 @@ limitations under the License. */ #include "paddle/framework/executor.h" #include "gtest/gtest.h" -TEST(Executor, Init) {} \ No newline at end of file +using namespace paddle::platform; +using namespace paddle::framework; + +TEST(Executor, Init) { + ProgramDesc pdesc; + CPUPlace cpu_place; + Executor* executor = NewLocalExecutor(cpu_place, pdesc, true); + executor->Run(); +} \ No newline at end of file -- GitLab