Skip to content
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

Fix_StackOverFlow_case5 #50447

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from 7 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
16 changes: 16 additions & 0 deletions paddle/phi/kernels/cpu/graph_reindex_kernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,22 @@ void GraphReindexKernel(const Context& dev_ctx,
}
src[i] = node_map[node];
}
/*
check if x dim and count dim all equal 1
the count's data must less or equal to 10
*/
const int cs = count.dims()[0];
if ((bs == 1) && (cs == 1)) {
PADDLE_ENFORCE_LE(
count_data[0],
10,
phi::errors::OutOfRange(
"When X's dimension and count's dimension all equal to 1,"
"The count's data should be smaller or equal to 10."
"But received count's data = %d",
count_data[0]));
}

// Reindex Dst
// Add support for multi-type edges reindex
int num_edge_types = count.dims()[0] / bs;
Expand Down
16 changes: 16 additions & 0 deletions python/paddle/fluid/tests/unittests/test_graph_reindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,5 +532,21 @@ def test_heter_reindex_result_static(self):
np.testing.assert_allclose(out_nodes, out_nodes_2, rtol=1e-05)


class TestGraphReindex2(unittest.TestCase):
def setUp(self):
self.x = np.arange(16).astype("int32")

def test_reindex_countValue(self):
paddle.disable_static()
res = []
x = paddle.to_tensor(self.x)
y = np.array(res).astype("int32")

def test_countValue_dynamic():
paddle.incubate.graph_reindex(x, x, x, y, y, False)
Copy link
Contributor

Choose a reason for hiding this comment

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

可以在545-546之间打个日志,可以发现 test_countValue_dynamic 方法是不会被执行的。
你可以仅保留 546行,删除545行,来执行单测看看报错信息,报错信息是
image
这个报错信息意思是你的入参错误,y 应该是 tensor,而不是 ndarray


self.assertRaises(ValueError, test_countValue_dynamic)
Copy link
Contributor

Choose a reason for hiding this comment

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

单测检测到的 ValueError 是其他问题导致的 ValueError,并不是你新增的异常检测代码所抛出的。
仅仅保留 546 行再执行单测,就可以看到真正的报错信息



if __name__ == "__main__":
unittest.main()