From b94584cf4b70dc9074779b512f8e4eb14ad032e0 Mon Sep 17 00:00:00 2001 From: dangqingqing Date: Tue, 1 Aug 2017 17:18:09 +0800 Subject: [PATCH] Rename recurrent_network_op recurrent_op. --- paddle/operators/CMakeLists.txt | 6 ++---- .../{recurrent_network_op.cc => recurrent_op.cc} | 13 +++++++++---- .../{recurrent_network_op.h => recurrent_op.h} | 0 ...rent_network_op_test.cc => recurrent_op_test.cc} | 2 +- paddle/pybind/CMakeLists.txt | 2 +- 5 files changed, 13 insertions(+), 10 deletions(-) rename paddle/operators/{recurrent_network_op.cc => recurrent_op.cc} (97%) rename paddle/operators/{recurrent_network_op.h => recurrent_op.h} (100%) rename paddle/operators/{recurrent_network_op_test.cc => recurrent_op_test.cc} (99%) diff --git a/paddle/operators/CMakeLists.txt b/paddle/operators/CMakeLists.txt index 5085e1b9255..9d28404f687 100644 --- a/paddle/operators/CMakeLists.txt +++ b/paddle/operators/CMakeLists.txt @@ -55,7 +55,5 @@ op_library(fc_op SRCS fc_op.cc DEPS mul_op rowwise_add_op sigmoid_op op_library(sgd_op SRCS sgd_op.cc sgd_op.cu) -op_library(recurrent_network_op SRCS recurrent_network_op.cc DEPS op_desc -tensor op_registry operator net) -cc_test(recurrent_network_op_test SRCS recurrent_network_op_test.cc DEPS -recurrent_network_op gtest mul_op add_op) +op_library(recurrent_op SRCS recurrent_op.cc DEPS op_desc tensor op_registry operator net) +cc_test(recurrent_op_test SRCS recurrent_op_test.cc DEPS recurrent_op gtest mul_op add_op) diff --git a/paddle/operators/recurrent_network_op.cc b/paddle/operators/recurrent_op.cc similarity index 97% rename from paddle/operators/recurrent_network_op.cc rename to paddle/operators/recurrent_op.cc index dcb1ac19d2c..b3132c2020d 100644 --- a/paddle/operators/recurrent_network_op.cc +++ b/paddle/operators/recurrent_op.cc @@ -12,7 +12,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/operators/recurrent_network_op.h" +#include "paddle/operators/recurrent_op.h" #include #include @@ -108,8 +108,13 @@ void LinkMemories(std::vector>& scopes, std::shared_ptr scope = scopes[step_id]; std::shared_ptr linked_scope = scopes[step_id + offset]; for (auto& attr : memories) { + PADDLE_ENFORCE(scope->HasVariable(attr.pre_var), + "the pre-memory [%s] is not in scope.", + attr.pre_var); + PADDLE_ENFORCE(linked_scope->HasVariable(attr.var), + "the memory [%s] is not in linked scope.", + attr.var); auto mem = scope->GetVariable(attr.pre_var)->GetMutable(); - // maybe share variable is better? auto linked_mem = linked_scope->GetVariable(attr.var)->GetMutable(); if (infer_shape_mode) { mem->Resize(linked_mem->dims()); @@ -295,12 +300,12 @@ public: const auto& name = RecurrentOp::kArgName; // inputs and outputs stored in proto AddInputs(name.inlinks, - "the input that need to be segmented for each step."); + "the inputs that need to be segmented for each step."); AddInputs(name.boot_memories, "variables to initialize memories."); AddInput(name.step_net, "network shared by all steps."); AddOutputs(name.outlinks, - "the output that need to concated for all steps."); + "the outputs that need to concated for all steps."); AddOutput(name.step_scopes, "step scopes"); // Attributes stored in AttributeMap diff --git a/paddle/operators/recurrent_network_op.h b/paddle/operators/recurrent_op.h similarity index 100% rename from paddle/operators/recurrent_network_op.h rename to paddle/operators/recurrent_op.h diff --git a/paddle/operators/recurrent_network_op_test.cc b/paddle/operators/recurrent_op_test.cc similarity index 99% rename from paddle/operators/recurrent_network_op_test.cc rename to paddle/operators/recurrent_op_test.cc index 635c2fe0381..4bff8a0ed63 100644 --- a/paddle/operators/recurrent_network_op_test.cc +++ b/paddle/operators/recurrent_op_test.cc @@ -18,7 +18,7 @@ #include "paddle/framework/op_registry.h" #include "paddle/framework/operator.h" #include "paddle/framework/tensor.h" -#include "paddle/operators/recurrent_network_op.h" +#include "paddle/operators/recurrent_op.h" namespace paddle { namespace operators { diff --git a/paddle/pybind/CMakeLists.txt b/paddle/pybind/CMakeLists.txt index 7d0e68a8f30..43d8e17ec1c 100644 --- a/paddle/pybind/CMakeLists.txt +++ b/paddle/pybind/CMakeLists.txt @@ -1,2 +1,2 @@ cc_library(paddle_pybind SHARED SRCS pybind.cc DEPS pybind python - add_op fc_op sgd_op cross_entropy_op recurrent_network_op) + add_op fc_op sgd_op cross_entropy_op recurrent_op) -- GitLab