Files
concrete/compiler/lib/Bindings/Python/FHEModule.cpp
youben11 f1161f7f6d chore: formatting
Quick fix due to ordering of includes, had to add #include
<mlir/Transforms/DialectConversion.h> to include/concretelang/Conversion/Utils/GenericOpTypeConversionPattern.h
2022-01-03 09:29:19 +01:00

39 lines
1.3 KiB
C++

// Part of the Concrete Compiler Project, under the BSD3 License with Zama
// Exceptions. See
// https://github.com/zama-ai/homomorphizer/blob/master/LICENSE.txt for license
// information.
#include "DialectModules.h"
#include "concretelang-c/Dialect/FHE.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::concretelang;
using namespace mlir::python::adaptors;
/// Populate the fhe python module.
void mlir::concretelang::python::populateDialectFHESubmodule(
pybind11::module &m) {
m.doc() = "FHE dialect Python native extension";
mlir_type_subclass(m, "EncryptedIntegerType", fheTypeIsAnEncryptedIntegerType)
.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(
fheEncryptedIntegerTypeGetChecked(ctx, width, emitException));
});
}