tests(LUT): use relative error

This commit is contained in:
youben11
2021-09-03 08:55:50 +01:00
committed by Quentin Bourgerie
parent 1e07733257
commit c4dd639ea7
2 changed files with 21 additions and 4 deletions

View File

@@ -15,6 +15,17 @@ from zamalang import CompilerEngine
(5, 7),
12,
),
],
)
def test_compile_and_run(mlir_input, args, expected_result):
engine = CompilerEngine()
engine.compile_fhe(mlir_input)
assert engine.run(*args) == expected_result
@pytest.mark.parametrize(
"mlir_input, args, expected_result, tab_size",
[
(
"""
func @main(%arg0: !HLFHE.eint<7>) -> !HLFHE.eint<7> {
@@ -26,10 +37,11 @@ from zamalang import CompilerEngine
""",
(5,),
5,
128,
),
],
)
def test_compile_and_run(mlir_input, args, expected_result):
def test_compile_and_run_tlu(mlir_input, args, expected_result, tab_size):
engine = CompilerEngine()
engine.compile_fhe(mlir_input)
assert engine.run(*args) == expected_result
assert abs(engine.run(*args) - expected_result) / tab_size < 0.1