diff --git a/benchmarks/124_minus_x.py b/benchmarks/124_minus_x.py index e178dfdd7..6ce40b321 100644 --- a/benchmarks/124_minus_x.py +++ b/benchmarks/124_minus_x.py @@ -2,6 +2,7 @@ import random +import numpy as np from common import BENCHMARK_CONFIGURATION import concrete.numpy as hnp @@ -36,7 +37,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/124_minus_x_tensor.py b/benchmarks/124_minus_x_tensor.py index 3fa2c349b..a311faa3f 100644 --- a/benchmarks/124_minus_x_tensor.py +++ b/benchmarks/124_minus_x_tensor.py @@ -26,7 +26,7 @@ def main(): inputs = [] labels = [] for _ in range(4): - sample_x = np.random.randint(0, 2 ** 6, size=(3,)) + sample_x = np.random.randint(0, 2 ** 6, size=(3,), dtype=np.uint8) inputs.append([sample_x]) labels.append(function_to_compile(*inputs[-1])) @@ -37,7 +37,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/c_concatenate_x.py b/benchmarks/c_concatenate_x.py index 939f52062..da54411b1 100644 --- a/benchmarks/c_concatenate_x.py +++ b/benchmarks/c_concatenate_x.py @@ -18,7 +18,7 @@ def main(): inputs = [] labels = [] for _ in range(4): - sample_x = np.random.randint(0, 2 ** 3, size=(4, 5)) + sample_x = np.random.randint(0, 2 ** 3, size=(4, 5), dtype=np.uint8) inputs.append([sample_x]) labels.append(function_to_compile(*inputs[-1])) @@ -38,7 +38,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/c_matmul_x.py b/benchmarks/c_matmul_x.py index cb04999eb..6509c46d0 100644 --- a/benchmarks/c_matmul_x.py +++ b/benchmarks/c_matmul_x.py @@ -7,19 +7,19 @@ import concrete.numpy as hnp def main(): - c = np.arange(20, 30).reshape((5, 2)) + c = np.arange(1, 7).reshape((3, 2)) def function_to_compile(x): return np.matmul(c, x) - x = hnp.EncryptedTensor(hnp.UnsignedInteger(3), shape=(2, 4)) + x = hnp.EncryptedTensor(hnp.UnsignedInteger(2), shape=(2, 3)) - inputset = [(np.random.randint(0, 2 ** 3, size=(2, 4))) for _ in range(128)] + inputset = [(np.random.randint(0, 2 ** 2, size=(2, 3)),) for _ in range(128)] inputs = [] labels = [] for _ in range(4): - sample_x = np.random.randint(0, 2 ** 3, size=(2, 4)) + sample_x = np.random.randint(0, 2 ** 2, size=(2, 3), dtype=np.uint8) inputs.append([sample_x]) labels.append(function_to_compile(*inputs[-1])) @@ -39,7 +39,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/multi_table_lookup.py b/benchmarks/multi_table_lookup.py index 65ca0c2f3..1c3d6f14d 100644 --- a/benchmarks/multi_table_lookup.py +++ b/benchmarks/multi_table_lookup.py @@ -38,7 +38,7 @@ def main(): inputs = [] labels = [] for _ in range(50): - sample_x = np.random.randint(0, 2 ** input_bits, size=(3, 2)) + sample_x = np.random.randint(0, 2 ** input_bits, size=(3, 2), dtype=np.uint8) inputs.append([sample_x]) labels.append(function_to_compile(*inputs[-1])) @@ -49,7 +49,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/single_table_lookup.py b/benchmarks/single_table_lookup.py index 5db7af140..35ae894a1 100644 --- a/benchmarks/single_table_lookup.py +++ b/benchmarks/single_table_lookup.py @@ -2,6 +2,7 @@ import random +import numpy as np from common import BENCHMARK_CONFIGURATION import concrete.numpy as hnp @@ -41,7 +42,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x-index-0-and-0.py b/benchmarks/x-index-0-and-0.py index 3471f7f05..98d664fb7 100644 --- a/benchmarks/x-index-0-and-0.py +++ b/benchmarks/x-index-0-and-0.py @@ -26,7 +26,7 @@ def main(): inputs = [] labels = [] for _ in range(100): - sample_x = np.random.randint(0, 2 ** 3, size=(3, 2)) + sample_x = np.random.randint(0, 2 ** 3, size=(3, 2), dtype=np.uint8) inputs.append([sample_x]) labels.append(function_to_compile(*inputs[-1])) @@ -37,7 +37,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x-index-0.py b/benchmarks/x-index-0.py index 6ea8975e1..ce05272f3 100644 --- a/benchmarks/x-index-0.py +++ b/benchmarks/x-index-0.py @@ -26,7 +26,7 @@ def main(): inputs = [] labels = [] for _ in range(100): - sample_x = np.random.randint(0, 2 ** 3, size=(3,)) + sample_x = np.random.randint(0, 2 ** 3, size=(3,), dtype=np.uint8) inputs.append([sample_x]) labels.append(function_to_compile(*inputs[-1])) @@ -37,7 +37,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x-index-1.py b/benchmarks/x-index-1.py index 9505b6548..14a71af7f 100644 --- a/benchmarks/x-index-1.py +++ b/benchmarks/x-index-1.py @@ -37,7 +37,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x-index-colon-2.py b/benchmarks/x-index-colon-2.py index eaf5d8978..632e868a0 100644 --- a/benchmarks/x-index-colon-2.py +++ b/benchmarks/x-index-colon-2.py @@ -26,7 +26,7 @@ def main(): inputs = [] labels = [] for _ in range(100): - sample_x = np.random.randint(0, 2 ** 3, size=(3,)) + sample_x = np.random.randint(0, 2 ** 3, size=(3,), dtype=np.uint8) inputs.append([sample_x]) labels.append(function_to_compile(*inputs[-1])) @@ -37,7 +37,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x-index-colon-and-1.py b/benchmarks/x-index-colon-and-1.py index 1509faf76..a938cddc2 100644 --- a/benchmarks/x-index-colon-and-1.py +++ b/benchmarks/x-index-colon-and-1.py @@ -26,7 +26,7 @@ def main(): inputs = [] labels = [] for _ in range(100): - sample_x = np.random.randint(0, 2 ** 3, size=(3, 2)) + sample_x = np.random.randint(0, 2 ** 3, size=(3, 2), dtype=np.uint8) inputs.append([sample_x]) labels.append(function_to_compile(*inputs[-1])) @@ -37,7 +37,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x-index-colon.py b/benchmarks/x-index-colon.py index d3f172f8b..24a553bb3 100644 --- a/benchmarks/x-index-colon.py +++ b/benchmarks/x-index-colon.py @@ -26,7 +26,7 @@ def main(): inputs = [] labels = [] for _ in range(100): - sample_x = np.random.randint(0, 2 ** 3, size=(3,)) + sample_x = np.random.randint(0, 2 ** 3, size=(3,), dtype=np.uint8) inputs.append([sample_x]) labels.append(function_to_compile(*inputs[-1])) @@ -37,7 +37,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x-index-minus-1.py b/benchmarks/x-index-minus-1.py index 163104363..005a5db90 100644 --- a/benchmarks/x-index-minus-1.py +++ b/benchmarks/x-index-minus-1.py @@ -26,7 +26,7 @@ def main(): inputs = [] labels = [] for _ in range(100): - sample_x = np.random.randint(0, 2 ** 3, size=(3,)) + sample_x = np.random.randint(0, 2 ** 3, size=(3,), dtype=np.uint8) inputs.append([sample_x]) labels.append(function_to_compile(*inputs[-1])) @@ -37,7 +37,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x-index-one-colon.py b/benchmarks/x-index-one-colon.py index e24480d7a..608480c92 100644 --- a/benchmarks/x-index-one-colon.py +++ b/benchmarks/x-index-one-colon.py @@ -37,7 +37,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x-reversed.py b/benchmarks/x-reversed.py index 25503c6ed..7d49199b6 100644 --- a/benchmarks/x-reversed.py +++ b/benchmarks/x-reversed.py @@ -26,7 +26,7 @@ def main(): inputs = [] labels = [] for _ in range(100): - sample_x = np.random.randint(0, 2 ** 3, size=(3,)) + sample_x = np.random.randint(0, 2 ** 3, size=(3,), dtype=np.uint8) inputs.append([sample_x]) labels.append(function_to_compile(*inputs[-1])) @@ -37,7 +37,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_concatenate_c.py b/benchmarks/x_concatenate_c.py index 8392c154d..2c1b18973 100644 --- a/benchmarks/x_concatenate_c.py +++ b/benchmarks/x_concatenate_c.py @@ -18,7 +18,7 @@ def main(): inputs = [] labels = [] for _ in range(4): - sample_x = np.random.randint(0, 2 ** 3, size=(4, 5)) + sample_x = np.random.randint(0, 2 ** 3, size=(4, 5), dtype=np.uint8) inputs.append([sample_x]) labels.append(function_to_compile(*inputs[-1])) @@ -38,7 +38,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_concatenate_y.py b/benchmarks/x_concatenate_y.py index e0b0e599b..f8deb2650 100644 --- a/benchmarks/x_concatenate_y.py +++ b/benchmarks/x_concatenate_y.py @@ -21,8 +21,8 @@ def main(): inputs = [] labels = [] for _ in range(4): - sample_x = np.random.randint(0, 2 ** 3, size=(4, 5)) - sample_y = np.random.randint(0, 2 ** 3, size=(4, 5)) + sample_x = np.random.randint(0, 2 ** 3, size=(4, 5), dtype=np.uint8) + sample_y = np.random.randint(0, 2 ** 3, size=(4, 5), dtype=np.uint8) inputs.append([sample_x, sample_y]) labels.append(function_to_compile(*inputs[-1])) @@ -42,7 +42,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_index_colon_and_y_clear.py b/benchmarks/x_index_colon_and_y_clear.py index 0e6712f01..c56cdf4e7 100644 --- a/benchmarks/x_index_colon_and_y_clear.py +++ b/benchmarks/x_index_colon_and_y_clear.py @@ -44,7 +44,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_index_colon_and_y_encrypted.py b/benchmarks/x_index_colon_and_y_encrypted.py index 3b65e05b9..cacbf2647 100644 --- a/benchmarks/x_index_colon_and_y_encrypted.py +++ b/benchmarks/x_index_colon_and_y_encrypted.py @@ -44,7 +44,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_index_colon_colon_minus_1_and_y_and_z_clear.py b/benchmarks/x_index_colon_colon_minus_1_and_y_and_z_clear.py index 7fcfb68b4..7c5dc4631 100644 --- a/benchmarks/x_index_colon_colon_minus_1_and_y_and_z_clear.py +++ b/benchmarks/x_index_colon_colon_minus_1_and_y_and_z_clear.py @@ -37,7 +37,7 @@ def main(): inputs = [] labels = [] for _ in range(100): - sample_x = np.random.randint(0, 2 ** 3, size=(5, 4, 2)) + sample_x = np.random.randint(0, 2 ** 3, size=(5, 4, 2), dtype=np.uint8) sample_y = random.randint(0, (2 ** 2) - 1) sample_z = random.randint(0, (2 ** 1) - 1) @@ -50,7 +50,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_index_colon_colon_minus_1_and_y_and_z_encrypted.py b/benchmarks/x_index_colon_colon_minus_1_and_y_and_z_encrypted.py index 632051c50..838a971fc 100644 --- a/benchmarks/x_index_colon_colon_minus_1_and_y_and_z_encrypted.py +++ b/benchmarks/x_index_colon_colon_minus_1_and_y_and_z_encrypted.py @@ -50,7 +50,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_index_y_and_1_colon_clear.py b/benchmarks/x_index_y_and_1_colon_clear.py index 359f26054..40eef55cc 100644 --- a/benchmarks/x_index_y_and_1_colon_clear.py +++ b/benchmarks/x_index_y_and_1_colon_clear.py @@ -44,7 +44,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_index_y_and_1_colon_encrypted.py b/benchmarks/x_index_y_and_1_colon_encrypted.py index 3a3ea62ae..cb02ce735 100644 --- a/benchmarks/x_index_y_and_1_colon_encrypted.py +++ b/benchmarks/x_index_y_and_1_colon_encrypted.py @@ -32,7 +32,7 @@ def main(): inputs = [] labels = [] for _ in range(100): - sample_x = np.random.randint(0, 2 ** 3, size=(4, 5)) + sample_x = np.random.randint(0, 2 ** 3, size=(4, 5), dtype=np.uint8) sample_y = random.randint(0, (2 ** 2) - 1) inputs.append([sample_x, sample_y]) @@ -44,7 +44,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_index_y_and_colon_and_z_clear.py b/benchmarks/x_index_y_and_colon_and_z_clear.py index 69542b101..dc0a4d710 100644 --- a/benchmarks/x_index_y_and_colon_and_z_clear.py +++ b/benchmarks/x_index_y_and_colon_and_z_clear.py @@ -50,7 +50,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_index_y_and_colon_and_z_encrypted.py b/benchmarks/x_index_y_and_colon_and_z_encrypted.py index ab3b7e511..6ff450bc7 100644 --- a/benchmarks/x_index_y_and_colon_and_z_encrypted.py +++ b/benchmarks/x_index_y_and_colon_and_z_encrypted.py @@ -37,7 +37,7 @@ def main(): inputs = [] labels = [] for _ in range(100): - sample_x = np.random.randint(0, 2 ** 3, size=(4, 5, 2)) + sample_x = np.random.randint(0, 2 ** 3, size=(4, 5, 2), dtype=np.uint8) sample_y = random.randint(0, (2 ** 2) - 1) sample_z = random.randint(0, (2 ** 1) - 1) @@ -50,7 +50,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_index_y_and_colon_clear.py b/benchmarks/x_index_y_and_colon_clear.py index 8c6870604..61ef027d8 100644 --- a/benchmarks/x_index_y_and_colon_clear.py +++ b/benchmarks/x_index_y_and_colon_clear.py @@ -32,7 +32,7 @@ def main(): inputs = [] labels = [] for _ in range(100): - sample_x = np.random.randint(0, 2 ** 3, size=(4, 2)) + sample_x = np.random.randint(0, 2 ** 3, size=(4, 2), dtype=np.uint8) sample_y = random.randint(0, (2 ** 2) - 1) inputs.append([sample_x, sample_y]) @@ -44,7 +44,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_index_y_and_colon_encrypted.py b/benchmarks/x_index_y_and_colon_encrypted.py index 6c230664d..393f9004b 100644 --- a/benchmarks/x_index_y_and_colon_encrypted.py +++ b/benchmarks/x_index_y_and_colon_encrypted.py @@ -32,7 +32,7 @@ def main(): inputs = [] labels = [] for _ in range(100): - sample_x = np.random.randint(0, 2 ** 3, size=(4, 2)) + sample_x = np.random.randint(0, 2 ** 3, size=(4, 2), dtype=np.uint8) sample_y = random.randint(0, (2 ** 2) - 1) inputs.append([sample_x, sample_y]) @@ -44,7 +44,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_index_y_and_z_and_0_clear.py b/benchmarks/x_index_y_and_z_and_0_clear.py index ea3921bb5..26f72890e 100644 --- a/benchmarks/x_index_y_and_z_and_0_clear.py +++ b/benchmarks/x_index_y_and_z_and_0_clear.py @@ -50,7 +50,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_index_y_and_z_and_0_encrypted.py b/benchmarks/x_index_y_and_z_and_0_encrypted.py index d9a5fecba..1bc88d6fa 100644 --- a/benchmarks/x_index_y_and_z_and_0_encrypted.py +++ b/benchmarks/x_index_y_and_z_and_0_encrypted.py @@ -37,7 +37,7 @@ def main(): inputs = [] labels = [] for _ in range(100): - sample_x = np.random.randint(0, 2 ** 3, size=(4, 2, 5)) + sample_x = np.random.randint(0, 2 ** 3, size=(4, 2, 5), dtype=np.uint8) sample_y = random.randint(0, (2 ** 2) - 1) sample_z = random.randint(0, (2 ** 1) - 1) @@ -50,7 +50,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_index_y_and_z_clear.py b/benchmarks/x_index_y_and_z_clear.py index a3cee932b..e1d07896a 100644 --- a/benchmarks/x_index_y_and_z_clear.py +++ b/benchmarks/x_index_y_and_z_clear.py @@ -18,7 +18,7 @@ def main(): inputset = [ ( - np.random.randint(0, 2 ** 3, size=(4, 2)), + np.random.randint(0, 2 ** 3, size=(4, 2), dtype=np.uint8), random.randint(0, (2 ** 2) - 1), random.randint(0, (2 ** 1) - 1), ) @@ -37,7 +37,7 @@ def main(): inputs = [] labels = [] for _ in range(100): - sample_x = np.random.randint(0, 2 ** 3, size=(4, 2)) + sample_x = np.random.randint(0, 2 ** 3, size=(4, 2), dtype=np.uint8) sample_y = random.randint(0, (2 ** 2) - 1) sample_z = random.randint(0, (2 ** 1) - 1) @@ -50,7 +50,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_index_y_and_z_encrypted.py b/benchmarks/x_index_y_and_z_encrypted.py index 4f525d22c..70633763c 100644 --- a/benchmarks/x_index_y_and_z_encrypted.py +++ b/benchmarks/x_index_y_and_z_encrypted.py @@ -50,7 +50,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_index_y_clear.py b/benchmarks/x_index_y_clear.py index 5e4f4ee6c..2b43bdeee 100644 --- a/benchmarks/x_index_y_clear.py +++ b/benchmarks/x_index_y_clear.py @@ -32,7 +32,7 @@ def main(): inputs = [] labels = [] for _ in range(100): - sample_x = np.random.randint(0, 2 ** 3, size=(4,)) + sample_x = np.random.randint(0, 2 ** 3, size=(4,), dtype=np.uint8) sample_y = random.randint(0, (2 ** 2) - 1) inputs.append([sample_x, sample_y]) @@ -44,7 +44,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_index_y_encrypted.py b/benchmarks/x_index_y_encrypted.py index 76db6bbc3..5acc5321c 100644 --- a/benchmarks/x_index_y_encrypted.py +++ b/benchmarks/x_index_y_encrypted.py @@ -32,7 +32,7 @@ def main(): inputs = [] labels = [] for _ in range(100): - sample_x = np.random.randint(0, 2 ** 3, size=(4,)) + sample_x = np.random.randint(0, 2 ** 3, size=(4,), dtype=np.uint8) sample_y = random.randint(0, (2 ** 2) - 1) inputs.append([sample_x, sample_y]) @@ -44,7 +44,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_matmul_c.py b/benchmarks/x_matmul_c.py index a63c4797a..c05a2bf18 100644 --- a/benchmarks/x_matmul_c.py +++ b/benchmarks/x_matmul_c.py @@ -7,19 +7,19 @@ import concrete.numpy as hnp def main(): - c = np.arange(20).reshape((4, 5)) + c = np.arange(6).reshape((3, 2)) def function_to_compile(x): return np.matmul(x, c) - x = hnp.EncryptedTensor(hnp.UnsignedInteger(3), shape=(2, 4)) + x = hnp.EncryptedTensor(hnp.UnsignedInteger(2), shape=(2, 3)) - inputset = [(np.random.randint(0, 2 ** 3, size=(2, 4))) for _ in range(128)] + inputset = [(np.random.randint(0, 2 ** 2, size=(2, 3)),) for _ in range(128)] inputs = [] labels = [] for _ in range(4): - sample_x = np.random.randint(0, 2 ** 3, size=(2, 4)) + sample_x = np.random.randint(0, 2 ** 2, size=(2, 3), dtype=np.uint8) inputs.append([sample_x]) labels.append(function_to_compile(*inputs[-1])) @@ -39,7 +39,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_matmul_y.py b/benchmarks/x_matmul_y.py index 13ab3e485..e2f415ddd 100644 --- a/benchmarks/x_matmul_y.py +++ b/benchmarks/x_matmul_y.py @@ -10,19 +10,19 @@ def main(): def function_to_compile(x, y): return np.matmul(x, y) - x = hnp.EncryptedTensor(hnp.UnsignedInteger(3), shape=(2, 4)) - y = hnp.EncryptedTensor(hnp.UnsignedInteger(3), shape=(4, 5)) + x = hnp.EncryptedTensor(hnp.UnsignedInteger(2), shape=(2, 3)) + y = hnp.EncryptedTensor(hnp.UnsignedInteger(2), shape=(3, 2)) inputset = [ - (np.random.randint(0, 2 ** 3, size=(2, 4)), np.random.randint(0, 2 ** 3, size=(4, 5))) + (np.random.randint(0, 2 ** 2, size=(2, 3)), np.random.randint(0, 2 ** 2, size=(3, 2))) for _ in range(128) ] inputs = [] labels = [] for _ in range(4): - sample_x = np.random.randint(0, 2 ** 3, size=(2, 4)) - sample_y = np.random.randint(0, 2 ** 3, size=(4, 5)) + sample_x = np.random.randint(0, 2 ** 2, size=(2, 3), dtype=np.uint8) + sample_y = np.random.randint(0, 2 ** 2, size=(3, 2), dtype=np.uint8) inputs.append([sample_x, sample_y]) labels.append(function_to_compile(*inputs[-1])) @@ -42,7 +42,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_minus_1_2_3.py b/benchmarks/x_minus_1_2_3.py index 68e1db305..feaa5fb7e 100644 --- a/benchmarks/x_minus_1_2_3.py +++ b/benchmarks/x_minus_1_2_3.py @@ -26,7 +26,7 @@ def main(): inputs = [] labels = [] for _ in range(4): - sample_x = np.random.randint(3, 2 ** 3, size=(3,)) + sample_x = np.random.randint(3, 2 ** 3, size=(3,), dtype=np.uint8) inputs.append([sample_x]) labels.append(function_to_compile(*inputs[-1])) @@ -37,7 +37,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_minus_1_2_3_broadcasted.py b/benchmarks/x_minus_1_2_3_broadcasted.py index 7641653ab..76f26c10f 100644 --- a/benchmarks/x_minus_1_2_3_broadcasted.py +++ b/benchmarks/x_minus_1_2_3_broadcasted.py @@ -28,7 +28,7 @@ def main(): inputs = [] labels = [] for _ in range(4): - sample_x = np.random.randint(3, 2 ** 3, size=(2, 3)) + sample_x = np.random.randint(3, 2 ** 3, size=(2, 3), dtype=np.uint8) inputs.append([sample_x]) labels.append(function_to_compile(*inputs[-1])) @@ -39,7 +39,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_minus_24.py b/benchmarks/x_minus_24.py index 8efceaec0..e2b41ec93 100644 --- a/benchmarks/x_minus_24.py +++ b/benchmarks/x_minus_24.py @@ -2,6 +2,7 @@ import random +import numpy as np from common import BENCHMARK_CONFIGURATION import concrete.numpy as hnp @@ -36,7 +37,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_minus_24_tensor.py b/benchmarks/x_minus_24_tensor.py index 209717586..0dbdcb546 100644 --- a/benchmarks/x_minus_24_tensor.py +++ b/benchmarks/x_minus_24_tensor.py @@ -26,7 +26,7 @@ def main(): inputs = [] labels = [] for _ in range(4): - sample_x = np.random.randint(24, 2 ** 6, size=(3,)) + sample_x = np.random.randint(24, 2 ** 6, size=(3,), dtype=np.uint8) inputs.append([sample_x]) labels.append(function_to_compile(*inputs[-1])) @@ -37,7 +37,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_minus_y.py b/benchmarks/x_minus_y.py index cc6fee277..0f1488a8a 100644 --- a/benchmarks/x_minus_y.py +++ b/benchmarks/x_minus_y.py @@ -3,6 +3,7 @@ import itertools import random +import numpy as np from common import BENCHMARK_CONFIGURATION import concrete.numpy as hnp @@ -41,7 +42,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_minus_y_broadcasted_tensors.py b/benchmarks/x_minus_y_broadcasted_tensors.py index bb88176f4..39e0669dc 100644 --- a/benchmarks/x_minus_y_broadcasted_tensors.py +++ b/benchmarks/x_minus_y_broadcasted_tensors.py @@ -30,8 +30,8 @@ def main(): inputs = [] labels = [] for _ in range(4): - sample_x = np.random.randint(4, 2 ** 3, size=(3,)) - sample_y = np.random.randint(0, 5, size=(2, 3)) + sample_x = np.random.randint(4, 2 ** 3, size=(3,), dtype=np.uint8) + sample_y = np.random.randint(0, 5, size=(2, 3), dtype=np.uint8) inputs.append([sample_x, sample_y]) labels.append(function_to_compile(*inputs[-1])) @@ -42,7 +42,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_minus_y_tensor_and_scalar.py b/benchmarks/x_minus_y_tensor_and_scalar.py index 480ee10ea..13bc6d2b2 100644 --- a/benchmarks/x_minus_y_tensor_and_scalar.py +++ b/benchmarks/x_minus_y_tensor_and_scalar.py @@ -41,7 +41,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_minus_y_tensors.py b/benchmarks/x_minus_y_tensors.py index ab8892d21..f2347eca8 100644 --- a/benchmarks/x_minus_y_tensors.py +++ b/benchmarks/x_minus_y_tensors.py @@ -29,8 +29,8 @@ def main(): inputs = [] labels = [] for _ in range(4): - sample_x = np.random.randint(3, 2 ** 3, size=(3,)) - sample_y = np.random.randint(0, 4, size=(3,)) + sample_x = np.random.randint(3, 2 ** 3, size=(3,), dtype=np.uint8) + sample_y = np.random.randint(0, 4, size=(3,), dtype=np.uint8) inputs.append([sample_x, sample_y]) labels.append(function_to_compile(*inputs[-1])) @@ -41,7 +41,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_negative.py b/benchmarks/x_negative.py index 0dff55aba..3f373bb67 100644 --- a/benchmarks/x_negative.py +++ b/benchmarks/x_negative.py @@ -17,7 +17,7 @@ def main(): inputs = [] labels = [] for _ in range(4): - sample_x = np.random.randint(0, 2 ** 3, size=(10, 6)) + sample_x = np.random.randint(0, 2 ** 3, size=(10, 6), dtype=np.uint8) inputs.append([sample_x]) labels.append(function_to_compile(*inputs[-1])) @@ -37,7 +37,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_plus_1_2_3.py b/benchmarks/x_plus_1_2_3.py index 46a6f7742..79ac21bc1 100644 --- a/benchmarks/x_plus_1_2_3.py +++ b/benchmarks/x_plus_1_2_3.py @@ -26,7 +26,7 @@ def main(): inputs = [] labels = [] for _ in range(4): - sample_x = np.random.randint(0, 2 ** 3, size=(3,)) + sample_x = np.random.randint(0, 2 ** 3, size=(3,), dtype=np.uint8) inputs.append([sample_x]) labels.append(function_to_compile(*inputs[-1])) @@ -37,7 +37,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_plus_1_2_3_broadcasted.py b/benchmarks/x_plus_1_2_3_broadcasted.py index b1865cec6..be5178a80 100644 --- a/benchmarks/x_plus_1_2_3_broadcasted.py +++ b/benchmarks/x_plus_1_2_3_broadcasted.py @@ -26,7 +26,7 @@ def main(): inputs = [] labels = [] for _ in range(4): - sample_x = np.random.randint(0, 2 ** 3, size=(2, 3)) + sample_x = np.random.randint(0, 2 ** 3, size=(2, 3), dtype=np.uint8) inputs.append([sample_x]) labels.append(function_to_compile(*inputs[-1])) @@ -37,7 +37,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_plus_42.py b/benchmarks/x_plus_42.py index 9b28ddff3..880796950 100644 --- a/benchmarks/x_plus_42.py +++ b/benchmarks/x_plus_42.py @@ -2,6 +2,7 @@ import random +import numpy as np from common import BENCHMARK_CONFIGURATION import concrete.numpy as hnp @@ -36,7 +37,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_plus_42_10b.py b/benchmarks/x_plus_42_10b.py index a04045ee0..17173f7a3 100644 --- a/benchmarks/x_plus_42_10b.py +++ b/benchmarks/x_plus_42_10b.py @@ -2,6 +2,7 @@ import random +import numpy as np from common import BENCHMARK_CONFIGURATION import concrete.numpy as hnp @@ -39,7 +40,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_plus_42_11b.py b/benchmarks/x_plus_42_11b.py index dab6dc583..2b37cf182 100644 --- a/benchmarks/x_plus_42_11b.py +++ b/benchmarks/x_plus_42_11b.py @@ -2,6 +2,7 @@ import random +import numpy as np from common import BENCHMARK_CONFIGURATION import concrete.numpy as hnp @@ -39,7 +40,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_plus_42_12b.py b/benchmarks/x_plus_42_12b.py index 8bd6005d6..840c8b1bc 100644 --- a/benchmarks/x_plus_42_12b.py +++ b/benchmarks/x_plus_42_12b.py @@ -2,6 +2,7 @@ import random +import numpy as np from common import BENCHMARK_CONFIGURATION import concrete.numpy as hnp @@ -39,7 +40,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_plus_42_13b.py b/benchmarks/x_plus_42_13b.py index d8d18d1ea..23ba9f2f8 100644 --- a/benchmarks/x_plus_42_13b.py +++ b/benchmarks/x_plus_42_13b.py @@ -2,6 +2,7 @@ import random +import numpy as np from common import BENCHMARK_CONFIGURATION import concrete.numpy as hnp @@ -39,7 +40,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_plus_42_14b.py b/benchmarks/x_plus_42_14b.py index 2e51a4acf..b3aa9ed0d 100644 --- a/benchmarks/x_plus_42_14b.py +++ b/benchmarks/x_plus_42_14b.py @@ -2,6 +2,7 @@ import random +import numpy as np from common import BENCHMARK_CONFIGURATION import concrete.numpy as hnp @@ -39,7 +40,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_plus_42_15b.py b/benchmarks/x_plus_42_15b.py index 1411de3e9..49001df50 100644 --- a/benchmarks/x_plus_42_15b.py +++ b/benchmarks/x_plus_42_15b.py @@ -2,6 +2,7 @@ import random +import numpy as np from common import BENCHMARK_CONFIGURATION import concrete.numpy as hnp @@ -39,7 +40,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_plus_42_16b.py b/benchmarks/x_plus_42_16b.py index 5f6ce8ee3..fbfa5799a 100644 --- a/benchmarks/x_plus_42_16b.py +++ b/benchmarks/x_plus_42_16b.py @@ -2,6 +2,7 @@ import random +import numpy as np from common import BENCHMARK_CONFIGURATION import concrete.numpy as hnp @@ -39,7 +40,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_plus_42_32b.py b/benchmarks/x_plus_42_32b.py index 45b9cba5b..a526e3d30 100644 --- a/benchmarks/x_plus_42_32b.py +++ b/benchmarks/x_plus_42_32b.py @@ -2,6 +2,7 @@ import random +import numpy as np from common import BENCHMARK_CONFIGURATION import concrete.numpy as hnp @@ -39,7 +40,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_plus_42_8b.py b/benchmarks/x_plus_42_8b.py index 2c0aeb5fb..f46f1930a 100644 --- a/benchmarks/x_plus_42_8b.py +++ b/benchmarks/x_plus_42_8b.py @@ -2,6 +2,7 @@ import random +import numpy as np from common import BENCHMARK_CONFIGURATION import concrete.numpy as hnp @@ -39,7 +40,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_plus_42_9b.py b/benchmarks/x_plus_42_9b.py index b68cfc963..d71a1b602 100644 --- a/benchmarks/x_plus_42_9b.py +++ b/benchmarks/x_plus_42_9b.py @@ -2,6 +2,7 @@ import random +import numpy as np from common import BENCHMARK_CONFIGURATION import concrete.numpy as hnp @@ -39,7 +40,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_plus_42_tensor.py b/benchmarks/x_plus_42_tensor.py index 2bbf7acc9..f697e0273 100644 --- a/benchmarks/x_plus_42_tensor.py +++ b/benchmarks/x_plus_42_tensor.py @@ -37,7 +37,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_plus_y.py b/benchmarks/x_plus_y.py index e58f5f0d9..13db22dd4 100644 --- a/benchmarks/x_plus_y.py +++ b/benchmarks/x_plus_y.py @@ -2,6 +2,7 @@ import random +import numpy as np from common import BENCHMARK_CONFIGURATION import concrete.numpy as hnp @@ -38,7 +39,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_plus_y_broadcasted_tensors.py b/benchmarks/x_plus_y_broadcasted_tensors.py index a917e3c52..4292f4f2f 100644 --- a/benchmarks/x_plus_y_broadcasted_tensors.py +++ b/benchmarks/x_plus_y_broadcasted_tensors.py @@ -30,8 +30,8 @@ def main(): inputs = [] labels = [] for _ in range(4): - sample_x = np.random.randint(0, 2 ** 3, size=(3,)) - sample_y = np.random.randint(0, 2 ** 3, size=(2, 3)) + sample_x = np.random.randint(0, 2 ** 3, size=(3,), dtype=np.uint8) + sample_y = np.random.randint(0, 2 ** 3, size=(2, 3), dtype=np.uint8) inputs.append([sample_x, sample_y]) labels.append(function_to_compile(*inputs[-1])) @@ -42,7 +42,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_plus_y_tensor_and_scalar.py b/benchmarks/x_plus_y_tensor_and_scalar.py index fd108c0dd..d7bc0dc79 100644 --- a/benchmarks/x_plus_y_tensor_and_scalar.py +++ b/benchmarks/x_plus_y_tensor_and_scalar.py @@ -29,7 +29,7 @@ def main(): inputs = [] labels = [] for _ in range(4): - sample_x = np.random.randint(0, 2 ** 3, size=(3,)) + sample_x = np.random.randint(0, 2 ** 3, size=(3,), dtype=np.uint8) sample_y = random.randint(0, 2 ** 3 - 1) inputs.append([sample_x, sample_y]) @@ -41,7 +41,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_plus_y_tensors.py b/benchmarks/x_plus_y_tensors.py index 6f9c1970d..cb37c8daf 100644 --- a/benchmarks/x_plus_y_tensors.py +++ b/benchmarks/x_plus_y_tensors.py @@ -30,8 +30,8 @@ def main(): inputs = [] labels = [] for _ in range(4): - sample_x = np.random.randint(0, 2 ** 3, size=(3,)) - sample_y = np.random.randint(0, 2 ** 3, size=(3,)) + sample_x = np.random.randint(0, 2 ** 3, size=(3,), dtype=np.uint8) + sample_y = np.random.randint(0, 2 ** 3, size=(3,), dtype=np.uint8) inputs.append([sample_x, sample_y]) labels.append(function_to_compile(*inputs[-1])) @@ -42,7 +42,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_reshape.py b/benchmarks/x_reshape.py index 36461e713..371c8aed0 100644 --- a/benchmarks/x_reshape.py +++ b/benchmarks/x_reshape.py @@ -17,7 +17,7 @@ def main(): inputs = [] labels = [] for _ in range(4): - sample_x = np.random.randint(0, 2 ** 3, size=(10, 6)) + sample_x = np.random.randint(0, 2 ** 3, size=(10, 6), dtype=np.uint8) inputs.append([sample_x]) labels.append(function_to_compile(*inputs[-1])) @@ -37,7 +37,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_times_1_2_3.py b/benchmarks/x_times_1_2_3.py index 839509e62..70b88e82e 100644 --- a/benchmarks/x_times_1_2_3.py +++ b/benchmarks/x_times_1_2_3.py @@ -26,7 +26,7 @@ def main(): inputs = [] labels = [] for _ in range(4): - sample_x = np.random.randint(0, 2 ** 3, size=(3,)) + sample_x = np.random.randint(0, 2 ** 3, size=(3,), dtype=np.uint8) inputs.append([sample_x]) labels.append(function_to_compile(*inputs[-1])) @@ -37,7 +37,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_times_1_2_3_broadcasted.py b/benchmarks/x_times_1_2_3_broadcasted.py index fcd5299c0..34caf542c 100644 --- a/benchmarks/x_times_1_2_3_broadcasted.py +++ b/benchmarks/x_times_1_2_3_broadcasted.py @@ -26,7 +26,7 @@ def main(): inputs = [] labels = [] for _ in range(4): - sample_x = np.random.randint(0, 2 ** 3, size=(2, 3)) + sample_x = np.random.randint(0, 2 ** 3, size=(2, 3), dtype=np.uint8) inputs.append([sample_x]) labels.append(function_to_compile(*inputs[-1])) @@ -37,7 +37,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_times_7.py b/benchmarks/x_times_7.py index 2c8ba90c1..ecad203e0 100644 --- a/benchmarks/x_times_7.py +++ b/benchmarks/x_times_7.py @@ -2,6 +2,7 @@ import random +import numpy as np from common import BENCHMARK_CONFIGURATION import concrete.numpy as hnp @@ -36,7 +37,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_times_7_tensor.py b/benchmarks/x_times_7_tensor.py index ef0bd900b..75ca326d0 100644 --- a/benchmarks/x_times_7_tensor.py +++ b/benchmarks/x_times_7_tensor.py @@ -26,7 +26,7 @@ def main(): inputs = [] labels = [] for _ in range(4): - sample_x = np.random.randint(0, 2 ** 3, size=(3,)) + sample_x = np.random.randint(0, 2 ** 3, size=(3,), dtype=np.uint8) inputs.append([sample_x]) labels.append(function_to_compile(*inputs[-1])) @@ -37,7 +37,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_times_y.py b/benchmarks/x_times_y.py index b7c261cb3..ac6c94a6e 100644 --- a/benchmarks/x_times_y.py +++ b/benchmarks/x_times_y.py @@ -3,6 +3,7 @@ import itertools import random +import numpy as np from common import BENCHMARK_CONFIGURATION import concrete.numpy as hnp @@ -41,7 +42,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_times_y_broadcasted_tensors.py b/benchmarks/x_times_y_broadcasted_tensors.py index 65ec15ce0..923727092 100644 --- a/benchmarks/x_times_y_broadcasted_tensors.py +++ b/benchmarks/x_times_y_broadcasted_tensors.py @@ -30,8 +30,8 @@ def main(): inputs = [] labels = [] for _ in range(4): - sample_x = np.random.randint(0, 2 ** 3, size=(3,)) - sample_y = np.random.randint(0, 2 ** 3, size=(2, 3)) + sample_x = np.random.randint(0, 2 ** 3, size=(3,), dtype=np.uint8) + sample_y = np.random.randint(0, 2 ** 3, size=(2, 3), dtype=np.uint8) inputs.append([sample_x, sample_y]) labels.append(function_to_compile(*inputs[-1])) @@ -42,7 +42,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_times_y_tensor_and_scalar.py b/benchmarks/x_times_y_tensor_and_scalar.py index 878bbae00..55f49d5cd 100644 --- a/benchmarks/x_times_y_tensor_and_scalar.py +++ b/benchmarks/x_times_y_tensor_and_scalar.py @@ -41,7 +41,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_times_y_tensors.py b/benchmarks/x_times_y_tensors.py index ca94ee518..f1fe465ca 100644 --- a/benchmarks/x_times_y_tensors.py +++ b/benchmarks/x_times_y_tensors.py @@ -30,8 +30,8 @@ def main(): inputs = [] labels = [] for _ in range(4): - sample_x = np.random.randint(0, 2 ** 3, size=(3,)) - sample_y = np.random.randint(0, 2 ** 3, size=(3,)) + sample_x = np.random.randint(0, 2 ** 3, size=(3,), dtype=np.uint8) + sample_y = np.random.randint(0, 2 ** 3, size=(3,), dtype=np.uint8) inputs.append([sample_x, sample_y]) labels.append(function_to_compile(*inputs[-1])) @@ -42,7 +42,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_to_the_power_of_2.py b/benchmarks/x_to_the_power_of_2.py index 863b3256f..e66b3bc43 100644 --- a/benchmarks/x_to_the_power_of_2.py +++ b/benchmarks/x_to_the_power_of_2.py @@ -1,7 +1,8 @@ -# bench: Unit Target: x**2 +# bench: Unit Target: x ** 2 import random +import numpy as np from common import BENCHMARK_CONFIGURATION import concrete.numpy as hnp @@ -36,7 +37,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/benchmarks/x_tranpose.py b/benchmarks/x_tranpose.py index 2965c9deb..b01b84177 100644 --- a/benchmarks/x_tranpose.py +++ b/benchmarks/x_tranpose.py @@ -17,7 +17,7 @@ def main(): inputs = [] labels = [] for _ in range(4): - sample_x = np.random.randint(0, 2 ** 3, size=(2, 4)) + sample_x = np.random.randint(0, 2 ** 3, size=(2, 4), dtype=np.uint8) inputs.append([sample_x]) labels.append(function_to_compile(*inputs[-1])) @@ -37,7 +37,7 @@ def main(): result_i = engine.run(*input_i) # bench: Measure: End - if result_i == label_i: + if np.array_equal(result_i, label_i): correct += 1 # bench: Measure: Accuracy (%) = (correct / len(inputs)) * 100 diff --git a/script/progress_tracker_utils/measure.py b/script/progress_tracker_utils/measure.py index 2609d04b5..1991c2a6d 100644 --- a/script/progress_tracker_utils/measure.py +++ b/script/progress_tracker_utils/measure.py @@ -14,7 +14,7 @@ def name_to_id(name): """Convert a human readable name to a url friendly id (e.g., `x + y` to `x-plus-y`)""" name = name.replace("-", "minus") - name = name.replace("**", "-to-the-power-of-") + name = name.replace(" ** ", "-to-the-power-of-") name = name.replace("+", "plus") name = name.replace("*", "times") name = name.replace("/", "over") @@ -24,6 +24,8 @@ def name_to_id(name): name = name.replace(" ", "-") name = name.replace("(", "") name = name.replace(")", "") + name = name.replace("[", "") + name = name.replace("]", "") name = name.replace(",", "") name = name.replace(".", "-")