halide / Halide

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

Python bindings do not support int64 constants #8224

Closed jansel closed 4 months ago

jansel commented 4 months ago

It appears that integer constants that don't fit in an int32 are broken:

>>> import halide as hl
>>> hl.cast(hl.Int(64), 0x7fffffff)
<halide.Expr of type int64: (int64)2147483647>
>>> hl.cast(hl.Int(64), 0x7fffffff+1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: cast(): incompatible function arguments. The following argument types are supported:
    1. (arg0: Halide::Type, arg1: halide.halide_.Expr) -> halide.halide_.Expr

Invoked with: <halide.Type int64>, 2147483648
>>> 
jansel commented 4 months ago

Looks like this can be fixed with halide.i64(0x7fffffff+1), but it would be good to have a better error message here.

steven-johnson commented 4 months ago

Looks like this can be fixed with halide.i64(0x7fffffff+1), but it would be good to have a better error message here.

Agreed. We would welcome a patch to improve it :-)