diff --git a/paddle/operators/CMakeLists.txt b/paddle/operators/CMakeLists.txt index 5085e1b92555eebd1c5a7af9bf9af99bc6c90333..9d28404f687dca0e36ee24d4712bbae82d60d620 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 dcb1ac19d2cb197bb54783e90c891fbd98c99e1a..b3132c2020d332b2d70d3f642d5cd75fb42f2316 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 635c2fe0381679bb08965317f69721909bd25157..4bff8a0ed633522fcd83f865586a557e824312b7 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 7d0e68a8f30de609b870c81c3bdb7aee090f15d3..43d8e17ec1c94aaccd2c7f392218dfad54d3c632 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)