LibrarySupport.
Library support provides a way to compile an MLIR program into a library that can be later loaded to execute the compiled code.
- DEFAULT_OUTPUT_PATH
Support class for library compilation and execution.
__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
Path where to store compilation artifacts.
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
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
get_shared_lib_path() → str
Get the path where the shared library is expected to be.
Returns:
str
: path to the shared library
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
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
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
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
reload() → LibraryCompilationResult
Reload the library compilation result from the output_dir_path.
Returns:
LibraryCompilationResult
: loaded library
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
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