warp icon indicating copy to clipboard operation
warp copied to clipboard

[BUG] isfinite(), isnan(), and isinf() should only accept float types

Open c0d1f1ed opened this issue 8 months ago • 2 comments

Bug Description

Currently wp.isfinite(), wp.isnan(), and isinf() accept integer scalars and vectors, which arguably does not produce useful results.

Arguments pro accepting integer arguments:

  • Python does accept scalar integers for these math functions, but this appears to involve an implicit conversion, which Warp kernels do not support. Type safety is an exception to supporting Pythonic syntax and semantics in kernels, to facilitate translation to CUDA and preserve performance.

Arguments against accepting integer arguments:

  • It requires ~100 function signatures which serve no practical purpose and slow down compilation.
  • Other floating-point math functions (e.g. wp.sqrt()) just accept Float arguments, even when Python (implicitly) also accepts integers.

c0d1f1ed avatar Jul 17 '25 23:07 c0d1f1ed

@mmacklin any thoughts on this since it affects kernel syntax? I don't think there's a need for a deprecation warning since I doubt anyone was relying on this and it's trivial to work around.

c0d1f1ed avatar Aug 11 '25 16:08 c0d1f1ed

Agree they seem to serve no real purpose - compatibility with Python may be useful though.

Would be good to know what 100 functions does to compile times before making a decision based on that though.

mmacklin avatar Aug 12 '25 00:08 mmacklin