提交 e946fc15 编写于 作者: Y Yang Yang

add elementwise_add

上级 1a0d8fab
...@@ -44,7 +44,7 @@ add_custom_command(TARGET framework_py_proto POST_BUILD ...@@ -44,7 +44,7 @@ add_custom_command(TARGET framework_py_proto POST_BUILD
cc_library(backward SRCS backward.cc DEPS net_op) cc_library(backward SRCS backward.cc DEPS net_op)
cc_test(backward_test SRCS backward_test.cc DEPS backward recurrent_op device_context) 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_test(executor_test SRCS executor_test.cc DEPS executor)
cc_library(tensor_array SRCS tensor_array.cc DEPS lod_tensor) cc_library(tensor_array SRCS tensor_array.cc DEPS lod_tensor)
......
...@@ -31,6 +31,31 @@ Executor::Executor(const std::vector<platform::Place>& places) { ...@@ -31,6 +31,31 @@ Executor::Executor(const std::vector<platform::Place>& places) {
void Executor::Run(const ProgramDesc& pdesc, Scope* scope, void Executor::Run(const ProgramDesc& pdesc, Scope* scope,
std::vector<Tensor>* outputs) { std::vector<Tensor>* outputs) {
// operators running // 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<op_ptr> 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(); Scope& local_scope = scope->NewScope();
local_scope.NewVar(); local_scope.NewVar();
for (auto device : devices_) { for (auto device : devices_) {
......
...@@ -15,6 +15,7 @@ limitations under the License. */ ...@@ -15,6 +15,7 @@ limitations under the License. */
#pragma once #pragma once
#include "paddle/framework/framework.pb.h" #include "paddle/framework/framework.pb.h"
#include "paddle/framework/op_info.h"
#include "paddle/framework/scope.h" #include "paddle/framework/scope.h"
#include "paddle/framework/tensor.h" #include "paddle/framework/tensor.h"
#include "paddle/platform/device.h" #include "paddle/platform/device.h"
......
...@@ -13,9 +13,15 @@ See the License for the specific language governing permissions and ...@@ -13,9 +13,15 @@ See the License for the specific language governing permissions and
limitations under the License. */ limitations under the License. */
#include "paddle/framework/executor.h" #include "paddle/framework/executor.h"
#include "gtest/gtest.h"
#include "paddle/framework/attribute.h" #include "paddle/framework/attribute.h"
#include "gtest/gtest.h" #include <gtest/gtest.h>
#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::platform;
using namespace paddle::framework; using namespace paddle::framework;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册