halide / Halide

a language for fast, portable data-parallel computation
https://halide-lang.org
Other
5.92k stars 1.07k forks source link

warn on fixed-point/integer overflow #817

Open abadams opened 9 years ago

abadams commented 9 years ago

I think we have the ability to detect most potential integer/fixed point overflow issues using interval arithmetic. We could warn on things like:

ImageParam a(UInt(8), 1), b(UInt(8), 1);

f(x) = a(x) + b(x); // 8-bit overflow!

but not warn on things like:

f(x) = (a(x) % 64) * min(b(x), 4); // max possible value is 63*4

We'd need a clean way to tell Halide that a warning is a false positive though.

abadams commented 9 years ago

This is a feature request from someone who works with integer pipelines a lot and sometimes has bugs where they forget to upcast before a multiply.