mirror of
https://github.com/zama-ai/tfhe-rs.git
synced 2026-01-10 07:08:03 -05:00
feat(tfhe): new tfhe-rs package, initial commit
This commit is contained in:
20
scripts/c_api_tests.sh
Executable file
20
scripts/c_api_tests.sh
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
CURR_DIR="$(dirname "$0")"
|
||||
ARCH_FEATURE="$("${CURR_DIR}/get_arch_feature.sh")"
|
||||
REPO_ROOT="${CURR_DIR}/.."
|
||||
TFHE_BUILD_DIR="${REPO_ROOT}/tfhe/build/"
|
||||
|
||||
mkdir -p "${TFHE_BUILD_DIR}"
|
||||
|
||||
cd "${TFHE_BUILD_DIR}"
|
||||
|
||||
cmake .. -DCMAKE_BUILD_TYPE=RELEASE
|
||||
|
||||
RUSTFLAGS="-C target-cpu=native" cargo ${1:+"${1}"} build \
|
||||
--release --features="${ARCH_FEATURE}",boolean-c-api,shortint-c-api -p tfhe
|
||||
|
||||
make -j
|
||||
make "test"
|
||||
19
scripts/get_arch_feature.sh
Executable file
19
scripts/get_arch_feature.sh
Executable file
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
ARCH_FEATURE=x86_64
|
||||
|
||||
IS_AARCH64="$( (uname -a | grep -c arm64) || true)"
|
||||
|
||||
if [[ "${IS_AARCH64}" != "0" ]]; then
|
||||
ARCH_FEATURE=aarch64
|
||||
fi
|
||||
|
||||
UNAME="$(uname)"
|
||||
|
||||
if [[ "${UNAME}" == "Linux" || "${UNAME}" == "Darwin" ]]; then
|
||||
ARCH_FEATURE="${ARCH_FEATURE}-unix"
|
||||
fi
|
||||
|
||||
echo "${ARCH_FEATURE}"
|
||||
60
scripts/shortint-tests.sh
Executable file
60
scripts/shortint-tests.sh
Executable file
@@ -0,0 +1,60 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
CURR_DIR="$(dirname "$0")"
|
||||
ARCH_FEATURE="$("${CURR_DIR}/get_arch_feature.sh")"
|
||||
|
||||
nproc_bin=nproc
|
||||
|
||||
# macOS detects CPUs differently
|
||||
if [[ $(uname) == "Darwin" ]]; then
|
||||
nproc_bin="sysctl -n hw.logicalcpu"
|
||||
fi
|
||||
|
||||
n_threads="$(${nproc_bin})"
|
||||
|
||||
if uname -a | grep "arm64"; then
|
||||
if [[ $(uname) == "Darwin" ]]; then
|
||||
# Keys are 4.7 gigs at max, CI M1 macs only has 8 gigs of RAM
|
||||
n_threads=1
|
||||
fi
|
||||
else
|
||||
# Keys are 4.7 gigs at max, test machine has 32 gigs of RAM
|
||||
n_threads=6
|
||||
fi
|
||||
|
||||
filter_expression=''\
|
||||
'('\
|
||||
' test(/^shortint::server_key::.*_param_message_1_carry_1$/)'\
|
||||
'or test(/^shortint::server_key::.*_param_message_1_carry_2$/)'\
|
||||
'or test(/^shortint::server_key::.*_param_message_1_carry_3$/)'\
|
||||
'or test(/^shortint::server_key::.*_param_message_1_carry_4$/)'\
|
||||
'or test(/^shortint::server_key::.*_param_message_1_carry_5$/)'\
|
||||
'or test(/^shortint::server_key::.*_param_message_1_carry_6$/)'\
|
||||
'or test(/^shortint::server_key::.*_param_message_2_carry_2$/)'\
|
||||
'or test(/^shortint::server_key::.*_param_message_3_carry_3$/)'\
|
||||
'or test(/^shortint::server_key::.*_param_message_4_carry_4$/)'\
|
||||
')'\
|
||||
'and not test(~smart_add_and_mul)' # This test is too slow
|
||||
|
||||
export RUSTFLAGS="-C target-cpu=native"
|
||||
|
||||
# Run tests only no examples or benches
|
||||
cargo ${1:+"${1}"} nextest run \
|
||||
--tests \
|
||||
--release \
|
||||
--package tfhe \
|
||||
--profile ci \
|
||||
--features="${ARCH_FEATURE}",shortint,internal-keycache \
|
||||
--test-threads "${n_threads}" \
|
||||
-E "${filter_expression}"
|
||||
|
||||
cargo ${1:+"${1}"} test \
|
||||
--release \
|
||||
--package tfhe \
|
||||
--features="${ARCH_FEATURE}",shortint,internal-keycache \
|
||||
--doc \
|
||||
shortint::
|
||||
|
||||
echo "Test ran in $SECONDS seconds"
|
||||
Reference in New Issue
Block a user