mirror of
https://github.com/zama-ai/concrete.git
synced 2026-02-09 12:15:09 -05:00
35 lines
1.2 KiB
C++
35 lines
1.2 KiB
C++
#include "DialectModules.h"
|
|
|
|
#include "zamalang-c/Dialect/HLFHE.h"
|
|
|
|
#include "mlir-c/BuiltinAttributes.h"
|
|
#include "mlir/Bindings/Python/PybindAdaptors.h"
|
|
#include "mlir/IR/Diagnostics.h"
|
|
#include "llvm/ADT/SmallString.h"
|
|
#include "llvm/Support/raw_ostream.h"
|
|
|
|
#include <pybind11/pybind11.h>
|
|
#include <pybind11/pytypes.h>
|
|
#include <pybind11/stl.h>
|
|
|
|
using namespace mlir::zamalang;
|
|
using namespace mlir::python::adaptors;
|
|
|
|
/// Populate the hlfhe python module.
|
|
void mlir::zamalang::python::populateDialectHLFHESubmodule(
|
|
pybind11::module &m) {
|
|
m.doc() = "HLFHE dialect Python native extension";
|
|
|
|
mlir_type_subclass(m, "EncryptedIntegerType",
|
|
hlfheTypeIsAnEncryptedIntegerType)
|
|
.def_classmethod("get", [](pybind11::object cls, MlirContext ctx,
|
|
unsigned width) {
|
|
// We want the user to receive a python exception for not being able to
|
|
// create the eint
|
|
auto emitException = []() -> mlir::InFlightDiagnostic {
|
|
throw std::invalid_argument("can't create eint with the given width");
|
|
};
|
|
return cls(
|
|
hlfheEncryptedIntegerTypeGetChecked(ctx, width, emitException));
|
|
});
|
|
} |