Skip to content

Commit

Permalink
chore(common): fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
aPere3 committed Oct 28, 2024
1 parent b6523b5 commit 019daf8
Show file tree
Hide file tree
Showing 13 changed files with 385 additions and 144 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ const Config DEFAULT_CONFIG = {UNSPECIFIED_P_ERROR,
DEFAULT_CACHE_ON_DISK,
DEFAULT_CIPHERTEXT_MODULUS_LOG,
DEFAULT_FFT_PRECISION,
concrete_optimizer::ParameterRestrictions {},
concrete_optimizer::ParameterRestrictions{},
DEFAULT_COMPOSITION_RULES,
DEFAULT_COMPOSABLE};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,76 +445,115 @@ void mlir::concretelang::python::populateCompilerAPISubmodule(
},
"Set security level.", arg("security_level"))
.def("set_glwe_pbs_restrictions",
[](CompilationOptions &options, std::optional<uint64_t> log2_polynomial_size_min, std::optional<uint64_t> log2_polynomial_size_max,
std::optional<uint64_t> glwe_dimension_min, std::optional<uint64_t> glwe_dimension_max) {
[](CompilationOptions &options,
std::optional<uint64_t> log2_polynomial_size_min,
std::optional<uint64_t> log2_polynomial_size_max,
std::optional<uint64_t> glwe_dimension_min,
std::optional<uint64_t> glwe_dimension_max) {
if (log2_polynomial_size_min) {
options.optimizerConfig.parameter_restrictions.glwe_pbs.log2_polynomial_size_min = std::make_shared<uint64_t>(*log2_polynomial_size_min);
options.optimizerConfig.parameter_restrictions.glwe_pbs
.log2_polynomial_size_min =
std::make_shared<uint64_t>(*log2_polynomial_size_min);
}
if (log2_polynomial_size_max) {
options.optimizerConfig.parameter_restrictions.glwe_pbs.log2_polynomial_size_max = std::make_shared<uint64_t>(*log2_polynomial_size_max);
options.optimizerConfig.parameter_restrictions.glwe_pbs
.log2_polynomial_size_max =
std::make_shared<uint64_t>(*log2_polynomial_size_max);
}
if (glwe_dimension_min) {
options.optimizerConfig.parameter_restrictions.glwe_pbs.glwe_dimension_min = std::make_shared<uint64_t>(*glwe_dimension_min);
options.optimizerConfig.parameter_restrictions.glwe_pbs
.glwe_dimension_min =
std::make_shared<uint64_t>(*glwe_dimension_min);
}
if (glwe_dimension_max) {
options.optimizerConfig.parameter_restrictions.glwe_pbs.glwe_dimension_max = std::make_shared<uint64_t>(*glwe_dimension_max);
options.optimizerConfig.parameter_restrictions.glwe_pbs
.glwe_dimension_max =
std::make_shared<uint64_t>(*glwe_dimension_max);
}
})
.def("set_free_glwe_restrictions",
[](CompilationOptions &options, std::optional<uint64_t> log2_polynomial_size_min, std::optional<uint64_t> log2_polynomial_size_max,
std::optional<uint64_t> glwe_dimension_min, std::optional<uint64_t> glwe_dimension_max) {
[](CompilationOptions &options,
std::optional<uint64_t> log2_polynomial_size_min,
std::optional<uint64_t> log2_polynomial_size_max,
std::optional<uint64_t> glwe_dimension_min,
std::optional<uint64_t> glwe_dimension_max) {
if (log2_polynomial_size_min) {
options.optimizerConfig.parameter_restrictions.free_glwe.log2_polynomial_size_min = std::make_shared<uint64_t>(*log2_polynomial_size_min);
options.optimizerConfig.parameter_restrictions.free_glwe
.log2_polynomial_size_min =
std::make_shared<uint64_t>(*log2_polynomial_size_min);
}
if (log2_polynomial_size_max) {
options.optimizerConfig.parameter_restrictions.free_glwe.log2_polynomial_size_max = std::make_shared<uint64_t>(*log2_polynomial_size_max);
options.optimizerConfig.parameter_restrictions.free_glwe
.log2_polynomial_size_max =
std::make_shared<uint64_t>(*log2_polynomial_size_max);
}
if (glwe_dimension_min) {
options.optimizerConfig.parameter_restrictions.free_glwe.glwe_dimension_min = std::make_shared<uint64_t>(*glwe_dimension_min);
options.optimizerConfig.parameter_restrictions.free_glwe
.glwe_dimension_min =
std::make_shared<uint64_t>(*glwe_dimension_min);
}
if (glwe_dimension_max) {
options.optimizerConfig.parameter_restrictions.free_glwe.glwe_dimension_max = std::make_shared<uint64_t>(*glwe_dimension_max);
options.optimizerConfig.parameter_restrictions.free_glwe
.glwe_dimension_max =
std::make_shared<uint64_t>(*glwe_dimension_max);
}
})
.def("set_br_decomposition_restrictions",
[](CompilationOptions &options, std::optional<uint64_t> log2_base_min, std::optional<uint64_t> log2_base_max,
std::optional<uint64_t> level_min, std::optional<uint64_t> level_max) {
[](CompilationOptions &options,
std::optional<uint64_t> log2_base_min,
std::optional<uint64_t> log2_base_max,
std::optional<uint64_t> level_min,
std::optional<uint64_t> level_max) {
if (log2_base_min) {
options.optimizerConfig.parameter_restrictions.br_decomposition.log2_base_min = std::make_shared<uint64_t>(*log2_base_min);
options.optimizerConfig.parameter_restrictions.br_decomposition
.log2_base_min = std::make_shared<uint64_t>(*log2_base_min);
}
if (log2_base_max) {
options.optimizerConfig.parameter_restrictions.br_decomposition.log2_base_max = std::make_shared<uint64_t>(*log2_base_max);
options.optimizerConfig.parameter_restrictions.br_decomposition
.log2_base_max = std::make_shared<uint64_t>(*log2_base_max);
}
if (level_min) {
options.optimizerConfig.parameter_restrictions.br_decomposition.level_min = std::make_shared<uint64_t>(*level_min);
options.optimizerConfig.parameter_restrictions.br_decomposition
.level_min = std::make_shared<uint64_t>(*level_min);
}
if (level_max) {
options.optimizerConfig.parameter_restrictions.br_decomposition.level_max = std::make_shared<uint64_t>(*level_max);
options.optimizerConfig.parameter_restrictions.br_decomposition
.level_max = std::make_shared<uint64_t>(*level_max);
}
})
.def("set_ks_decomposition_restrictions",
[](CompilationOptions &options, std::optional<uint64_t> log2_base_min, std::optional<uint64_t> log2_base_max,
std::optional<uint64_t> level_min, std::optional<uint64_t> level_max) {
[](CompilationOptions &options,
std::optional<uint64_t> log2_base_min,
std::optional<uint64_t> log2_base_max,
std::optional<uint64_t> level_min,
std::optional<uint64_t> level_max) {
if (log2_base_min) {
options.optimizerConfig.parameter_restrictions.ks_decomposition.log2_base_min = std::make_shared<uint64_t>(*log2_base_min);
options.optimizerConfig.parameter_restrictions.ks_decomposition
.log2_base_min = std::make_shared<uint64_t>(*log2_base_min);
}
if (log2_base_max) {
options.optimizerConfig.parameter_restrictions.ks_decomposition.log2_base_max = std::make_shared<uint64_t>(*log2_base_max);
options.optimizerConfig.parameter_restrictions.ks_decomposition
.log2_base_max = std::make_shared<uint64_t>(*log2_base_max);
}
if (level_min) {
options.optimizerConfig.parameter_restrictions.ks_decomposition.level_min = std::make_shared<uint64_t>(*level_min);
options.optimizerConfig.parameter_restrictions.ks_decomposition
.level_min = std::make_shared<uint64_t>(*level_min);
}
if (level_max) {
options.optimizerConfig.parameter_restrictions.ks_decomposition.level_max = std::make_shared<uint64_t>(*level_max);
options.optimizerConfig.parameter_restrictions.ks_decomposition
.level_max = std::make_shared<uint64_t>(*level_max);
}
})
.def("set_free_lwe_restrictions",
[](CompilationOptions &options, std::optional<uint64_t> free_lwe_min, std::optional<uint64_t> free_lwe_max) {
[](CompilationOptions &options, std::optional<uint64_t> free_lwe_min,
std::optional<uint64_t> free_lwe_max) {
if (free_lwe_min) {
options.optimizerConfig.parameter_restrictions.free_lwe_min = std::make_shared<uint64_t>(*free_lwe_min);
options.optimizerConfig.parameter_restrictions.free_lwe_min =
std::make_shared<uint64_t>(*free_lwe_min);
}
if (free_lwe_max) {
options.optimizerConfig.parameter_restrictions.free_lwe_max = std::make_shared<uint64_t>(*free_lwe_max);
options.optimizerConfig.parameter_restrictions.free_lwe_max =
std::make_shared<uint64_t>(*free_lwe_max);
}
})
.def(
Expand Down
20 changes: 12 additions & 8 deletions compilers/concrete-optimizer/charts/src/bin/norm2_complexity.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
use charts::{draw, Serie};
use concrete_optimizer::computing_cost::cpu::CpuComplexity;
use concrete_optimizer::config;
use concrete_optimizer::global_parameters::DEFAUT_DOMAINS;
use concrete_optimizer::global_parameters::DEFAULT_DOMAINS;
use concrete_optimizer::optimization::atomic_pattern::{self as optimize_atomic_pattern};
use concrete_optimizer::optimization::config::{Config, SearchSpace};
use concrete_optimizer::optimization::decomposition;
use concrete_optimizer::optimization::wop_atomic_pattern::optimize as optimize_wop_atomic_pattern;

pub const _4_SIGMA: f64 = 1.0 - 0.999_936_657_516;
const MIN_LOG_POLY_SIZE: u64 = DEFAUT_DOMAINS
.glwe_pbs_constrained
const MIN_LOG_POLY_SIZE: u64 = DEFAULT_DOMAINS
.glwe_pbs_constrained_cpu
.log2_polynomial_size
.start;
const MAX_LOG_POLY_SIZE: u64 = DEFAUT_DOMAINS.glwe_pbs_constrained.log2_polynomial_size.end - 1;
pub const MAX_GLWE_DIM: u64 = DEFAUT_DOMAINS.glwe_pbs_constrained.glwe_dimension.end - 1;
pub const MIN_LWE_DIM: u64 = DEFAUT_DOMAINS.free_glwe.glwe_dimension.start;
pub const MAX_LWE_DIM: u64 = DEFAUT_DOMAINS.free_glwe.glwe_dimension.end - 1;
const MAX_LOG_POLY_SIZE: u64 = DEFAULT_DOMAINS
.glwe_pbs_constrained_cpu
.log2_polynomial_size
.end
- 1;
pub const MAX_GLWE_DIM: u64 = DEFAULT_DOMAINS.glwe_pbs_constrained_cpu.glwe_dimension.end - 1;
pub const MIN_LWE_DIM: u64 = DEFAULT_DOMAINS.free_glwe.glwe_dimension.start;
pub const MAX_LWE_DIM: u64 = DEFAULT_DOMAINS.free_glwe.glwe_dimension.end - 1;

fn main() -> Result<(), Box<dyn std::error::Error>> {
let sum_size = 4096;
Expand All @@ -31,7 +35,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
glwe_log_polynomial_sizes,
glwe_dimensions,
internal_lwe_dimensions,
levelled_only_lwe_dimensions: DEFAUT_DOMAINS.free_lwe,
levelled_only_lwe_dimensions: DEFAULT_DOMAINS.free_lwe,
};

let precision = 8;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
use charts::{draw, Serie};
use concrete_optimizer::computing_cost::cpu::CpuComplexity;
use concrete_optimizer::config;
use concrete_optimizer::global_parameters::DEFAUT_DOMAINS;
use concrete_optimizer::global_parameters::DEFAULT_DOMAINS;
use concrete_optimizer::optimization::atomic_pattern::{self as optimize_atomic_pattern};
use concrete_optimizer::optimization::config::{Config, SearchSpace};
use concrete_optimizer::optimization::decomposition;
use concrete_optimizer::optimization::wop_atomic_pattern::optimize as optimize_wop_atomic_pattern;

pub const _4_SIGMA: f64 = 1.0 - 0.999_936_657_516;
const MIN_LOG_POLY_SIZE: u64 = DEFAUT_DOMAINS
.glwe_pbs_constrained
const MIN_LOG_POLY_SIZE: u64 = DEFAULT_DOMAINS
.glwe_pbs_constrained_cpu
.log2_polynomial_size
.start;
const MAX_LOG_POLY_SIZE: u64 = DEFAUT_DOMAINS.glwe_pbs_constrained.log2_polynomial_size.end - 1;
pub const MAX_GLWE_DIM: u64 = DEFAUT_DOMAINS.glwe_pbs_constrained.glwe_dimension.end - 1;
pub const MIN_LWE_DIM: u64 = DEFAUT_DOMAINS.free_glwe.glwe_dimension.start;
pub const MAX_LWE_DIM: u64 = DEFAUT_DOMAINS.free_glwe.glwe_dimension.end - 1;
const MAX_LOG_POLY_SIZE: u64 = DEFAULT_DOMAINS
.glwe_pbs_constrained_cpu
.log2_polynomial_size
.end
- 1;
pub const MAX_GLWE_DIM: u64 = DEFAULT_DOMAINS.glwe_pbs_constrained_cpu.glwe_dimension.end - 1;
pub const MIN_LWE_DIM: u64 = DEFAULT_DOMAINS.free_glwe.glwe_dimension.start;
pub const MAX_LWE_DIM: u64 = DEFAULT_DOMAINS.free_glwe.glwe_dimension.end - 1;

fn main() -> Result<(), Box<dyn std::error::Error>> {
let processing_unit = config::ProcessingUnit::Cpu;
Expand All @@ -37,7 +41,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
glwe_log_polynomial_sizes,
glwe_dimensions,
internal_lwe_dimensions,
levelled_only_lwe_dimensions: DEFAUT_DOMAINS.free_lwe,
levelled_only_lwe_dimensions: DEFAULT_DOMAINS.free_lwe,
};

let config = Config {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ $(INTERFACE_LIB): $(INTERFACE_LIB_ORIG)
TESTS_SOURCES = tests/src/main.cpp
TEST_DEP_LIBS = -l pthread -ldl
tests/tests_exe: $(INTERFACE_LIB) $(INTERFACE_HEADER) $(INTERFACE_CPP) $(TESTS_SOURCES)
g++ -Wall -Werror -Wextra -o $@ $(TESTS_SOURCES) $(INTERFACE_CPP) $(INTERFACE_LIB) -I $(shell dirname $(INTERFACE_HEADER)) $(TEST_DEP_LIBS)
g++ -Wall -Werror -Wextra -std=c++17 -o $@ $(TESTS_SOURCES) $(INTERFACE_CPP) $(INTERFACE_LIB) -I $(shell dirname $(INTERFACE_HEADER)) $(TEST_DEP_LIBS)
chmod +x $@

test: tests/tests_exe
Expand Down
Loading

0 comments on commit 019daf8

Please sign in to comment.