NVIDIA / warp

A Python framework for high performance GPU simulation and graphics
https://nvidia.github.io/warp/
Other
4.27k stars 243 forks source link

[BUG] Incorrect `iter_reverse` function for range #311

Closed fbxiang closed 1 month ago

fbxiang commented 2 months ago

Bug Description

The iter_reverse function for range seems to only work for step = 1. https://github.com/NVIDIA/warp/blob/3b00f16a3e2a96415625eeb22139c8476e4170fe/warp/native/range.h#L96-L107 I think it needs to be something like the following? (Not thoroughly tested)

    rev.start = r.start + (r.end - r.start - sign(r.step)) / r.step * r.step;
    rev.end = rev.start - r.end + r.start;

System Information

No response

christophercrouzet commented 1 month ago

Hi @fbxiang, thank you for reporting this issue and apologies for any inconvenience caused!

Your proposed fix is correct and we've prepared a MR internally to address it.

christophercrouzet commented 1 month ago

It's been merged as part of commit c0dbdf9 and will be part of the next release of Warp, thanks again!