Skip to content

Fix RNN unittest bugs. #940

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 3 additions & 15 deletions paddle/gserver/dataproviders/PyDataProvider2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,19 +252,9 @@ class PyDataProvider2 : public DataProvider {
// only for instance will make python reference-count error.
//
// So here, we increase reference count manually.
if (gModuleClsPtrs_.find((uintptr_t)module.get()) !=
gModuleClsPtrs_.end()) {
// Multi instance use same module
Py_XINCREF(module.get());
Py_XINCREF(moduleDict.get());
} else {
gModuleClsPtrs_.insert((uintptr_t)module.get());
}
if (gModuleClsPtrs_.find((uintptr_t)cls.get()) != gModuleClsPtrs_.end()) {
Py_XINCREF(cls.get());
} else {
gModuleClsPtrs_.insert((uintptr_t)cls.get());
}
Py_XINCREF(module.get());
Py_XINCREF(moduleDict.get());
Py_XINCREF(cls.get());

PyObjectPtr fileListInPy = loadPyFileLists(fileListName);
PyDict_SetItemString(kwargs.get(), "file_list", fileListInPy.get());
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里之前是第一次引用这个module的时候,不会增加reference count。应该是错误的。

每次载入model的时候,都应该增加reference count

Expand Down Expand Up @@ -471,7 +461,6 @@ class PyDataProvider2 : public DataProvider {
std::vector<std::string> fileLists_;
std::vector<SlotHeader> headers_;
static PyObjectPtr zeroTuple_;
static std::unordered_set<uintptr_t> gModuleClsPtrs_;

class PositionRandom {
public:
Expand Down Expand Up @@ -671,7 +660,6 @@ class PyDataProvider2 : public DataProvider {
}
};

std::unordered_set<uintptr_t> PyDataProvider2::gModuleClsPtrs_;
PyObjectPtr PyDataProvider2::zeroTuple_(PyTuple_New(0));

REGISTER_DATA_PROVIDER_EX(py2, PyDataProvider2);
Expand Down
6 changes: 3 additions & 3 deletions paddle/gserver/tests/test_RecurrentGradientMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ TEST(RecurrentGradientMachine, HasSubSequence) {
}
}

TEST(RecurrentGradientMachine, DISABLED_rnn) {
TEST(RecurrentGradientMachine, rnn) {
for (bool useGpu : {false, true}) {
test("gserver/tests/sequence_rnn.conf",
"gserver/tests/sequence_nest_rnn.conf",
Expand All @@ -136,7 +136,7 @@ TEST(RecurrentGradientMachine, DISABLED_rnn) {
}
}

TEST(RecurrentGradientMachine, DISABLED_rnn_multi_input) {
TEST(RecurrentGradientMachine, rnn_multi_input) {
for (bool useGpu : {false, true}) {
test("gserver/tests/sequence_rnn_multi_input.conf",
"gserver/tests/sequence_nest_rnn_multi_input.conf",
Expand All @@ -145,7 +145,7 @@ TEST(RecurrentGradientMachine, DISABLED_rnn_multi_input) {
}
}

TEST(RecurrentGradientMachine, DISABLED_rnn_multi_unequalength_input) {
TEST(RecurrentGradientMachine, rnn_multi_unequalength_input) {
for (bool useGpu : {false, true}) {
test("gserver/tests/sequence_rnn_multi_unequalength_inputs.py",
"gserver/tests/sequence_nest_rnn_multi_unequalength_inputs.py",
Expand Down