From c35c57e508391a429c26729cbf0c9647eefd0681 Mon Sep 17 00:00:00 2001 From: Luis Montero Date: Wed, 5 Jun 2024 10:40:45 +0200 Subject: [PATCH] chore: exact to appox --- .../cifar_brevitas_training/evaluate_one_example_fhe.py | 6 ++++-- .../cifar/cifar_brevitas_training/evaluate_torch_cml.py | 7 ++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/use_case_examples/cifar/cifar_brevitas_training/evaluate_one_example_fhe.py b/use_case_examples/cifar/cifar_brevitas_training/evaluate_one_example_fhe.py index a290f03d6..b87fb5743 100644 --- a/use_case_examples/cifar/cifar_brevitas_training/evaluate_one_example_fhe.py +++ b/use_case_examples/cifar/cifar_brevitas_training/evaluate_one_example_fhe.py @@ -84,11 +84,13 @@ def wrapper(*args, **kwargs): # Multi-parameter strategy is used in order to speed-up the FHE executions base_configuration = Configuration() +exactness = fhe.Exactness.APPROXIMATE + tlu_optimizer = TLU1bitDecomposition( n_jumps_limit=2, - exactness=fhe.Exactness.EXACT, + exactness=exactness, ) -rounding = InsertRounding(6) +rounding = InsertRounding(6, exactness=exactness) configuration = Configuration( dump_artifacts_on_unexpected_failures=False, diff --git a/use_case_examples/cifar/cifar_brevitas_training/evaluate_torch_cml.py b/use_case_examples/cifar/cifar_brevitas_training/evaluate_torch_cml.py index aac92b5b6..b9473cf5c 100644 --- a/use_case_examples/cifar/cifar_brevitas_training/evaluate_torch_cml.py +++ b/use_case_examples/cifar/cifar_brevitas_training/evaluate_torch_cml.py @@ -36,7 +36,7 @@ def evaluate(torch_model, cml_model, device, num_workers): # Import and load the CIFAR test dataset (following bnn_pynq_train.py) test_set = get_test_set(dataset="CIFAR10", datadir=CURRENT_DIR / ".datasets/") - test_set = Subset(test_set, np.arange(128)) + # test_set = Subset(test_set, np.arange(128)) test_loader = DataLoader(test_set, batch_size=128, shuffle=False, num_workers=num_workers) torch_top_1_batches = [] @@ -121,12 +121,13 @@ def main(args): # Eval mode model.eval() + exactness=fhe.Exactness.APPROXIMATE # Multi-parameter strategy is used in order to speed-up the FHE executions tlu_optimizer = TLU1bitDecomposition( n_jumps_limit=2, - exactness=fhe.Exactness.EXACT, + exactness=exactness, ) - insert_rounding = InsertRounding(6) + insert_rounding = InsertRounding(6,exactness=exactness) # debug_processor = Debug() cfg = Configuration( verbose=True,