mirror of
https://github.com/zama-ai/concrete.git
synced 2026-02-08 19:44:57 -05:00
feat: allow fine-grained control on verbosity settings
This commit is contained in:
@@ -440,9 +440,21 @@ class Compiler:
|
||||
if self.artifacts is not None:
|
||||
self.artifacts.add_mlir_to_compile(mlir)
|
||||
|
||||
show_graph = self.configuration.verbose or self.configuration.show_graph
|
||||
show_mlir = self.configuration.verbose or self.configuration.show_mlir
|
||||
show_optimizer = self.configuration.verbose or self.configuration.show_optimizer
|
||||
show_graph = (
|
||||
self.configuration.show_graph
|
||||
if self.configuration.show_graph is not None
|
||||
else self.configuration.verbose
|
||||
)
|
||||
show_mlir = (
|
||||
self.configuration.show_mlir
|
||||
if self.configuration.show_mlir is not None
|
||||
else self.configuration.verbose
|
||||
)
|
||||
show_optimizer = (
|
||||
self.configuration.show_optimizer
|
||||
if self.configuration.show_optimizer is not None
|
||||
else self.configuration.verbose
|
||||
)
|
||||
|
||||
columns = 0
|
||||
if show_graph or show_mlir or show_optimizer:
|
||||
|
||||
@@ -15,9 +15,9 @@ class Configuration:
|
||||
# pylint: disable=too-many-instance-attributes
|
||||
|
||||
verbose: bool
|
||||
show_graph: bool
|
||||
show_mlir: bool
|
||||
show_optimizer: bool
|
||||
show_graph: Optional[bool]
|
||||
show_mlir: Optional[bool]
|
||||
show_optimizer: Optional[bool]
|
||||
dump_artifacts_on_unexpected_failures: bool
|
||||
enable_unsafe_features: bool
|
||||
virtual: bool
|
||||
@@ -60,9 +60,9 @@ class Configuration:
|
||||
def __init__(
|
||||
self,
|
||||
verbose: bool = False,
|
||||
show_graph: bool = False,
|
||||
show_mlir: bool = False,
|
||||
show_optimizer: bool = False,
|
||||
show_graph: Optional[bool] = None,
|
||||
show_mlir: Optional[bool] = None,
|
||||
show_optimizer: Optional[bool] = None,
|
||||
dump_artifacts_on_unexpected_failures: bool = True,
|
||||
enable_unsafe_features: bool = False,
|
||||
virtual: bool = False,
|
||||
@@ -133,6 +133,11 @@ class Configuration:
|
||||
is_correctly_typed = False
|
||||
expected = "Optional[float]"
|
||||
|
||||
elif name in ["show_graph", "show_mlir", "show_optimizer"]:
|
||||
if not (value is None or isinstance(value, bool)):
|
||||
is_correctly_typed = False
|
||||
expected = "Optional[bool]"
|
||||
|
||||
elif not isinstance(value, hint): # type: ignore
|
||||
is_correctly_typed = False
|
||||
|
||||
|
||||
@@ -98,7 +98,13 @@ class Server:
|
||||
options.set_p_error(configuration.p_error)
|
||||
else:
|
||||
options.set_global_p_error(configuration.global_p_error)
|
||||
options.set_display_optimizer_choice(configuration.verbose or configuration.show_optimizer)
|
||||
|
||||
show_optimizer = (
|
||||
configuration.show_optimizer
|
||||
if configuration.show_optimizer is not None
|
||||
else configuration.verbose
|
||||
)
|
||||
options.set_display_optimizer_choice(show_optimizer)
|
||||
|
||||
if configuration.jit:
|
||||
|
||||
|
||||
@@ -52,17 +52,20 @@ Additional kwarg to `compile` function have higher precedence. So if you set an
|
||||
|
||||
## Options
|
||||
|
||||
* **show\_graph**: bool = False
|
||||
* **show\_graph**: Optional[bool] = None
|
||||
* Whether to print computation graph during compilation.
|
||||
`True` means always to print, `False` means always to not print, `None` means print depending on verbose configuration below.
|
||||
|
||||
* **show\_mlir**: bool = False
|
||||
* **show\_mlir**: Optional[bool] = None
|
||||
* Whether to print MLIR during compilation.
|
||||
`True` means always to print, `False` means always to not print, `None` means print depending on verbose configuration below.
|
||||
|
||||
* **show\_optimizer**: bool = False
|
||||
* **show\_optimizer**: Optional[bool] = None
|
||||
* Whether to print optimizer output during compilation.
|
||||
`True` means always to print, `False` means always to not print, `None` means print depending on verbose configuration below.
|
||||
|
||||
* **verbose**: bool = False
|
||||
* Whether to print computation graph and MLIR during compilation.
|
||||
* Whether to print details related to compilation.
|
||||
|
||||
* **dump\_artifacts\_on\_unexpected\_failures**: bool = True
|
||||
* Whether to export debugging artifacts automatically on compilation failures.
|
||||
|
||||
@@ -80,6 +80,12 @@ def test_configuration_fork():
|
||||
"Unexpected type for keyword argument 'p_error' "
|
||||
"(expected 'Optional[float]', got 'str')",
|
||||
),
|
||||
pytest.param(
|
||||
{"show_optimizer": "please"},
|
||||
TypeError,
|
||||
"Unexpected type for keyword argument 'show_optimizer' "
|
||||
"(expected 'Optional[bool]', got 'str')",
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_configuration_bad_fork(kwargs, expected_error, expected_message):
|
||||
|
||||
Reference in New Issue
Block a user