mirror of
https://github.com/zama-ai/concrete.git
synced 2026-02-09 03:55:04 -05:00
chore(python test): clean test case by adding ids
This commit is contained in:
@@ -5,7 +5,7 @@ from zamalang import CompilerEngine
|
||||
@pytest.mark.parametrize(
|
||||
"mlir_input, args, expected_result",
|
||||
[
|
||||
(
|
||||
pytest.param(
|
||||
"""
|
||||
func @main(%arg0: !HLFHE.eint<7>, %arg1: i8) -> !HLFHE.eint<7> {
|
||||
%1 = "HLFHE.add_eint_int"(%arg0, %arg1): (!HLFHE.eint<7>, i8) -> (!HLFHE.eint<7>)
|
||||
@@ -14,8 +14,9 @@ from zamalang import CompilerEngine
|
||||
""",
|
||||
(5, 7),
|
||||
12,
|
||||
id="add_eint_int"
|
||||
),
|
||||
(
|
||||
pytest.param(
|
||||
"""
|
||||
func @main(%arg0: tensor<4x!HLFHE.eint<7>>, %arg1: tensor<4xi8>) -> !HLFHE.eint<7>
|
||||
{
|
||||
@@ -26,6 +27,7 @@ from zamalang import CompilerEngine
|
||||
""",
|
||||
([1, 2, 3, 4], [4, 3, 2, 1]),
|
||||
20,
|
||||
id="dot_eint_int"
|
||||
),
|
||||
],
|
||||
)
|
||||
@@ -38,7 +40,7 @@ def test_compile_and_run(mlir_input, args, expected_result):
|
||||
@pytest.mark.parametrize(
|
||||
"mlir_input, args, expected_result, tab_size",
|
||||
[
|
||||
(
|
||||
pytest.param(
|
||||
"""
|
||||
func @main(%arg0: !HLFHE.eint<7>) -> !HLFHE.eint<7> {
|
||||
%tlu = std.constant dense<[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127]> : tensor<128xi64>
|
||||
@@ -49,6 +51,7 @@ def test_compile_and_run(mlir_input, args, expected_result):
|
||||
(73,),
|
||||
73,
|
||||
128,
|
||||
id="apply_lookup_table"
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -3,44 +3,59 @@ from zamalang import compiler
|
||||
|
||||
|
||||
VALID_INPUTS = [
|
||||
"""
|
||||
func @add_eint_int(%arg0: !HLFHE.eint<2>) -> !HLFHE.eint<2> {
|
||||
%0 = constant 1 : i3
|
||||
%1 = "HLFHE.add_eint_int"(%arg0, %0): (!HLFHE.eint<2>, i3) -> (!HLFHE.eint<2>)
|
||||
return %1: !HLFHE.eint<2>
|
||||
}
|
||||
""",
|
||||
"""
|
||||
func @apply_lookup_table(%arg0: !HLFHE.eint<2>, %arg1: tensor<4xi2>) -> !HLFHE.eint<2> {
|
||||
%1 = "HLFHE.apply_lookup_table"(%arg0, %arg1): (!HLFHE.eint<2>, tensor<4xi2>) -> (!HLFHE.eint<2>)
|
||||
return %1: !HLFHE.eint<2>
|
||||
}
|
||||
""",
|
||||
"""
|
||||
func @dot_eint_int(%arg0: tensor<2x!HLFHE.eint<2>>,
|
||||
%arg1: tensor<2xi3>) -> !HLFHE.eint<2>
|
||||
{
|
||||
%1 = "HLFHE.dot_eint_int"(%arg0, %arg1) :
|
||||
(tensor<2x!HLFHE.eint<2>>, tensor<2xi3>) -> !HLFHE.eint<2>
|
||||
return %1 : !HLFHE.eint<2>
|
||||
}
|
||||
""",
|
||||
"""
|
||||
func @main(%arg0: !HLFHE.eint<7>) -> !HLFHE.eint<7> {
|
||||
%tlu = std.constant dense<[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127]> : tensor<128xi64>
|
||||
%1 = "HLFHE.apply_lookup_table"(%arg0, %tlu): (!HLFHE.eint<7>, tensor<128xi64>) -> (!HLFHE.eint<7>)
|
||||
return %1: !HLFHE.eint<7>
|
||||
}
|
||||
""",
|
||||
pytest.param(
|
||||
"""
|
||||
func @add_eint_int(%arg0: !HLFHE.eint<2>) -> !HLFHE.eint<2> {
|
||||
%0 = constant 1 : i3
|
||||
%1 = "HLFHE.add_eint_int"(%arg0, %0): (!HLFHE.eint<2>, i3) -> (!HLFHE.eint<2>)
|
||||
return %1: !HLFHE.eint<2>
|
||||
}
|
||||
""",
|
||||
id="add_eint_int_cst",
|
||||
),
|
||||
pytest.param(
|
||||
"""
|
||||
func @apply_lookup_table(%arg0: !HLFHE.eint<2>, %arg1: tensor<4xi2>) -> !HLFHE.eint<2> {
|
||||
%1 = "HLFHE.apply_lookup_table"(%arg0, %arg1): (!HLFHE.eint<2>, tensor<4xi2>) -> (!HLFHE.eint<2>)
|
||||
return %1: !HLFHE.eint<2>
|
||||
}
|
||||
""",
|
||||
id="add_eint_int_cst",
|
||||
),
|
||||
pytest.param(
|
||||
"""
|
||||
func @dot_eint_int(%arg0: tensor<2x!HLFHE.eint<2>>,
|
||||
%arg1: tensor<2xi3>) -> !HLFHE.eint<2>
|
||||
{
|
||||
%1 = "HLFHE.dot_eint_int"(%arg0, %arg1) :
|
||||
(tensor<2x!HLFHE.eint<2>>, tensor<2xi3>) -> !HLFHE.eint<2>
|
||||
return %1 : !HLFHE.eint<2>
|
||||
}
|
||||
""",
|
||||
id="add_eint_int_cst",
|
||||
),
|
||||
pytest.param(
|
||||
"""
|
||||
func @main(%arg0: !HLFHE.eint<7>) -> !HLFHE.eint<7> {
|
||||
%tlu = std.constant dense<[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127]> : tensor<128xi64>
|
||||
%1 = "HLFHE.apply_lookup_table"(%arg0, %tlu): (!HLFHE.eint<7>, tensor<128xi64>) -> (!HLFHE.eint<7>)
|
||||
return %1: !HLFHE.eint<7>
|
||||
}
|
||||
""",
|
||||
id="add_eint_int_cst",
|
||||
),
|
||||
]
|
||||
|
||||
INVALID_INPUTS = [
|
||||
"nothing really mlir",
|
||||
"""
|
||||
func @test(%arg0: !HLFHE.eint<0>) {
|
||||
return
|
||||
}
|
||||
""",
|
||||
pytest.param("nothing really mlir", id="add_eint_int_cst"),
|
||||
pytest.param(
|
||||
"""
|
||||
func @test(%arg0: !HLFHE.eint<0>) {
|
||||
return
|
||||
}
|
||||
""",
|
||||
id="add_eint_int_cst",
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user