From 30df69366da0e39f231838ec5e182aca0f2e89a9 Mon Sep 17 00:00:00 2001 From: Quentin Bourgerie Date: Thu, 1 Sep 2022 10:20:37 +0200 Subject: [PATCH] enhance(python-bindings): Expose the option to set or not the v0 strategy of the optimizer. --- compiler/lib/Bindings/Python/CompilerAPIModule.cpp | 5 ++++- .../Python/concrete/compiler/compilation_options.py | 13 +++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/compiler/lib/Bindings/Python/CompilerAPIModule.cpp b/compiler/lib/Bindings/Python/CompilerAPIModule.cpp index d375f24ec..a62ad49e8 100644 --- a/compiler/lib/Bindings/Python/CompilerAPIModule.cpp +++ b/compiler/lib/Bindings/Python/CompilerAPIModule.cpp @@ -62,8 +62,11 @@ void mlir::concretelang::python::populateCompilerAPISubmodule( .def("set_display_optimizer_choice", [](CompilationOptions &options, bool display) { options.optimizerConfig.display = display; + }) + .def("set_strategy_v0", + [](CompilationOptions &options, bool strategy_v0) { + options.optimizerConfig.strategy_v0 = strategy_v0; }); - ; pybind11::class_( m, "JITCompilationResult"); diff --git a/compiler/lib/Bindings/Python/concrete/compiler/compilation_options.py b/compiler/lib/Bindings/Python/concrete/compiler/compilation_options.py index 70a01d674..ca5a4f28a 100644 --- a/compiler/lib/Bindings/Python/concrete/compiler/compilation_options.py +++ b/compiler/lib/Bindings/Python/concrete/compiler/compilation_options.py @@ -164,3 +164,16 @@ class CompilationOptions(WrapperCpp): if not isinstance(display, bool): raise TypeError("display should be a bool") self.cpp().set_display_optimizer_choice(display) + + def set_strategy_v0(self, enable: bool): + """Set the strategy of the optimizer to the v0 one. + + Args: + enable (bool): if true the compiler use the V0 optimizer strategy. + + Raises: + TypeError: if the value is not a bool + """ + if not isinstance(enable, bool): + raise TypeError("enable should be a bool") + self.cpp().set_strategy_v0(enable)