cornell-zhang / allo

Allo: A Programming Model for Composable Accelerator Design
https://cornell-zhang.github.io/allo
Apache License 2.0
134 stars 28 forks source link

[BUG] Mismatch in datatype of bool #173

Closed AdrianLiu00 closed 1 month ago

AdrianLiu00 commented 2 months ago

Describe the bug There may be some mismatch between data type of bool defined in allo and the original python one. So the not bool syntax is not compiled and executed as our wishes.

To Reproduce

import allo
from allo.ir.types import int8, bool

def testcase[Ty](flag:  bool) -> "Ty":
    X: Ty
    if not flag:
        X = 1
    else:
        X = 0
    return X

s = allo.customize(testcase, instantiate=[int8])
mod = s.build()

flag : bool = True
output = mod(flag)

print(output)

Buggy output

[Data Type] Input type mismatch: i1 vs i32. Please use NumPy array to wrap the data to avoid possible result mismatch
  warnings.warn(self.message, category=self.category)
1

Expected behavior Output 0 from the else branch.