mirror of
https://github.com/zama-ai/concrete.git
synced 2026-02-09 12:15:09 -05:00
feat(CAPI): add CompilationFeedback API
This commit is contained in:
@@ -44,6 +44,7 @@ DEFINE_C_API_STRUCT(EvaluationKeys, void);
|
||||
DEFINE_C_API_STRUCT(LambdaArgument, void);
|
||||
DEFINE_C_API_STRUCT(PublicArguments, void);
|
||||
DEFINE_C_API_STRUCT(PublicResult, void);
|
||||
DEFINE_C_API_STRUCT(CompilationFeedback, void);
|
||||
|
||||
#undef DEFINE_C_API_STRUCT
|
||||
|
||||
@@ -69,6 +70,7 @@ DEFINE_NULL_PTR_CHECKER(evaluationKeysIsNull, EvaluationKeys);
|
||||
DEFINE_NULL_PTR_CHECKER(lambdaArgumentIsNull, LambdaArgument);
|
||||
DEFINE_NULL_PTR_CHECKER(publicArgumentsIsNull, PublicArguments);
|
||||
DEFINE_NULL_PTR_CHECKER(publicResultIsNull, PublicResult);
|
||||
DEFINE_NULL_PTR_CHECKER(compilationFeedbackIsNull, CompilationFeedback);
|
||||
|
||||
#undef DEFINE_NULL_PTR_CHECKER
|
||||
|
||||
@@ -167,6 +169,9 @@ MLIR_CAPI_EXPORTED ServerLambda librarySupportLoadServerLambda(
|
||||
MLIR_CAPI_EXPORTED ClientParameters librarySupportLoadClientParameters(
|
||||
LibrarySupport support, LibraryCompilationResult result);
|
||||
|
||||
MLIR_CAPI_EXPORTED CompilationFeedback librarySupportLoadCompilationFeedback(
|
||||
LibrarySupport support, LibraryCompilationResult result);
|
||||
|
||||
MLIR_CAPI_EXPORTED PublicResult
|
||||
librarySupportServerCall(LibrarySupport support, ServerLambda server,
|
||||
PublicArguments args, EvaluationKeys evalKeys);
|
||||
@@ -250,6 +255,35 @@ MLIR_CAPI_EXPORTED LambdaArgument publicResultDecrypt(PublicResult publicResult,
|
||||
|
||||
MLIR_CAPI_EXPORTED void publicResultDestroy(PublicResult publicResult);
|
||||
|
||||
/// ********** CompilationFeedback CAPI ****************************************
|
||||
|
||||
MLIR_CAPI_EXPORTED double
|
||||
compilationFeedbackGetComplexity(CompilationFeedback feedback);
|
||||
|
||||
MLIR_CAPI_EXPORTED double
|
||||
compilationFeedbackGetPError(CompilationFeedback feedback);
|
||||
|
||||
MLIR_CAPI_EXPORTED double
|
||||
compilationFeedbackGetGlobalPError(CompilationFeedback feedback);
|
||||
|
||||
MLIR_CAPI_EXPORTED uint64_t
|
||||
compilationFeedbackGetTotalSecretKeysSize(CompilationFeedback feedback);
|
||||
|
||||
MLIR_CAPI_EXPORTED uint64_t
|
||||
compilationFeedbackGetTotalBootstrapKeysSize(CompilationFeedback feedback);
|
||||
|
||||
MLIR_CAPI_EXPORTED uint64_t
|
||||
compilationFeedbackGetTotalKeyswitchKeysSize(CompilationFeedback feedback);
|
||||
|
||||
MLIR_CAPI_EXPORTED uint64_t
|
||||
compilationFeedbackGetTotalInputsSize(CompilationFeedback feedback);
|
||||
|
||||
MLIR_CAPI_EXPORTED uint64_t
|
||||
compilationFeedbackGetTotalOutputsSize(CompilationFeedback feedback);
|
||||
|
||||
MLIR_CAPI_EXPORTED void
|
||||
compilationFeedbackDestroy(CompilationFeedback feedback);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -56,6 +56,8 @@ DEFINE_C_API_PTR_METHODS_WITH_ERROR(
|
||||
PublicArguments, mlir::concretelang::clientlib::PublicArguments)
|
||||
DEFINE_C_API_PTR_METHODS_WITH_ERROR(PublicResult,
|
||||
mlir::concretelang::clientlib::PublicResult)
|
||||
DEFINE_C_API_PTR_METHODS_WITH_ERROR(CompilationFeedback,
|
||||
mlir::concretelang::CompilationFeedback)
|
||||
|
||||
#undef DEFINE_C_API_PTR_METHODS_WITH_ERROR
|
||||
|
||||
|
||||
@@ -21,6 +21,10 @@
|
||||
if (error != NULL) \
|
||||
delete[] error;
|
||||
|
||||
/// ********** Utilities *******************************************************
|
||||
|
||||
void mlirStringRefDestroy(MlirStringRef str) { delete[] str.data; }
|
||||
|
||||
/// ********** CompilationOptions CAPI *****************************************
|
||||
|
||||
CompilationOptions
|
||||
@@ -145,7 +149,7 @@ MlirStringRef compilationResultGetModuleString(CompilationResult result) {
|
||||
}
|
||||
|
||||
void compilationResultDestroyModuleString(MlirStringRef str) {
|
||||
delete str.data;
|
||||
mlirStringRefDestroy(str);
|
||||
}
|
||||
|
||||
void compilationResultDestroy(CompilationResult result){
|
||||
@@ -223,6 +227,19 @@ librarySupportLoadClientParameters(LibrarySupport support,
|
||||
new mlir::concretelang::clientlib::ClientParameters(paramsOrError.get()));
|
||||
}
|
||||
|
||||
CompilationFeedback
|
||||
librarySupportLoadCompilationFeedback(LibrarySupport support,
|
||||
LibraryCompilationResult result) {
|
||||
auto feedbackOrError =
|
||||
unwrap(support)->loadCompilationFeedback(*unwrap(result));
|
||||
if (!feedbackOrError) {
|
||||
return wrap((mlir::concretelang::CompilationFeedback *)NULL,
|
||||
llvm::toString(feedbackOrError.takeError()));
|
||||
}
|
||||
return wrap(
|
||||
new mlir::concretelang::CompilationFeedback(feedbackOrError.get()));
|
||||
}
|
||||
|
||||
PublicResult librarySupportServerCall(LibrarySupport support,
|
||||
ServerLambda server_lambda,
|
||||
PublicArguments args,
|
||||
@@ -533,3 +550,44 @@ LambdaArgument publicResultDecrypt(PublicResult publicResult, KeySet keySet) {
|
||||
void publicResultDestroy(PublicResult publicResult) {
|
||||
C_STRUCT_CLEANER(publicResult)
|
||||
}
|
||||
|
||||
/// ********** CompilationFeedback CAPI ****************************************
|
||||
|
||||
double compilationFeedbackGetComplexity(CompilationFeedback feedback) {
|
||||
return unwrap(feedback)->complexity;
|
||||
}
|
||||
|
||||
double compilationFeedbackGetPError(CompilationFeedback feedback) {
|
||||
return unwrap(feedback)->pError;
|
||||
}
|
||||
|
||||
double compilationFeedbackGetGlobalPError(CompilationFeedback feedback) {
|
||||
return unwrap(feedback)->globalPError;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
compilationFeedbackGetTotalSecretKeysSize(CompilationFeedback feedback) {
|
||||
return unwrap(feedback)->totalSecretKeysSize;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
compilationFeedbackGetTotalBootstrapKeysSize(CompilationFeedback feedback) {
|
||||
return unwrap(feedback)->totalBootstrapKeysSize;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
compilationFeedbackGetTotalKeyswitchKeysSize(CompilationFeedback feedback) {
|
||||
return unwrap(feedback)->totalKeyswitchKeysSize;
|
||||
}
|
||||
|
||||
uint64_t compilationFeedbackGetTotalInputsSize(CompilationFeedback feedback) {
|
||||
return unwrap(feedback)->totalInputsSize;
|
||||
}
|
||||
|
||||
uint64_t compilationFeedbackGetTotalOutputsSize(CompilationFeedback feedback) {
|
||||
return unwrap(feedback)->totalOutputsSize;
|
||||
}
|
||||
|
||||
void compilationFeedbackDestroy(CompilationFeedback feedback) {
|
||||
C_STRUCT_CLEANER(feedback)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user