test(benchmark): Add more micro benchmarks on parallel lookup table

This commit is contained in:
Quentin Bourgerie
2022-10-14 16:58:16 +02:00
committed by Ayoub Benaissa
parent f91514e7ff
commit a5047586f4
4 changed files with 53 additions and 2 deletions

1
compiler/.gitignore vendored
View File

@@ -10,3 +10,4 @@ concrete-core-ffi*
# Test-generated artifacts
concrete-compiler_compilation_artifacts/
py_test_lib_compile_and_run_custom_perror/
tests/end_to_end_fixture/end_to_end_linalg_apply_lookup_table.yaml

View File

@@ -241,10 +241,13 @@ run-end-to-end-gpu-tests: build-end-to-end-gpu-tests
# benchmark
generate-benchmarks:
python ./tests/end_to_end_fixture/end_to_end_linalg_apply_lookup_table_gen.py &> tests/end_to_end_fixture/end_to_end_linalg_apply_lookup_table.yaml
build-benchmarks: build-initialized
cmake --build $(BUILD_DIR) --target end_to_end_benchmark
run-benchmarks: build-benchmarks
run-benchmarks: build-benchmarks generate-benchmarks
$(BUILD_DIR)/bin/end_to_end_benchmark --benchmark_out=benchmarks_results.json --benchmark_out_format=json --benchmark_repetitions=10 --benchmark_report_aggregates_only=true
build-mlbench: build-initialized

View File

@@ -157,6 +157,10 @@ auto _ = {
"FHELinalg", "tests/end_to_end_fixture/end_to_end_fhelinalg.yaml"),
registerEndToEndTestFromFile(
"FHELinalg", "tests/end_to_end_fixture/end_to_end_programs.yaml",
0x8000000)};
0x8000000),
registerEndToEndTestFromFile(
"FHETLU",
"tests/end_to_end_fixture/end_to_end_linalg_apply_lookup_table.yaml"),
};
BENCHMARK_MAIN();

View File

@@ -0,0 +1,43 @@
from platform import mac_ver
import numpy as np
MIN_PRECISON = 1
MAX_PRECISION = 16
N_CT = [1, 10, 100, 1000, 10000]
def main():
print("# /!\ DO NOT EDIT MANUALLY THIS FILE MANUALLY")
print("# /!\ THIS FILE HAS BEEN GENERATED THANKS THE end_to_end_levelled_gen.py scripts")
np.random.seed(0)
for n_ct in N_CT:
for p in range(MIN_PRECISON, MAX_PRECISION+1):
if p != 1:
print("---")
max_value = (2 ** p) - 1
random_lut = np.random.randint(max_value+1, size=2**p)
# identity_apply_lookup_table
print(
"description: apply_lookup_table_{0}bits_{1}ct".format(p, n_ct))
print("program: |")
print(
" func.func @main(%arg0: tensor<{1}x!FHE.eint<{0}>>) -> tensor<{1}x!FHE.eint<{0}>> {{".format(p, n_ct))
print(" %tlu = arith.constant dense<[{0}]> : tensor<{1}xi64>".format(
','.join(map(str, random_lut)), 2**p))
print(
" %1 = \"FHELinalg.apply_lookup_table\"(%arg0, %tlu): (tensor<{2}x!FHE.eint<{0}>>, tensor<{1}xi64>) -> (tensor<{2}x!FHE.eint<{0}>>)".format(p, 2**p, n_ct))
print(" return %1: tensor<{1}x!FHE.eint<{0}>>".format(p, n_ct))
print(" }")
random_input = np.random.randint(max_value+1, size=n_ct)
print("tests:")
print(" - inputs:")
print(
" - tensor: [{0}]".format(','.join(map(str, random_input))))
print(" shape: [{0}]".format(n_ct))
outputs = np.vectorize(lambda i: random_lut[i])(random_input)
print(" outputs:")
print(" - tensor: [{0}]".format(','.join(map(str, outputs))))
print(" shape: [{0}]".format(n_ct))
main()