tracel-ai / cubecl

Multi-platform high-performance compute language extension for Rust.
https://burn.dev
Apache License 2.0
625 stars 28 forks source link

Issues with negative floats and infinite floats #68

Open cBournhonesque opened 2 months ago

cBournhonesque commented 2 months ago

F32::new(f32::INFINITY) does not work, it expands as

let _var_0 = f32::INFINITY;
F32::__expand_new(context, _var_0)

instead of something like

let _var_0 = cubecl::frontend::ExpandElementTyped::from_lit(f32::INFINITY);
F32::__expand_new(context, _var_0)

Similar problem with negative floats: F32::new(-10.0) does not work

louisfd commented 2 months ago

Thanks, The negative floats problem was already identified in #11 , as for infinity your idea is great.

RianGoossens commented 1 month ago

Something to consider here is that wgsl does not support infinity as a literal, at all. You can't even bypass it by doing something like let x = 1.0 / 0.0;, the compiler will catch it.