mirror of
https://github.com/zama-ai/concrete.git
synced 2026-02-08 19:44:57 -05:00
test: add chunked eint e2e tests
This commit is contained in:
@@ -238,6 +238,9 @@ run-rust-tests: rust-bindings
|
||||
|
||||
## end-to-end-tests
|
||||
|
||||
build-end-to-end-jit-chunked-int: build-initialized
|
||||
cmake --build $(BUILD_DIR) --target end_to_end_jit_chunked_int
|
||||
|
||||
build-end-to-end-jit-test: build-initialized
|
||||
cmake --build $(BUILD_DIR) --target end_to_end_jit_test
|
||||
|
||||
@@ -253,7 +256,7 @@ build-end-to-end-jit-fhelinalg: build-initialized
|
||||
build-end-to-end-jit-lambda: build-initialized
|
||||
cmake --build $(BUILD_DIR) --target end_to_end_jit_lambda
|
||||
|
||||
build-end-to-end-tests: build-end-to-end-jit-test build-end-to-end-test build-end-to-end-jit-encrypted-tensor build-end-to-end-jit-fhelinalg build-end-to-end-jit-lambda
|
||||
build-end-to-end-tests: build-end-to-end-jit-chunked-int build-end-to-end-jit-test build-end-to-end-test build-end-to-end-jit-encrypted-tensor build-end-to-end-jit-fhelinalg build-end-to-end-jit-lambda
|
||||
|
||||
### end-to-end-tests CPU
|
||||
|
||||
|
||||
@@ -20,6 +20,8 @@ if(CONCRETELANG_DATAFLOW_EXECUTION_ENABLED)
|
||||
add_compile_options(-DCONCRETELANG_DATAFLOW_TESTING_ENABLED)
|
||||
endif()
|
||||
|
||||
add_concretecompiler_unittest(end_to_end_jit_chunked_int end_to_end_jit_chunked_int.cc globals.cc)
|
||||
|
||||
add_concretecompiler_unittest(end_to_end_jit_test end_to_end_jit_test.cc globals.cc)
|
||||
|
||||
add_concretecompiler_unittest(end_to_end_jit_encrypted_tensor end_to_end_jit_encrypted_tensor.cc globals.cc)
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "end_to_end_jit_test.h"
|
||||
#include "tests_tools/GtestEnvironment.h"
|
||||
|
||||
TEST(Lambda_chunked_int, chunked_int_add_eint) {
|
||||
checkedJit(lambda, R"XXX(
|
||||
func.func @main(%arg0: !FHE.eint<64>, %arg1: !FHE.eint<64>) -> !FHE.eint<64> {
|
||||
%1 = "FHE.add_eint"(%arg0, %arg1): (!FHE.eint<64>, !FHE.eint<64>) -> (!FHE.eint<64>)
|
||||
return %1: !FHE.eint<64>
|
||||
}
|
||||
)XXX",
|
||||
"main", DEFAULT_useDefaultFHEConstraints,
|
||||
DEFAULT_dataflowParallelize, DEFAULT_loopParallelize,
|
||||
DEFAULT_batchConcreteOps, DEFAULT_global_p_error, true, 4, 2);
|
||||
ASSERT_EXPECTED_VALUE(lambda(1_u64, 2_u64), (uint64_t)3);
|
||||
ASSERT_EXPECTED_VALUE(lambda(72057594037927936_u64, 10000_u64),
|
||||
(uint64_t)72057594037937936);
|
||||
ASSERT_EXPECTED_VALUE(lambda(2057594037927936_u64, 1111_u64),
|
||||
(uint64_t)2057594037929047);
|
||||
}
|
||||
@@ -12,20 +12,38 @@
|
||||
#include "globals.h"
|
||||
#include "tests_tools/assert.h"
|
||||
|
||||
llvm::StringRef DEFAULT_func = "main";
|
||||
bool DEFAULT_useDefaultFHEConstraints = false;
|
||||
bool DEFAULT_dataflowParallelize = false;
|
||||
bool DEFAULT_loopParallelize = false;
|
||||
bool DEFAULT_batchConcreteOps = false;
|
||||
double DEFAULT_global_p_error = TEST_ERROR_RATE;
|
||||
bool DEFAULT_chunkedIntegers = false;
|
||||
unsigned int DEFAULT_chunkSize = 4;
|
||||
unsigned int DEFAULT_chunkWidth = 2;
|
||||
|
||||
// Jit-compiles the function specified by `func` from `src` and
|
||||
// returns the corresponding lambda. Any compilation errors are caught
|
||||
// and reult in abnormal termination.
|
||||
inline llvm::Expected<
|
||||
mlir::concretelang::ClientServer<mlir::concretelang::JITSupport>>
|
||||
internalCheckedJit(llvm::StringRef src, llvm::StringRef func = "main",
|
||||
bool useDefaultFHEConstraints = false,
|
||||
bool dataflowParallelize = false,
|
||||
bool loopParallelize = false, bool batchConcreteOps = false,
|
||||
double global_p_error = TEST_ERROR_RATE) {
|
||||
internalCheckedJit(
|
||||
llvm::StringRef src, llvm::StringRef func = DEFAULT_func,
|
||||
bool useDefaultFHEConstraints = DEFAULT_useDefaultFHEConstraints,
|
||||
bool dataflowParallelize = DEFAULT_dataflowParallelize,
|
||||
bool loopParallelize = DEFAULT_loopParallelize,
|
||||
bool batchConcreteOps = DEFAULT_batchConcreteOps,
|
||||
double global_p_error = DEFAULT_global_p_error,
|
||||
bool chunkedIntegers = DEFAULT_chunkedIntegers,
|
||||
unsigned int chunkSize = DEFAULT_chunkSize,
|
||||
unsigned int chunkWidth = DEFAULT_chunkWidth) {
|
||||
|
||||
auto options =
|
||||
mlir::concretelang::CompilationOptions(std::string(func.data()));
|
||||
options.optimizerConfig.global_p_error = global_p_error;
|
||||
options.chunkIntegers = chunkedIntegers;
|
||||
options.chunkSize = chunkSize;
|
||||
options.chunkWidth = chunkWidth;
|
||||
if (useDefaultFHEConstraints) {
|
||||
options.v0FHEConstraints = defaultV0Constraints;
|
||||
options.optimizerConfig.strategy_v0 = true;
|
||||
|
||||
Reference in New Issue
Block a user