Unverified Commit 567c5acf authored by Quan (Andy) Gan's avatar Quan (Andy) Gan Committed by GitHub
Browse files

[Feature?] BUG_ON macro and sanity check of FindEdges (#2168)

* Sanity check for FindEdges

* [Feature?] BUG_ON() macro for sanity check
parent b10b541c
...@@ -540,6 +540,21 @@ DGL_DLL int DGLStreamStreamSynchronize(int device_type, ...@@ -540,6 +540,21 @@ DGL_DLL int DGLStreamStreamSynchronize(int device_type,
DGLStreamHandle src, DGLStreamHandle src,
DGLStreamHandle dst); DGLStreamHandle dst);
/*!
* \brief Bug report macro.
*
* This serves as a sanity check on system side to make sure the code is correct by
* checking whether a condition always holds for complex reasons. Failing the
* condition signifies a system bug instead of users giving invalid inputs or using
* the functionality incorrectly.
*
* Hints the user to file a bug report if the condition fails.
*/
#define BUG_ON(cond) \
CHECK(cond) << "A bug has been occurred. " \
"Please file a bug report at https://github.com/dmlc/dgl/issues. " \
"Message: "
#ifdef __cplusplus #ifdef __cplusplus
} // DGL_EXTERN_C } // DGL_EXTERN_C
#endif #endif
......
...@@ -325,6 +325,8 @@ std::pair<dgl_id_t, dgl_id_t> COO::FindEdge(dgl_id_t eid) const { ...@@ -325,6 +325,8 @@ std::pair<dgl_id_t, dgl_id_t> COO::FindEdge(dgl_id_t eid) const {
EdgeArray COO::FindEdges(IdArray eids) const { EdgeArray COO::FindEdges(IdArray eids) const {
CHECK(aten::IsValidIdArray(eids)) << "Invalid edge id array"; CHECK(aten::IsValidIdArray(eids)) << "Invalid edge id array";
BUG_ON(aten::IsNullArray(adj_.data)) <<
"FindEdges requires the internal COO matrix not having EIDs.";
return EdgeArray{aten::IndexSelect(adj_.row, eids), return EdgeArray{aten::IndexSelect(adj_.row, eids),
aten::IndexSelect(adj_.col, eids), aten::IndexSelect(adj_.col, eids),
eids}; eids};
......
...@@ -232,6 +232,8 @@ class UnitGraph::COO : public BaseHeteroGraph { ...@@ -232,6 +232,8 @@ class UnitGraph::COO : public BaseHeteroGraph {
EdgeArray FindEdges(dgl_type_t etype, IdArray eids) const override { EdgeArray FindEdges(dgl_type_t etype, IdArray eids) const override {
CHECK(aten::IsValidIdArray(eids)) << "Invalid edge id array"; CHECK(aten::IsValidIdArray(eids)) << "Invalid edge id array";
BUG_ON(aten::IsNullArray(adj_.data)) <<
"FindEdges requires the internal COO matrix not having EIDs.";
return EdgeArray{aten::IndexSelect(adj_.row, eids), return EdgeArray{aten::IndexSelect(adj_.row, eids),
aten::IndexSelect(adj_.col, eids), aten::IndexSelect(adj_.col, eids),
eids}; eids};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment