diff --git a/paddle/framework/CMakeLists.txt b/paddle/framework/CMakeLists.txt index cbd39dd0954e97d7de8d8dd7659bf45a67736544..58e78e9a6a4877f7b3fef61b1715d4e27d6ead79 100644 --- a/paddle/framework/CMakeLists.txt +++ b/paddle/framework/CMakeLists.txt @@ -44,7 +44,7 @@ add_custom_command(TARGET framework_py_proto POST_BUILD 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 op_registry device scope framework_proto) +cc_library(executor SRCS executor.cc DEPS op_registry device scope framework_proto ${GLOB_OP_LIB}) cc_test(executor_test SRCS executor_test.cc DEPS executor) cc_library(tensor_array SRCS tensor_array.cc DEPS lod_tensor) diff --git a/paddle/framework/executor.cc b/paddle/framework/executor.cc index a61f0f71622efb0c9b69b3274c7aab1ab61060ea..94b9b3b350910f0853a95ecd6e0e00af5ac47f8c 100644 --- a/paddle/framework/executor.cc +++ b/paddle/framework/executor.cc @@ -31,6 +31,31 @@ Executor::Executor(const std::vector& places) { void Executor::Run(const ProgramDesc& pdesc, Scope* scope, std::vector* outputs) { // operators running + // TODO(tonyyang-svail): + // - only runs the first block + // - only runs on the first device + auto& block = pdesc.blocks(0); + auto& device = devices_[0]; + + for (auto& var : block.vars()) { + scope->NewVar(var.name()); + } + + // std::vector ops; + for (auto& op_desc : block.ops()) { + auto op = framework::OpRegistry::CreateOp(op_desc); + // op->InferShape(*scope); + op->Run(*scope, *device->cpu_device_context); + } + + // TODO(tonyyang-svail): need to test gpu device + // device_->cpu_device_context->Wait(); + // #ifndef PADDLE_ONLY_CPU + // if (device_->cuda_device_context) { + // device_->cuda_device_context->Wait(); + // } + // #endif + Scope& local_scope = scope->NewScope(); local_scope.NewVar(); for (auto device : devices_) { diff --git a/paddle/framework/executor.h b/paddle/framework/executor.h index 5d6d7f37a6a66affa92cfe1d1bc89327d365107b..cdb80bc10413d7bc3f4e42065ec4545c625c1b72 100644 --- a/paddle/framework/executor.h +++ b/paddle/framework/executor.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include "paddle/framework/framework.pb.h" +#include "paddle/framework/op_info.h" #include "paddle/framework/scope.h" #include "paddle/framework/tensor.h" #include "paddle/platform/device.h" diff --git a/paddle/framework/executor_test.cc b/paddle/framework/executor_test.cc index 4560d6c503eba9e5a43bd2ae2b28df5614d5f2c0..11255af808aaee3e17cec70d41ae30fcbc5d5d18 100644 --- a/paddle/framework/executor_test.cc +++ b/paddle/framework/executor_test.cc @@ -13,9 +13,15 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/framework/executor.h" +#include "gtest/gtest.h" #include "paddle/framework/attribute.h" -#include "gtest/gtest.h" +#include +#include "paddle/framework/grad_op_builder.h" +#include "paddle/framework/op_registry.h" +#include "paddle/framework/operator.h" + +USE_OP(elementwise_add); using namespace paddle::platform; using namespace paddle::framework;