fix(benchmarks): treat warnings as errors in benchmarks

This commit is contained in:
Umut
2021-10-07 13:31:58 +03:00
parent 6affa54473
commit 57b3be2f6d
34 changed files with 330 additions and 170 deletions

View File

@@ -2,6 +2,8 @@
import random
from common import BENCHMARK_CONFIGURATION
import concrete.numpy as hnp
@@ -16,6 +18,7 @@ def main():
function_to_compile,
{"x": x},
[(i,) for i in range(2 ** 3)],
compilation_configuration=BENCHMARK_CONFIGURATION,
)
# Measure: End

View File

@@ -1,6 +1,7 @@
# Target: 124 - x (Tensor)
import numpy as np
from common import BENCHMARK_CONFIGURATION
import concrete.numpy as hnp
@@ -11,15 +12,15 @@ def main():
x = hnp.EncryptedTensor(hnp.UnsignedInteger(6), shape=(3,))
inputset = [
(np.array([36, 50, 24]),),
(np.array([41, 60, 51]),),
(np.array([25, 31, 24]),),
(np.array([34, 47, 27]),),
]
inputset = [(np.random.randint(0, 2 ** 6, size=(3,)),) for _ in range(32)]
# Measure: Compilation Time (ms)
engine = hnp.compile_numpy_function(function_to_compile, {"x": x}, inputset)
engine = hnp.compile_numpy_function(
function_to_compile,
{"x": x},
inputset,
compilation_configuration=BENCHMARK_CONFIGURATION,
)
# Measure: End
inputs = []

8
benchmarks/common.py Normal file
View File

@@ -0,0 +1,8 @@
import concrete.numpy as hnp
BENCHMARK_CONFIGURATION = hnp.CompilationConfiguration(
dump_artifacts_on_unexpected_failures=True,
enable_topological_optimizations=True,
check_every_input_in_inputset=True,
treat_warnings_as_errors=True,
)

View File

@@ -5,13 +5,16 @@
# pylint: disable=C0301
import numpy as np
from common import BENCHMARK_CONFIGURATION
import concrete.numpy as hnp
def main():
x = np.array([[130], [110], [100], [145], [160], [185], [200], [80], [50]], dtype=np.float32)
y = np.array([325, 295, 268, 400, 420, 500, 520, 220, 120], dtype=np.float32)
x = np.array(
[[69], [130], [110], [100], [145], [160], [185], [200], [80], [50]], dtype=np.float32
)
y = np.array([181, 325, 295, 268, 400, 420, 500, 520, 220, 120], dtype=np.float32)
class Model:
w = None
@@ -150,6 +153,7 @@ def main():
function_to_compile,
{"x_0": hnp.EncryptedScalar(hnp.UnsignedInteger(input_bits))},
inputset,
compilation_configuration=BENCHMARK_CONFIGURATION,
)
# Measure: End

View File

@@ -2,13 +2,40 @@
import numpy as np
import torch
from common import BENCHMARK_CONFIGURATION
import concrete.numpy as hnp
def main():
x = torch.tensor([[1, 1], [1, 2], [2, 1], [4, 1], [3, 2], [4, 2]]).float()
y = torch.tensor([[0], [0], [0], [1], [1], [1]]).float()
x = torch.tensor(
[
[1, 1],
[1, 1.5],
[1.5, 1.2],
[1, 2],
[2, 1],
[4, 1],
[4, 1.5],
[3.5, 1.8],
[3, 2],
[4, 2],
]
).float()
y = torch.tensor(
[
[0],
[0],
[0],
[0],
[0],
[1],
[1],
[1],
[1],
[1],
]
).float()
class Model(torch.nn.Module):
def __init__(self, n):
@@ -218,6 +245,7 @@ def main():
"x_1": hnp.EncryptedScalar(hnp.UnsignedInteger(input_bits)),
},
inputset,
compilation_configuration=BENCHMARK_CONFIGURATION,
)
# Measure: End

View File

@@ -2,6 +2,8 @@
import random
from common import BENCHMARK_CONFIGURATION
import concrete.numpy as hnp
@@ -21,6 +23,7 @@ def main():
function_to_compile,
{"x": x},
[(i,) for i in range(2 ** input_bits)],
compilation_configuration=BENCHMARK_CONFIGURATION,
)
# Measure: End

View File

@@ -1,6 +1,7 @@
# Target: x - [1, 2, 3]
import numpy as np
from common import BENCHMARK_CONFIGURATION
import concrete.numpy as hnp
@@ -11,15 +12,15 @@ def main():
x = hnp.EncryptedTensor(hnp.UnsignedInteger(3), shape=(3,))
inputset = [
(np.array([6, 2, 4]),),
(np.array([1, 3, 5]),),
(np.array([5, 7, 2]),),
(np.array([1, 7, 7]),),
]
inputset = [(np.random.randint(0, 2 ** 2, size=(3,)) + np.array([1, 2, 3]),) for _ in range(32)]
# Measure: Compilation Time (ms)
engine = hnp.compile_numpy_function(function_to_compile, {"x": x}, inputset)
engine = hnp.compile_numpy_function(
function_to_compile,
{"x": x},
inputset,
compilation_configuration=BENCHMARK_CONFIGURATION,
)
# Measure: End
inputs = []

View File

@@ -1,6 +1,7 @@
# Target: x - [1, 2, 3] (Broadcasted)
import numpy as np
from common import BENCHMARK_CONFIGURATION
import concrete.numpy as hnp
@@ -12,14 +13,16 @@ def main():
x = hnp.EncryptedTensor(hnp.UnsignedInteger(3), shape=(2, 3))
inputset = [
(np.array([[4, 7, 7], [6, 2, 4]]),),
(np.array([[6, 2, 4], [1, 3, 1]]),),
(np.array([[6, 2, 4], [5, 7, 5]]),),
(np.array([[5, 7, 5], [4, 7, 7]]),),
(np.random.randint(0, 2 ** 2, size=(2, 3)) + np.array([1, 2, 3]),) for _ in range(32)
]
# Measure: Compilation Time (ms)
engine = hnp.compile_numpy_function(function_to_compile, {"x": x}, inputset)
engine = hnp.compile_numpy_function(
function_to_compile,
{"x": x},
inputset,
compilation_configuration=BENCHMARK_CONFIGURATION,
)
# Measure: End
inputs = []

View File

@@ -2,6 +2,8 @@
import random
from common import BENCHMARK_CONFIGURATION
import concrete.numpy as hnp
@@ -15,7 +17,8 @@ def main():
engine = hnp.compile_numpy_function(
function_to_compile,
{"x": x},
[(i,) for i in range(2 ** 6)],
[(i,) for i in range(24, 2 ** 6)],
compilation_configuration=BENCHMARK_CONFIGURATION,
)
# Measure: End

View File

@@ -1,6 +1,7 @@
# Target: x - 24 (Tensor)
import numpy as np
from common import BENCHMARK_CONFIGURATION
import concrete.numpy as hnp
@@ -11,15 +12,15 @@ def main():
x = hnp.EncryptedTensor(hnp.UnsignedInteger(6), shape=(3,))
inputset = [
(np.array([36, 50, 24]),),
(np.array([41, 60, 51]),),
(np.array([25, 31, 24]),),
(np.array([34, 47, 27]),),
]
inputset = [(np.random.randint(0, 2 ** 5, size=(3,)) + 24,) for _ in range(32)]
# Measure: Compilation Time (ms)
engine = hnp.compile_numpy_function(function_to_compile, {"x": x}, inputset)
engine = hnp.compile_numpy_function(
function_to_compile,
{"x": x},
inputset,
compilation_configuration=BENCHMARK_CONFIGURATION,
)
# Measure: End
inputs = []

View File

@@ -3,6 +3,8 @@
import itertools
import random
from common import BENCHMARK_CONFIGURATION
import concrete.numpy as hnp
@@ -16,7 +18,12 @@ def main():
inputset = itertools.product(range(4, 8), range(0, 4))
# Measure: Compilation Time (ms)
engine = hnp.compile_numpy_function(function_to_compile, {"x": x, "y": y}, inputset)
engine = hnp.compile_numpy_function(
function_to_compile,
{"x": x, "y": y},
inputset,
compilation_configuration=BENCHMARK_CONFIGURATION,
)
# Measure: End
inputs = []

View File

@@ -1,6 +1,7 @@
# Target: x - y (Broadcasted Tensors)
import numpy as np
from common import BENCHMARK_CONFIGURATION
import concrete.numpy as hnp
@@ -10,17 +11,20 @@ def main():
return x - y
x = hnp.EncryptedTensor(hnp.UnsignedInteger(3), shape=(3,))
y = hnp.EncryptedTensor(hnp.UnsignedInteger(3), shape=(2, 3))
y = hnp.EncryptedTensor(hnp.UnsignedInteger(2), shape=(2, 3))
inputset = [
(np.array([6, 2, 4]), np.array([[5, 1, 3], [0, 0, 4]])),
(np.array([1, 3, 1]), np.array([[0, 3, 1], [1, 2, 1]])),
(np.array([5, 1, 2]), np.array([[5, 0, 2], [2, 1, 1]])),
(np.array([0, 7, 7]), np.array([[0, 5, 1], [0, 7, 2]])),
(np.random.randint(4, 8, size=(3,)), np.random.randint(0, 4, size=(2, 3)))
for _ in range(32)
]
# Measure: Compilation Time (ms)
engine = hnp.compile_numpy_function(function_to_compile, {"x": x, "y": y}, inputset)
engine = hnp.compile_numpy_function(
function_to_compile,
{"x": x, "y": y},
inputset,
compilation_configuration=BENCHMARK_CONFIGURATION,
)
# Measure: End
inputs = []

View File

@@ -3,6 +3,7 @@
import random
import numpy as np
from common import BENCHMARK_CONFIGURATION
import concrete.numpy as hnp
@@ -12,17 +13,17 @@ def main():
return x - y
x = hnp.EncryptedTensor(hnp.UnsignedInteger(3), shape=(3,))
y = hnp.EncryptedScalar(hnp.UnsignedInteger(3))
y = hnp.EncryptedScalar(hnp.UnsignedInteger(2))
inputset = [
(np.array([6, 2, 4]), 2),
(np.array([1, 3, 1]), 1),
(np.array([5, 4, 7]), 4),
(np.array([5, 7, 6]), 5),
]
inputset = [(np.random.randint(4, 8, size=(3,)), random.randint(0, 3)) for _ in range(32)]
# Measure: Compilation Time (ms)
engine = hnp.compile_numpy_function(function_to_compile, {"x": x, "y": y}, inputset)
engine = hnp.compile_numpy_function(
function_to_compile,
{"x": x, "y": y},
inputset,
compilation_configuration=BENCHMARK_CONFIGURATION,
)
# Measure: End
inputs = []

View File

@@ -1,6 +1,7 @@
# Target: x - y (Tensors)
import numpy as np
from common import BENCHMARK_CONFIGURATION
import concrete.numpy as hnp
@@ -10,17 +11,19 @@ def main():
return x - y
x = hnp.EncryptedTensor(hnp.UnsignedInteger(3), shape=(3,))
y = hnp.EncryptedTensor(hnp.UnsignedInteger(3), shape=(3,))
y = hnp.EncryptedTensor(hnp.UnsignedInteger(2), shape=(3,))
inputset = [
(np.array([6, 2, 4]), np.array([4, 1, 2])),
(np.array([1, 3, 1]), np.array([1, 1, 0])),
(np.array([5, 1, 2]), np.array([4, 1, 1])),
(np.array([0, 7, 7]), np.array([0, 7, 0])),
(np.random.randint(4, 8, size=(3,)), np.random.randint(0, 4, size=(3,))) for _ in range(32)
]
# Measure: Compilation Time (ms)
engine = hnp.compile_numpy_function(function_to_compile, {"x": x, "y": y}, inputset)
engine = hnp.compile_numpy_function(
function_to_compile,
{"x": x, "y": y},
inputset,
compilation_configuration=BENCHMARK_CONFIGURATION,
)
# Measure: End
inputs = []

View File

@@ -1,6 +1,7 @@
# Target: x + [1, 2, 3]
import numpy as np
from common import BENCHMARK_CONFIGURATION
import concrete.numpy as hnp
@@ -11,15 +12,15 @@ def main():
x = hnp.EncryptedTensor(hnp.UnsignedInteger(3), shape=(3,))
inputset = [
(np.array([6, 2, 4]),),
(np.array([1, 3, 1]),),
(np.array([5, 1, 2]),),
(np.array([0, 7, 7]),),
]
inputset = [(np.random.randint(0, 2 ** 3, size=(3,)),) for _ in range(32)]
# Measure: Compilation Time (ms)
engine = hnp.compile_numpy_function(function_to_compile, {"x": x}, inputset)
engine = hnp.compile_numpy_function(
function_to_compile,
{"x": x},
inputset,
compilation_configuration=BENCHMARK_CONFIGURATION,
)
# Measure: End
inputs = []

View File

@@ -1,6 +1,7 @@
# Target: x + [1, 2, 3] (Broadcasted)
import numpy as np
from common import BENCHMARK_CONFIGURATION
import concrete.numpy as hnp
@@ -11,15 +12,15 @@ def main():
x = hnp.EncryptedTensor(hnp.UnsignedInteger(3), shape=(2, 3))
inputset = [
(np.array([[0, 7, 7], [6, 2, 4]]),),
(np.array([[6, 2, 4], [1, 3, 1]]),),
(np.array([[6, 2, 4], [5, 1, 2]]),),
(np.array([[5, 1, 2], [0, 7, 7]]),),
]
inputset = [(np.random.randint(0, 2 ** 3, size=(2, 3)),) for _ in range(32)]
# Measure: Compilation Time (ms)
engine = hnp.compile_numpy_function(function_to_compile, {"x": x}, inputset)
engine = hnp.compile_numpy_function(
function_to_compile,
{"x": x},
inputset,
compilation_configuration=BENCHMARK_CONFIGURATION,
)
# Measure: End
inputs = []

View File

@@ -2,6 +2,8 @@
import random
from common import BENCHMARK_CONFIGURATION
import concrete.numpy as hnp
@@ -15,7 +17,8 @@ def main():
engine = hnp.compile_numpy_function(
function_to_compile,
{"x": x},
[(6,), (1,), (5,), (2,)],
[(i,) for i in range(2 ** 3)],
compilation_configuration=BENCHMARK_CONFIGURATION,
)
# Measure: End

View File

@@ -1,6 +1,7 @@
# Target: x + 42 (Tensor)
import numpy as np
from common import BENCHMARK_CONFIGURATION
import concrete.numpy as hnp
@@ -11,15 +12,15 @@ def main():
x = hnp.EncryptedTensor(hnp.UnsignedInteger(3), shape=(3,))
inputset = [
(np.array([6, 2, 4]),),
(np.array([1, 3, 1]),),
(np.array([5, 1, 2]),),
(np.array([0, 7, 7]),),
]
inputset = [(np.random.randint(0, 2 ** 3, size=(3,)),) for _ in range(32)]
# Measure: Compilation Time (ms)
engine = hnp.compile_numpy_function(function_to_compile, {"x": x}, inputset)
engine = hnp.compile_numpy_function(
function_to_compile,
{"x": x},
inputset,
compilation_configuration=BENCHMARK_CONFIGURATION,
)
# Measure: End
inputs = []

View File

@@ -2,6 +2,8 @@
import random
from common import BENCHMARK_CONFIGURATION
import concrete.numpy as hnp
@@ -16,7 +18,8 @@ def main():
engine = hnp.compile_numpy_function(
function_to_compile,
{"x": x, "y": y},
[(6, 1), (1, 4), (5, 3), (2, 0), (7, 7)],
[(random.randint(0, 7), random.randint(0, 7)) for _ in range(32)],
compilation_configuration=BENCHMARK_CONFIGURATION,
)
# Measure: End

View File

@@ -1,6 +1,7 @@
# Target: x + y (Broadcasted Tensors)
import numpy as np
from common import BENCHMARK_CONFIGURATION
import concrete.numpy as hnp
@@ -13,14 +14,17 @@ def main():
y = hnp.EncryptedTensor(hnp.UnsignedInteger(3), shape=(2, 3))
inputset = [
(np.array([6, 2, 4]), np.array([[5, 1, 2], [0, 7, 7]])),
(np.array([1, 3, 1]), np.array([[0, 7, 7], [6, 2, 4]])),
(np.array([5, 1, 2]), np.array([[6, 2, 4], [1, 3, 1]])),
(np.array([0, 7, 7]), np.array([[1, 3, 1], [5, 1, 2]])),
(np.random.randint(0, 2 ** 3, size=(3,)), np.random.randint(0, 2 ** 3, size=(2, 3)))
for _ in range(32)
]
# Measure: Compilation Time (ms)
engine = hnp.compile_numpy_function(function_to_compile, {"x": x, "y": y}, inputset)
engine = hnp.compile_numpy_function(
function_to_compile,
{"x": x, "y": y},
inputset,
compilation_configuration=BENCHMARK_CONFIGURATION,
)
# Measure: End
inputs = []

View File

@@ -3,6 +3,7 @@
import random
import numpy as np
from common import BENCHMARK_CONFIGURATION
import concrete.numpy as hnp
@@ -14,15 +15,15 @@ def main():
x = hnp.EncryptedTensor(hnp.UnsignedInteger(3), shape=(3,))
y = hnp.EncryptedScalar(hnp.UnsignedInteger(3))
inputset = [
(np.array([6, 2, 4]), 4),
(np.array([1, 3, 1]), 1),
(np.array([5, 1, 2]), 2),
(np.array([0, 7, 7]), 5),
]
inputset = [(np.random.randint(0, 8, size=(3,)), random.randint(0, 7)) for _ in range(32)]
# Measure: Compilation Time (ms)
engine = hnp.compile_numpy_function(function_to_compile, {"x": x, "y": y}, inputset)
engine = hnp.compile_numpy_function(
function_to_compile,
{"x": x, "y": y},
inputset,
compilation_configuration=BENCHMARK_CONFIGURATION,
)
# Measure: End
inputs = []

View File

@@ -1,6 +1,7 @@
# Target: x + y (Tensors)
import numpy as np
from common import BENCHMARK_CONFIGURATION
import concrete.numpy as hnp
@@ -13,14 +14,17 @@ def main():
y = hnp.EncryptedTensor(hnp.UnsignedInteger(3), shape=(3,))
inputset = [
(np.array([6, 2, 4]), np.array([0, 7, 7])),
(np.array([1, 3, 1]), np.array([6, 2, 4])),
(np.array([5, 1, 2]), np.array([1, 3, 1])),
(np.array([0, 7, 7]), np.array([5, 1, 2])),
(np.random.randint(0, 2 ** 3, size=(3,)), np.random.randint(0, 2 ** 3, size=(3,)))
for _ in range(32)
]
# Measure: Compilation Time (ms)
engine = hnp.compile_numpy_function(function_to_compile, {"x": x, "y": y}, inputset)
engine = hnp.compile_numpy_function(
function_to_compile,
{"x": x, "y": y},
inputset,
compilation_configuration=BENCHMARK_CONFIGURATION,
)
# Measure: End
inputs = []

View File

@@ -1,6 +1,7 @@
# Target: x * [1, 2, 3]
import numpy as np
from common import BENCHMARK_CONFIGURATION
import concrete.numpy as hnp
@@ -11,15 +12,15 @@ def main():
x = hnp.EncryptedTensor(hnp.UnsignedInteger(3), shape=(3,))
inputset = [
(np.array([6, 2, 4]),),
(np.array([1, 3, 1]),),
(np.array([5, 1, 2]),),
(np.array([0, 7, 7]),),
]
inputset = [(np.random.randint(0, 2 ** 3, size=(3,)),) for _ in range(32)]
# Measure: Compilation Time (ms)
engine = hnp.compile_numpy_function(function_to_compile, {"x": x}, inputset)
engine = hnp.compile_numpy_function(
function_to_compile,
{"x": x},
inputset,
compilation_configuration=BENCHMARK_CONFIGURATION,
)
# Measure: End
inputs = []

View File

@@ -1,6 +1,7 @@
# Target: x * [1, 2, 3] (Broadcasted)
import numpy as np
from common import BENCHMARK_CONFIGURATION
import concrete.numpy as hnp
@@ -11,15 +12,15 @@ def main():
x = hnp.EncryptedTensor(hnp.UnsignedInteger(3), shape=(2, 3))
inputset = [
(np.array([[0, 7, 7], [6, 2, 4]]),),
(np.array([[6, 2, 4], [1, 3, 1]]),),
(np.array([[6, 2, 4], [5, 1, 2]]),),
(np.array([[5, 1, 2], [0, 7, 7]]),),
]
inputset = [(np.random.randint(0, 2 ** 3, size=(2, 3)),) for _ in range(32)]
# Measure: Compilation Time (ms)
engine = hnp.compile_numpy_function(function_to_compile, {"x": x}, inputset)
engine = hnp.compile_numpy_function(
function_to_compile,
{"x": x},
inputset,
compilation_configuration=BENCHMARK_CONFIGURATION,
)
# Measure: End
inputs = []

View File

@@ -2,6 +2,8 @@
import random
from common import BENCHMARK_CONFIGURATION
import concrete.numpy as hnp
@@ -16,6 +18,7 @@ def main():
function_to_compile,
{"x": x},
[(i,) for i in range(2 ** 4)],
compilation_configuration=BENCHMARK_CONFIGURATION,
)
# Measure: End

View File

@@ -1,6 +1,7 @@
# Target: x * 7 (Tensor)
import numpy as np
from common import BENCHMARK_CONFIGURATION
import concrete.numpy as hnp
@@ -11,15 +12,15 @@ def main():
x = hnp.EncryptedTensor(hnp.UnsignedInteger(3), shape=(3,))
inputset = [
(np.array([6, 2, 4]),),
(np.array([1, 3, 1]),),
(np.array([5, 1, 2]),),
(np.array([0, 7, 7]),),
]
inputset = [(np.random.randint(0, 2 ** 3, size=(3,)),) for _ in range(32)]
# Measure: Compilation Time (ms)
engine = hnp.compile_numpy_function(function_to_compile, {"x": x}, inputset)
engine = hnp.compile_numpy_function(
function_to_compile,
{"x": x},
inputset,
compilation_configuration=BENCHMARK_CONFIGURATION,
)
# Measure: End
inputs = []

View File

@@ -3,6 +3,8 @@
import itertools
import random
from common import BENCHMARK_CONFIGURATION
import concrete.numpy as hnp
@@ -16,7 +18,12 @@ def main():
inputset = itertools.product(range(4, 8), range(0, 4))
# Measure: Compilation Time (ms)
engine = hnp.compile_numpy_function(function_to_compile, {"x": x, "y": y}, inputset)
engine = hnp.compile_numpy_function(
function_to_compile,
{"x": x, "y": y},
inputset,
compilation_configuration=BENCHMARK_CONFIGURATION,
)
# Measure: End
inputs = []

View File

@@ -1,6 +1,7 @@
# Target: x * y (Broadcasted Tensors)
import numpy as np
from common import BENCHMARK_CONFIGURATION
import concrete.numpy as hnp
@@ -13,14 +14,17 @@ def main():
y = hnp.EncryptedTensor(hnp.UnsignedInteger(3), shape=(2, 3))
inputset = [
(np.array([6, 2, 4]), np.array([[5, 1, 2], [0, 7, 7]])),
(np.array([1, 3, 1]), np.array([[0, 7, 7], [6, 2, 4]])),
(np.array([5, 1, 2]), np.array([[6, 2, 4], [1, 3, 1]])),
(np.array([0, 7, 7]), np.array([[1, 3, 1], [5, 1, 2]])),
(np.random.randint(0, 2 ** 3, size=(3,)), np.random.randint(0, 2 ** 3, size=(2, 3)))
for _ in range(32)
]
# Measure: Compilation Time (ms)
engine = hnp.compile_numpy_function(function_to_compile, {"x": x, "y": y}, inputset)
engine = hnp.compile_numpy_function(
function_to_compile,
{"x": x, "y": y},
inputset,
compilation_configuration=BENCHMARK_CONFIGURATION,
)
# Measure: End
inputs = []

View File

@@ -3,6 +3,7 @@
import random
import numpy as np
from common import BENCHMARK_CONFIGURATION
import concrete.numpy as hnp
@@ -14,15 +15,15 @@ def main():
x = hnp.EncryptedTensor(hnp.UnsignedInteger(3), shape=(3,))
y = hnp.EncryptedScalar(hnp.UnsignedInteger(3))
inputset = [
(np.array([6, 2, 4]), 4),
(np.array([1, 3, 1]), 1),
(np.array([5, 1, 2]), 2),
(np.array([0, 7, 7]), 5),
]
inputset = [(np.random.randint(0, 8, size=(3,)), random.randint(0, 7)) for _ in range(32)]
# Measure: Compilation Time (ms)
engine = hnp.compile_numpy_function(function_to_compile, {"x": x, "y": y}, inputset)
engine = hnp.compile_numpy_function(
function_to_compile,
{"x": x, "y": y},
inputset,
compilation_configuration=BENCHMARK_CONFIGURATION,
)
# Measure: End
inputs = []

View File

@@ -1,6 +1,7 @@
# Target: x * y (Tensors)
import numpy as np
from common import BENCHMARK_CONFIGURATION
import concrete.numpy as hnp
@@ -13,14 +14,17 @@ def main():
y = hnp.EncryptedTensor(hnp.UnsignedInteger(3), shape=(3,))
inputset = [
(np.array([6, 2, 4]), np.array([0, 7, 7])),
(np.array([1, 3, 1]), np.array([6, 2, 4])),
(np.array([5, 1, 2]), np.array([1, 3, 1])),
(np.array([0, 7, 7]), np.array([5, 1, 2])),
(np.random.randint(0, 2 ** 3, size=(3,)), np.random.randint(0, 2 ** 3, size=(3,)))
for _ in range(32)
]
# Measure: Compilation Time (ms)
engine = hnp.compile_numpy_function(function_to_compile, {"x": x, "y": y}, inputset)
engine = hnp.compile_numpy_function(
function_to_compile,
{"x": x, "y": y},
inputset,
compilation_configuration=BENCHMARK_CONFIGURATION,
)
# Measure: End
inputs = []

View File

@@ -2,6 +2,8 @@
import random
from common import BENCHMARK_CONFIGURATION
import concrete.numpy as hnp
@@ -15,7 +17,8 @@ def main():
engine = hnp.compile_numpy_function(
function_to_compile,
{"x": x},
[(6,), (1,), (5,), (2,)],
[(i,) for i in range(2 ** 3)],
compilation_configuration=BENCHMARK_CONFIGURATION,
)
# Measure: End

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -261,7 +261,8 @@ def main():
scripts = list(base.glob("*.py"))
# Create a directory to store temporary scripts
os.makedirs(".benchmarks/scripts", exist_ok=True)
shutil.rmtree(".benchmarks/scripts", ignore_errors=True)
shutil.copytree(base, ".benchmarks/scripts")
# Process each script under the base directory
for path in scripts: