9.8 KiB
module concrete.compiler.library_support
LibrarySupport.
Library support provides a way to compile an MLIR program into a library that can be later loaded to execute the compiled code.
Global Variables
- DEFAULT_OUTPUT_PATH
class LibrarySupport
Support class for library compilation and execution.
method __init__
__init__(library_support: LibrarySupport)
Wrap the native Cpp object.
Args:
library_support(_LibrarySupport): object to wrap
Raises:
TypeError: if library_support is not of type _LibrarySupport
property output_dir_path
Path where to store compilation artifacts.
method compile
compile(
mlir_program: Union[str, Module],
options: CompilationOptions = <concrete.compiler.compilation_options.CompilationOptions object at ADDRESS>,
compilation_context: Optional[CompilationContext] = None
) → LibraryCompilationResult
Compile an MLIR program using Concrete dialects into a library.
Args:
mlir_program(Union[str, MlirModule]): mlir program to compile (textual or in-memory)options(CompilationOptions): compilation options
Raises:
TypeError: if mlir_program is not of type str or MlirModuleTypeError: if options is not of type CompilationOptions
Returns:
LibraryCompilationResult: the result of the library compilation
method get_program_info_path
get_program_info_path() → str
Get the path where the program info file is expected to be.
Returns:
str: path to the program info file
method get_shared_lib_path
get_shared_lib_path() → str
Get the path where the shared library is expected to be.
Returns:
str: path to the shared library
method load_client_parameters
load_client_parameters(
library_compilation_result: LibraryCompilationResult
) → ClientParameters
Load the client parameters from the library compilation result.
Args:
library_compilation_result(LibraryCompilationResult): compilation result of the library
Raises:
TypeError: if library_compilation_result is not of type LibraryCompilationResult
Returns:
ClientParameters: appropriate client parameters for the compiled library
method load_compilation_feedback
load_compilation_feedback(
compilation_result: LibraryCompilationResult
) → ProgramCompilationFeedback
Load the compilation feedback from the compilation result.
Args:
compilation_result(LibraryCompilationResult): result of the compilation
Raises:
TypeError: if compilation_result is not of type LibraryCompilationResult
Returns:
ProgramCompilationFeedback: the compilation feedback for the compiled program
method load_server_lambda
load_server_lambda(
library_compilation_result: LibraryCompilationResult,
simulation: bool,
circuit_name: str = 'main'
) → LibraryLambda
Load the server lambda for a given circuit from the library compilation result.
Args:
library_compilation_result(LibraryCompilationResult): compilation result of the librarysimulation(bool): use simulation for executioncircuit_name(str): name of the circuit to be loaded
Raises:
TypeError: if library_compilation_result is not of type LibraryCompilationResult, if circuit_name is not of type str or
Returns:
LibraryLambda: executable reference to the library
method new
new(
output_path: str = '/Users/benoitchevalliermames/Documents/Zama/Git/concrete/tempdirectoryforapidocs/concrete-compiler_compilation_artifacts',
runtime_library_path: Optional[str] = None,
generateSharedLib: bool = True,
generateStaticLib: bool = False,
generateClientParameters: bool = True,
generateCompilationFeedback: bool = True,
generateCppHeader: bool = False
) → LibrarySupport
Build a LibrarySupport.
Args:
output_path(str, optional): path where to store compilation artifacts. Defaults to DEFAULT_OUTPUT_PATH.runtime_library_path(Optional[str], optional): path to the runtime library. Defaults to None.generateSharedLib(bool): whether to emit shared library or not. Default to True.generateStaticLib(bool): whether to emit static library or not. Default to False.generateClientParameters(bool): whether to emit client parameters or not. Default to True.generateCppHeader(bool): whether to emit cpp header or not. Default to False.
Raises:
TypeError: if output_path is not of type strTypeError: if runtime_library_path is not of type strTypeError: if one of the generation flags is not of type bool
Returns: LibrarySupport
method reload
reload() → LibraryCompilationResult
Reload the library compilation result from the output_dir_path.
Returns:
LibraryCompilationResult: loaded library
method server_call
server_call(
library_lambda: LibraryLambda,
public_arguments: PublicArguments,
evaluation_keys: EvaluationKeys
) → PublicResult
Call the library with public_arguments.
Args:
library_lambda(LibraryLambda): reference to the compiled librarypublic_arguments(PublicArguments): arguments to use for executionevaluation_keys(EvaluationKeys): evaluation keys to use for execution
Raises:
TypeError: if library_lambda is not of type LibraryLambdaTypeError: if public_arguments is not of type PublicArgumentsTypeError: if evaluation_keys is not of type EvaluationKeys
Returns:
PublicResult: result of the execution
method simulate
simulate(
library_lambda: LibraryLambda,
public_arguments: PublicArguments
) → PublicResult
Call the library with public_arguments in simulation mode.
Args:
library_lambda(LibraryLambda): reference to the compiled librarypublic_arguments(PublicArguments): arguments to use for execution
Raises:
TypeError: if library_lambda is not of type LibraryLambdaTypeError: if public_arguments is not of type PublicArguments
Returns:
PublicResult: result of the execution