fix: fix issues for certain form of functions

Table which was created contained too large values, for cells which were never accessed
closes #949
This commit is contained in:
Benoit Chevallier-Mames
2021-11-24 15:28:34 +01:00
committed by Benoit Chevallier
parent 62475c34cd
commit 39b168dfd5
2 changed files with 7 additions and 3 deletions

View File

@@ -282,7 +282,12 @@ class IntermediateNodeConverter:
table = tables[0][0]
lut_shape: Tuple[int, ...] = (len(table),)
lut_values = numpy.array(table, dtype=numpy.uint64)
# The reduction on 63b is to avoid problems like doing a TLU of
# the form T[j] = 2<<j, for j which is supposed to be 7b as per
# constraint of the compiler, while in practice, it is a small
# value. Reducing on 64b was not ok for some reason
lut_values = numpy.array(table % (2 << 63), dtype=numpy.uint64)
else:
assert_true(isinstance(output, TensorValue))
assert isinstance(output, TensorValue)

View File

@@ -683,9 +683,8 @@ def test_compile_and_run_correctness(
[
pytest.param(lambda x: x ** 2, ((0, 10),), ["x"]),
pytest.param(lambda x: 2 ** (x % 5), ((0, 20),), ["x"]),
# FIXME: Fails, #949 pytest.param(lambda x: abs(~x), ((0, 13),), ["x"]),
pytest.param(lambda x: x << 1, ((0, 13),), ["x"]),
# FIXME: Fails, #949 pytest.param(lambda x: 2 << (x % 6), ((0, 13),), ["x"]),
pytest.param(lambda x: 2 << (x % 6), ((0, 13),), ["x"]),
pytest.param(lambda x: x >> 2, ((30, 100),), ["x"]),
pytest.param(lambda x: 115 >> (x % 3), ((0, 17),), ["x"]),
pytest.param(lambda x: x % 7, ((0, 100),), ["x"]),