Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 2 additions & 25 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -23,33 +23,10 @@ llvm.configure(
use_repo(llvm, hermetic_llvm = "llvm-project")

# Macros for building with HEIR
bazel_dep(name = "rules_heir", version = "0.1.1")
bazel_dep(name = "rules_heir", version = "0.1.2")

heir_repos = use_extension("@rules_heir//heir:extensions.bzl", "heir_repositories")
heir_repos.platform(
cpu = "x86_64",
heir_opt_sha256 = "919bca7b663e73ad4c550f0145cf3d66c70812d9d77adeabb23275f13874b0af",
heir_opt_url = "https://github.com/google/heir/releases/download/v2026.08.11.dev0/heir-opt-manylinux_2_28_x86_64",
heir_translate_sha256 = "5f184dcbe350ae0a2cfdfa3ca364a02cfa827bdebedab208ada3a529f8acab1d",
heir_translate_url = "https://github.com/google/heir/releases/download/v2026.08.11.dev0/heir-translate-manylinux_2_28_x86_64",
os = "linux",
)
heir_repos.platform(
cpu = "aarch64",
heir_opt_sha256 = "136d29bc519126ae1032789ffdccebd097b27bbcc54dbc02146d2e0ad1c4bcdf",
heir_opt_url = "https://github.com/google/heir/releases/download/v2026.08.11.dev0/heir-opt-manylinux_2_28_aarch64",
heir_translate_sha256 = "b71b17bf0548c48503d2c9ecc17e230f85bb679bb8d4fc62a7b4c05168e6d1f8",
heir_translate_url = "https://github.com/google/heir/releases/download/v2026.08.11.dev0/heir-translate-manylinux_2_28_aarch64",
os = "linux",
)
heir_repos.platform(
cpu = "arm64",
heir_opt_sha256 = "4a1490bcbb157d1437bc600c4a79790baa64069ee29fe0ba210401baa2de9543",
heir_opt_url = "https://github.com/google/heir/releases/download/v2026.08.11.dev0/heir-opt-macosx_11_0_arm64",
heir_translate_sha256 = "bc58ae375b9ead6b2259fcf6f3b1f43af49880f4019839db11ad6af199aaaaa2",
heir_translate_url = "https://github.com/google/heir/releases/download/v2026.08.11.dev0/heir-translate-macosx_11_0_arm64",
os = "macos",
)
heir_repos.config(nightly = True)
use_repo(
heir_repos,
"heir_linux_aarch64",
Expand Down
5 changes: 5 additions & 0 deletions demos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ This directory contains a set of demos using HEIR to compile pre-trained
PyTorch models to FHE. All of the models are pre-compiled with scripts
providing command to quickly run and assess model performance.

**Note:** Occasionally the HEIR developers make API-backwards incompatible
changes to the generated APIs, which will cause some of these examples
to fail to compile until the following day, when HEIR's nightly build
runs and produces a new binary.

## MNIST

The classic [MNIST](https://en.wikipedia.org/wiki/MNIST_database) digit
Expand Down
18 changes: 9 additions & 9 deletions demos/cc_fraud/debug/model_debug.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#map1 = affine_map<(d0, d1) -> (d1)>
module {
func.func @cc_fraud(%arg0: tensor<1x82xf32> {secret.secret}) -> tensor<1x2xf32> {
debug.validate %arg0 {name = "input", metadata = "input"} : tensor<1x82xf32>
debug.validate %arg0 <name = "input", metadata = "input"> : tensor<1x82xf32>
%cst = arith.constant 0.000000e+00 : f32
%cst_0 = arith.constant 1.000000e+00 : f32
%cst_1 = arith.constant dense_resource<torch_tensor_2_torch.float32> : tensor<2xf32>
Expand All @@ -16,13 +16,13 @@ module {
%1 = tensor.empty() : tensor<1x128xf32>
%2 = linalg.fill ins(%cst : f32) outs(%1 : tensor<1x128xf32>) -> tensor<1x128xf32>
%3 = linalg.matmul ins(%arg0, %transposed : tensor<1x82xf32>, tensor<82x128xf32>) outs(%2 : tensor<1x128xf32>) -> tensor<1x128xf32>
debug.validate %3 {name = "layer1_matmul", metadata = "layer1_matmul"} : tensor<1x128xf32>
debug.validate %3 <name = "layer1_matmul", metadata = "layer1_matmul"> : tensor<1x128xf32>
%4 = linalg.generic {indexing_maps = [#map, #map1, #map], iterator_types = ["parallel", "parallel"]} ins(%3, %cst_6 : tensor<1x128xf32>, tensor<128xf32>) outs(%1 : tensor<1x128xf32>) {
^bb0(%in: f32, %in_9: f32, %out: f32):
%17 = arith.addf %in, %in_9 : f32
linalg.yield %17 : f32
} -> tensor<1x128xf32>
debug.validate %4 {name = "layer1_bias", metadata = "layer1_bias"} : tensor<1x128xf32>
debug.validate %4 <name = "layer1_bias", metadata = "layer1_bias"> : tensor<1x128xf32>
%5 = linalg.generic {degree = 7 : i32, domain_lower = -10.000000e+00 : f64, domain_upper = 10.000000e+00 : f64, indexing_maps = [#map, #map], iterator_types = ["parallel", "parallel"]} ins(%4 : tensor<1x128xf32>) outs(%1 : tensor<1x128xf32>) {
^bb0(%in: f32, %out: f32):
%17 = arith.negf %in : f32
Expand All @@ -31,19 +31,19 @@ module {
%20 = arith.divf %cst_0, %19 : f32
linalg.yield %20 : f32
} -> tensor<1x128xf32>
debug.validate %5 {name = "layer1_sigmoid", metadata = "layer1_sigmoid"} : tensor<1x128xf32>
debug.validate %5 <name = "layer1_sigmoid", metadata = "layer1_sigmoid"> : tensor<1x128xf32>
%6 = tensor.empty() : tensor<128x64xf32>
%transposed_7 = linalg.transpose ins(%cst_4 : tensor<64x128xf32>) outs(%6 : tensor<128x64xf32>) permutation = [1, 0]
%7 = tensor.empty() : tensor<1x64xf32>
%8 = linalg.fill ins(%cst : f32) outs(%7 : tensor<1x64xf32>) -> tensor<1x64xf32>
%9 = linalg.matmul ins(%5, %transposed_7 : tensor<1x128xf32>, tensor<128x64xf32>) outs(%8 : tensor<1x64xf32>) -> tensor<1x64xf32>
debug.validate %9 {name = "layer2_matmul", metadata = "layer2_matmul"} : tensor<1x64xf32>
debug.validate %9 <name = "layer2_matmul", metadata = "layer2_matmul"> : tensor<1x64xf32>
%10 = linalg.generic {indexing_maps = [#map, #map1, #map], iterator_types = ["parallel", "parallel"]} ins(%9, %cst_3 : tensor<1x64xf32>, tensor<64xf32>) outs(%7 : tensor<1x64xf32>) {
^bb0(%in: f32, %in_9: f32, %out: f32):
%17 = arith.addf %in, %in_9 : f32
linalg.yield %17 : f32
} -> tensor<1x64xf32>
debug.validate %10 {name = "layer2_bias", metadata = "layer2_bias"} : tensor<1x64xf32>
debug.validate %10 <name = "layer2_bias", metadata = "layer2_bias"> : tensor<1x64xf32>
%11 = linalg.generic {degree = 7 : i32, domain_lower = -10.000000e+00 : f64, domain_upper = 10.000000e+00 : f64, indexing_maps = [#map, #map], iterator_types = ["parallel", "parallel"]} ins(%10 : tensor<1x64xf32>) outs(%7 : tensor<1x64xf32>) {
^bb0(%in: f32, %out: f32):
%17 = arith.negf %in : f32
Expand All @@ -52,19 +52,19 @@ module {
%20 = arith.divf %cst_0, %19 : f32
linalg.yield %20 : f32
} -> tensor<1x64xf32>
debug.validate %11 {name = "layer2_sigmoid", metadata = "layer2_sigmoid"} : tensor<1x64xf32>
debug.validate %11 <name = "layer2_sigmoid", metadata = "layer2_sigmoid"> : tensor<1x64xf32>
%12 = tensor.empty() : tensor<64x2xf32>
%transposed_8 = linalg.transpose ins(%cst_2 : tensor<2x64xf32>) outs(%12 : tensor<64x2xf32>) permutation = [1, 0]
%13 = tensor.empty() : tensor<1x2xf32>
%14 = linalg.fill ins(%cst : f32) outs(%13 : tensor<1x2xf32>) -> tensor<1x2xf32>
%15 = linalg.matmul ins(%11, %transposed_8 : tensor<1x64xf32>, tensor<64x2xf32>) outs(%14 : tensor<1x2xf32>) -> tensor<1x2xf32>
debug.validate %15 {name = "layer3_matmul", metadata = "layer3_matmul"} : tensor<1x2xf32>
debug.validate %15 <name = "layer3_matmul", metadata = "layer3_matmul"> : tensor<1x2xf32>
%16 = linalg.generic {indexing_maps = [#map, #map1, #map], iterator_types = ["parallel", "parallel"]} ins(%15, %cst_1 : tensor<1x2xf32>, tensor<2xf32>) outs(%13 : tensor<1x2xf32>) {
^bb0(%in: f32, %in_9: f32, %out: f32):
%17 = arith.addf %in, %in_9 : f32
linalg.yield %17 : f32
} -> tensor<1x2xf32>
debug.validate %16 {name = "layer3_bias", metadata = "layer3_bias"} : tensor<1x2xf32>
debug.validate %16 <name = "layer3_bias", metadata = "layer3_bias"> : tensor<1x2xf32>
return %16 : tensor<1x2xf32>
}
}
Expand Down
18 changes: 9 additions & 9 deletions demos/cc_fraud/debug/model_timing.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#map1 = affine_map<(d0, d1) -> (d1)>
module {
func.func @cc_fraud(%arg0: tensor<1x82xf32> {secret.secret}) -> tensor<1x2xf32> {
debug.validate %arg0 {name = "input", metadata = "input"} : tensor<1x82xf32>
debug.validate %arg0 <name = "input", metadata = "input"> : tensor<1x82xf32>
%cst = arith.constant 0.000000e+00 : f32
%cst_0 = arith.constant 1.000000e+00 : f32
%cst_1 = arith.constant dense_resource<torch_tensor_2_torch.float32> : tensor<2xf32>
Expand All @@ -16,13 +16,13 @@ module {
%1 = tensor.empty() : tensor<1x128xf32>
%2 = linalg.fill ins(%cst : f32) outs(%1 : tensor<1x128xf32>) -> tensor<1x128xf32>
%3 = linalg.matmul ins(%arg0, %transposed : tensor<1x82xf32>, tensor<82x128xf32>) outs(%2 : tensor<1x128xf32>) -> tensor<1x128xf32>
debug.validate %3 {name = "layer1_matmul", metadata = "layer1_matmul"} : tensor<1x128xf32>
debug.validate %3 <name = "layer1_matmul", metadata = "layer1_matmul"> : tensor<1x128xf32>
%4 = linalg.generic {indexing_maps = [#map, #map1, #map], iterator_types = ["parallel", "parallel"]} ins(%3, %cst_6 : tensor<1x128xf32>, tensor<128xf32>) outs(%1 : tensor<1x128xf32>) {
^bb0(%in: f32, %in_9: f32, %out: f32):
%17 = arith.addf %in, %in_9 : f32
linalg.yield %17 : f32
} -> tensor<1x128xf32>
debug.validate %4 {name = "layer1_bias", metadata = "layer1_bias"} : tensor<1x128xf32>
debug.validate %4 <name = "layer1_bias", metadata = "layer1_bias"> : tensor<1x128xf32>
%5 = linalg.generic {degree = 3 : i32, domain_lower = -10.000000e+00 : f64, domain_upper = 10.000000e+00 : f64, indexing_maps = [#map, #map], iterator_types = ["parallel", "parallel"]} ins(%4 : tensor<1x128xf32>) outs(%1 : tensor<1x128xf32>) {
^bb0(%in: f32, %out: f32):
%17 = arith.negf %in : f32
Expand All @@ -31,19 +31,19 @@ module {
%20 = arith.divf %cst_0, %19 : f32
linalg.yield %20 : f32
} -> tensor<1x128xf32>
debug.validate %5 {name = "layer1_sigmoid", metadata = "layer1_sigmoid"} : tensor<1x128xf32>
debug.validate %5 <name = "layer1_sigmoid", metadata = "layer1_sigmoid"> : tensor<1x128xf32>
%6 = tensor.empty() : tensor<128x64xf32>
%transposed_7 = linalg.transpose ins(%cst_4 : tensor<64x128xf32>) outs(%6 : tensor<128x64xf32>) permutation = [1, 0]
%7 = tensor.empty() : tensor<1x64xf32>
%8 = linalg.fill ins(%cst : f32) outs(%7 : tensor<1x64xf32>) -> tensor<1x64xf32>
%9 = linalg.matmul ins(%5, %transposed_7 : tensor<1x128xf32>, tensor<128x64xf32>) outs(%8 : tensor<1x64xf32>) -> tensor<1x64xf32>
debug.validate %9 {name = "layer2_matmul", metadata = "layer2_matmul"} : tensor<1x64xf32>
debug.validate %9 <name = "layer2_matmul", metadata = "layer2_matmul"> : tensor<1x64xf32>
%10 = linalg.generic {indexing_maps = [#map, #map1, #map], iterator_types = ["parallel", "parallel"]} ins(%9, %cst_3 : tensor<1x64xf32>, tensor<64xf32>) outs(%7 : tensor<1x64xf32>) {
^bb0(%in: f32, %in_9: f32, %out: f32):
%17 = arith.addf %in, %in_9 : f32
linalg.yield %17 : f32
} -> tensor<1x64xf32>
debug.validate %10 {name = "layer2_bias", metadata = "layer2_bias"} : tensor<1x64xf32>
debug.validate %10 <name = "layer2_bias", metadata = "layer2_bias"> : tensor<1x64xf32>
%11 = linalg.generic {degree = 3 : i32, domain_lower = -10.000000e+00 : f64, domain_upper = 10.000000e+00 : f64, indexing_maps = [#map, #map], iterator_types = ["parallel", "parallel"]} ins(%10 : tensor<1x64xf32>) outs(%7 : tensor<1x64xf32>) {
^bb0(%in: f32, %out: f32):
%17 = arith.negf %in : f32
Expand All @@ -52,19 +52,19 @@ module {
%20 = arith.divf %cst_0, %19 : f32
linalg.yield %20 : f32
} -> tensor<1x64xf32>
debug.validate %11 {name = "layer2_sigmoid", metadata = "layer2_sigmoid"} : tensor<1x64xf32>
debug.validate %11 <name = "layer2_sigmoid", metadata = "layer2_sigmoid"> : tensor<1x64xf32>
%12 = tensor.empty() : tensor<64x2xf32>
%transposed_8 = linalg.transpose ins(%cst_2 : tensor<2x64xf32>) outs(%12 : tensor<64x2xf32>) permutation = [1, 0]
%13 = tensor.empty() : tensor<1x2xf32>
%14 = linalg.fill ins(%cst : f32) outs(%13 : tensor<1x2xf32>) -> tensor<1x2xf32>
%15 = linalg.matmul ins(%11, %transposed_8 : tensor<1x64xf32>, tensor<64x2xf32>) outs(%14 : tensor<1x2xf32>) -> tensor<1x2xf32>
debug.validate %15 {name = "layer3_matmul", metadata = "layer3_matmul"} : tensor<1x2xf32>
debug.validate %15 <name = "layer3_matmul", metadata = "layer3_matmul"> : tensor<1x2xf32>
%16 = linalg.generic {indexing_maps = [#map, #map1, #map], iterator_types = ["parallel", "parallel"]} ins(%15, %cst_1 : tensor<1x2xf32>, tensor<2xf32>) outs(%13 : tensor<1x2xf32>) {
^bb0(%in: f32, %in_9: f32, %out: f32):
%17 = arith.addf %in, %in_9 : f32
linalg.yield %17 : f32
} -> tensor<1x2xf32>
debug.validate %16 {name = "layer3_bias", metadata = "layer3_bias"} : tensor<1x2xf32>
debug.validate %16 <name = "layer3_bias", metadata = "layer3_bias"> : tensor<1x2xf32>
return %16 : tensor<1x2xf32>
}
}
Expand Down
5 changes: 2 additions & 3 deletions demos/cc_fraud/lattigo/evaluate_fhe.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,10 @@ func main() {
// FHE evaluation
fmt.Println("Running FHE evaluation (preprocessed)...")
t0 = time.Now()
ctZero1 := fraud_model_lattigo.Cc_fraud__encrypt__zero__0(evaluator, params, ecd, encryptor)
ctZero2 := fraud_model_lattigo.Cc_fraud__encrypt__zero__1(evaluator, params, ecd, encryptor)
ctZeros := fraud_model_lattigo.Cc_fraud__encrypt__zeros(evaluator, params, ecd, encryptor)
encryptedOutput := fraud_model_lattigo.Cc_fraud__preprocessed(
evaluator, params, ecd, encryptedFeatures,
ctZero1, ctZero2,
ctZeros,
preprocessedWeights,
)
fmt.Printf(" Took %v\n", time.Since(t0))
Expand Down
5 changes: 2 additions & 3 deletions demos/cc_fraud/lattigo/evaluate_fhe_debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,10 @@ func main() {
// FHE evaluation (with debug callbacks)
fmt.Println("\n--- Starting FHE Evaluation (with Debug Callbacks) ---")
t0 = time.Now()
ctZero1 := fraud_model_lattigo_debug.Cc_fraud__encrypt__zero__0(evaluator, params, ecd, encryptor)
ctZero2 := fraud_model_lattigo_debug.Cc_fraud__encrypt__zero__1(evaluator, params, ecd, encryptor)
ctZeros := fraud_model_lattigo_debug.Cc_fraud__encrypt__zeros(evaluator, params, ecd, encryptor)
encryptedOutput := fraud_model_lattigo_debug.Cc_fraud__preprocessed(
evaluator, params, ecd, decryptor, encryptedFeatures,
ctZero1, ctZero2,
ctZeros,
preprocessedWeights,
)
fmt.Printf("--- FHE Evaluation Completed in %v ---\n\n", time.Since(t0))
Expand Down
8 changes: 3 additions & 5 deletions demos/cc_fraud/lattigo/evaluate_fhe_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,10 @@ func main() {
fmt.Println("Encrypting all input features and zero accumulators sequentially...")
t0 = time.Now()
encryptedInputs := make([][]*rlwe.Ciphertext, numRows)
ctZeros1 := make([]*rlwe.Ciphertext, numRows)
ctZeros2 := make([]*rlwe.Ciphertext, numRows)
ctZeros := make([][]*rlwe.Ciphertext, numRows)
for i := 0; i < numRows; i++ {
encryptedInputs[i] = fraud_model_lattigo.Cc_fraud__encrypt__arg0(evaluator, params, ecd, encryptor, allFeatures[i])
ctZeros1[i] = fraud_model_lattigo.Cc_fraud__encrypt__zero__0(evaluator, params, ecd, encryptor)
ctZeros2[i] = fraud_model_lattigo.Cc_fraud__encrypt__zero__1(evaluator, params, ecd, encryptor)
ctZeros[i] = fraud_model_lattigo.Cc_fraud__encrypt__zeros(evaluator, params, ecd, encryptor)
}
fmt.Printf(" Took %v\n", time.Since(t0))

Expand All @@ -67,7 +65,7 @@ func main() {
localEvaluator := evaluator.ShallowCopy()
encryptedOutputs[idx] = fraud_model_lattigo.Cc_fraud__preprocessed(
localEvaluator, params, ecd, encryptedInputs[idx],
ctZeros1[idx], ctZeros2[idx],
ctZeros[idx],
preprocessedWeights,
)
}(i)
Expand Down
5 changes: 2 additions & 3 deletions demos/cc_fraud/lattigo/evaluate_fhe_timing.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,10 @@ func main() {
// FHE evaluation (preprocessed with timing callbacks)
fmt.Println("Running FHE evaluation (preprocessed with timing callbacks)...")
t0 = time.Now()
ctZero1 := fraud_model_lattigo_timing.Cc_fraud__encrypt__zero__0(evaluator, params, ecd, encryptor)
ctZero2 := fraud_model_lattigo_timing.Cc_fraud__encrypt__zero__1(evaluator, params, ecd, encryptor)
ctZeros := fraud_model_lattigo_timing.Cc_fraud__encrypt__zeros(evaluator, params, ecd, encryptor)
encryptedOutput := fraud_model_lattigo_timing.Cc_fraud__preprocessed(
evaluator, params, ecd, decryptor, encryptedFeatures,
ctZero1, ctZero2,
ctZeros,
preprocessedWeights,
)
fmt.Printf(" Took %v\n", time.Since(t0))
Expand Down
6 changes: 2 additions & 4 deletions demos/cc_fraud/openfhe/evaluate_fhe.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,11 @@ def main():
# Call the FHE function
print("Running FHE evaluation (preprocessed)...")
t0 = time.time()
ct_zero_1 = fraud_model_pybind.cc_fraud__encrypt__zero__0(cc, public_key)
ct_zero_2 = fraud_model_pybind.cc_fraud__encrypt__zero__1(cc, public_key)
ct_zeros = fraud_model_pybind.cc_fraud__encrypt__zeros(cc, public_key)
encrypted_output = fraud_model_pybind.cc_fraud__preprocessed(
cc,
encrypted_features,
ct_zero_1,
ct_zero_2,
ct_zeros,
prep_struct,
)
print(f" Took {time.time() - t0:.4f} seconds")
Expand Down
6 changes: 2 additions & 4 deletions demos/cc_fraud/openfhe/evaluate_fhe_debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,12 @@ def main():
# for debug)
print("\n--- Starting FHE Evaluation (with Debug Callbacks) ---")
t0 = time.time()
ct_zero_1 = fraud_model_pybind.cc_fraud__encrypt__zero__0(cc, public_key)
ct_zero_2 = fraud_model_pybind.cc_fraud__encrypt__zero__1(cc, public_key)
ct_zeros = fraud_model_pybind.cc_fraud__encrypt__zeros(cc, public_key)
encrypted_output = fraud_model_pybind.cc_fraud__preprocessed(
cc,
secret_key,
encrypted_features,
ct_zero_1,
ct_zero_2,
ct_zeros,
prep_struct,
)
print(f"--- FHE Evaluation Completed in {time.time() - t0:.4f} seconds ---\n")
Expand Down
6 changes: 2 additions & 4 deletions demos/cc_fraud/openfhe/evaluate_fhe_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,13 @@ def main():
encrypted_features = fraud_model_pybind.cc_fraud__encrypt__arg0(
cc, features, public_key
)
ct_zero_1 = fraud_model_pybind.cc_fraud__encrypt__zero__0(cc, public_key)
ct_zero_2 = fraud_model_pybind.cc_fraud__encrypt__zero__1(cc, public_key)
ct_zeros = fraud_model_pybind.cc_fraud__encrypt__zeros(cc, public_key)

# Call the FHE function (using preprocessed weights)
encrypted_output = fraud_model_pybind.cc_fraud__preprocessed(
cc,
encrypted_features,
ct_zero_1,
ct_zero_2,
ct_zeros,
prep_struct,
)

Expand Down
10 changes: 2 additions & 8 deletions demos/cc_fraud/openfhe/evaluate_fhe_timing.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,12 @@ def main():

print("Running FHE evaluation (preprocessed with timing callbacks)...")
t0 = time.time()
ct_zero_1 = fraud_model_timing_pybind.cc_fraud__encrypt__zero__0(
cc, public_key
)
ct_zero_2 = fraud_model_timing_pybind.cc_fraud__encrypt__zero__1(
cc, public_key
)
ct_zeros = fraud_model_timing_pybind.cc_fraud__encrypt__zeros(cc, public_key)
encrypted_output = fraud_model_timing_pybind.cc_fraud__preprocessed(
cc,
secret_key,
encrypted_features,
ct_zero_1,
ct_zero_2,
ct_zeros,
prep_struct,
)
print(f" Took {time.time() - t0:.4f} seconds")
Expand Down
10 changes: 2 additions & 8 deletions demos/criteo/lattigo/evaluate_fhe.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,7 @@ func main() {

fmt.Println("Encrypting zeros...")
t0 = time.Now()
zero0 := criteo.Run_inference__encrypt__zero__0(evaluator, params, encoder, encryptor)
zero1 := criteo.Run_inference__encrypt__zero__1(evaluator, params, encoder, encryptor)
zero2 := criteo.Run_inference__encrypt__zero__2(evaluator, params, encoder, encryptor)
zero3 := criteo.Run_inference__encrypt__zero__3(evaluator, params, encoder, encryptor)
zero4 := criteo.Run_inference__encrypt__zero__4(evaluator, params, encoder, encryptor)
zero5 := criteo.Run_inference__encrypt__zero__5(evaluator, params, encoder, encryptor)
zero6 := criteo.Run_inference__encrypt__zero__6(evaluator, params, encoder, encryptor)
ctZeros := criteo.Run_inference__encrypt__zeros(evaluator, params, encoder, encryptor)
fmt.Printf(" Took %v\n", time.Since(t0))

fmt.Println("Running preprocessing...")
Expand All @@ -61,7 +55,7 @@ func main() {
encryptedOutput := criteo.Run_inference__preprocessed(
bootstrappingEvaluator, evaluator, params, encoder,
cts0, cts1, cts2,
zero0, zero1, zero2, zero3, zero4, zero5, zero6,
ctZeros,
preprocessedWeights,
)
fmt.Printf(" Took %v\n", time.Since(t0))
Expand Down
Loading
Loading