Files
concrete/compilers/concrete-compiler/compiler/lib/Dialect/FHE/Interfaces/FHEInterfacesInstances.cpp
Nikita Frolov 73a992f0a6 refactor(compiler): generalize noise calculation in FHE/FHELinalg
Instead of having one `getSQManp` implementation per op with a lot of repetition, the noise
calculation is now modular.

- Ops that implements`UnaryEint`/`BinaryInt`/`BinaryEint` interfaces share the operand noise
presence check.
- For many scalar ops no further calculation is needed. If it's not the case, an op can override
`sqMANP`.
- Integer operand types lookups are abstracted into `BinaryInt::operandIntType()`
- Finding largest operand value for a type is abstracted into `BinaryInt::operandMaxConstant`
- Noise calculation for matmul ops is simplified and it's now general enough to work for
`matmul_eint_int`, `matmul_int_eint` and `dot_eint_int` at once.
2023-09-12 14:51:53 +01:00

25 lines
789 B
C++

// Part of the Concrete Compiler Project, under the BSD3 License with Zama
// Exceptions. See
// https://github.com/zama-ai/concrete-compiler-internal/blob/main/LICENSE.txt
// for license information.
#include "concretelang/Dialect/FHE/Interfaces/FHEInterfacesInstances.h"
#include "concretelang/Dialect/FHE/IR/FHEDialect.h"
#include "concretelang/Dialect/FHE/Interfaces/FHEInterfaces.h"
#include "mlir/Dialect/Tensor/IR/Tensor.h"
namespace mlir {
namespace concretelang {
namespace FHE {
using namespace mlir::tensor;
void registerFheInterfacesExternalModels(DialectRegistry &registry) {
registry.addExtension(+[](MLIRContext *ctx, TensorDialect *dialect) {
ExtractOp::attachInterface<UnaryEint>(*ctx);
});
}
} // namespace FHE
} // namespace concretelang
} // namespace mlir