Skip to content

Commit

Permalink
test(compiler): Test compress_input_ciphertext + simulation
Browse files Browse the repository at this point in the history
  • Loading branch information
BourgerieQuentin committed Apr 8, 2024
1 parent 364d56c commit 52f0292
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,10 @@ class TestProgram {

Result<ClientCircuit> getClientCircuit(std::string name = "main") {
OUTCOME_TRY(auto lib, getLibrary());
OUTCOME_TRY(auto ks, getKeyset());
Keyset ks{};
if (!isSimulation()) {
OUTCOME_TRY(ks, getKeyset());
}
auto programInfo = lib.getProgramInfo();
OUTCOME_TRY(auto clientProgram,
ClientProgram::create(programInfo, ks.client, encryptionCsprng,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -496,3 +496,18 @@ func.func @dec(%arg0: !FHE.eint<3>) -> !FHE.eint<3> {
ASSERT_EQ(lambda_dec({Tensor<uint64_t>(1)}), (uint64_t)0);
ASSERT_EQ(lambda_dec({Tensor<uint64_t>(4)}), (uint64_t)3);
}

/// https://github.com/zama-ai/concrete-internal/issues/655
TEST(CompileAndRun, compress_input_and_simulate) {
mlir::concretelang::CompilationOptions options;
options.compressInputCiphertexts = true;
options.simulate = true;
TestProgram circuit(options);
ASSERT_OUTCOME_HAS_VALUE(circuit.compile(R"XXX(
func.func @main(%arg0: !FHE.eint<3>) -> !FHE.eint<3> {
return %arg0: !FHE.eint<3>
}
)XXX"));
ASSERT_ASSIGN_OUTCOME_VALUE(result, circuit.call({Tensor<uint64_t>(7)}));
ASSERT_EQ(result[0].getTensor<uint64_t>().value()[0], (uint64_t)(7));
}

0 comments on commit 52f0292

Please sign in to comment.