Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix test_separated_inference in weekly CI #347

Merged
merged 1 commit into from
Oct 9, 2023
Merged
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
22 changes: 16 additions & 6 deletions tests/sklearn/test_sklearn_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,14 +582,24 @@ def check_separated_inference(model, fhe_circuit, x, check_float_array_equal):
# Quantize an input (float)
q_x = model.quantize_input(x)

# Encrypt the input
q_x_encrypted = fhe_circuit.encrypt(q_x)
q_y_pred_list = []
for q_x_i in q_x:
# Expected input shape for 'encrypt' method is (1, n_features) while q_x_i
# is of shape (n_features,)
q_x_i = numpy.expand_dims(q_x_i, 0)

# Execute the linear product in FHE
q_y_pred_encrypted = fhe_circuit.run(q_x_encrypted)
# Encrypt the input
q_x_encrypted_i = fhe_circuit.encrypt(q_x_i)

# Decrypt the result (integer)
q_y_pred = fhe_circuit.decrypt(q_y_pred_encrypted)
# Execute the linear product in FHE
q_y_pred_encrypted_i = fhe_circuit.run(q_x_encrypted_i)

# Decrypt the result (integer)
q_y_pred_i = fhe_circuit.decrypt(q_y_pred_encrypted_i)

q_y_pred_list.append(q_y_pred_i[0])

q_y_pred = numpy.array(q_y_pred_list)

# De-quantize the result
y_pred = model.dequantize_output(q_y_pred)
Expand Down
Loading