[Bug Fix] Improve binary search handling in JIdxForJOffsets#325
Conversation
Refactor binary search logic to handle cases with duplicate offsets correctly. Signed-off-by: Yuqin Liang <YuqinLiangX@gmail.com>
There was a problem hiding this comment.
Thanks a lot for the fix! I added a few comments about conforming to codestyle. You can see all the style fixes here: https://github.com/openvdb/fvdb-core/actions/runs/19194298081/job/55129073233?pr=325
If possible, could you also add a unit test in Python? You can add it to tests/unit/test_jagged_tensor.py
|
@fwilliams @harrism hello, I have formatted the code using clang-format as you suggested. |
harrism
left a comment
There was a problem hiding this comment.
Thanks so much for the great contribution! Can you please add a C++ test? Should only need a couple lines in an existing test.
|
@harrism hello, I have add two unit tests to I also run the unit test in my local env, without the kernel modification, the JIdxFromJOffsetsCUDA runs fail as expected. with the kernel modification, both JIdxFromJOffsetsCPU and JIdxFromJOffsetsCUDA can run successfully. |
Signed-off-by: Yuqin Liang <YuqinLiangX@gmail.com>
Signed-off-by: Yuqin Liang <YuqinLiangX@gmail.com>
Signed-off-by: Yuqin Liang <YuqinLiangX@gmail.com>
|
@harrism hello, I discovered that my previous commits weren't GPG signed. |
|
Thank you for this fix and the new test. We look forward to your future contributions! |


Refactor binary search logic to handle cases with duplicate offsets correctly.
The original jidx from joffsets binary search can not handle the case that when joffsets has same values.
For example, joffsets is [0, 10, 10, 40], when idx = 10, the original code will wrongly set jidx to -1.