Skip to content

Commit

Permalink
Merge pull request #1130 from zama-ai/feat/tfhers-tensor
Browse files Browse the repository at this point in the history
Support TFHE-rs tensors
  • Loading branch information
youben11 authored Nov 7, 2024
2 parents dbf16ef + 89833b8 commit 2b5bd80
Show file tree
Hide file tree
Showing 16 changed files with 724 additions and 455 deletions.
18 changes: 11 additions & 7 deletions backends/concrete-cpu/implementation/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 5 additions & 7 deletions backends/concrete-cpu/implementation/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ crate-type = ["lib", "staticlib"]


[dependencies]
concrete-csprng = { git = "https://github.com/zama-ai/tfhe-rs.git", rev = "483a4fe", optional = true, features = [
"generator_fallback",
] }
concrete-csprng = { version = "0.4.1", optional = true, features = ["generator_fallback"] }
concrete-cpu-noise-model = { path = "../noise-model/" }
concrete-security-curves = { path = "../../../tools/parameter-curves/concrete-security-curves-rust" }
libc = { version = "0.2", default-features = false }
Expand All @@ -31,16 +29,16 @@ serde = "~1"
rayon = { version = "1.6", optional = true }
once_cell = { version = "1.16", optional = true }

tfhe = { git = "https://github.com/zama-ai/tfhe-rs.git", rev = "483a4fe", features = ["integer"] }
tfhe = { version = "0.8.6", features = ["integer"] }

[target.x86_64-unknown-unix-gnu.dependencies]
tfhe = { git = "https://github.com/zama-ai/tfhe-rs.git", rev = "483a4fe", features = ["integer", "x86_64-unix"] }
tfhe = { version = "0.8.6", features = ["integer", "x86_64-unix"] }

[target.aarch64-unknown-unix-gnu.dependencies]
tfhe = { git = "https://github.com/zama-ai/tfhe-rs.git", rev = "483a4fe", features = ["integer", "aarch64-unix"] }
tfhe = { version = "0.8.6", features = ["integer", "aarch64-unix"] }

[target.x86_64-pc-windows-gnu.dependencies]
tfhe = { git = "https://github.com/zama-ai/tfhe-rs.git", rev = "483a4fe", features = ["integer", "x86_64"] }
tfhe = { version = "0.8.6", features = ["integer", "x86_64"] }

[features]
default = ["parallel", "std", "csprng"]
Expand Down
14 changes: 9 additions & 5 deletions backends/concrete-cpu/implementation/include/concrete-cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -372,12 +372,14 @@ void concrete_cpu_keyswitch_lwe_ciphertext_u64(uint64_t *ct_out,
size_t concrete_cpu_lwe_array_to_tfhers_int8(const uint64_t *lwe_vec_buffer,
uint8_t *buffer,
size_t buffer_len,
struct TfhersFheIntDescription fheint_desc);
size_t n_elem,
struct TfhersFheIntDescription desc);

size_t concrete_cpu_lwe_array_to_tfhers_uint8(const uint64_t *lwe_vec_buffer,
uint8_t *buffer,
size_t buffer_len,
struct TfhersFheIntDescription fheuint_desc);
size_t n_elem,
struct TfhersFheIntDescription desc);

size_t concrete_cpu_lwe_ciphertext_size_u64(size_t lwe_dimension);

Expand Down Expand Up @@ -418,16 +420,18 @@ size_t concrete_cpu_serialize_lwe_secret_key_u64(const uint64_t *lwe_sk,
uint8_t *out_buffer,
size_t out_buffer_len);

size_t concrete_cpu_tfhers_fheint_buffer_size_u64(size_t lwe_size, size_t n_cts);
size_t concrete_cpu_tfhers_fheint_buffer_size_u64(size_t lwe_size, size_t n_cts, size_t n_elem);

int64_t concrete_cpu_tfhers_int8_to_lwe_array(const uint8_t *serialized_data_ptr,
size_t serialized_data_len,
int64_t concrete_cpu_tfhers_int8_to_lwe_array(const uint8_t *buffer,
size_t buffer_len,
uint64_t *lwe_vec_buffer,
size_t n_elem,
struct TfhersFheIntDescription desc);

int64_t concrete_cpu_tfhers_uint8_to_lwe_array(const uint8_t *buffer,
size_t buffer_len,
uint64_t *lwe_vec_buffer,
size_t n_elem,
struct TfhersFheIntDescription desc);

size_t concrete_cpu_tfhers_unknown_noise_level(void);
Expand Down
Loading

0 comments on commit 2b5bd80

Please sign in to comment.