mirror of
https://github.com/zama-ai/concrete.git
synced 2026-02-09 03:55:04 -05:00
feat(CAPI): API to get the width of an eint/esint
This commit is contained in:
@@ -36,6 +36,12 @@ fheEncryptedSignedIntegerTypeGetChecked(MlirContext context, unsigned width);
|
||||
/// If the type is an EncryptedSignedInteger
|
||||
MLIR_CAPI_EXPORTED bool fheTypeIsAnEncryptedSignedIntegerType(MlirType);
|
||||
|
||||
/// \brief Get bitwidth of the encrypted integer type.
|
||||
///
|
||||
/// \return bitwidth of the encrypted integer or 0 if it's not an encrypted
|
||||
/// integer
|
||||
MLIR_CAPI_EXPORTED unsigned fheTypeIntegerWidthGet(MlirType);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -61,3 +61,16 @@ MlirTypeOrError fheEncryptedSignedIntegerTypeGetChecked(MlirContext ctx,
|
||||
unsigned width) {
|
||||
return IntegerTypeGetChecked<EncryptedSignedIntegerType>(ctx, width);
|
||||
}
|
||||
|
||||
unsigned fheTypeIntegerWidthGet(MlirType integerType) {
|
||||
mlir::Type type = unwrap(integerType);
|
||||
auto eint = type.dyn_cast_or_null<EncryptedIntegerType>();
|
||||
if (eint) {
|
||||
return eint.getWidth();
|
||||
}
|
||||
auto esint = type.dyn_cast_or_null<EncryptedSignedIntegerType>();
|
||||
if (esint) {
|
||||
return esint.getWidth();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user