halide / Halide

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

python_tutorial_lesson_10_aot_compilation_run incompatible with Numpy 2 #8380

Closed alexreinking closed 3 months ago

alexreinking commented 3 months ago

Numpy no longer automatically truncates Python integers to the destination type. So the following code causes an overflow error now:

    input = np.empty((640, 480), dtype=np.uint8, order='F')
    for y in range(480):
        for x in range(640):
            input[x, y] = x ^ (y + 1)

We can recover the old behavior by manually masking.

    input = np.empty((640, 480), dtype=np.uint8, order='F')
    for y in range(480):
        for x in range(640):
            input[x, y] = (x ^ (y + 1)) & 0xFF