refacto: remove iter usage for passing a dataset

- it is still supported but not required and more confusing
This commit is contained in:
Arthur Meyre
2021-09-15 18:08:17 +02:00
parent 2296bcd457
commit 381c81b76c
14 changed files with 400 additions and 506 deletions

View File

@@ -145,7 +145,7 @@ def main():
engine = hnp.compile_numpy_function(
function_to_compile,
{"x_0": hnp.EncryptedScalar(hnp.UnsignedInteger(input_bits))},
iter(inputset),
inputset,
)
# Measure: End

View File

@@ -214,7 +214,7 @@ def main():
"x_0": hnp.EncryptedScalar(hnp.UnsignedInteger(input_bits)),
"x_1": hnp.EncryptedScalar(hnp.UnsignedInteger(input_bits)),
},
iter(inputset),
inputset,
)
# Measure: End

View File

@@ -20,7 +20,7 @@ def main():
engine = hnp.compile_numpy_function(
function_to_compile,
{"x": x},
iter([(i,) for i in range(2 ** input_bits)]),
[(i,) for i in range(2 ** input_bits)],
)
# Measure: End

View File

@@ -15,7 +15,7 @@ def main():
engine = hnp.compile_numpy_function(
function_to_compile,
{"x": x},
iter([(6,), (1,), (5,), (2,)]),
[(6,), (1,), (5,), (2,)],
)
# Measure: End

View File

@@ -16,7 +16,7 @@ def main():
engine = hnp.compile_numpy_function(
function_to_compile,
{"x": x, "y": y},
iter([(6, 1), (1, 4), (5, 3), (2, 0), (7, 7)]),
[(6, 1), (1, 4), (5, 3), (2, 0), (7, 7)],
)
# Measure: End

View File

@@ -15,7 +15,7 @@ def main():
engine = hnp.compile_numpy_function(
function_to_compile,
{"x": x},
iter([(6,), (1,), (5,), (2,)]),
[(6,), (1,), (5,), (2,)],
)
# Measure: End

View File

@@ -24,7 +24,7 @@ y = hnp.EncryptedScalar(hnp.UnsignedInteger(1))
# Compile the function to its homomorphic equivalent
engine = hnp.compile_numpy_function(
f, {"x": x, "y": y},
iter([(0, 0), (0, 1), (1, 0), (1, 1), (2, 0), (2, 1), (3, 0), (3, 1)]),
[(0, 0), (0, 1), (1, 0), (1, 1), (2, 0), (2, 1), (3, 0), (3, 1)],
)
# Make homomorphic inference

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -39,7 +39,7 @@ Finally, we can compile our function to its homomorphic equivalent.
```python
engine = hnp.compile_numpy_function(
f, {"x": x, "y": y},
inputset=iter(inputset),
inputset=inputset,
)
```

View File

@@ -22,7 +22,7 @@ def test_artifacts_export():
compile_numpy_function(
function,
{"x": EncryptedScalar(UnsignedInteger(7))},
iter([(0,), (1,), (2,)]),
[(0,), (1,), (2,)],
compilation_artifacts=artifacts,
)

View File

@@ -49,7 +49,7 @@ def test_enable_topological_optimizations(test_helpers, function_to_trace, fused
param: EncryptedScalar(Integer(32, is_signed=False))
for param in signature(function_to_trace).parameters.keys()
},
iter([(1,), (2,), (3,)]),
[(1,), (2,), (3,)],
CompilationConfiguration(dump_artifacts_on_unexpected_failures=False),
)
op_graph_not_optimized = compile_numpy_function_into_op_graph(
@@ -58,7 +58,7 @@ def test_enable_topological_optimizations(test_helpers, function_to_trace, fused
param: EncryptedScalar(Integer(32, is_signed=False))
for param in signature(function_to_trace).parameters.keys()
},
iter([(1,), (2,), (3,)]),
[(1,), (2,), (3,)],
CompilationConfiguration(
dump_artifacts_on_unexpected_failures=False,
enable_topological_optimizations=False,

View File

@@ -18,7 +18,7 @@ def test_draw_graph_with_saving():
op_graph = compile_numpy_function_into_op_graph(
function,
{"x": EncryptedScalar(Integer(7, True))},
iter([(-2,), (-1,), (0,), (1,), (2,)]),
[(-2,), (-1,), (0,), (1,), (2,)],
)
with tempfile.TemporaryDirectory() as tmp:

View File

@@ -198,7 +198,7 @@ def test_compile_function_with_direct_tlu():
op_graph = compile_numpy_function_into_op_graph(
function,
{"x": EncryptedScalar(Integer(2, is_signed=False))},
iter([(0,), (1,), (2,), (3,)]),
[(0,), (1,), (2,), (3,)],
)
str_of_the_graph = get_printable_graph(op_graph, show_data_types=True)
@@ -217,7 +217,7 @@ def test_compile_function_with_direct_tlu_overflow():
compile_numpy_function_into_op_graph(
function,
{"x": EncryptedScalar(Integer(3, is_signed=False))},
iter([(0,), (1,), (2,), (3,), (4,), (5,), (6,), (7,)]),
[(0,), (1,), (2,), (3,), (4,), (5,), (6,), (7,)],
CompilationConfiguration(dump_artifacts_on_unexpected_failures=False),
)