[Feature] Added exclude_self and output_batch to knn graph construction (Issues #4323 #4316)
Description
- Added
exclude_selfandoutput_batchoptions toknn_graphandsegmented_knn_graph, and their wrappers,dgl.nn.KNNGraphanddgl.nn.SegmentedKNNGraphfor Issue #4316 - Updated out-of-date comments on
remove_edgesandremove_self_loop, since they now preserve batch information as of PR #3119 , for Issue #4323 - Added test cases to
test_remove_selfloopandtest_knn_cuda
Checklist
Please feel free to remove inapplicable items for your PR.
- [x] The PR title starts with [$CATEGORY] (such as [NN], [Model], [Doc], [Feature]])
- [x] Changes are complete (i.e. I finished coding on this PR)
- [x] All changes have test coverage
- [x] Code is well-documented
- [x] To the best of my knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change
- [x] Related issue is referred in this PR
To trigger regression tests:
-
@dgl-bot run [instance-type] [which tests] [compare-with-branch]; For example:@dgl-bot run g4dn.4xlarge all dmlc/masteror@dgl-bot run c5.9xlarge kernel,api dmlc/master
Commit ID: 3af4388419bd7f5660cb778d4d46288c115daab1
Build ID: 1
Status: ✅ CI test succeeded
Report path: link
Full logs path: link
Commit ID: ff6efb41bca4f0ecc247e62b48e453be3e8a7f28
Build ID: 2
Status: ✅ CI test succeeded
Report path: link
Full logs path: link
Commit ID: 8ed2f0d1d625410c525a5764bc5f51d227fae688
Build ID: 3
Status: ❌ CI test failed in Stage [Lint Check].
Report path: link
Full logs path: link
Commit ID: eed0d9879e2f3763a4d48afa033b0c724557f0f2
Build ID: 4
Status: ✅ CI test succeeded
Report path: link
Full logs path: link
Commit ID: c65ebba2bfc6d0c4dcf02105d2cd68d61e6657c7
Build ID: 5
Status: ✅ CI test succeeded
Report path: link
Full logs path: link
One question for the team. Is it possible to further reduce the number of new arguments? For example, can we omit output_batch and always assign batch information to the output when the input x is 3D? I'm just pushing everyone to think hard if the current one is a minimal design for user.
can we omit
output_batchand always assign batch information to the output when the inputxis 3D?
I'd be happy to omit both output_batch and exclude_self (by having it always exclude self-loop edges), if people would be okay with that. I added them defaulting to False to avoid breaking compatibility.
After the weekly sync we agreed that the batch information (output_batch) can be omitted and we can go straight to set the batch information, since it would not break existing code. We will keep exclude_self though.
the batch information (
output_batch) can be omitted ... We will keepexclude_selfthough.
Done. Thanks!