mirror of
https://github.com/zama-ai/concrete.git
synced 2026-04-17 03:00:54 -04:00
feat(concrete-compiler): add support for key type parameters and attributes
This commit is contained in:
committed by
Quentin Bourgerie
parent
5c1a15c514
commit
a2b143f409
@@ -357,7 +357,8 @@ def Concrete_WopPBSCRTLweTensorOp : Concrete_Op<"wop_pbs_crt_lwe_tensor", [Pure]
|
||||
I32Attr : $packingKeySwitchBaseLog,
|
||||
// Circuit bootstrap parameters
|
||||
I32Attr : $circuitBootstrapLevel,
|
||||
I32Attr : $circuitBootstrapBaseLog
|
||||
I32Attr : $circuitBootstrapBaseLog,
|
||||
I64ArrayAttr:$crtDecomposition
|
||||
);
|
||||
let results = (outs Concrete_LweCRTTensor:$result);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
set(LLVM_TARGET_DEFINITIONS TFHEAttrs.td)
|
||||
mlir_tablegen(TFHEAttrs.h.inc -gen-attrdef-decls -attrdefs-dialect=TFHE)
|
||||
mlir_tablegen(TFHEAttrs.cpp.inc -gen-attrdef-defs -attrdefs-dialect=TFHE)
|
||||
|
||||
set(LLVM_TARGET_DEFINITIONS TFHEOps.td)
|
||||
mlir_tablegen(TFHEOps.h.inc -gen-op-decls)
|
||||
mlir_tablegen(TFHEOps.cpp.inc -gen-op-defs)
|
||||
@@ -10,4 +14,5 @@ add_dependencies(mlir-headers MLIRTFHEOpsIncGen)
|
||||
|
||||
add_concretelang_doc(TFHEOps TFHEDialect concretelang/ -gen-dialect-doc -dialect=TFHE)
|
||||
add_concretelang_doc(TFHEOps TFHEOps concretelang/ -gen-op-doc)
|
||||
add_concretelang_doc(TFHEOps TFHEAttrs concretelang/ -gen-attrdef-doc)
|
||||
add_concretelang_doc(TFHETypes TFHETypes concretelang/ -gen-typedef-doc)
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
// 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.
|
||||
|
||||
#ifndef CONCRETELANG_DIALECT_TFHE_IR_TFHEATTRS_H
|
||||
#define CONCRETELANG_DIALECT_TFHE_IR_TFHEATTRS_H
|
||||
|
||||
#include "concretelang/Dialect/TFHE/IR/TFHEParameters.h"
|
||||
#include "llvm/ADT/TypeSwitch.h"
|
||||
#include <mlir/Dialect/Func/IR/FuncOps.h>
|
||||
#include <mlir/IR/BuiltinOps.h>
|
||||
#include <mlir/IR/BuiltinTypes.h>
|
||||
#include <mlir/IR/DialectImplementation.h>
|
||||
|
||||
#define GET_ATTRDEF_CLASSES
|
||||
#include "concretelang/Dialect/TFHE/IR/TFHEAttrs.h.inc"
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,69 @@
|
||||
//===- TFHEOps.td - High level FHE dialect ops ----------------*- tablegen
|
||||
//-*-===//
|
||||
//
|
||||
// This file is licensed under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef CONCRETELANG_DIALECT_TFHE_IR_TFHE_ATTRS
|
||||
#define CONCRETELANG_DIALECT_TFHE_IR_TFHE_ATTRS
|
||||
|
||||
include "concretelang/Dialect/TFHE/IR/TFHEDialect.td"
|
||||
include "concretelang/Dialect/TFHE/IR/TFHETypes.td"
|
||||
include "mlir/IR/AttrTypeBase.td"
|
||||
include "mlir/IR/OpBase.td"
|
||||
|
||||
class TFHE_Attr<string name, string attrMnemonic, list<Trait> traits = []>: AttrDef<TFHE_Dialect, name, traits> {
|
||||
let mnemonic = attrMnemonic;
|
||||
}
|
||||
|
||||
def TFHE_KeyswitchKeyAttr: TFHE_Attr<"GLWEKeyswitchKey", "ksk"> {
|
||||
|
||||
let summary = "An attribute representing keyswitch key.";
|
||||
|
||||
let parameters = (ins
|
||||
"mlir::concretelang::TFHE::GLWESecretKey":$inputKey,
|
||||
"mlir::concretelang::TFHE::GLWESecretKey":$outputKey,
|
||||
"int":$levels,
|
||||
"int":$baseLog
|
||||
);
|
||||
|
||||
let assemblyFormat = "`<` $inputKey `,` $outputKey `,` $levels `,` $baseLog `>`";
|
||||
}
|
||||
|
||||
def TFHE_BootstrapKeyAttr: TFHE_Attr<"GLWEBootstrapKey", "bsk"> {
|
||||
|
||||
let summary = "An attribute representing bootstrap key.";
|
||||
|
||||
let parameters = (ins
|
||||
"mlir::concretelang::TFHE::GLWESecretKey":$inputKey,
|
||||
"mlir::concretelang::TFHE::GLWESecretKey":$outputKey,
|
||||
"int":$polySize,
|
||||
"int":$glweDim,
|
||||
"int":$levels,
|
||||
"int":$baseLog
|
||||
);
|
||||
|
||||
let assemblyFormat = "`<` $inputKey `,` $outputKey `,` $polySize `,` $glweDim `,` $levels `,` $baseLog `>`";
|
||||
}
|
||||
|
||||
def TFHE_PackingKeyswitchKeyAttr: TFHE_Attr<"GLWEPackingKeyswitchKey", "pksk"> {
|
||||
|
||||
let summary = "An attribute representing Wop Pbs key.";
|
||||
|
||||
let parameters = (ins
|
||||
"mlir::concretelang::TFHE::GLWESecretKey":$inputKey,
|
||||
"mlir::concretelang::TFHE::GLWESecretKey":$outputKey,
|
||||
"int" : $outputPolySize,
|
||||
"int" : $inputLweDim,
|
||||
"int" : $levels,
|
||||
"int" : $baseLog
|
||||
);
|
||||
|
||||
let assemblyFormat = "`<` $inputKey `,` $outputKey`,` $outputPolySize`,` $inputLweDim `,` $levels `,` $baseLog `>`";
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -18,6 +18,7 @@ def TFHE_Dialect : Dialect {
|
||||
A dialect for representation of high level operation on fully homomorphic ciphertext.
|
||||
}];
|
||||
let useDefaultTypePrinterParser = 1;
|
||||
let useDefaultAttributePrinterParser = 1;
|
||||
let cppNamespace = "::mlir::concretelang::TFHE";
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <mlir/Interfaces/ControlFlowInterfaces.h>
|
||||
#include <mlir/Interfaces/SideEffectInterfaces.h>
|
||||
|
||||
#include "concretelang/Dialect/TFHE/IR/TFHEAttrs.h"
|
||||
#include "concretelang/Dialect/TFHE/IR/TFHETypes.h"
|
||||
|
||||
#define GET_OP_CLASSES
|
||||
|
||||
@@ -12,9 +12,9 @@
|
||||
|
||||
include "mlir/Interfaces/SideEffectInterfaces.td"
|
||||
include "mlir/Interfaces/ControlFlowInterfaces.td"
|
||||
|
||||
include "concretelang/Dialect/TFHE/IR/TFHEDialect.td"
|
||||
include "concretelang/Dialect/TFHE/IR/TFHETypes.td"
|
||||
include "concretelang/Dialect/TFHE/IR/TFHEAttrs.td"
|
||||
|
||||
class TFHE_Op<string mnemonic, list<Trait> traits = []>
|
||||
: Op<TFHE_Dialect, mnemonic, traits>;
|
||||
@@ -125,12 +125,11 @@ def TFHE_KeySwitchGLWEOp : TFHE_Op<"keyswitch_glwe"> {
|
||||
let summary = "Change the encryption parameters of a glwe ciphertext by "
|
||||
"applying a keyswitch";
|
||||
|
||||
let arguments = (ins
|
||||
let arguments = (ins
|
||||
TFHE_GLWECipherTextType : $ciphertext,
|
||||
I32Attr : $level,
|
||||
I32Attr : $baseLog
|
||||
TFHE_KeyswitchKeyAttr : $key
|
||||
);
|
||||
|
||||
|
||||
|
||||
let results = (outs TFHE_GLWECipherTextType : $result);
|
||||
}
|
||||
@@ -143,10 +142,7 @@ def TFHE_BootstrapGLWEOp : TFHE_Op<"bootstrap_glwe"> {
|
||||
let arguments = (ins
|
||||
TFHE_GLWECipherTextType : $ciphertext,
|
||||
1DTensorOf<[I64]> : $lookup_table,
|
||||
I32Attr : $level,
|
||||
I32Attr : $baseLog,
|
||||
I32Attr : $polySize,
|
||||
I32Attr : $glweDimension
|
||||
TFHE_BootstrapKeyAttr: $key
|
||||
);
|
||||
|
||||
let results = (outs TFHE_GLWECipherTextType : $result);
|
||||
@@ -158,23 +154,14 @@ def TFHE_WopPBSGLWEOp : TFHE_Op<"wop_pbs_glwe"> {
|
||||
let arguments = (ins
|
||||
Type<And<[TensorOf<[TFHE_GLWECipherTextType]>.predicate, HasStaticShapePred]>>: $ciphertexts,
|
||||
2DTensorOf<[I64]> : $lookupTable,
|
||||
// Bootstrap parameters
|
||||
I32Attr : $bootstrapLevel,
|
||||
I32Attr : $bootstrapBaseLog,
|
||||
// Keyswitch parameters
|
||||
I32Attr : $keyswitchLevel,
|
||||
I32Attr : $keyswitchBaseLog,
|
||||
// Packing keyswitch key parameters
|
||||
I32Attr : $packingKeySwitchInputLweDimension,
|
||||
I32Attr : $packingKeySwitchoutputPolynomialSize,
|
||||
I32Attr : $packingKeySwitchLevel,
|
||||
I32Attr : $packingKeySwitchBaseLog,
|
||||
// Circuit bootstrap parameters
|
||||
I32Attr : $circuitBootstrapLevel,
|
||||
I32Attr : $circuitBootstrapBaseLog,
|
||||
// Crt decomposition
|
||||
I64ArrayAttr: $crtDecomposition
|
||||
TFHE_KeyswitchKeyAttr: $ksk,
|
||||
TFHE_BootstrapKeyAttr: $bsk,
|
||||
TFHE_PackingKeyswitchKeyAttr: $pksk,
|
||||
I64ArrayAttr: $crtDecomposition,
|
||||
I32Attr: $cbsLevels,
|
||||
I32Attr: $cbsBaseLog
|
||||
);
|
||||
|
||||
let results = (outs Type<And<[TensorOf<[TFHE_GLWECipherTextType]>.predicate, HasStaticShapePred]>>:$result);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
// 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.
|
||||
|
||||
#ifndef CONCRETELANG_DIALECT_TFHE_IR_TFHEPARAMETERS_H
|
||||
#define CONCRETELANG_DIALECT_TFHE_IR_TFHEPARAMETERS_H
|
||||
|
||||
#include "llvm/ADT/TypeSwitch.h"
|
||||
#include <mlir/Dialect/Func/IR/FuncOps.h>
|
||||
#include <mlir/IR/BuiltinOps.h>
|
||||
#include <mlir/IR/BuiltinTypes.h>
|
||||
#include <mlir/IR/DialectImplementation.h>
|
||||
|
||||
namespace mlir {
|
||||
namespace concretelang {
|
||||
namespace TFHE {
|
||||
|
||||
/// A type parameter representing GLWE secret key.
|
||||
///
|
||||
/// A glwe secret key is basically a glwe dimension, a polynomial size, and an
|
||||
/// id that makes it possible to disambiguate potential keys with with same
|
||||
/// parameters.
|
||||
///
|
||||
/// Note that a key can be instantiated to a `none` key, to serve as a
|
||||
/// placeholder in the IR. In this case, none of its data are actually usable
|
||||
/// for lowering to the `Concrete` dialect. Once the
|
||||
/// `TFHEGlobalParameterization` was performed, there should remain no such
|
||||
/// `none` keys in the IR.
|
||||
class GLWESecretKey {
|
||||
public:
|
||||
/// Creates a new none key.
|
||||
GLWESecretKey();
|
||||
/// Create a new key from parameters.
|
||||
GLWESecretKey(int64_t dimension, int64_t polySize, int64_t id);
|
||||
bool operator==(GLWESecretKey other);
|
||||
bool operator==(const GLWESecretKey other) const;
|
||||
bool operator!=(GLWESecretKey other);
|
||||
/// Returns the dimension associated with this key, if the key is not none.
|
||||
mlir::Optional<int64_t> getDimension() const;
|
||||
/// Returns the polynomial size associated with this key, if the key is not
|
||||
/// none.
|
||||
mlir::Optional<int64_t> getPolySize() const;
|
||||
/// Returns the id associated with this key, if the key is not none.
|
||||
mlir::Optional<int64_t> getId() const;
|
||||
/// Returns true if the key was not filled with valid parameters.
|
||||
bool isNotParameterized() const;
|
||||
|
||||
private:
|
||||
int64_t dimension;
|
||||
int64_t polySize;
|
||||
int64_t id;
|
||||
};
|
||||
|
||||
llvm::hash_code hash_value(const GLWESecretKey &key);
|
||||
} // namespace TFHE
|
||||
} // namespace concretelang
|
||||
} // namespace mlir
|
||||
|
||||
namespace mlir {
|
||||
|
||||
AsmPrinter &operator<<(AsmPrinter &p,
|
||||
mlir::concretelang::TFHE::GLWESecretKey key);
|
||||
|
||||
template <> struct FieldParser<mlir::concretelang::TFHE::GLWESecretKey> {
|
||||
static FailureOr<mlir::concretelang::TFHE::GLWESecretKey>
|
||||
parse(AsmParser &parser);
|
||||
};
|
||||
} // namespace mlir
|
||||
|
||||
#endif
|
||||
@@ -6,6 +6,7 @@
|
||||
#ifndef CONCRETELANG_DIALECT_TFHE_IR_TFHETYPES_H
|
||||
#define CONCRETELANG_DIALECT_TFHE_IR_TFHETYPES_H
|
||||
|
||||
#include "concretelang/Dialect/TFHE/IR/TFHEParameters.h"
|
||||
#include "llvm/ADT/TypeSwitch.h"
|
||||
#include <mlir/Dialect/Func/IR/FuncOps.h>
|
||||
#include <mlir/IR/BuiltinOps.h>
|
||||
|
||||
@@ -10,7 +10,7 @@ class TFHE_Type<string name, list<Trait> traits = []>
|
||||
: TypeDef<TFHE_Dialect, name, traits> {}
|
||||
|
||||
def TFHE_GLWECipherTextType
|
||||
: TFHE_Type<"GLWECipherText", [MemRefElementTypeInterface]> {
|
||||
: TFHE_Type<"GLWECipherText", [ MemRefElementTypeInterface ]> {
|
||||
let mnemonic = "glwe";
|
||||
|
||||
let summary = "A GLWE ciphertext";
|
||||
@@ -18,15 +18,9 @@ def TFHE_GLWECipherTextType
|
||||
let description = [{An GLWE cipher text}];
|
||||
|
||||
let parameters = (ins
|
||||
// The size of the mask
|
||||
"signed":$dimension,
|
||||
// Size of the polynome
|
||||
"signed":$polynomialSize,
|
||||
// Number of bits of the ciphertext
|
||||
"signed":$bits,
|
||||
// Number of bits of the plain text representation
|
||||
"signed":$p
|
||||
);
|
||||
// The size of the mask
|
||||
"mlir::concretelang::TFHE::GLWESecretKey"
|
||||
: $key);
|
||||
|
||||
let hasCustomAssemblyFormat = 1;
|
||||
|
||||
@@ -35,8 +29,7 @@ def TFHE_GLWECipherTextType
|
||||
let extraClassDeclaration = [{
|
||||
// Returns true if has an unparametrized parameters
|
||||
bool hasUnparametrizedParameters() {
|
||||
return getDimension() == -1 || getPolynomialSize() == -1 ||
|
||||
getBits() == -1 || getP() == -1;
|
||||
return getKey().isNotParameterized();
|
||||
};
|
||||
}];
|
||||
}
|
||||
|
||||
@@ -309,13 +309,13 @@ llvm::SmallVector<mlir::utils::IteratorType> parallelIteratorType(int n) {
|
||||
/// becomes:
|
||||
///
|
||||
/// #map = affine_map<(d0, d1) -> (d0, d1)>
|
||||
/// %init = linalg.init_tensor [2, 3] : tensor<2x3x!TFHE.glwe<{_,_,_}{2}>>
|
||||
/// %init = linalg.init_tensor [2, 3] : tensor<2x3x!TFHE.glwe<sk?>>
|
||||
/// %output = linalg.generic {indexing_maps = [#map, #map, #map], iterator_types
|
||||
/// = ["parallel", "parallel"]} ins(%arg0, %arg2 :
|
||||
/// tensor<2x3x!TFHE.glwe<{_,_,_}{2}>>, tensor<2x3xindex>) outs(%0 :
|
||||
/// tensor<2x3x!TFHE.glwe<{_,_,_}{2}>>) {
|
||||
/// ^bb0(%arg3: !TFHE.glwe<{_,_,_}{2}>, %lut_idx: index, %arg5:
|
||||
/// !TFHE.glwe<{_,_,_}{2}>): // no predecessors
|
||||
/// tensor<2x3x!TFHE.glwe<sk?>>, tensor<2x3xindex>) outs(%0 :
|
||||
/// tensor<2x3x!TFHE.glwe<sk?>>) {
|
||||
/// ^bb0(%arg3: !TFHE.glwe<sk?>, %lut_idx: index, %arg5:
|
||||
/// !TFHE.glwe<sk?>): // no predecessors
|
||||
/// %lut = tensor.extract_slice %arg1[%[[LUTIDX]], 0] [1,4] [1, 1]
|
||||
/// : tensor<5x4xi64> to tensor<4xi64>
|
||||
/// %res = "TFHE.apply_lookup_table"(%arg3, %[[LUT]])
|
||||
@@ -323,10 +323,10 @@ llvm::SmallVector<mlir::utils::IteratorType> parallelIteratorType(int n) {
|
||||
/// glweDimension = -1 : i32,
|
||||
/// levelBS = -1 : i32, levelKS = -1 : i32, outputSizeKS =
|
||||
/// -1 : i32, polynomialSize = -1 : i32}
|
||||
/// : (!TFHE.glwe<{_,_,_}{2}>, tensor<4xi64>) ->
|
||||
/// !TFHE.glwe<{_,_,_}{2}> linalg.yield %res :
|
||||
/// !TFHE.glwe<{_,_,_}{2}>
|
||||
/// } -> tensor<2x3x!TFHE.glwe<{_,_,_}{2}>>
|
||||
/// : (!TFHE.glwe<sk?>, tensor<4xi64>) ->
|
||||
/// !TFHE.glwe<sk?> linalg.yield %res :
|
||||
/// !TFHE.glwe<sk?>
|
||||
/// } -> tensor<2x3x!TFHE.glwe<sk?>>
|
||||
|
||||
namespace FHELinalg = mlir::concretelang::FHELinalg;
|
||||
|
||||
@@ -450,8 +450,8 @@ struct FHELinalgApplyMappedLookupTableToLinalgGeneric
|
||||
/// %lut) {baseLogBS = -1 : i32, baseLogKS = -1 : i32, glweDimension
|
||||
/// = -1 : i32, levelBS = -1 : i32, levelKS = -1 : i32, outputSizeKS
|
||||
/// = -1 : i32, polynomialSize = -1 : i32} :
|
||||
/// (!TFHE.glwe<{_,_,_}{2}>, tensor<4xi64>) ->
|
||||
/// !TFHE.glwe<{_,_,_}{2}>
|
||||
/// (!TFHE.glwe<sk?>, tensor<4xi64>) ->
|
||||
/// !TFHE.glwe<sk?>
|
||||
/// linalg.yield %0 : !FHE.eint<2>
|
||||
/// }
|
||||
/// }
|
||||
|
||||
@@ -46,7 +46,7 @@ mlir::RankedTensorType convertEncrypted(mlir::MLIRContext *context,
|
||||
uint64_t crtLength) {
|
||||
return mlir::RankedTensorType::get(
|
||||
mlir::ArrayRef<int64_t>((int64_t)crtLength),
|
||||
TFHE::GLWECipherTextType::get(context, -1, -1, -1, enc.getWidth()));
|
||||
TFHE::GLWECipherTextType::get(context, TFHE::GLWESecretKey()));
|
||||
}
|
||||
|
||||
/// Converts `Tensor<FHE::AnyEncryptedInteger>` into a
|
||||
@@ -59,15 +59,13 @@ maybeConvertEncryptedTensor(mlir::MLIRContext *context,
|
||||
if (!maybeEncryptedTensor.getElementType().isa<FHE::FheIntegerInterface>()) {
|
||||
return (mlir::Type)(maybeEncryptedTensor);
|
||||
}
|
||||
auto encType =
|
||||
maybeEncryptedTensor.getElementType().cast<FHE::FheIntegerInterface>();
|
||||
auto currentShape = maybeEncryptedTensor.getShape();
|
||||
mlir::SmallVector<int64_t> newShape =
|
||||
mlir::SmallVector<int64_t>(currentShape.begin(), currentShape.end());
|
||||
newShape.push_back((int64_t)crtLength);
|
||||
return mlir::RankedTensorType::get(
|
||||
llvm::ArrayRef<int64_t>(newShape),
|
||||
TFHE::GLWECipherTextType::get(context, -1, -1, -1, encType.getWidth()));
|
||||
TFHE::GLWECipherTextType::get(context, TFHE::GLWESecretKey()));
|
||||
}
|
||||
|
||||
/// Converts any encrypted type to `TFHE::GlweCiphetext` if the
|
||||
@@ -580,8 +578,16 @@ struct ApplyLookupTableEintOpPattern
|
||||
// Replace the lut with an encoded / expanded one.
|
||||
auto wopPBS = rewriter.create<TFHE::WopPBSGLWEOp>(
|
||||
op.getLoc(), converter->convertType(op.getType()), adaptor.getA(),
|
||||
newLut, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
rewriter.getI64ArrayAttr({}));
|
||||
newLut,
|
||||
TFHE::GLWEKeyswitchKeyAttr::get(op.getContext(), TFHE::GLWESecretKey(),
|
||||
TFHE::GLWESecretKey(), -1, -1),
|
||||
TFHE::GLWEBootstrapKeyAttr::get(op.getContext(), TFHE::GLWESecretKey(),
|
||||
TFHE::GLWESecretKey(), -1, -1, -1, -1),
|
||||
TFHE::GLWEPackingKeyswitchKeyAttr::get(
|
||||
op.getContext(), TFHE::GLWESecretKey(), TFHE::GLWESecretKey(), -1,
|
||||
-1, -1, -1),
|
||||
rewriter.getI64ArrayAttr({}), rewriter.getI32IntegerAttr(-1),
|
||||
rewriter.getI32IntegerAttr(-1));
|
||||
|
||||
rewriter.replaceOp(op, {wopPBS.getResult()});
|
||||
return ::mlir::success();
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "concretelang/Dialect/RT/IR/RTTypes.h"
|
||||
#include "concretelang/Dialect/TFHE/IR/TFHEDialect.h"
|
||||
#include "concretelang/Dialect/TFHE/IR/TFHEOps.h"
|
||||
#include "concretelang/Dialect/TFHE/IR/TFHEParameters.h"
|
||||
#include "concretelang/Dialect/TFHE/IR/TFHETypes.h"
|
||||
#include "concretelang/Dialect/Tracing/IR/TracingOps.h"
|
||||
|
||||
@@ -42,7 +43,7 @@ namespace typing {
|
||||
/// Converts an encrypted integer into `TFHE::GlweCiphetext`.
|
||||
TFHE::GLWECipherTextType convertEncrypted(mlir::MLIRContext *context,
|
||||
FHE::FheIntegerInterface enc) {
|
||||
return TFHE::GLWECipherTextType::get(context, -1, -1, -1, enc.getWidth());
|
||||
return TFHE::GLWECipherTextType::get(context, TFHE::GLWESecretKey());
|
||||
}
|
||||
|
||||
/// Converts `Tensor<FHE::AnyEncryptedInteger>` into a
|
||||
@@ -54,12 +55,10 @@ maybeConvertEncryptedTensor(mlir::MLIRContext *context,
|
||||
if (!maybeEncryptedTensor.getElementType().isa<FHE::FheIntegerInterface>()) {
|
||||
return (mlir::Type)(maybeEncryptedTensor);
|
||||
}
|
||||
auto enc =
|
||||
maybeEncryptedTensor.getElementType().cast<FHE::FheIntegerInterface>();
|
||||
auto currentShape = maybeEncryptedTensor.getShape();
|
||||
return mlir::RankedTensorType::get(
|
||||
currentShape,
|
||||
TFHE::GLWECipherTextType::get(context, -1, -1, -1, enc.getWidth()));
|
||||
TFHE::GLWECipherTextType::get(context, TFHE::GLWESecretKey()));
|
||||
}
|
||||
|
||||
/// Converts any encrypted type to `TFHE::GlweCiphetext` if the
|
||||
@@ -81,9 +80,8 @@ public:
|
||||
return convertEncrypted(type.getContext(), type);
|
||||
});
|
||||
addConversion([](FHE::EncryptedBooleanType type) {
|
||||
return TFHE::GLWECipherTextType::get(
|
||||
type.getContext(), -1, -1, -1,
|
||||
mlir::concretelang::FHE::EncryptedBooleanType::getWidth());
|
||||
return TFHE::GLWECipherTextType::get(type.getContext(),
|
||||
TFHE::GLWESecretKey());
|
||||
});
|
||||
addConversion([](mlir::RankedTensorType type) {
|
||||
return maybeConvertEncryptedTensor(type.getContext(), type);
|
||||
@@ -369,12 +367,15 @@ struct ApplyLookupTableEintOpPattern
|
||||
// Insert keyswitch
|
||||
auto ksOp = rewriter.create<TFHE::KeySwitchGLWEOp>(
|
||||
op.getLoc(), getTypeConverter()->convertType(adaptor.getA().getType()),
|
||||
input, -1, -1);
|
||||
input,
|
||||
TFHE::GLWEKeyswitchKeyAttr::get(op.getContext(), TFHE::GLWESecretKey(),
|
||||
TFHE::GLWESecretKey(), -1, -1));
|
||||
|
||||
// Insert bootstrap
|
||||
rewriter.replaceOpWithNewOp<TFHE::BootstrapGLWEOp>(
|
||||
op, getTypeConverter()->convertType(op.getType()), ksOp, newLut, -1, -1,
|
||||
-1, -1);
|
||||
op, getTypeConverter()->convertType(op.getType()), ksOp, newLut,
|
||||
TFHE::GLWEBootstrapKeyAttr::get(op.getContext(), TFHE::GLWESecretKey(),
|
||||
TFHE::GLWESecretKey(), -1, -1, -1, -1));
|
||||
|
||||
return mlir::success();
|
||||
};
|
||||
@@ -553,9 +554,15 @@ struct RoundEintOpPattern : public ScalarOpPattern<FHE::RoundEintOp> {
|
||||
// The lookup is performed ...
|
||||
|
||||
mlir::Value keyswitched = rewriter.create<TFHE::KeySwitchGLWEOp>(
|
||||
op.getLoc(), truncationInputTy, shiftedRotatedInput, -1, -1);
|
||||
op.getLoc(), truncationInputTy, shiftedRotatedInput,
|
||||
TFHE::GLWEKeyswitchKeyAttr::get(op->getContext(),
|
||||
TFHE::GLWESecretKey(),
|
||||
TFHE::GLWESecretKey(), -1, -1));
|
||||
mlir::Value bootstrapped = rewriter.create<TFHE::BootstrapGLWEOp>(
|
||||
op.getLoc(), truncationInputTy, keyswitched, lut, -1, -1, -1, -1);
|
||||
op.getLoc(), truncationInputTy, keyswitched, lut,
|
||||
TFHE::GLWEBootstrapKeyAttr::get(
|
||||
op->getContext(), TFHE::GLWESecretKey(), TFHE::GLWESecretKey(),
|
||||
-1, -1, -1, -1));
|
||||
|
||||
//------------------------------------------------------------- CORRECTION
|
||||
// The correction is performed to achieve our right shift semantic.
|
||||
@@ -571,8 +578,8 @@ struct RoundEintOpPattern : public ScalarOpPattern<FHE::RoundEintOp> {
|
||||
|
||||
mlir::Value minusIsolatedBit = rewriter.create<TFHE::NegGLWEOp>(
|
||||
op.getLoc(), truncationInputTy, extractedBit);
|
||||
truncationInputTy = TFHE::GLWECipherTextType::get(
|
||||
rewriter.getContext(), -1, -1, -1, truncationInputTy.getP() - 1);
|
||||
truncationInputTy = TFHE::GLWECipherTextType::get(rewriter.getContext(),
|
||||
TFHE::GLWESecretKey());
|
||||
mlir::Value truncationOutput = rewriter.create<TFHE::AddGLWEOp>(
|
||||
op.getLoc(), truncationInputTy, previousOutput, minusIsolatedBit);
|
||||
previousOutput = truncationOutput;
|
||||
|
||||
@@ -35,8 +35,8 @@ struct TFHEGlobalParametrizationPass
|
||||
using mlir::concretelang::TFHE::GLWECipherTextType;
|
||||
|
||||
/// TFHEGlobalParametrizationTypeConverter is a TypeConverter that transform
|
||||
/// `TFHE.glwe<{_,_,_}{p}>` to
|
||||
/// `TFHE.glwe<{glweDimension,polynomialSize,bits}{p'}>`
|
||||
/// `TFHE.glwe<sk[?]>` to
|
||||
/// `TFHE.glwe<sk[id]<glweDimension,polynomialSize>>`
|
||||
class TFHEGlobalParametrizationTypeConverter : public mlir::TypeConverter {
|
||||
|
||||
public:
|
||||
@@ -67,35 +67,32 @@ public:
|
||||
});
|
||||
}
|
||||
|
||||
TFHE::GLWECipherTextType glweInterPBSType(GLWECipherTextType &type) {
|
||||
auto bits = 64;
|
||||
TFHE::GLWESecretKey getInterPBSKey() {
|
||||
auto dimension = cryptoParameters.getNBigLweDimension();
|
||||
auto polynomialSize = 1;
|
||||
auto precision = (signed)type.getP();
|
||||
if ((int)dimension == type.getDimension() &&
|
||||
(int)polynomialSize == type.getPolynomialSize()) {
|
||||
return type;
|
||||
}
|
||||
return TFHE::GLWECipherTextType::get(type.getContext(), dimension,
|
||||
polynomialSize, bits, precision);
|
||||
// Warning, for now we use hardcoded ids. Later on, we expect the optimizer
|
||||
// to give the id.
|
||||
auto id = 1;
|
||||
return mlir::concretelang::TFHE::GLWESecretKey(dimension, polynomialSize,
|
||||
id);
|
||||
}
|
||||
|
||||
TFHE::GLWECipherTextType glweLookupTableType(GLWECipherTextType &type) {
|
||||
auto bits = 64;
|
||||
auto dimension = cryptoParameters.glweDimension;
|
||||
auto polynomialSize = cryptoParameters.getPolynomialSize();
|
||||
auto precision = (signed)type.getP();
|
||||
return TFHE::GLWECipherTextType::get(type.getContext(), dimension,
|
||||
polynomialSize, bits, precision);
|
||||
TFHE::GLWECipherTextType glweInterPBSType(GLWECipherTextType &type) {
|
||||
return TFHE::GLWECipherTextType::get(type.getContext(), getInterPBSKey());
|
||||
}
|
||||
|
||||
TFHE::GLWESecretKey getIntraPBSKey() {
|
||||
auto dimension = cryptoParameters.nSmall;
|
||||
auto polynomialSize = 1;
|
||||
// Warning, for now we use hardcoded ids. Later on, we expect the optimizer
|
||||
// to give the id.
|
||||
auto id = 3;
|
||||
return mlir::concretelang::TFHE::GLWESecretKey(dimension, polynomialSize,
|
||||
id);
|
||||
}
|
||||
|
||||
TFHE::GLWECipherTextType glweIntraPBSType(GLWECipherTextType &type) {
|
||||
auto bits = 64;
|
||||
auto dimension = cryptoParameters.nSmall;
|
||||
auto polynomialSize = 1;
|
||||
auto precision = (signed)type.getP();
|
||||
return TFHE::GLWECipherTextType::get(type.getContext(), dimension,
|
||||
polynomialSize, bits, precision);
|
||||
return TFHE::GLWECipherTextType::get(type.getContext(), getIntraPBSKey());
|
||||
}
|
||||
|
||||
mlir::concretelang::V0Parameter cryptoParameters;
|
||||
@@ -120,9 +117,13 @@ struct KeySwitchGLWEOpPattern
|
||||
.cast<mlir::concretelang::TFHE::GLWECipherTextType>();
|
||||
auto outputTy = ksOp.getResult().getType().cast<TFHE::GLWECipherTextType>();
|
||||
auto newOutputTy = converter.glweIntraPBSType(outputTy);
|
||||
auto newOp = rewriter.replaceOpWithNewOp<TFHE::KeySwitchGLWEOp>(
|
||||
ksOp, newOutputTy, ksOp.getCiphertext(), cryptoParameters.ksLevel,
|
||||
auto newInputKey = converter.getInterPBSKey();
|
||||
auto newOutputKey = converter.getIntraPBSKey();
|
||||
auto keyswitchKey = TFHE::GLWEKeyswitchKeyAttr::get(
|
||||
ksOp->getContext(), newInputKey, newOutputKey, cryptoParameters.ksLevel,
|
||||
cryptoParameters.ksLogBase);
|
||||
auto newOp = rewriter.replaceOpWithNewOp<TFHE::KeySwitchGLWEOp>(
|
||||
ksOp, newOutputTy, ksOp.getCiphertext(), keyswitchKey);
|
||||
rewriter.startRootUpdate(newOp);
|
||||
newOp.getCiphertext().setType(newInputTy);
|
||||
rewriter.finalizeRootUpdate(newOp);
|
||||
@@ -151,11 +152,17 @@ struct BootstrapGLWEOpPattern
|
||||
bsOp.getCiphertext().getType().cast<TFHE::GLWECipherTextType>();
|
||||
auto newInputTy = converter.glweIntraPBSType(inputTy);
|
||||
auto outputTy = bsOp.getResult().getType().cast<TFHE::GLWECipherTextType>();
|
||||
auto newOutputTy = converter.convertType(outputTy);
|
||||
auto newOutputTy =
|
||||
converter.convertType(outputTy).cast<TFHE::GLWECipherTextType>();
|
||||
auto newInputKey = converter.getIntraPBSKey();
|
||||
auto newOutputKey = converter.getInterPBSKey();
|
||||
auto bootstrapKey = TFHE::GLWEBootstrapKeyAttr::get(
|
||||
bsOp->getContext(), newInputKey, newOutputKey,
|
||||
cryptoParameters.getPolynomialSize(), cryptoParameters.glweDimension,
|
||||
cryptoParameters.brLevel, cryptoParameters.brLogBase);
|
||||
auto newOp = rewriter.replaceOpWithNewOp<TFHE::BootstrapGLWEOp>(
|
||||
bsOp, newOutputTy, bsOp.getCiphertext(), bsOp.getLookupTable(),
|
||||
cryptoParameters.brLevel, cryptoParameters.brLogBase,
|
||||
cryptoParameters.getPolynomialSize(), cryptoParameters.glweDimension);
|
||||
bootstrapKey);
|
||||
rewriter.startRootUpdate(newOp);
|
||||
newOp.getCiphertext().setType(newInputTy);
|
||||
rewriter.finalizeRootUpdate(newOp);
|
||||
@@ -179,34 +186,41 @@ struct WopPBSGLWEOpPattern : public mlir::OpRewritePattern<TFHE::WopPBSGLWEOp> {
|
||||
mlir::LogicalResult
|
||||
matchAndRewrite(TFHE::WopPBSGLWEOp wopPBSOp,
|
||||
mlir::PatternRewriter &rewriter) const override {
|
||||
auto newOp = rewriter.replaceOpWithNewOp<TFHE::WopPBSGLWEOp>(
|
||||
wopPBSOp, converter.convertType(wopPBSOp.getResult().getType()),
|
||||
wopPBSOp.getCiphertexts(), wopPBSOp.getLookupTable(),
|
||||
// Bootstrap parameters
|
||||
cryptoParameters.brLevel, cryptoParameters.brLogBase,
|
||||
// Keyswitch parameters
|
||||
cryptoParameters.ksLevel, cryptoParameters.ksLogBase,
|
||||
// Packing keyswitch key parameters
|
||||
cryptoParameters.largeInteger->wopPBS.packingKeySwitch
|
||||
.inputLweDimension,
|
||||
auto inputTy =
|
||||
wopPBSOp.getCiphertexts().getType().cast<mlir::RankedTensorType>();
|
||||
auto newInputTy =
|
||||
converter.convertType(inputTy).cast<mlir::RankedTensorType>();
|
||||
auto outputTy = wopPBSOp.getType().cast<mlir::RankedTensorType>();
|
||||
auto newOutputType = converter.convertType(outputTy);
|
||||
auto interKey = converter.getInterPBSKey();
|
||||
auto intraKey = converter.getIntraPBSKey();
|
||||
auto keyswitchKey = TFHE::GLWEKeyswitchKeyAttr::get(
|
||||
wopPBSOp->getContext(), interKey, intraKey, cryptoParameters.ksLevel,
|
||||
cryptoParameters.ksLogBase);
|
||||
auto bootstrapKey = TFHE::GLWEBootstrapKeyAttr::get(
|
||||
wopPBSOp->getContext(), intraKey, interKey,
|
||||
cryptoParameters.getPolynomialSize(), cryptoParameters.glweDimension,
|
||||
cryptoParameters.brLevel, cryptoParameters.brLogBase);
|
||||
auto packingKeyswitchKey = TFHE::GLWEPackingKeyswitchKeyAttr::get(
|
||||
wopPBSOp->getContext(), interKey, interKey,
|
||||
cryptoParameters.largeInteger->wopPBS.packingKeySwitch
|
||||
.outputPolynomialSize,
|
||||
cryptoParameters.largeInteger->wopPBS.packingKeySwitch
|
||||
.inputLweDimension,
|
||||
cryptoParameters.largeInteger->wopPBS.packingKeySwitch.level,
|
||||
cryptoParameters.largeInteger->wopPBS.packingKeySwitch.baseLog,
|
||||
// Circuit bootstrap parameters
|
||||
cryptoParameters.largeInteger->wopPBS.circuitBootstrap.level,
|
||||
cryptoParameters.largeInteger->wopPBS.circuitBootstrap.baseLog,
|
||||
// Crt decomposition
|
||||
cryptoParameters.largeInteger->wopPBS.packingKeySwitch.baseLog);
|
||||
auto newOp = rewriter.replaceOpWithNewOp<TFHE::WopPBSGLWEOp>(
|
||||
wopPBSOp, newOutputType, wopPBSOp.getCiphertexts(),
|
||||
wopPBSOp.getLookupTable(), keyswitchKey, bootstrapKey,
|
||||
packingKeyswitchKey,
|
||||
rewriter.getI64ArrayAttr(
|
||||
cryptoParameters.largeInteger->crtDecomposition));
|
||||
cryptoParameters.largeInteger->crtDecomposition),
|
||||
rewriter.getI32IntegerAttr(
|
||||
cryptoParameters.largeInteger->wopPBS.circuitBootstrap.level),
|
||||
rewriter.getI32IntegerAttr(
|
||||
cryptoParameters.largeInteger->wopPBS.circuitBootstrap.baseLog));
|
||||
rewriter.startRootUpdate(newOp);
|
||||
auto ctType =
|
||||
wopPBSOp.getCiphertexts().getType().cast<mlir::RankedTensorType>();
|
||||
auto ciphertextType =
|
||||
ctType.getElementType().cast<TFHE::GLWECipherTextType>();
|
||||
auto newType = mlir::RankedTensorType::get(
|
||||
ctType.getShape(), converter.glweInterPBSType(ciphertextType));
|
||||
newOp.getCiphertexts().setType(newType);
|
||||
newOp.getCiphertexts().setType(newInputTy);
|
||||
rewriter.finalizeRootUpdate(newOp);
|
||||
return mlir::success();
|
||||
};
|
||||
@@ -282,8 +296,9 @@ void TFHEGlobalParametrizationPass::runOnOperation() {
|
||||
cryptoParameters);
|
||||
target.addDynamicallyLegalOp<TFHE::KeySwitchGLWEOp>(
|
||||
[&](TFHE::KeySwitchGLWEOp op) {
|
||||
return op.getLevel() != (uint32_t)-1 &&
|
||||
op.getBaseLog() != (uint32_t)-1;
|
||||
return !op.getKey().getInputKey().isNotParameterized() &&
|
||||
!op.getKey().getOutputKey().isNotParameterized() &&
|
||||
op.getKey().getBaseLog() != 0 && op.getKey().getLevels() != 0;
|
||||
});
|
||||
patterns.add<BootstrapGLWEOpPattern>(&getContext(), converter,
|
||||
cryptoParameters);
|
||||
|
||||
@@ -37,8 +37,8 @@ struct TFHEToConcretePass : public TFHEToConcreteBase<TFHEToConcretePass> {
|
||||
using mlir::concretelang::TFHE::GLWECipherTextType;
|
||||
|
||||
/// TFHEToConcreteTypeConverter is a TypeConverter that transform
|
||||
/// `TFHE.glwe<{dimension,1,bits}{p}>` to `tensor<dimension+1, i64>>`
|
||||
/// `tensor<...xTFHE.glwe<{dimension,1,bits}{p}>>` to
|
||||
/// `TFHE.glwe<sk(id){dimension,1}>` to `tensor<dimension+1, i64>>`
|
||||
/// `tensor<...xTFHE.glwe<sk(id){dimension,1}>>` to
|
||||
/// `tensor<...xdimension+1, i64>>`
|
||||
class TFHEToConcreteTypeConverter : public mlir::TypeConverter {
|
||||
|
||||
@@ -46,11 +46,11 @@ public:
|
||||
TFHEToConcreteTypeConverter() {
|
||||
addConversion([](mlir::Type type) { return type; });
|
||||
addConversion([&](GLWECipherTextType type) {
|
||||
assert(type.getPolynomialSize() <= 1 &&
|
||||
assert(!type.getKey().isNotParameterized());
|
||||
assert(type.getKey().getPolySize().value() == 1 &&
|
||||
"converter doesn't support polynomialSize > 1");
|
||||
assert(type.getDimension() != -1);
|
||||
llvm::SmallVector<int64_t, 2> shape;
|
||||
shape.push_back(type.getDimension() + 1);
|
||||
shape.push_back(type.getKey().getDimension().value() + 1);
|
||||
return mlir::RankedTensorType::get(
|
||||
shape, mlir::IntegerType::get(type.getContext(), 64));
|
||||
});
|
||||
@@ -62,8 +62,8 @@ public:
|
||||
mlir::SmallVector<int64_t> newShape;
|
||||
newShape.reserve(type.getShape().size() + 1);
|
||||
newShape.append(type.getShape().begin(), type.getShape().end());
|
||||
assert(glwe.getDimension() != -1);
|
||||
newShape.push_back(glwe.getDimension() + 1);
|
||||
assert(!glwe.getKey().isNotParameterized());
|
||||
newShape.push_back(glwe.getKey().getDimension().value() + 1);
|
||||
mlir::Type r = mlir::RankedTensorType::get(
|
||||
newShape, mlir::IntegerType::get(type.getContext(), 64));
|
||||
return r;
|
||||
@@ -124,11 +124,52 @@ struct BootstrapGLWEOpPattern
|
||||
TFHE::GLWECipherTextType inputType =
|
||||
bsOp.getCiphertext().getType().cast<TFHE::GLWECipherTextType>();
|
||||
|
||||
auto polySize = adaptor.getKey().getPolySize();
|
||||
auto glweDimension = adaptor.getKey().getGlweDim();
|
||||
auto levels = adaptor.getKey().getLevels();
|
||||
auto baseLog = adaptor.getKey().getBaseLog();
|
||||
auto inputLweDimension = inputType.getKey().getDimension().value();
|
||||
|
||||
rewriter.replaceOpWithNewOp<Concrete::BootstrapLweTensorOp>(
|
||||
bsOp, this->getTypeConverter()->convertType(resultType),
|
||||
adaptor.getCiphertext(), adaptor.getLookupTable(),
|
||||
inputType.getDimension(), adaptor.getPolySize(), adaptor.getLevel(),
|
||||
adaptor.getBaseLog(), adaptor.getGlweDimension());
|
||||
adaptor.getCiphertext(), adaptor.getLookupTable(), inputLweDimension,
|
||||
polySize, levels, baseLog, glweDimension);
|
||||
|
||||
return mlir::success();
|
||||
}
|
||||
};
|
||||
|
||||
struct WopPBSGLWEOpPattern
|
||||
: public mlir::OpConversionPattern<TFHE::WopPBSGLWEOp> {
|
||||
|
||||
WopPBSGLWEOpPattern(mlir::MLIRContext *context,
|
||||
mlir::TypeConverter &typeConverter)
|
||||
: mlir::OpConversionPattern<TFHE::WopPBSGLWEOp>(
|
||||
typeConverter, context,
|
||||
mlir::concretelang::DEFAULT_PATTERN_BENEFIT) {}
|
||||
|
||||
::mlir::LogicalResult
|
||||
matchAndRewrite(TFHE::WopPBSGLWEOp op, TFHE::WopPBSGLWEOp::Adaptor adaptor,
|
||||
mlir::ConversionPatternRewriter &rewriter) const override {
|
||||
|
||||
auto bsBaseLog = adaptor.getBsk().getBaseLog();
|
||||
auto bsLevels = adaptor.getBsk().getLevels();
|
||||
auto cbsBaseLog = adaptor.getCbsBaseLog();
|
||||
auto cbsLevels = adaptor.getCbsLevels();
|
||||
auto ksBaseLog = adaptor.getKsk().getBaseLog();
|
||||
auto ksLevels = adaptor.getKsk().getLevels();
|
||||
auto pksBaseLog = adaptor.getPksk().getBaseLog();
|
||||
auto pksLevels = adaptor.getPksk().getLevels();
|
||||
auto pksInputLweDim = adaptor.getPksk().getInputLweDim();
|
||||
auto pksOutputPolySize = adaptor.getPksk().getOutputPolySize();
|
||||
auto crtDecomposition = adaptor.getCrtDecompositionAttr();
|
||||
auto resultType = op.getType();
|
||||
|
||||
rewriter.replaceOpWithNewOp<Concrete::WopPBSCRTLweTensorOp>(
|
||||
op, this->getTypeConverter()->convertType(resultType),
|
||||
adaptor.getCiphertexts(), adaptor.getLookupTable(), bsLevels, bsBaseLog,
|
||||
ksLevels, ksBaseLog, pksInputLweDim, pksOutputPolySize, pksLevels,
|
||||
pksBaseLog, cbsLevels, cbsBaseLog, crtDecomposition);
|
||||
|
||||
return mlir::success();
|
||||
}
|
||||
@@ -153,10 +194,14 @@ struct KeySwitchGLWEOpPattern
|
||||
TFHE::GLWECipherTextType inputType =
|
||||
ksOp.getCiphertext().getType().cast<TFHE::GLWECipherTextType>();
|
||||
|
||||
auto levels = adaptor.getKey().getLevels();
|
||||
auto baseLog = adaptor.getKey().getBaseLog();
|
||||
auto inputDim = inputType.getKey().getDimension().value();
|
||||
auto outputDim = resultType.getKey().getDimension().value();
|
||||
|
||||
rewriter.replaceOpWithNewOp<Concrete::KeySwitchLweTensorOp>(
|
||||
ksOp, this->getTypeConverter()->convertType(resultType),
|
||||
adaptor.getCiphertext(), adaptor.getLevel(), adaptor.getBaseLog(),
|
||||
inputType.getDimension(), resultType.getDimension());
|
||||
adaptor.getCiphertext(), levels, baseLog, inputDim, outputDim);
|
||||
|
||||
return mlir::success();
|
||||
}
|
||||
@@ -521,8 +566,8 @@ struct FromElementsOpPattern
|
||||
//
|
||||
// ```mlir
|
||||
// %0 = "ShapeOp" %arg0 [reassocations...]
|
||||
// : tensor<...x!TFHE.glwe<{dimension,1,bits}{p}>> into
|
||||
// tensor<...x!TFHE.glwe<{dimension,1,bits}{p}>>
|
||||
// : tensor<...x!TFHE.glwe<sk(id){dimension,1}>> into
|
||||
// tensor<...x!TFHE.glwe<sk(id){dimension,1}>>
|
||||
// ```
|
||||
//
|
||||
// becomes:
|
||||
@@ -663,17 +708,15 @@ void TFHEToConcretePass::runOnOperation() {
|
||||
mlir::concretelang::Concrete::EncodeLutForCrtWopPBSTensorOp, true>,
|
||||
mlir::concretelang::GenericOneToOneOpConversionPattern<
|
||||
mlir::concretelang::TFHE::EncodePlaintextWithCrtOp,
|
||||
mlir::concretelang::Concrete::EncodePlaintextWithCrtTensorOp, true>,
|
||||
mlir::concretelang::GenericOneToOneOpConversionPattern<
|
||||
mlir::concretelang::TFHE::WopPBSGLWEOp,
|
||||
mlir::concretelang::Concrete::WopPBSCRTLweTensorOp, true>>(
|
||||
mlir::concretelang::Concrete::EncodePlaintextWithCrtTensorOp, true>>(
|
||||
&getContext(), converter);
|
||||
// pattern of remaining TFHE ops
|
||||
patterns.insert<ZeroOpPattern<mlir::concretelang::TFHE::ZeroGLWEOp>,
|
||||
ZeroOpPattern<mlir::concretelang::TFHE::ZeroTensorGLWEOp>>(
|
||||
&getContext());
|
||||
patterns.insert<SubIntGLWEOpPattern, BootstrapGLWEOpPattern,
|
||||
KeySwitchGLWEOpPattern>(&getContext(), converter);
|
||||
KeySwitchGLWEOpPattern, WopPBSGLWEOpPattern>(&getContext(),
|
||||
converter);
|
||||
|
||||
// Add patterns to rewrite tensor operators that works on tensors of TFHE GLWE
|
||||
// types
|
||||
|
||||
@@ -3,6 +3,7 @@ add_mlir_dialect_library(
|
||||
TFHEDialect.cpp
|
||||
TFHEOps.cpp
|
||||
TFHETypes.cpp
|
||||
TFHEParameters.cpp
|
||||
ADDITIONAL_HEADER_DIRS
|
||||
${PROJECT_SOURCE_DIR}/include/concretelang/Dialect/TFHE
|
||||
DEPENDS
|
||||
|
||||
@@ -5,7 +5,9 @@
|
||||
|
||||
#include "concretelang/Dialect/TFHE/IR/TFHEDialect.h"
|
||||
#include "concretelang/Dialect/TFHE/IR/TFHEOps.h"
|
||||
#include "concretelang/Dialect/TFHE/IR/TFHETypes.h"
|
||||
|
||||
#define GET_ATTRDEF_CLASSES
|
||||
#include "concretelang/Dialect/TFHE/IR/TFHEAttrs.cpp.inc"
|
||||
|
||||
#define GET_TYPEDEF_CLASSES
|
||||
#include "concretelang/Dialect/TFHE/IR/TFHEOpsTypes.cpp.inc"
|
||||
@@ -26,20 +28,25 @@ void TFHEDialect::initialize() {
|
||||
#define GET_TYPEDEF_LIST
|
||||
#include "concretelang/Dialect/TFHE/IR/TFHEOpsTypes.cpp.inc"
|
||||
>();
|
||||
|
||||
addAttributes<
|
||||
#define GET_ATTRDEF_LIST
|
||||
#include "concretelang/Dialect/TFHE/IR/TFHEAttrs.cpp.inc"
|
||||
>();
|
||||
}
|
||||
|
||||
/// Verify that GLWE parameter are consistant
|
||||
/// - The bits parameter is 64 (we support only this for v0)
|
||||
::mlir::LogicalResult GLWECipherTextType::verify(
|
||||
::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError,
|
||||
signed dimension, signed polynomialSize, signed bits, signed p) {
|
||||
if (bits != -1 && bits != 64) {
|
||||
emitError() << "GLWE bits parameter can only be 64";
|
||||
GLWESecretKey key) {
|
||||
if (!key.isNotParameterized() && key.getPolySize().value() == 0) {
|
||||
emitError() << "GLWE key has zero poly size.";
|
||||
return ::mlir::failure();
|
||||
}
|
||||
if (p == 0) {
|
||||
emitError() << "GLWE p parameter must be positive";
|
||||
return mlir::failure();
|
||||
if (!key.isNotParameterized() && key.getDimension().value() == 0) {
|
||||
emitError() << "GLWE key has zero dimension.";
|
||||
return ::mlir::failure();
|
||||
}
|
||||
return ::mlir::success();
|
||||
}
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
|
||||
#include "mlir/IR/Region.h"
|
||||
|
||||
#include "concretelang/Dialect/FHE/IR/FHEOps.h"
|
||||
#include "concretelang/Dialect/TFHE/IR/TFHEAttrs.h"
|
||||
#include "concretelang/Dialect/TFHE/IR/TFHEDialect.h"
|
||||
#include "concretelang/Dialect/TFHE/IR/TFHEOps.h"
|
||||
#include "concretelang/Dialect/TFHE/IR/TFHETypes.h"
|
||||
|
||||
@@ -13,37 +14,20 @@ namespace mlir {
|
||||
namespace concretelang {
|
||||
namespace TFHE {
|
||||
|
||||
void emitOpErrorForIncompatibleGLWEParameter(mlir::OpState &op,
|
||||
llvm::Twine parameter) {
|
||||
op.emitOpError() << "should have the same GLWE '" << parameter
|
||||
<< "' parameter";
|
||||
void emitOpErrorForKeyMismatch(mlir::OpState &op) {
|
||||
op.emitOpError() << "should have the same GLWE Secret Key";
|
||||
}
|
||||
|
||||
mlir::LogicalResult _verifyGLWEIntegerOperator(mlir::OpState &op,
|
||||
GLWECipherTextType &a,
|
||||
IntegerType &b,
|
||||
GLWECipherTextType &result) {
|
||||
// verify consistency of a and result GLWE parameter
|
||||
if (a.getDimension() != result.getDimension()) {
|
||||
emitOpErrorForIncompatibleGLWEParameter(op, "dimension");
|
||||
return mlir::failure();
|
||||
}
|
||||
if (a.getPolynomialSize() != result.getPolynomialSize()) {
|
||||
emitOpErrorForIncompatibleGLWEParameter(op, "polynomialSize");
|
||||
return mlir::failure();
|
||||
}
|
||||
if (a.getBits() != result.getBits()) {
|
||||
emitOpErrorForIncompatibleGLWEParameter(op, "bits");
|
||||
return mlir::failure();
|
||||
}
|
||||
if (a.getP() != result.getP()) {
|
||||
emitOpErrorForIncompatibleGLWEParameter(op, "p");
|
||||
// verify consistency of a and result GLWE secret key
|
||||
if (a.getKey() != result.getKey()) {
|
||||
emitOpErrorForKeyMismatch(op);
|
||||
return mlir::failure();
|
||||
}
|
||||
|
||||
if ((int)b.getWidth() != 64) {
|
||||
op.emitOpError() << "should have the width of `b` equals to 64.";
|
||||
}
|
||||
// verify consistency of width of inputs
|
||||
if ((int)b.getWidth() != 64) {
|
||||
op.emitOpError() << "should have the width of `b` equals 64 : "
|
||||
@@ -53,9 +37,6 @@ mlir::LogicalResult _verifyGLWEIntegerOperator(mlir::OpState &op,
|
||||
return mlir::success();
|
||||
}
|
||||
|
||||
/// verifyGLWEIntegerOperator verify parameters of operators that has the
|
||||
/// following signature (!TFHE.glwe<{dim,poly,bits}{p}>, ip+1) ->
|
||||
/// (!TFHE.glwe<{dim,poly,bits}{p}>))
|
||||
template <class Operator>
|
||||
mlir::LogicalResult verifyGLWEIntegerOperator(Operator &op) {
|
||||
auto a = ((mlir::Type)(op.getA().getType())).cast<GLWECipherTextType>();
|
||||
@@ -66,9 +47,6 @@ mlir::LogicalResult verifyGLWEIntegerOperator(Operator &op) {
|
||||
return _verifyGLWEIntegerOperator(op, a, b, result);
|
||||
}
|
||||
|
||||
/// verifyIntegerGLWEOperator verify parameters of operators that has the
|
||||
/// following signature (ip+1, !TFHE.glwe<{dim,poly,bits}{p}>) ->
|
||||
/// (!TFHE.glwe<{dim,poly,bits}{p}>))
|
||||
template <class Operator>
|
||||
mlir::LogicalResult verifyIntegerGLWEOperator(Operator &op) {
|
||||
auto a = ((mlir::Type)(op.getA().getType())).cast<IntegerType>();
|
||||
@@ -79,10 +57,8 @@ mlir::LogicalResult verifyIntegerGLWEOperator(Operator &op) {
|
||||
return _verifyGLWEIntegerOperator(op, b, a, result);
|
||||
}
|
||||
|
||||
/// verifyBinaryGLWEOperator verify parameters of operators that has the
|
||||
/// following signature (!TFHE.glwe<{dim,poly,bits}{p}>,
|
||||
/// !TFHE.glwe<{dim,poly,bits}{p}>) ->
|
||||
/// (!TFHE.glwe<{dim,poly,bits}{p}>))
|
||||
/// verifyBinaryGLWEOperator verify parameters of operators that have the same
|
||||
/// secret key.
|
||||
template <class Operator>
|
||||
mlir::LogicalResult verifyBinaryGLWEOperator(Operator &op) {
|
||||
auto a = ((mlir::Type)(op.getA().getType())).cast<GLWECipherTextType>();
|
||||
@@ -90,49 +66,26 @@ mlir::LogicalResult verifyBinaryGLWEOperator(Operator &op) {
|
||||
auto result =
|
||||
((mlir::Type)(op.getResult().getType())).cast<GLWECipherTextType>();
|
||||
|
||||
// verify consistency of a and result GLWE parameter
|
||||
if (a.getDimension() != b.getDimension() ||
|
||||
a.getDimension() != result.getDimension()) {
|
||||
emitOpErrorForIncompatibleGLWEParameter(op, "dimension");
|
||||
return mlir::failure();
|
||||
}
|
||||
if (a.getPolynomialSize() != b.getPolynomialSize() ||
|
||||
a.getPolynomialSize() != result.getPolynomialSize()) {
|
||||
emitOpErrorForIncompatibleGLWEParameter(op, "polynomialSize");
|
||||
return mlir::failure();
|
||||
}
|
||||
if (a.getBits() != b.getBits() || a.getBits() != result.getBits()) {
|
||||
emitOpErrorForIncompatibleGLWEParameter(op, "bits");
|
||||
// verify consistency of a and result GLWE secret key.
|
||||
if (a.getKey() != b.getKey() || a.getKey() != result.getKey()) {
|
||||
emitOpErrorForKeyMismatch(op);
|
||||
return mlir::failure();
|
||||
}
|
||||
|
||||
return mlir::success();
|
||||
}
|
||||
|
||||
/// verifyUnaryGLWEOperator verify parameters of operators that has the
|
||||
/// following signature (!TFHE.glwe<{dim,poly,bits}{p}>) ->
|
||||
/// (!TFHE.glwe<{dim,poly,bits}{p}>))
|
||||
/// verifyUnaryGLWEOperator verify parameters of operators that have the same
|
||||
/// secret key.
|
||||
template <class Operator>
|
||||
mlir::LogicalResult verifyUnaryGLWEOperator(Operator &op) {
|
||||
auto a = ((mlir::Type)(op.getA().getType())).cast<GLWECipherTextType>();
|
||||
auto result =
|
||||
((mlir::Type)(op.getResult().getType())).cast<GLWECipherTextType>();
|
||||
|
||||
// verify consistency of a and result GLWE parameter
|
||||
if (a.getDimension() != result.getDimension()) {
|
||||
emitOpErrorForIncompatibleGLWEParameter(op, "dimension");
|
||||
return mlir::failure();
|
||||
}
|
||||
if (a.getPolynomialSize() != result.getPolynomialSize()) {
|
||||
emitOpErrorForIncompatibleGLWEParameter(op, "polynomialSize");
|
||||
return mlir::failure();
|
||||
}
|
||||
if (a.getBits() != result.getBits()) {
|
||||
emitOpErrorForIncompatibleGLWEParameter(op, "bits");
|
||||
return mlir::failure();
|
||||
}
|
||||
if (a.getP() != result.getP()) {
|
||||
emitOpErrorForIncompatibleGLWEParameter(op, "p");
|
||||
// verify consistency of a and result GLWE secret key.
|
||||
if (a.getKey() != result.getKey()) {
|
||||
emitOpErrorForKeyMismatch(op);
|
||||
return mlir::failure();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
// 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/TFHE/IR/TFHEParameters.h"
|
||||
|
||||
namespace mlir {
|
||||
namespace concretelang {
|
||||
namespace TFHE {
|
||||
|
||||
GLWESecretKey::GLWESecretKey() {
|
||||
dimension = -1;
|
||||
polySize = -1;
|
||||
id = -1;
|
||||
}
|
||||
|
||||
GLWESecretKey::GLWESecretKey(int64_t dimension, int64_t polySize, int64_t id) {
|
||||
assert(dimension > 0);
|
||||
assert(polySize > 0);
|
||||
assert(id > 0);
|
||||
this->dimension = dimension;
|
||||
this->polySize = polySize;
|
||||
this->id = id;
|
||||
}
|
||||
|
||||
bool GLWESecretKey::operator==(GLWESecretKey other) {
|
||||
return this->id == other.id && this->dimension == other.dimension &&
|
||||
this->polySize == other.polySize;
|
||||
}
|
||||
|
||||
bool GLWESecretKey::operator==(const GLWESecretKey other) const {
|
||||
return this->id == other.id && this->dimension == other.dimension &&
|
||||
this->polySize == other.polySize;
|
||||
}
|
||||
|
||||
bool GLWESecretKey::operator!=(GLWESecretKey other) {
|
||||
return this->id != other.id || this->dimension != other.dimension ||
|
||||
this->polySize != other.polySize;
|
||||
}
|
||||
|
||||
std::optional<int64_t> GLWESecretKey::getDimension() const {
|
||||
if (this->isNotParameterized()) {
|
||||
return std::nullopt;
|
||||
} else {
|
||||
return this->dimension;
|
||||
}
|
||||
}
|
||||
|
||||
std::optional<int64_t> GLWESecretKey::getPolySize() const {
|
||||
if (this->isNotParameterized()) {
|
||||
return std::nullopt;
|
||||
} else {
|
||||
return this->polySize;
|
||||
}
|
||||
}
|
||||
|
||||
mlir::Optional<int64_t> GLWESecretKey::getId() const {
|
||||
if (this->isNotParameterized()) {
|
||||
return std::nullopt;
|
||||
} else {
|
||||
return this->id;
|
||||
}
|
||||
}
|
||||
|
||||
bool GLWESecretKey::isNotParameterized() const { return id <= 0; }
|
||||
|
||||
llvm::hash_code hash_value(const GLWESecretKey &key) {
|
||||
return llvm::hash_combine("GlweSecretKey", key.getDimension(),
|
||||
key.getPolySize(), key.getId());
|
||||
}
|
||||
|
||||
} // namespace TFHE
|
||||
} // namespace concretelang
|
||||
} // namespace mlir
|
||||
|
||||
namespace mlir {
|
||||
AsmPrinter &operator<<(AsmPrinter &p,
|
||||
mlir::concretelang::TFHE::GLWESecretKey key) {
|
||||
if (key.isNotParameterized()) {
|
||||
p << "sk[?]";
|
||||
} else {
|
||||
p << "sk[" << key.getId() << "]<" << key.getPolySize().value() << ","
|
||||
<< key.getDimension().value() << ">";
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
FailureOr<mlir::concretelang::TFHE::GLWESecretKey>
|
||||
FieldParser<mlir::concretelang::TFHE::GLWESecretKey>::parse(AsmParser &parser) {
|
||||
int64_t dimension = -1, polySize = -1, id = -1;
|
||||
if (parser.parseKeyword("sk") || parser.parseLSquare()) {
|
||||
return mlir::failure();
|
||||
}
|
||||
auto maybeId = parser.parseOptionalInteger(id);
|
||||
if (maybeId.has_value()) {
|
||||
if (maybeId.value() || parser.parseRSquare() || parser.parseLess() ||
|
||||
parser.parseInteger(polySize) || parser.parseComma() ||
|
||||
parser.parseInteger(dimension) || parser.parseGreater()) {
|
||||
return mlir::failure();
|
||||
}
|
||||
} else {
|
||||
if (parser.parseQuestion() || parser.parseRSquare()) {
|
||||
return mlir::failure();
|
||||
}
|
||||
}
|
||||
if (id <= 0) {
|
||||
return mlir::concretelang::TFHE::GLWESecretKey();
|
||||
} else {
|
||||
return mlir::concretelang::TFHE::GLWESecretKey(dimension, polySize, id);
|
||||
}
|
||||
}
|
||||
} // namespace mlir
|
||||
@@ -4,6 +4,7 @@
|
||||
// for license information.
|
||||
|
||||
#include <concretelang/Dialect/TFHE/IR/TFHETypes.h>
|
||||
#include <mlir/IR/DialectImplementation.h>
|
||||
|
||||
namespace mlir {
|
||||
namespace concretelang {
|
||||
@@ -18,57 +19,28 @@ void printSigned(mlir::AsmPrinter &p, signed i) {
|
||||
|
||||
void GLWECipherTextType::print(mlir::AsmPrinter &p) const {
|
||||
p << "<";
|
||||
p << "{";
|
||||
printSigned(p, getDimension());
|
||||
p << ",";
|
||||
printSigned(p, getPolynomialSize());
|
||||
p << ",";
|
||||
printSigned(p, getBits());
|
||||
p << "}";
|
||||
|
||||
p << "{";
|
||||
printSigned(p, getP());
|
||||
p << "}>";
|
||||
p << getKey();
|
||||
p << ">";
|
||||
}
|
||||
|
||||
mlir::Type GLWECipherTextType::parse(AsmParser &parser) {
|
||||
if (parser.parseLess())
|
||||
return mlir::Type();
|
||||
|
||||
if (parser.parseLBrace())
|
||||
return mlir::Type();
|
||||
|
||||
// First parameters block
|
||||
int dimension = -1;
|
||||
if (parser.parseOptionalKeyword("_") && parser.parseInteger(dimension))
|
||||
return mlir::Type();
|
||||
if (parser.parseComma())
|
||||
return mlir::Type();
|
||||
int polynomialSize = -1;
|
||||
if (parser.parseOptionalKeyword("_") && parser.parseInteger(polynomialSize))
|
||||
return mlir::Type();
|
||||
if (parser.parseComma())
|
||||
return mlir::Type();
|
||||
int bits = -1;
|
||||
if (parser.parseOptionalKeyword("_") && parser.parseInteger(bits))
|
||||
return mlir::Type();
|
||||
if (parser.parseRBrace())
|
||||
return mlir::Type();
|
||||
|
||||
// Next parameters block
|
||||
if (parser.parseLBrace())
|
||||
return mlir::Type();
|
||||
int p = -1;
|
||||
if (parser.parseInteger(p))
|
||||
return mlir::Type();
|
||||
if (parser.parseRBrace())
|
||||
FailureOr<mlir::concretelang::TFHE::GLWESecretKey> maybeKey =
|
||||
FieldParser<GLWESecretKey>::parse(parser);
|
||||
if (failed(maybeKey))
|
||||
return mlir::Type();
|
||||
|
||||
if (parser.parseGreater())
|
||||
return mlir::Type();
|
||||
|
||||
Location loc = parser.getEncodedSourceLoc(parser.getNameLoc());
|
||||
return getChecked(loc, loc.getContext(), dimension, polynomialSize, bits, p);
|
||||
|
||||
return getChecked(loc, loc.getContext(), maybeKey.value());
|
||||
}
|
||||
|
||||
} // namespace TFHE
|
||||
} // namespace concretelang
|
||||
} // namespace mlir
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: concretecompiler --action=dump-llvm-ir %s
|
||||
// RUN: concretecompiler --action=dump-llvm-ir %s
|
||||
// Just ensure that compile
|
||||
// https://github.com/zama-ai/concrete-compiler-internal/issues/785
|
||||
func.func @main(%arg0: !FHE.eint<15>, %cst: tensor<32768xi64>) -> tensor<1x!FHE.eint<15>> {
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
// RUN: concretecompiler --optimize-tfhe=false --action=dump-tfhe %s --large-integer-crt-decomposition=2,3,5,7,11 --large-integer-circuit-bootstrap=2,9 --large-integer-packing-keyswitch=694,1024,4,9 --v0-parameter=2,10,693,4,9,7,2 2>&1| FileCheck %s
|
||||
|
||||
//CHECK: func.func @add_eint(%[[Varg0:.*]]: tensor<5x!TFHE.glwe<{_,_,_}{7}>>, %[[Varg1:.*]]: tensor<5x!TFHE.glwe<{_,_,_}{7}>>) -> tensor<5x!TFHE.glwe<{_,_,_}{7}>> {
|
||||
//CHECK-NEXT: %[[V0:.*]] = bufferization.alloc_tensor() : tensor<5x!TFHE.glwe<{_,_,_}{7}>>
|
||||
//CHECK: func.func @add_eint(%[[Varg0:.*]]: tensor<5x!TFHE.glwe<sk[?]>>, %[[Varg1:.*]]: tensor<5x!TFHE.glwe<sk[?]>>) -> tensor<5x!TFHE.glwe<sk[?]>> {
|
||||
//CHECK-NEXT: %[[V0:.*]] = bufferization.alloc_tensor() : tensor<5x!TFHE.glwe<sk[?]>>
|
||||
//CHECK-NEXT: %[[Vc0:.*]] = arith.constant 0 : index
|
||||
//CHECK-NEXT: %[[Vc1:.*]] = arith.constant 1 : index
|
||||
//CHECK-NEXT: %[[Vc5:.*]] = arith.constant 5 : index
|
||||
//CHECK-NEXT: %[[V1:.*]] = scf.for %[[Varg2:.*]] = %[[Vc0]] to %[[Vc5]] step %[[Vc1]] iter_args(%[[Varg3:.*]] = %[[V0]]) -> (tensor<5x!TFHE.glwe<{_,_,_}{7}>>) {
|
||||
//CHECK-NEXT: %[[V2:.*]] = tensor.extract %[[Varg0]][%[[Varg2]]] : tensor<5x!TFHE.glwe<{_,_,_}{7}>>
|
||||
//CHECK-NEXT: %[[V3:.*]] = tensor.extract %[[Varg1]][%[[Varg2]]] : tensor<5x!TFHE.glwe<{_,_,_}{7}>>
|
||||
//CHECK-NEXT: %[[V4:.*]] = "TFHE.add_glwe"(%[[V2]], %[[V3]]) : (!TFHE.glwe<{_,_,_}{7}>, !TFHE.glwe<{_,_,_}{7}>) -> !TFHE.glwe<{_,_,_}{7}>
|
||||
//CHECK-NEXT: %[[V5:.*]] = tensor.insert %[[V4]] into %[[Varg3]][%[[Varg2]]] : tensor<5x!TFHE.glwe<{_,_,_}{7}>>
|
||||
//CHECK-NEXT: scf.yield %[[V5]] : tensor<5x!TFHE.glwe<{_,_,_}{7}>>
|
||||
//CHECK-NEXT: %[[V1:.*]] = scf.for %[[Varg2:.*]] = %[[Vc0]] to %[[Vc5]] step %[[Vc1]] iter_args(%[[Varg3:.*]] = %[[V0]]) -> (tensor<5x!TFHE.glwe<sk[?]>>) {
|
||||
//CHECK-NEXT: %[[V2:.*]] = tensor.extract %[[Varg0]][%[[Varg2]]] : tensor<5x!TFHE.glwe<sk[?]>>
|
||||
//CHECK-NEXT: %[[V3:.*]] = tensor.extract %[[Varg1]][%[[Varg2]]] : tensor<5x!TFHE.glwe<sk[?]>>
|
||||
//CHECK-NEXT: %[[V4:.*]] = "TFHE.add_glwe"(%[[V2]], %[[V3]]) : (!TFHE.glwe<sk[?]>, !TFHE.glwe<sk[?]>) -> !TFHE.glwe<sk[?]>
|
||||
//CHECK-NEXT: %[[V5:.*]] = tensor.insert %[[V4]] into %[[Varg3]][%[[Varg2]]] : tensor<5x!TFHE.glwe<sk[?]>>
|
||||
//CHECK-NEXT: scf.yield %[[V5]] : tensor<5x!TFHE.glwe<sk[?]>>
|
||||
//CHECK-NEXT: }
|
||||
//CHECK-NEXT: return %[[V1]] : tensor<5x!TFHE.glwe<{_,_,_}{7}>>
|
||||
//CHECK-NEXT: return %[[V1]] : tensor<5x!TFHE.glwe<sk[?]>>
|
||||
func.func @add_eint(%arg0: !FHE.eint<7>, %arg1: !FHE.eint<7>) -> !FHE.eint<7> {
|
||||
%1 = "FHE.add_eint"(%arg0, %arg1): (!FHE.eint<7>, !FHE.eint<7>) -> (!FHE.eint<7>)
|
||||
return %1: !FHE.eint<7>
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
// RUN: concretecompiler --optimize-tfhe=false --action=dump-tfhe %s --large-integer-crt-decomposition=2,3,5,7,11 --large-integer-circuit-bootstrap=2,9 --large-integer-packing-keyswitch=694,1024,4,9 --v0-parameter=2,10,693,4,9,7,2 2>&1| FileCheck %s
|
||||
|
||||
// CHECK: func.func @add_eint_int(%[[Varg0:.*]]: tensor<5x!TFHE.glwe<{_,_,_}{7}>>) -> tensor<5x!TFHE.glwe<{_,_,_}{7}>> {
|
||||
// CHECK: func.func @add_eint_int(%[[Varg0:.*]]: tensor<5x!TFHE.glwe<sk[?]>>) -> tensor<5x!TFHE.glwe<sk[?]>> {
|
||||
// CHECK-NEXT: %[[Vc1_i8:.*]] = arith.constant 1 : i8
|
||||
// CHECK-NEXT: %[[V0:.*]] = arith.extsi %[[Vc1_i8]] : i8 to i64
|
||||
// CHECK-NEXT: %[[V1:.*]] = "TFHE.encode_plaintext_with_crt"(%[[V0]]) {mods = [2, 3, 5, 7, 11], modsProd = 2310 : i64} : (i64) -> tensor<5xi64>
|
||||
// CHECK-NEXT: %[[V2:.*]] = bufferization.alloc_tensor() : tensor<5x!TFHE.glwe<{_,_,_}{7}>>
|
||||
// CHECK-NEXT: %[[V2:.*]] = bufferization.alloc_tensor() : tensor<5x!TFHE.glwe<sk[?]>>
|
||||
// CHECK-NEXT: %[[Vc0:.*]] = arith.constant 0 : index
|
||||
// CHECK-NEXT: %[[Vc1:.*]] = arith.constant 1 : index
|
||||
// CHECK-NEXT: %[[Vc5:.*]] = arith.constant 5 : index
|
||||
// CHECK-NEXT: %[[V3:.*]] = scf.for %[[Varg1:.*]] = %[[Vc0]] to %[[Vc5]] step %[[Vc1]] iter_args(%[[Varg2:.*]] = %[[V2]]) -> (tensor<5x!TFHE.glwe<{_,_,_}{7}>>) {
|
||||
// CHECK-NEXT: %[[V4:.*]] = tensor.extract %[[Varg0]][%[[Varg1]]] : tensor<5x!TFHE.glwe<{_,_,_}{7}>>
|
||||
// CHECK-NEXT: %[[V3:.*]] = scf.for %[[Varg1:.*]] = %[[Vc0]] to %[[Vc5]] step %[[Vc1]] iter_args(%[[Varg2:.*]] = %[[V2]]) -> (tensor<5x!TFHE.glwe<sk[?]>>) {
|
||||
// CHECK-NEXT: %[[V4:.*]] = tensor.extract %[[Varg0]][%[[Varg1]]] : tensor<5x!TFHE.glwe<sk[?]>>
|
||||
// CHECK-NEXT: %[[V5:.*]] = tensor.extract %[[V1]][%[[Varg1]]] : tensor<5xi64>
|
||||
// CHECK-NEXT: %[[V6:.*]] = "TFHE.add_glwe_int"(%[[V4]], %[[V5]]) : (!TFHE.glwe<{_,_,_}{7}>, i64) -> !TFHE.glwe<{_,_,_}{7}>
|
||||
// CHECK-NEXT: %[[V7:.*]] = tensor.insert %[[V6]] into %[[Varg2]][%[[Varg1]]] : tensor<5x!TFHE.glwe<{_,_,_}{7}>>
|
||||
// CHECK-NEXT: scf.yield %[[V7]] : tensor<5x!TFHE.glwe<{_,_,_}{7}>>
|
||||
// CHECK-NEXT: %[[V6:.*]] = "TFHE.add_glwe_int"(%[[V4]], %[[V5]]) : (!TFHE.glwe<sk[?]>, i64) -> !TFHE.glwe<sk[?]>
|
||||
// CHECK-NEXT: %[[V7:.*]] = tensor.insert %[[V6]] into %[[Varg2]][%[[Varg1]]] : tensor<5x!TFHE.glwe<sk[?]>>
|
||||
// CHECK-NEXT: scf.yield %[[V7]] : tensor<5x!TFHE.glwe<sk[?]>>
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: return %[[V3]] : tensor<5x!TFHE.glwe<{_,_,_}{7}>>
|
||||
// CHECK-NEXT: return %[[V3]] : tensor<5x!TFHE.glwe<sk[?]>>
|
||||
func.func @add_eint_int(%arg0: !FHE.eint<7>) -> !FHE.eint<7> {
|
||||
%0 = arith.constant 1 : i8
|
||||
%1 = "FHE.add_eint_int"(%arg0, %0): (!FHE.eint<7>, i8) -> (!FHE.eint<7>)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// RUN: concretecompiler --optimize-tfhe=false --action=dump-tfhe %s --large-integer-crt-decomposition=2,3,5,7,11 --large-integer-circuit-bootstrap=2,9 --large-integer-packing-keyswitch=694,1024,4,9 --v0-parameter=2,10,693,4,9,7,2 2>&1| FileCheck %s
|
||||
|
||||
// CHECK: func.func @apply_lookup_table(%arg0: tensor<5x!TFHE.glwe<{_,_,_}{2}>>, %arg1: tensor<4xi64>) -> tensor<5x!TFHE.glwe<{_,_,_}{3}>>
|
||||
// CHECK: func.func @apply_lookup_table(%arg0: tensor<5x!TFHE.glwe<sk[?]>>, %arg1: tensor<4xi64>) -> tensor<5x!TFHE.glwe<sk[?]>>
|
||||
// CHECK-NEXT: %0 = "TFHE.encode_lut_for_crt_woppbs"(%arg1) {crtBits = [1, 2, 3, 3, 4], crtDecomposition = [2, 3, 5, 7, 11], isSigned = false, modulusProduct = 2310 : i32} : (tensor<4xi64>) -> tensor<5x8192xi64>
|
||||
// CHECK-NEXT: %1 = "TFHE.wop_pbs_glwe"(%arg0, %0) {bootstrapBaseLog = -1 : i32, bootstrapLevel = -1 : i32, circuitBootstrapBaseLog = -1 : i32, circuitBootstrapLevel = -1 : i32, crtDecomposition = [], keyswitchBaseLog = -1 : i32, keyswitchLevel = -1 : i32, packingKeySwitchBaseLog = -1 : i32, packingKeySwitchInputLweDimension = -1 : i32, packingKeySwitchLevel = -1 : i32, packingKeySwitchoutputPolynomialSize = -1 : i32} : (tensor<5x!TFHE.glwe<{_,_,_}{2}>>, tensor<5x8192xi64>) -> tensor<5x!TFHE.glwe<{_,_,_}{3}>>
|
||||
// CHECK-NEXT: return %1 : tensor<5x!TFHE.glwe<{_,_,_}{3}>>
|
||||
// CHECK-NEXT: %1 = "TFHE.wop_pbs_glwe"(%arg0, %0) {bsk = #TFHE.bsk<sk[?], sk[?], -1, -1, -1, -1>, cbsBaseLog = -1 : i32, cbsLevels = -1 : i32, crtDecomposition = [], ksk = #TFHE.ksk<sk[?], sk[?], -1, -1>, pksk = #TFHE.pksk<sk[?], sk[?], -1, -1, -1, -1>} : (tensor<5x!TFHE.glwe<sk[?]>>, tensor<5x8192xi64>) -> tensor<5x!TFHE.glwe<sk[?]>>
|
||||
// CHECK-NEXT: return %1 : tensor<5x!TFHE.glwe<sk[?]>>
|
||||
func.func @apply_lookup_table(%arg0: !FHE.eint<2>, %arg1: tensor<4xi64>) -> !FHE.eint<3> {
|
||||
%1 = "FHE.apply_lookup_table"(%arg0, %arg1): (!FHE.eint<2>, tensor<4xi64>) -> (!FHE.eint<3>)
|
||||
return %1: !FHE.eint<3>
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// RUN: concretecompiler --optimize-tfhe=false --action=dump-tfhe %s --large-integer-crt-decomposition=2,3,5,7,11 --large-integer-circuit-bootstrap=2,9 --large-integer-packing-keyswitch=694,1024,4,9 --v0-parameter=2,10,693,4,9,7,2 2>&1| FileCheck %s
|
||||
|
||||
// CHECK: func.func @apply_lookup_table_cst(%arg0: tensor<5x!TFHE.glwe<{_,_,_}{7}>>) -> tensor<5x!TFHE.glwe<{_,_,_}{7}>> {
|
||||
// CHECK: func.func @apply_lookup_table_cst(%arg0: tensor<5x!TFHE.glwe<sk[?]>>) -> tensor<5x!TFHE.glwe<sk[?]>> {
|
||||
// CHECK-NEXT: %cst = arith.constant dense<"0x00000000000000000100000000000000020000000000000003000000000000000400000000000000050000000000000006000000000000000700000000000000080000000000000009000000000000000A000000000000000B000000000000000C000000000000000D000000000000000E000000000000000F0000000000000010000000000000001100000000000000120000000000000013000000000000001400000000000000150000000000000016000000000000001700000000000000180000000000000019000000000000001A000000000000001B000000000000001C000000000000001D000000000000001E000000000000001F0000000000000020000000000000002100000000000000220000000000000023000000000000002400000000000000250000000000000026000000000000002700000000000000280000000000000029000000000000002A000000000000002B000000000000002C000000000000002D000000000000002E000000000000002F0000000000000030000000000000003100000000000000320000000000000033000000000000003400000000000000350000000000000036000000000000003700000000000000380000000000000039000000000000003A000000000000003B000000000000003C000000000000003D000000000000003E000000000000003F0000000000000040000000000000004100000000000000420000000000000043000000000000004400000000000000450000000000000046000000000000004700000000000000480000000000000049000000000000004A000000000000004B000000000000004C000000000000004D000000000000004E000000000000004F0000000000000050000000000000005100000000000000520000000000000053000000000000005400000000000000550000000000000056000000000000005700000000000000580000000000000059000000000000005A000000000000005B000000000000005C000000000000005D000000000000005E000000000000005F0000000000000060000000000000006100000000000000620000000000000063000000000000006400000000000000650000000000000066000000000000006700000000000000680000000000000069000000000000006A000000000000006B000000000000006C000000000000006D000000000000006E000000000000006F0000000000000070000000000000007100000000000000720000000000000073000000000000007400000000000000750000000000000076000000000000007700000000000000780000000000000079000000000000007A000000000000007B000000000000007C000000000000007D000000000000007E000000000000007F00000000000000"> : tensor<128xi64>
|
||||
// CHECK-NEXT: %0 = "TFHE.encode_lut_for_crt_woppbs"(%cst) {crtBits = [1, 2, 3, 3, 4], crtDecomposition = [2, 3, 5, 7, 11], isSigned = false, modulusProduct = 2310 : i32} : (tensor<128xi64>) -> tensor<5x8192xi64>
|
||||
// CHECK-NEXT: %1 = "TFHE.wop_pbs_glwe"(%arg0, %0) {bootstrapBaseLog = -1 : i32, bootstrapLevel = -1 : i32, circuitBootstrapBaseLog = -1 : i32, circuitBootstrapLevel = -1 : i32, crtDecomposition = [], keyswitchBaseLog = -1 : i32, keyswitchLevel = -1 : i32, packingKeySwitchBaseLog = -1 : i32, packingKeySwitchInputLweDimension = -1 : i32, packingKeySwitchLevel = -1 : i32, packingKeySwitchoutputPolynomialSize = -1 : i32} : (tensor<5x!TFHE.glwe<{_,_,_}{7}>>, tensor<5x8192xi64>) -> tensor<5x!TFHE.glwe<{_,_,_}{7}>>
|
||||
// CHECK-NEXT: return %1 : tensor<5x!TFHE.glwe<{_,_,_}{7}>>
|
||||
// CHECK-NEXT: %1 = "TFHE.wop_pbs_glwe"(%arg0, %0) {bsk = #TFHE.bsk<sk[?], sk[?], -1, -1, -1, -1>, cbsBaseLog = -1 : i32, cbsLevels = -1 : i32, crtDecomposition = [], ksk = #TFHE.ksk<sk[?], sk[?], -1, -1>, pksk = #TFHE.pksk<sk[?], sk[?], -1, -1, -1, -1>} : (tensor<5x!TFHE.glwe<sk[?]>>, tensor<5x8192xi64>) -> tensor<5x!TFHE.glwe<sk[?]>>
|
||||
// CHECK-NEXT: return %1 : tensor<5x!TFHE.glwe<sk[?]>>
|
||||
func.func @apply_lookup_table_cst(%arg0: !FHE.eint<7>) -> !FHE.eint<7> {
|
||||
%tlu = arith.constant dense<[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127]> : tensor<128xi64>
|
||||
%1 = "FHE.apply_lookup_table"(%arg0, %tlu): (!FHE.eint<7>, tensor<128xi64>) -> (!FHE.eint<7>)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// RUN: concretecompiler --optimize-tfhe=false --action=dump-tfhe %s --large-integer-crt-decomposition=2,3,5,7,11 --large-integer-circuit-bootstrap=2,9 --large-integer-packing-keyswitch=694,1024,4,9 --v0-parameter=2,10,693,4,9,7,2 2>&1| FileCheck %s
|
||||
|
||||
//CHECK: func.func @conv2d(%[[Varg0:.*]]: tensor<100x3x28x28x5x!TFHE.glwe<{_,_,_}{2}>>, %[[Varg1:.*]]: tensor<4x3x14x14xi3>, %[[Varg2:.*]]: tensor<4xi3>) -> tensor<100x4x15x15x5x!TFHE.glwe<{_,_,_}{2}>> {
|
||||
//CHECK: func.func @conv2d(%[[Varg0:.*]]: tensor<100x3x28x28x5x!TFHE.glwe<sk[?]>>, %[[Varg1:.*]]: tensor<4x3x14x14xi3>, %[[Varg2:.*]]: tensor<4xi3>) -> tensor<100x4x15x15x5x!TFHE.glwe<sk[?]>> {
|
||||
//CHECK-NEXT: %[[Vc0:.*]] = arith.constant 0 : index
|
||||
//CHECK-NEXT: %[[Vc100:.*]] = arith.constant 100 : index
|
||||
//CHECK-NEXT: %[[Vc1:.*]] = arith.constant 1 : index
|
||||
@@ -8,90 +8,90 @@
|
||||
//CHECK-NEXT: %[[Vc15:.*]] = arith.constant 15 : index
|
||||
//CHECK-NEXT: %[[Vc3:.*]] = arith.constant 3 : index
|
||||
//CHECK-NEXT: %[[Vc14:.*]] = arith.constant 14 : index
|
||||
//CHECK-NEXT: %[[V0:.*]] = "TFHE.zero_tensor"() : () -> tensor<100x4x15x15x5x!TFHE.glwe<{_,_,_}{2}>>
|
||||
//CHECK-NEXT: %[[V1:.*]] = scf.for %[[Varg3:.*]] = %[[Vc0]] to %[[Vc100]] step %[[Vc1]] iter_args(%[[Varg4:.*]] = %[[V0]]) -> (tensor<100x4x15x15x5x!TFHE.glwe<{_,_,_}{2}>>) {
|
||||
//CHECK-NEXT: %[[V3:.*]] = scf.for %[[Varg5:.*]] = %[[Vc0]] to %[[Vc4]] step %[[Vc1]] iter_args(%[[Varg6:.*]] = %[[Varg4]]) -> (tensor<100x4x15x15x5x!TFHE.glwe<{_,_,_}{2}>>) {
|
||||
//CHECK-NEXT: %[[V4:.*]] = scf.for %[[Varg7:.*]] = %[[Vc0]] to %[[Vc15]] step %[[Vc1]] iter_args(%[[Varg8:.*]] = %[[Varg6]]) -> (tensor<100x4x15x15x5x!TFHE.glwe<{_,_,_}{2}>>) {
|
||||
//CHECK-NEXT: %[[V5:.*]] = scf.for %[[Varg9:.*]] = %[[Vc0]] to %[[Vc15]] step %[[Vc1]] iter_args(%[[Varg10:.*]] = %[[Varg8]]) -> (tensor<100x4x15x15x5x!TFHE.glwe<{_,_,_}{2}>>) {
|
||||
//CHECK-NEXT: %[[V0:.*]] = "TFHE.zero_tensor"() : () -> tensor<100x4x15x15x5x!TFHE.glwe<sk[?]>>
|
||||
//CHECK-NEXT: %[[V1:.*]] = scf.for %[[Varg3:.*]] = %[[Vc0]] to %[[Vc100]] step %[[Vc1]] iter_args(%[[Varg4:.*]] = %[[V0]]) -> (tensor<100x4x15x15x5x!TFHE.glwe<sk[?]>>) {
|
||||
//CHECK-NEXT: %[[V3:.*]] = scf.for %[[Varg5:.*]] = %[[Vc0]] to %[[Vc4]] step %[[Vc1]] iter_args(%[[Varg6:.*]] = %[[Varg4]]) -> (tensor<100x4x15x15x5x!TFHE.glwe<sk[?]>>) {
|
||||
//CHECK-NEXT: %[[V4:.*]] = scf.for %[[Varg7:.*]] = %[[Vc0]] to %[[Vc15]] step %[[Vc1]] iter_args(%[[Varg8:.*]] = %[[Varg6]]) -> (tensor<100x4x15x15x5x!TFHE.glwe<sk[?]>>) {
|
||||
//CHECK-NEXT: %[[V5:.*]] = scf.for %[[Varg9:.*]] = %[[Vc0]] to %[[Vc15]] step %[[Vc1]] iter_args(%[[Varg10:.*]] = %[[Varg8]]) -> (tensor<100x4x15x15x5x!TFHE.glwe<sk[?]>>) {
|
||||
//CHECK-NEXT: %[[Vextracted:.*]] = tensor.extract %[[Varg2]]{{\[}}%[[Varg5]]{{\]}} : tensor<4xi3>
|
||||
//CHECK-NEXT: %[[Vc0_0:.*]] = arith.constant 0 : index
|
||||
//CHECK-NEXT: %[[Vextracted_slice:.*]] = tensor.extract_slice %[[Varg10]]{{\[}}%[[Varg3]], %[[Varg5]], %[[Varg7]], %[[Varg9]], %[[Vc0_0]]{{\] \[1, 1, 1, 1, 5\] \[1, 1, 1, 1, 1\]}} : tensor<100x4x15x15x5x!TFHE.glwe<{_,_,_}{2}>> to tensor<5x!TFHE.glwe<{_,_,_}{2}>>
|
||||
//CHECK-NEXT: %[[Vextracted_slice:.*]] = tensor.extract_slice %[[Varg10]]{{\[}}%[[Varg3]], %[[Varg5]], %[[Varg7]], %[[Varg9]], %[[Vc0_0]]{{\] \[1, 1, 1, 1, 5\] \[1, 1, 1, 1, 1\]}} : tensor<100x4x15x15x5x!TFHE.glwe<sk[?]>> to tensor<5x!TFHE.glwe<sk[?]>>
|
||||
//CHECK-NEXT: %[[V6:.*]] = arith.extsi %[[Vextracted]] : i3 to i64
|
||||
//CHECK-NEXT: %[[V7:.*]] = "TFHE.encode_plaintext_with_crt"(%[[V6]]) {mods = {{\[2, 3, 5, 7, 11\], modsProd}} = 2310 : i64} : (i64) -> tensor<5xi64>
|
||||
//CHECK-NEXT: %[[V8:.*]] = bufferization.alloc_tensor() : tensor<5x!TFHE.glwe<{_,_,_}{2}>>
|
||||
//CHECK-NEXT: %[[V8:.*]] = bufferization.alloc_tensor() : tensor<5x!TFHE.glwe<sk[?]>>
|
||||
//CHECK-NEXT: %[[Vc0_1:.*]] = arith.constant 0 : index
|
||||
//CHECK-NEXT: %[[Vc1_2:.*]] = arith.constant 1 : index
|
||||
//CHECK-NEXT: %[[Vc5:.*]] = arith.constant 5 : index
|
||||
//CHECK-NEXT: %[[V9:.*]] = scf.for %[[Varg11:.*]] = %[[Vc0_1]] to %[[Vc5]] step %[[Vc1_2]] iter_args(%[[Varg12:.*]] = %[[V8]]) -> (tensor<5x!TFHE.glwe<{_,_,_}{2}>>) {
|
||||
//CHECK-NEXT: %[[Vextracted_4:.*]] = tensor.extract %[[Vextracted_slice]]{{\[}}%[[Varg11]]{{\]}} : tensor<5x!TFHE.glwe<{_,_,_}{2}>>
|
||||
//CHECK-NEXT: %[[V9:.*]] = scf.for %[[Varg11:.*]] = %[[Vc0_1]] to %[[Vc5]] step %[[Vc1_2]] iter_args(%[[Varg12:.*]] = %[[V8]]) -> (tensor<5x!TFHE.glwe<sk[?]>>) {
|
||||
//CHECK-NEXT: %[[Vextracted_4:.*]] = tensor.extract %[[Vextracted_slice]]{{\[}}%[[Varg11]]{{\]}} : tensor<5x!TFHE.glwe<sk[?]>>
|
||||
//CHECK-NEXT: %[[Vextracted_5:.*]] = tensor.extract %[[V7]]{{\[}}%[[Varg11]]{{\]}} : tensor<5xi64>
|
||||
//CHECK-NEXT: %[[V10:.*]] = "TFHE.add_glwe_int"(%[[Vextracted_4]], %[[Vextracted_5]]) : (!TFHE.glwe<{_,_,_}{2}>, i64) -> !TFHE.glwe<{_,_,_}{2}>
|
||||
//CHECK-NEXT: %[[Vinserted:.*]] = tensor.insert %[[V10]] into %[[Varg12]]{{\[}}%[[Varg11]]{{\]}} : tensor<5x!TFHE.glwe<{_,_,_}{2}>>
|
||||
//CHECK-NEXT: scf.yield %[[Vinserted]] : tensor<5x!TFHE.glwe<{_,_,_}{2}>>
|
||||
//CHECK-NEXT: %[[V10:.*]] = "TFHE.add_glwe_int"(%[[Vextracted_4]], %[[Vextracted_5]]) : (!TFHE.glwe<sk[?]>, i64) -> !TFHE.glwe<sk[?]>
|
||||
//CHECK-NEXT: %[[Vinserted:.*]] = tensor.insert %[[V10]] into %[[Varg12]]{{\[}}%[[Varg11]]{{\]}} : tensor<5x!TFHE.glwe<sk[?]>>
|
||||
//CHECK-NEXT: scf.yield %[[Vinserted]] : tensor<5x!TFHE.glwe<sk[?]>>
|
||||
//CHECK-NEXT: }
|
||||
//CHECK-NEXT: %[[Vc0_3:.*]] = arith.constant 0 : index
|
||||
//CHECK-NEXT: %[[Vinserted_slice:.*]] = tensor.insert_slice %[[V9]] into %[[Varg10]]{{\[}}%[[Varg3]], %[[Varg5]], %[[Varg7]], %[[Varg9]], %[[Vc0_3]]{{\] \[1, 1, 1, 1, 5\] \[1, 1, 1, 1, 1\]}} : tensor<5x!TFHE.glwe<{_,_,_}{2}>> into tensor<100x4x15x15x5x!TFHE.glwe<{_,_,_}{2}>>
|
||||
//CHECK-NEXT: scf.yield %[[Vinserted_slice]] : tensor<100x4x15x15x5x!TFHE.glwe<{_,_,_}{2}>>
|
||||
//CHECK-NEXT: %[[Vinserted_slice:.*]] = tensor.insert_slice %[[V9]] into %[[Varg10]]{{\[}}%[[Varg3]], %[[Varg5]], %[[Varg7]], %[[Varg9]], %[[Vc0_3]]{{\] \[1, 1, 1, 1, 5\] \[1, 1, 1, 1, 1\]}} : tensor<5x!TFHE.glwe<sk[?]>> into tensor<100x4x15x15x5x!TFHE.glwe<sk[?]>>
|
||||
//CHECK-NEXT: scf.yield %[[Vinserted_slice]] : tensor<100x4x15x15x5x!TFHE.glwe<sk[?]>>
|
||||
//CHECK-NEXT: }
|
||||
//CHECK-NEXT: scf.yield %[[V5]] : tensor<100x4x15x15x5x!TFHE.glwe<{_,_,_}{2}>>
|
||||
//CHECK-NEXT: scf.yield %[[V5]] : tensor<100x4x15x15x5x!TFHE.glwe<sk[?]>>
|
||||
//CHECK-NEXT: }
|
||||
//CHECK-NEXT: scf.yield %[[V4]] : tensor<100x4x15x15x5x!TFHE.glwe<{_,_,_}{2}>>
|
||||
//CHECK-NEXT: scf.yield %[[V4]] : tensor<100x4x15x15x5x!TFHE.glwe<sk[?]>>
|
||||
//CHECK-NEXT: }
|
||||
//CHECK-NEXT: scf.yield %[[V3]] : tensor<100x4x15x15x5x!TFHE.glwe<{_,_,_}{2}>>
|
||||
//CHECK-NEXT: scf.yield %[[V3]] : tensor<100x4x15x15x5x!TFHE.glwe<sk[?]>>
|
||||
//CHECK-NEXT: }
|
||||
//CHECK-NEXT: %[[V2:.*]] = scf.for %[[Varg3:.*]] = %[[Vc0]] to %[[Vc100]] step %[[Vc1]] iter_args(%[[Varg4:.*]] = %[[V1]]) -> (tensor<100x4x15x15x5x!TFHE.glwe<{_,_,_}{2}>>) {
|
||||
//CHECK-NEXT: %[[V3:.*]] = scf.for %[[Varg5:.*]] = %[[Vc0]] to %[[Vc4]] step %[[Vc1]] iter_args(%[[Varg6:.*]] = %[[Varg4]]) -> (tensor<100x4x15x15x5x!TFHE.glwe<{_,_,_}{2}>>) {
|
||||
//CHECK-NEXT: %[[V4:.*]] = scf.for %[[Varg7:.*]] = %[[Vc0]] to %[[Vc15]] step %[[Vc1]] iter_args(%[[Varg8:.*]] = %[[Varg6]]) -> (tensor<100x4x15x15x5x!TFHE.glwe<{_,_,_}{2}>>) {
|
||||
//CHECK-NEXT: %[[V5:.*]] = scf.for %[[Varg9:.*]] = %[[Vc0]] to %[[Vc15]] step %[[Vc1]] iter_args(%[[Varg10:.*]] = %[[Varg8]]) -> (tensor<100x4x15x15x5x!TFHE.glwe<{_,_,_}{2}>>) {
|
||||
//CHECK-NEXT: %[[V6:.*]] = scf.for %[[Varg11:.*]] = %[[Vc0]] to %[[Vc3]] step %[[Vc1]] iter_args(%[[Varg12:.*]] = %[[Varg10]]) -> (tensor<100x4x15x15x5x!TFHE.glwe<{_,_,_}{2}>>) {
|
||||
//CHECK-NEXT: %[[V7:.*]] = scf.for %[[Varg13:.*]] = %[[Vc0]] to %[[Vc14]] step %[[Vc1]] iter_args(%[[Varg14:.*]] = %[[Varg12]]) -> (tensor<100x4x15x15x5x!TFHE.glwe<{_,_,_}{2}>>) {
|
||||
//CHECK-NEXT: %[[V8:.*]] = scf.for %[[Varg15:.*]] = %[[Vc0]] to %[[Vc14]] step %[[Vc1]] iter_args(%[[Varg16:.*]] = %[[Varg14]]) -> (tensor<100x4x15x15x5x!TFHE.glwe<{_,_,_}{2}>>) {
|
||||
//CHECK-NEXT: %[[V2:.*]] = scf.for %[[Varg3:.*]] = %[[Vc0]] to %[[Vc100]] step %[[Vc1]] iter_args(%[[Varg4:.*]] = %[[V1]]) -> (tensor<100x4x15x15x5x!TFHE.glwe<sk[?]>>) {
|
||||
//CHECK-NEXT: %[[V3:.*]] = scf.for %[[Varg5:.*]] = %[[Vc0]] to %[[Vc4]] step %[[Vc1]] iter_args(%[[Varg6:.*]] = %[[Varg4]]) -> (tensor<100x4x15x15x5x!TFHE.glwe<sk[?]>>) {
|
||||
//CHECK-NEXT: %[[V4:.*]] = scf.for %[[Varg7:.*]] = %[[Vc0]] to %[[Vc15]] step %[[Vc1]] iter_args(%[[Varg8:.*]] = %[[Varg6]]) -> (tensor<100x4x15x15x5x!TFHE.glwe<sk[?]>>) {
|
||||
//CHECK-NEXT: %[[V5:.*]] = scf.for %[[Varg9:.*]] = %[[Vc0]] to %[[Vc15]] step %[[Vc1]] iter_args(%[[Varg10:.*]] = %[[Varg8]]) -> (tensor<100x4x15x15x5x!TFHE.glwe<sk[?]>>) {
|
||||
//CHECK-NEXT: %[[V6:.*]] = scf.for %[[Varg11:.*]] = %[[Vc0]] to %[[Vc3]] step %[[Vc1]] iter_args(%[[Varg12:.*]] = %[[Varg10]]) -> (tensor<100x4x15x15x5x!TFHE.glwe<sk[?]>>) {
|
||||
//CHECK-NEXT: %[[V7:.*]] = scf.for %[[Varg13:.*]] = %[[Vc0]] to %[[Vc14]] step %[[Vc1]] iter_args(%[[Varg14:.*]] = %[[Varg12]]) -> (tensor<100x4x15x15x5x!TFHE.glwe<sk[?]>>) {
|
||||
//CHECK-NEXT: %[[V8:.*]] = scf.for %[[Varg15:.*]] = %[[Vc0]] to %[[Vc14]] step %[[Vc1]] iter_args(%[[Varg16:.*]] = %[[Varg14]]) -> (tensor<100x4x15x15x5x!TFHE.glwe<sk[?]>>) {
|
||||
//CHECK-NEXT: %[[V9:.*]] = affine.apply #map(%[[Varg7]], %[[Varg13]])
|
||||
//CHECK-NEXT: %[[V10:.*]] = affine.apply #map(%[[Varg9]], %[[Varg15]])
|
||||
//CHECK-NEXT: %[[Vc0_0:.*]] = arith.constant 0 : index
|
||||
//CHECK-NEXT: %[[Vextracted_slice:.*]] = tensor.extract_slice %[[Varg0]]{{\[}}%[[Varg3]], %[[Varg11]], %[[V9]], %[[V10]], %[[Vc0_0]]{{\] \[1, 1, 1, 1, 5\] \[1, 1, 1, 1, 1\]}} : tensor<100x3x28x28x5x!TFHE.glwe<{_,_,_}{2}>> to tensor<5x!TFHE.glwe<{_,_,_}{2}>>
|
||||
//CHECK-NEXT: %[[Vextracted_slice:.*]] = tensor.extract_slice %[[Varg0]]{{\[}}%[[Varg3]], %[[Varg11]], %[[V9]], %[[V10]], %[[Vc0_0]]{{\] \[1, 1, 1, 1, 5\] \[1, 1, 1, 1, 1\]}} : tensor<100x3x28x28x5x!TFHE.glwe<sk[?]>> to tensor<5x!TFHE.glwe<sk[?]>>
|
||||
//CHECK-NEXT: %[[Vextracted:.*]] = tensor.extract %[[Varg1]]{{\[}}%[[Varg5]], %[[Varg11]], %[[Varg13]], %[[Varg15]]{{\]}} : tensor<4x3x14x14xi3>
|
||||
//CHECK-NEXT: %[[Vc0_1:.*]] = arith.constant 0 : index
|
||||
//CHECK-NEXT: %[[Vextracted_slice_2:.*]] = tensor.extract_slice %[[Varg16]]{{\[}}%[[Varg3]], %[[Varg5]], %[[Varg7]], %[[Varg9]], %[[Vc0_1]]{{\] \[1, 1, 1, 1, 5\] \[1, 1, 1, 1, 1\]}} : tensor<100x4x15x15x5x!TFHE.glwe<{_,_,_}{2}>> to tensor<5x!TFHE.glwe<{_,_,_}{2}>>
|
||||
//CHECK-NEXT: %[[Vextracted_slice_2:.*]] = tensor.extract_slice %[[Varg16]]{{\[}}%[[Varg3]], %[[Varg5]], %[[Varg7]], %[[Varg9]], %[[Vc0_1]]{{\] \[1, 1, 1, 1, 5\] \[1, 1, 1, 1, 1\]}} : tensor<100x4x15x15x5x!TFHE.glwe<sk[?]>> to tensor<5x!TFHE.glwe<sk[?]>>
|
||||
//CHECK-NEXT: %[[V11:.*]] = arith.extsi %[[Vextracted]] : i3 to i64
|
||||
//CHECK-NEXT: %[[V12:.*]] = bufferization.alloc_tensor() : tensor<5x!TFHE.glwe<{_,_,_}{2}>>
|
||||
//CHECK-NEXT: %[[V12:.*]] = bufferization.alloc_tensor() : tensor<5x!TFHE.glwe<sk[?]>>
|
||||
//CHECK-NEXT: %[[Vc0_3:.*]] = arith.constant 0 : index
|
||||
//CHECK-NEXT: %[[Vc1_4:.*]] = arith.constant 1 : index
|
||||
//CHECK-NEXT: %[[Vc5:.*]] = arith.constant 5 : index
|
||||
//CHECK-NEXT: %[[V13:.*]] = scf.for %[[Varg17:.*]] = %[[Vc0_3]] to %[[Vc5]] step %[[Vc1_4]] iter_args(%[[Varg18:.*]] = %[[V12]]) -> (tensor<5x!TFHE.glwe<{_,_,_}{2}>>) {
|
||||
//CHECK-NEXT: %[[Vextracted_9:.*]] = tensor.extract %[[Vextracted_slice]]{{\[}}%[[Varg17]]{{\]}} : tensor<5x!TFHE.glwe<{_,_,_}{2}>>
|
||||
//CHECK-NEXT: %[[V16:.*]] = "TFHE.mul_glwe_int"(%[[Vextracted_9]], %[[V11]]) : (!TFHE.glwe<{_,_,_}{2}>, i64) -> !TFHE.glwe<{_,_,_}{2}>
|
||||
//CHECK-NEXT: %[[Vinserted:.*]] = tensor.insert %[[V16]] into %[[Varg18]]{{\[}}%[[Varg17]]{{\]}} : tensor<5x!TFHE.glwe<{_,_,_}{2}>>
|
||||
//CHECK-NEXT: scf.yield %[[Vinserted]] : tensor<5x!TFHE.glwe<{_,_,_}{2}>>
|
||||
//CHECK-NEXT: %[[V13:.*]] = scf.for %[[Varg17:.*]] = %[[Vc0_3]] to %[[Vc5]] step %[[Vc1_4]] iter_args(%[[Varg18:.*]] = %[[V12]]) -> (tensor<5x!TFHE.glwe<sk[?]>>) {
|
||||
//CHECK-NEXT: %[[Vextracted_9:.*]] = tensor.extract %[[Vextracted_slice]]{{\[}}%[[Varg17]]{{\]}} : tensor<5x!TFHE.glwe<sk[?]>>
|
||||
//CHECK-NEXT: %[[V16:.*]] = "TFHE.mul_glwe_int"(%[[Vextracted_9]], %[[V11]]) : (!TFHE.glwe<sk[?]>, i64) -> !TFHE.glwe<sk[?]>
|
||||
//CHECK-NEXT: %[[Vinserted:.*]] = tensor.insert %[[V16]] into %[[Varg18]]{{\[}}%[[Varg17]]{{\]}} : tensor<5x!TFHE.glwe<sk[?]>>
|
||||
//CHECK-NEXT: scf.yield %[[Vinserted]] : tensor<5x!TFHE.glwe<sk[?]>>
|
||||
//CHECK-NEXT: }
|
||||
//CHECK-NEXT: %[[V14:.*]] = bufferization.alloc_tensor() : tensor<5x!TFHE.glwe<{_,_,_}{2}>>
|
||||
//CHECK-NEXT: %[[V14:.*]] = bufferization.alloc_tensor() : tensor<5x!TFHE.glwe<sk[?]>>
|
||||
//CHECK-NEXT: %[[Vc0_5:.*]] = arith.constant 0 : index
|
||||
//CHECK-NEXT: %[[Vc1_6:.*]] = arith.constant 1 : index
|
||||
//CHECK-NEXT: %[[Vc5_7:.*]] = arith.constant 5 : index
|
||||
//CHECK-NEXT: %[[V15:.*]] = scf.for %[[Varg17:.*]] = %[[Vc0_5]] to %[[Vc5_7]] step %[[Vc1_6]] iter_args(%[[Varg18:.*]] = %[[V14]]) -> (tensor<5x!TFHE.glwe<{_,_,_}{2}>>) {
|
||||
//CHECK-NEXT: %[[Vextracted_9:.*]] = tensor.extract %[[Vextracted_slice_2]]{{\[}}%[[Varg17]]{{\]}} : tensor<5x!TFHE.glwe<{_,_,_}{2}>>
|
||||
//CHECK-NEXT: %[[Vextracted_10:.*]] = tensor.extract %[[V13]]{{\[}}%[[Varg17]]{{\]}} : tensor<5x!TFHE.glwe<{_,_,_}{2}>>
|
||||
//CHECK-NEXT: %[[V16:.*]] = "TFHE.add_glwe"(%[[Vextracted_9]], %[[Vextracted_10]]) : (!TFHE.glwe<{_,_,_}{2}>, !TFHE.glwe<{_,_,_}{2}>) -> !TFHE.glwe<{_,_,_}{2}>
|
||||
//CHECK-NEXT: %[[Vinserted:.*]] = tensor.insert %[[V16]] into %[[Varg18]]{{\[}}%[[Varg17]]{{\]}} : tensor<5x!TFHE.glwe<{_,_,_}{2}>>
|
||||
//CHECK-NEXT: scf.yield %[[Vinserted]] : tensor<5x!TFHE.glwe<{_,_,_}{2}>>
|
||||
//CHECK-NEXT: %[[V15:.*]] = scf.for %[[Varg17:.*]] = %[[Vc0_5]] to %[[Vc5_7]] step %[[Vc1_6]] iter_args(%[[Varg18:.*]] = %[[V14]]) -> (tensor<5x!TFHE.glwe<sk[?]>>) {
|
||||
//CHECK-NEXT: %[[Vextracted_9:.*]] = tensor.extract %[[Vextracted_slice_2]]{{\[}}%[[Varg17]]{{\]}} : tensor<5x!TFHE.glwe<sk[?]>>
|
||||
//CHECK-NEXT: %[[Vextracted_10:.*]] = tensor.extract %[[V13]]{{\[}}%[[Varg17]]{{\]}} : tensor<5x!TFHE.glwe<sk[?]>>
|
||||
//CHECK-NEXT: %[[V16:.*]] = "TFHE.add_glwe"(%[[Vextracted_9]], %[[Vextracted_10]]) : (!TFHE.glwe<sk[?]>, !TFHE.glwe<sk[?]>) -> !TFHE.glwe<sk[?]>
|
||||
//CHECK-NEXT: %[[Vinserted:.*]] = tensor.insert %[[V16]] into %[[Varg18]]{{\[}}%[[Varg17]]{{\]}} : tensor<5x!TFHE.glwe<sk[?]>>
|
||||
//CHECK-NEXT: scf.yield %[[Vinserted]] : tensor<5x!TFHE.glwe<sk[?]>>
|
||||
//CHECK-NEXT: }
|
||||
//CHECK-NEXT: %[[Vc0_8:.*]] = arith.constant 0 : index
|
||||
//CHECK-NEXT: %[[Vinserted_slice:.*]] = tensor.insert_slice %[[V15]] into %[[Varg16]]{{\[}}%[[Varg3]], %[[Varg5]], %[[Varg7]], %[[Varg9]], %[[Vc0_8]]{{\] \[1, 1, 1, 1, 5\] \[1, 1, 1, 1, 1\]}} : tensor<5x!TFHE.glwe<{_,_,_}{2}>> into tensor<100x4x15x15x5x!TFHE.glwe<{_,_,_}{2}>>
|
||||
//CHECK-NEXT: scf.yield %[[Vinserted_slice]] : tensor<100x4x15x15x5x!TFHE.glwe<{_,_,_}{2}>>
|
||||
//CHECK-NEXT: %[[Vinserted_slice:.*]] = tensor.insert_slice %[[V15]] into %[[Varg16]]{{\[}}%[[Varg3]], %[[Varg5]], %[[Varg7]], %[[Varg9]], %[[Vc0_8]]{{\] \[1, 1, 1, 1, 5\] \[1, 1, 1, 1, 1\]}} : tensor<5x!TFHE.glwe<sk[?]>> into tensor<100x4x15x15x5x!TFHE.glwe<sk[?]>>
|
||||
//CHECK-NEXT: scf.yield %[[Vinserted_slice]] : tensor<100x4x15x15x5x!TFHE.glwe<sk[?]>>
|
||||
//CHECK-NEXT: }
|
||||
//CHECK-NEXT: scf.yield %[[V8]] : tensor<100x4x15x15x5x!TFHE.glwe<{_,_,_}{2}>>
|
||||
//CHECK-NEXT: scf.yield %[[V8]] : tensor<100x4x15x15x5x!TFHE.glwe<sk[?]>>
|
||||
//CHECK-NEXT: }
|
||||
//CHECK-NEXT: scf.yield %[[V7]] : tensor<100x4x15x15x5x!TFHE.glwe<{_,_,_}{2}>>
|
||||
//CHECK-NEXT: scf.yield %[[V7]] : tensor<100x4x15x15x5x!TFHE.glwe<sk[?]>>
|
||||
//CHECK-NEXT: }
|
||||
//CHECK-NEXT: scf.yield %[[V6]] : tensor<100x4x15x15x5x!TFHE.glwe<{_,_,_}{2}>>
|
||||
//CHECK-NEXT: scf.yield %[[V6]] : tensor<100x4x15x15x5x!TFHE.glwe<sk[?]>>
|
||||
//CHECK-NEXT: }
|
||||
//CHECK-NEXT: scf.yield %[[V5]] : tensor<100x4x15x15x5x!TFHE.glwe<{_,_,_}{2}>>
|
||||
//CHECK-NEXT: scf.yield %[[V5]] : tensor<100x4x15x15x5x!TFHE.glwe<sk[?]>>
|
||||
//CHECK-NEXT: }
|
||||
//CHECK-NEXT: scf.yield %[[V4]] : tensor<100x4x15x15x5x!TFHE.glwe<{_,_,_}{2}>>
|
||||
//CHECK-NEXT: scf.yield %[[V4]] : tensor<100x4x15x15x5x!TFHE.glwe<sk[?]>>
|
||||
//CHECK-NEXT: }
|
||||
//CHECK-NEXT: scf.yield %[[V3]] : tensor<100x4x15x15x5x!TFHE.glwe<{_,_,_}{2}>>
|
||||
//CHECK-NEXT: scf.yield %[[V3]] : tensor<100x4x15x15x5x!TFHE.glwe<sk[?]>>
|
||||
//CHECK-NEXT: }
|
||||
//CHECK-NEXT: return %[[V2]] : tensor<100x4x15x15x5x!TFHE.glwe<{_,_,_}{2}>>
|
||||
//CHECK-NEXT: return %[[V2]] : tensor<100x4x15x15x5x!TFHE.glwe<sk[?]>>
|
||||
//CHECK-NEXT: }
|
||||
func.func @conv2d(%input: tensor<100x3x28x28x!FHE.eint<2>>, %weight: tensor<4x3x14x14xi3>, %bias: tensor<4xi3>) -> tensor<100x4x15x15x!FHE.eint<2>> {
|
||||
%1 = "FHELinalg.conv2d"(%input, %weight, %bias){strides = dense<[1,1]> : tensor<2xi64>, dilations = dense<[1,1]> : tensor<2xi64>, padding = dense<[0, 0, 0, 0]> : tensor<4xi64>}: (tensor<100x3x28x28x!FHE.eint<2>>, tensor<4x3x14x14xi3>, tensor<4xi3>) -> tensor<100x4x15x15x!FHE.eint<2>>
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
// RUN: concretecompiler --optimize-tfhe=false --action=dump-tfhe %s --large-integer-crt-decomposition=2,3,5,7,11 --large-integer-circuit-bootstrap=2,9 --large-integer-packing-keyswitch=694,1024,4,9 --v0-parameter=2,10,693,4,9,7,2 2>&1| FileCheck %s
|
||||
|
||||
// CHECK: func.func @mul_eint_int(%[[Varg0:.*]]: tensor<5x!TFHE.glwe<{_,_,_}{7}>>) -> tensor<5x!TFHE.glwe<{_,_,_}{7}>> {
|
||||
// CHECK: func.func @mul_eint_int(%[[Varg0:.*]]: tensor<5x!TFHE.glwe<sk[?]>>) -> tensor<5x!TFHE.glwe<sk[?]>> {
|
||||
// CHECK-NEXT: %[[Vc2_i8:.*]] = arith.constant 2 : i8
|
||||
// CHECK-NEXT: %[[V0:.*]] = arith.extsi %[[Vc2_i8]] : i8 to i64
|
||||
// CHECK-NEXT: %[[V1:.*]] = bufferization.alloc_tensor() : tensor<5x!TFHE.glwe<{_,_,_}{7}>>
|
||||
// CHECK-NEXT: %[[V1:.*]] = bufferization.alloc_tensor() : tensor<5x!TFHE.glwe<sk[?]>>
|
||||
// CHECK-NEXT: %[[Vc0:.*]] = arith.constant 0 : index
|
||||
// CHECK-NEXT: %[[Vc1:.*]] = arith.constant 1 : index
|
||||
// CHECK-NEXT: %[[Vc5:.*]] = arith.constant 5 : index
|
||||
// CHECK-NEXT: %[[V2:.*]] = scf.for %[[Varg1:.*]] = %[[Vc0]] to %[[Vc5]] step %[[Vc1]] iter_args(%[[Varg2:.*]] = %[[V1]]) -> (tensor<5x!TFHE.glwe<{_,_,_}{7}>>) {
|
||||
// CHECK-NEXT: %[[V3:.*]] = tensor.extract %[[Varg0]][%[[Varg1]]] : tensor<5x!TFHE.glwe<{_,_,_}{7}>>
|
||||
// CHECK-NEXT: %[[V4:.*]] = "TFHE.mul_glwe_int"(%[[V3]], %[[V0]]) : (!TFHE.glwe<{_,_,_}{7}>, i64) -> !TFHE.glwe<{_,_,_}{7}>
|
||||
// CHECK-NEXT: %[[V5:.*]] = tensor.insert %[[V4]] into %[[Varg2]][%[[Varg1]]] : tensor<5x!TFHE.glwe<{_,_,_}{7}>>
|
||||
// CHECK-NEXT: scf.yield %[[V5]] : tensor<5x!TFHE.glwe<{_,_,_}{7}>>
|
||||
// CHECK-NEXT: %[[V2:.*]] = scf.for %[[Varg1:.*]] = %[[Vc0]] to %[[Vc5]] step %[[Vc1]] iter_args(%[[Varg2:.*]] = %[[V1]]) -> (tensor<5x!TFHE.glwe<sk[?]>>) {
|
||||
// CHECK-NEXT: %[[V3:.*]] = tensor.extract %[[Varg0]][%[[Varg1]]] : tensor<5x!TFHE.glwe<sk[?]>>
|
||||
// CHECK-NEXT: %[[V4:.*]] = "TFHE.mul_glwe_int"(%[[V3]], %[[V0]]) : (!TFHE.glwe<sk[?]>, i64) -> !TFHE.glwe<sk[?]>
|
||||
// CHECK-NEXT: %[[V5:.*]] = tensor.insert %[[V4]] into %[[Varg2]][%[[Varg1]]] : tensor<5x!TFHE.glwe<sk[?]>>
|
||||
// CHECK-NEXT: scf.yield %[[V5]] : tensor<5x!TFHE.glwe<sk[?]>>
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: return %[[V2]] : tensor<5x!TFHE.glwe<{_,_,_}{7}>>
|
||||
// CHECK-NEXT: return %[[V2]] : tensor<5x!TFHE.glwe<sk[?]>>
|
||||
func.func @mul_eint_int(%arg0: !FHE.eint<7>) -> !FHE.eint<7> {
|
||||
%0 = arith.constant 2 : i8
|
||||
%1 = "FHE.mul_eint_int"(%arg0, %0): (!FHE.eint<7>, i8) -> (!FHE.eint<7>)
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
// RUN: concretecompiler --optimize-tfhe=false --action=dump-tfhe %s --large-integer-crt-decomposition=2,3,5,7,11 --large-integer-circuit-bootstrap=2,9 --large-integer-packing-keyswitch=694,1024,4,9 --v0-parameter=2,10,693,4,9,7,2 2>&1| FileCheck %s
|
||||
|
||||
// CHECK: func.func @neg_eint(%[[Varg0:.*]]: tensor<5x!TFHE.glwe<{_,_,_}{7}>>) -> tensor<5x!TFHE.glwe<{_,_,_}{7}>> {
|
||||
// CHECK-NEXT: %[[V0:.*]] = bufferization.alloc_tensor() : tensor<5x!TFHE.glwe<{_,_,_}{7}>>
|
||||
// CHECK: func.func @neg_eint(%[[Varg0:.*]]: tensor<5x!TFHE.glwe<sk[?]>>) -> tensor<5x!TFHE.glwe<sk[?]>> {
|
||||
// CHECK-NEXT: %[[V0:.*]] = bufferization.alloc_tensor() : tensor<5x!TFHE.glwe<sk[?]>>
|
||||
// CHECK-NEXT: %[[Vc0:.*]] = arith.constant 0 : index
|
||||
// CHECK-NEXT: %[[Vc1:.*]] = arith.constant 1 : index
|
||||
// CHECK-NEXT: %[[Vc5:.*]] = arith.constant 5 : index
|
||||
// CHECK-NEXT: %[[V1:.*]] = scf.for %[[Varg1:.*]] = %[[Vc0]] to %[[Vc5]] step %[[Vc1]] iter_args(%[[Varg2:.*]] = %[[V0]]) -> (tensor<5x!TFHE.glwe<{_,_,_}{7}>>) {
|
||||
// CHECK-NEXT: %[[V2:.*]] = tensor.extract %[[Varg0]][%[[Varg1]]] : tensor<5x!TFHE.glwe<{_,_,_}{7}>>
|
||||
// CHECK-NEXT: %[[V3:.*]] = "TFHE.neg_glwe"(%[[V2]]) : (!TFHE.glwe<{_,_,_}{7}>) -> !TFHE.glwe<{_,_,_}{7}>
|
||||
// CHECK-NEXT: %[[V4:.*]] = tensor.insert %[[V3]] into %[[Varg2]][%[[Varg1]]] : tensor<5x!TFHE.glwe<{_,_,_}{7}>>
|
||||
// CHECK-NEXT: scf.yield %[[V4]] : tensor<5x!TFHE.glwe<{_,_,_}{7}>>
|
||||
// CHECK-NEXT: %[[V1:.*]] = scf.for %[[Varg1:.*]] = %[[Vc0]] to %[[Vc5]] step %[[Vc1]] iter_args(%[[Varg2:.*]] = %[[V0]]) -> (tensor<5x!TFHE.glwe<sk[?]>>) {
|
||||
// CHECK-NEXT: %[[V2:.*]] = tensor.extract %[[Varg0]][%[[Varg1]]] : tensor<5x!TFHE.glwe<sk[?]>>
|
||||
// CHECK-NEXT: %[[V3:.*]] = "TFHE.neg_glwe"(%[[V2]]) : (!TFHE.glwe<sk[?]>) -> !TFHE.glwe<sk[?]>
|
||||
// CHECK-NEXT: %[[V4:.*]] = tensor.insert %[[V3]] into %[[Varg2]][%[[Varg1]]] : tensor<5x!TFHE.glwe<sk[?]>>
|
||||
// CHECK-NEXT: scf.yield %[[V4]] : tensor<5x!TFHE.glwe<sk[?]>>
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: return %[[V1]] : tensor<5x!TFHE.glwe<{_,_,_}{7}>>
|
||||
// CHECK-NEXT: return %[[V1]] : tensor<5x!TFHE.glwe<sk[?]>>
|
||||
// CHECK-NEXT: }
|
||||
func.func @neg_eint(%arg0: !FHE.eint<7>) -> !FHE.eint<7> {
|
||||
%1 = "FHE.neg_eint"(%arg0): (!FHE.eint<7>) -> (!FHE.eint<7>)
|
||||
|
||||
@@ -1,24 +1,25 @@
|
||||
// RUN: concretecompiler --optimize-tfhe=false --action=dump-tfhe %s --large-integer-crt-decomposition=2,3,5,7,11 --large-integer-circuit-bootstrap=2,9 --large-integer-packing-keyswitch=694,1024,4,9 --v0-parameter=2,10,693,4,9,7,2 2>&1| FileCheck %s
|
||||
|
||||
// CHECK: func.func @sub_int_eint(%[[Varg0:.*]]: tensor<5x!TFHE.glwe<{_,_,_}{7}>>) -> tensor<5x!TFHE.glwe<{_,_,_}{7}>> {
|
||||
// CHECK: func.func @sub_int_eint(%[[Varg0:.*]]: tensor<5x!TFHE.glwe<sk[?]>>) -> tensor<5x!TFHE.glwe<sk[?]>> {
|
||||
// CHECK-NEXT: %[[Vc1_i8:.*]] = arith.constant 1 : i8
|
||||
// CHECK-NEXT: %[[V0:.*]] = arith.extsi %[[Vc1_i8]] : i8 to i64
|
||||
// CHECK-NEXT: %[[V1:.*]] = "TFHE.encode_plaintext_with_crt"(%[[V0]]) {mods = [2, 3, 5, 7, 11], modsProd = 2310 : i64} : (i64) -> tensor<5xi64>
|
||||
// CHECK-NEXT: %[[V2:.*]] = bufferization.alloc_tensor() : tensor<5x!TFHE.glwe<{_,_,_}{7}>>
|
||||
// CHECK-NEXT: %[[V2:.*]] = bufferization.alloc_tensor() : tensor<5x!TFHE.glwe<sk[?]>>
|
||||
// CHECK-NEXT: %[[Vc0:.*]] = arith.constant 0 : index
|
||||
// CHECK-NEXT: %[[Vc1:.*]] = arith.constant 1 : index
|
||||
// CHECK-NEXT: %[[Vc5:.*]] = arith.constant 5 : index
|
||||
// CHECK-NEXT: %[[V3:.*]] = scf.for %[[Varg1:.*]] = %[[Vc0]] to %[[Vc5]] step %[[Vc1]] iter_args(%[[Varg2:.*]] = %[[V2]]) -> (tensor<5x!TFHE.glwe<{_,_,_}{7}>>) {
|
||||
// CHECK-NEXT: %[[V4:.*]] = tensor.extract %[[Varg0]][%[[Varg1]]] : tensor<5x!TFHE.glwe<{_,_,_}{7}>>
|
||||
// CHECK-NEXT: %[[V3:.*]] = scf.for %[[Varg1:.*]] = %[[Vc0]] to %[[Vc5]] step %[[Vc1]] iter_args(%[[Varg2:.*]] = %[[V2]]) -> (tensor<5x!TFHE.glwe<sk[?]>>) {
|
||||
// CHECK-NEXT: %[[V4:.*]] = tensor.extract %[[Varg0]][%[[Varg1]]] : tensor<5x!TFHE.glwe<sk[?]>>
|
||||
// CHECK-NEXT: %[[V5:.*]] = tensor.extract %[[V1]][%[[Varg1]]] : tensor<5xi64>
|
||||
// CHECK-NEXT: %[[V6:.*]] = "TFHE.sub_int_glwe"(%[[V5]], %[[V4]]) : (i64, !TFHE.glwe<{_,_,_}{7}>) -> !TFHE.glwe<{_,_,_}{7}>
|
||||
// CHECK-NEXT: %[[V7:.*]] = tensor.insert %[[V6]] into %[[Varg2]][%[[Varg1]]] : tensor<5x!TFHE.glwe<{_,_,_}{7}>>
|
||||
// CHECK-NEXT: scf.yield %[[V7]] : tensor<5x!TFHE.glwe<{_,_,_}{7}>>
|
||||
// CHECK-NEXT: %[[V6:.*]] = "TFHE.sub_int_glwe"(%[[V5]], %[[V4]]) : (i64, !TFHE.glwe<sk[?]>) -> !TFHE.glwe<sk[?]>
|
||||
// CHECK-NEXT: %[[V7:.*]] = tensor.insert %[[V6]] into %[[Varg2]][%[[Varg1]]] : tensor<5x!TFHE.glwe<sk[?]>>
|
||||
// CHECK-NEXT: scf.yield %[[V7]] : tensor<5x!TFHE.glwe<sk[?]>>
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: return %[[V3]] : tensor<5x!TFHE.glwe<{_,_,_}{7}>>
|
||||
// CHECK-NEXT: return %[[V3]] : tensor<5x!TFHE.glwe<sk[?]>>
|
||||
// CHECK-NEXT: }
|
||||
func.func @sub_int_eint(%arg0: !FHE.eint<7>) -> !FHE.eint<7> {
|
||||
%0 = arith.constant 1 : i8
|
||||
%1 = "FHE.sub_int_eint"(%0, %arg0): (i8, !FHE.eint<7>) -> (!FHE.eint<7>)
|
||||
return %1: !FHE.eint<7>
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// RUN: concretecompiler %s --optimize-tfhe=false --action=dump-tfhe 2>&1| FileCheck %s
|
||||
|
||||
// CHECK-LABEL: func.func @add_eint(%arg0: !TFHE.glwe<{_,_,_}{7}>, %arg1: !TFHE.glwe<{_,_,_}{7}>) -> !TFHE.glwe<{_,_,_}{7}>
|
||||
// CHECK-LABEL: func.func @add_eint(%arg0: !TFHE.glwe<sk[?]>, %arg1: !TFHE.glwe<sk[?]>) -> !TFHE.glwe<sk[?]>
|
||||
func.func @add_eint(%arg0: !FHE.eint<7>, %arg1: !FHE.eint<7>) -> !FHE.eint<7> {
|
||||
// CHECK-NEXT: %[[V1:.*]] = "TFHE.add_glwe"(%arg0, %arg1) : (!TFHE.glwe<{_,_,_}{7}>, !TFHE.glwe<{_,_,_}{7}>) -> !TFHE.glwe<{_,_,_}{7}>
|
||||
// CHECK-NEXT: return %[[V1]] : !TFHE.glwe<{_,_,_}{7}>
|
||||
// CHECK-NEXT: %[[V1:.*]] = "TFHE.add_glwe"(%arg0, %arg1) : (!TFHE.glwe<sk[?]>, !TFHE.glwe<sk[?]>) -> !TFHE.glwe<sk[?]>
|
||||
// CHECK-NEXT: return %[[V1]] : !TFHE.glwe<sk[?]>
|
||||
|
||||
%1 = "FHE.add_eint"(%arg0, %arg1): (!FHE.eint<7>, !FHE.eint<7>) -> (!FHE.eint<7>)
|
||||
return %1: !FHE.eint<7>
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
// RUN: concretecompiler %s --optimize-tfhe=false --action=dump-tfhe 2>&1| FileCheck %s
|
||||
|
||||
// CHECK-LABEL: func.func @add_eint_int(%arg0: !TFHE.glwe<{_,_,_}{7}>) -> !TFHE.glwe<{_,_,_}{7}>
|
||||
// CHECK-LABEL: func.func @add_eint_int(%arg0: !TFHE.glwe<sk[?]>) -> !TFHE.glwe<sk[?]>
|
||||
func.func @add_eint_int(%arg0: !FHE.eint<7>) -> !FHE.eint<7> {
|
||||
// CHECK-NEXT: %c1_i8 = arith.constant 1 : i8
|
||||
// CHECK-NEXT: %0 = arith.extsi %c1_i8 : i8 to i64
|
||||
// CHECK-NEXT: %c56_i64 = arith.constant 56 : i64
|
||||
// CHECK-NEXT: %1 = arith.shli %0, %c56_i64 : i64
|
||||
// CHECK-NEXT: %2 = "TFHE.add_glwe_int"(%arg0, %1) : (!TFHE.glwe<{_,_,_}{7}>, i64) -> !TFHE.glwe<{_,_,_}{7}>
|
||||
// CHECK-NEXT: return %2 : !TFHE.glwe<{_,_,_}{7}>
|
||||
// CHECK-NEXT: %2 = "TFHE.add_glwe_int"(%arg0, %1) : (!TFHE.glwe<sk[?]>, i64) -> !TFHE.glwe<sk[?]>
|
||||
// CHECK-NEXT: return %2 : !TFHE.glwe<sk[?]>
|
||||
|
||||
|
||||
%0 = arith.constant 1 : i8
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// RUN: concretecompiler %s --optimize-tfhe=false --action=dump-tfhe 2>&1| FileCheck %s
|
||||
|
||||
// CHECK: func.func @apply_lookup_table(%arg0: !TFHE.glwe<{_,_,_}{2}>, %arg1: tensor<4xi64>) -> !TFHE.glwe<{_,_,_}{3}> {
|
||||
// CHECK: func.func @apply_lookup_table(%arg0: !TFHE.glwe<sk[?]>, %arg1: tensor<4xi64>) -> !TFHE.glwe<sk[?]> {
|
||||
// CHECK-NEXT: %0 = "TFHE.encode_expand_lut_for_bootstrap"(%arg1) {isSigned = false, outputBits = 3 : i32, polySize = 256 : i32} : (tensor<4xi64>) -> tensor<256xi64>
|
||||
// CHECK-NEXT: %1 = "TFHE.keyswitch_glwe"(%arg0) {baseLog = -1 : i32, level = -1 : i32} : (!TFHE.glwe<{_,_,_}{2}>) -> !TFHE.glwe<{_,_,_}{2}>
|
||||
// CHECK-NEXT: %2 = "TFHE.bootstrap_glwe"(%1, %0) {baseLog = -1 : i32, glweDimension = -1 : i32, level = -1 : i32, polySize = -1 : i32} : (!TFHE.glwe<{_,_,_}{2}>, tensor<256xi64>) -> !TFHE.glwe<{_,_,_}{3}>
|
||||
// CHECK-NEXT: return %2 : !TFHE.glwe<{_,_,_}{3}>
|
||||
// CHECK-NEXT: %1 = "TFHE.keyswitch_glwe"(%arg0) {key = #TFHE.ksk<sk[?], sk[?], -1, -1>} : (!TFHE.glwe<sk[?]>) -> !TFHE.glwe<sk[?]>
|
||||
// CHECK-NEXT: %2 = "TFHE.bootstrap_glwe"(%1, %0) {key = #TFHE.bsk<sk[?], sk[?], -1, -1, -1, -1>} : (!TFHE.glwe<sk[?]>, tensor<256xi64>) -> !TFHE.glwe<sk[?]>
|
||||
// CHECK-NEXT: return %2 : !TFHE.glwe<sk[?]>
|
||||
func.func @apply_lookup_table(%arg0: !FHE.eint<2>, %arg1: tensor<4xi64>) -> !FHE.eint<3> {
|
||||
%1 = "FHE.apply_lookup_table"(%arg0, %arg1): (!FHE.eint<2>, tensor<4xi64>) -> (!FHE.eint<3>)
|
||||
return %1: !FHE.eint<3>
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// RUN: concretecompiler %s --optimize-tfhe=false --action=dump-tfhe 2>&1| FileCheck %s
|
||||
|
||||
//CHECK: func.func @apply_lookup_table_cst(%[[A0:.*]]: !TFHE.glwe<{_,_,_}{7}>) -> !TFHE.glwe<{_,_,_}{7}> {
|
||||
//CHECK: func.func @apply_lookup_table_cst(%[[A0:.*]]: !TFHE.glwe<sk[?]>) -> !TFHE.glwe<sk[?]> {
|
||||
|
||||
//CHECK-NEXT: %cst = arith.constant dense<"0x00000000000000000100000000000000020000000000000003000000000000000400000000000000050000000000000006000000000000000700000000000000080000000000000009000000000000000A000000000000000B000000000000000C000000000000000D000000000000000E000000000000000F0000000000000010000000000000001100000000000000120000000000000013000000000000001400000000000000150000000000000016000000000000001700000000000000180000000000000019000000000000001A000000000000001B000000000000001C000000000000001D000000000000001E000000000000001F0000000000000020000000000000002100000000000000220000000000000023000000000000002400000000000000250000000000000026000000000000002700000000000000280000000000000029000000000000002A000000000000002B000000000000002C000000000000002D000000000000002E000000000000002F0000000000000030000000000000003100000000000000320000000000000033000000000000003400000000000000350000000000000036000000000000003700000000000000380000000000000039000000000000003A000000000000003B000000000000003C000000000000003D000000000000003E000000000000003F0000000000000040000000000000004100000000000000420000000000000043000000000000004400000000000000450000000000000046000000000000004700000000000000480000000000000049000000000000004A000000000000004B000000000000004C000000000000004D000000000000004E000000000000004F0000000000000050000000000000005100000000000000520000000000000053000000000000005400000000000000550000000000000056000000000000005700000000000000580000000000000059000000000000005A000000000000005B000000000000005C000000000000005D000000000000005E000000000000005F0000000000000060000000000000006100000000000000620000000000000063000000000000006400000000000000650000000000000066000000000000006700000000000000680000000000000069000000000000006A000000000000006B000000000000006C000000000000006D000000000000006E000000000000006F0000000000000070000000000000007100000000000000720000000000000073000000000000007400000000000000750000000000000076000000000000007700000000000000780000000000000079000000000000007A000000000000007B000000000000007C000000000000007D000000000000007E000000000000007F00000000000000"> : tensor<128xi64>
|
||||
//CHECK-NEXT: %0 = "TFHE.encode_expand_lut_for_bootstrap"(%cst) {isSigned = false, outputBits = 7 : i32, polySize = 8192 : i32} : (tensor<128xi64>) -> tensor<8192xi64>
|
||||
//CHECK-NEXT: %1 = "TFHE.keyswitch_glwe"(%arg0) {baseLog = -1 : i32, level = -1 : i32} : (!TFHE.glwe<{_,_,_}{7}>) -> !TFHE.glwe<{_,_,_}{7}>
|
||||
//CHECK-NEXT: %2 = "TFHE.bootstrap_glwe"(%1, %0) {baseLog = -1 : i32, glweDimension = -1 : i32, level = -1 : i32, polySize = -1 : i32} : (!TFHE.glwe<{_,_,_}{7}>, tensor<8192xi64>) -> !TFHE.glwe<{_,_,_}{7}>
|
||||
//CHECK-NEXT: return %2 : !TFHE.glwe<{_,_,_}{7}>
|
||||
//CHECK-NEXT: %1 = "TFHE.keyswitch_glwe"(%arg0) {key = #TFHE.ksk<sk[?], sk[?], -1, -1>} : (!TFHE.glwe<sk[?]>) -> !TFHE.glwe<sk[?]>
|
||||
//CHECK-NEXT: %2 = "TFHE.bootstrap_glwe"(%1, %0) {key = #TFHE.bsk<sk[?], sk[?], -1, -1, -1, -1>} : (!TFHE.glwe<sk[?]>, tensor<8192xi64>) -> !TFHE.glwe<sk[?]>
|
||||
//CHECK-NEXT: return %2 : !TFHE.glwe<sk[?]>
|
||||
func.func @apply_lookup_table_cst(%arg0: !FHE.eint<7>) -> !FHE.eint<7> {
|
||||
%tlu = arith.constant dense<[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127]> : tensor<128xi64>
|
||||
%1 = "FHE.apply_lookup_table"(%arg0, %tlu): (!FHE.eint<7>, tensor<128xi64>) -> (!FHE.eint<7>)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// RUN: concretecompiler %s --optimize-tfhe=false --action=dump-tfhe 2>&1| FileCheck %s
|
||||
|
||||
// CHECK: func.func @conv2d(%[[Varg0:.*]]: tensor<100x3x28x28x!TFHE.glwe<{_,_,_}{2}>>, %[[Varg1:.*]]: tensor<4x3x14x14xi3>, %[[Varg2:.*]]: tensor<4xi3>) -> tensor<100x4x15x15x!TFHE.glwe<{_,_,_}{2}>> {
|
||||
// CHECK: func.func @conv2d(%[[Varg0:.*]]: tensor<100x3x28x28x!TFHE.glwe<sk[?]>>, %[[Varg1:.*]]: tensor<4x3x14x14xi3>, %[[Varg2:.*]]: tensor<4xi3>) -> tensor<100x4x15x15x!TFHE.glwe<sk[?]>> {
|
||||
// CHECK-NEXT: %[[Vc0:.*]] = arith.constant 0 : index
|
||||
// CHECK-NEXT: %[[Vc100:.*]] = arith.constant 100 : index
|
||||
// CHECK-NEXT: %[[Vc1:.*]] = arith.constant 1 : index
|
||||
@@ -8,57 +8,57 @@
|
||||
// CHECK-NEXT: %[[Vc15:.*]] = arith.constant 15 : index
|
||||
// CHECK-NEXT: %[[Vc3:.*]] = arith.constant 3 : index
|
||||
// CHECK-NEXT: %[[Vc14:.*]] = arith.constant 14 : index
|
||||
// CHECK-NEXT: %[[V0:.*]] = "TFHE.zero_tensor"() : () -> tensor<100x4x15x15x!TFHE.glwe<{_,_,_}{2}>>
|
||||
// CHECK-NEXT: %[[V1:.*]] = scf.for %[[Varg3:.*]] = %[[Vc0]] to %[[Vc100]] step %[[Vc1]] iter_args(%[[Varg4:.*]] = %[[V0]]) -> (tensor<100x4x15x15x!TFHE.glwe<{_,_,_}{2}>>) {
|
||||
// CHECK-NEXT: %[[V3:.*]] = scf.for %[[Varg5:.*]] = %[[Vc0]] to %[[Vc4]] step %[[Vc1]] iter_args(%[[Varg6:.*]] = %[[Varg4]]) -> (tensor<100x4x15x15x!TFHE.glwe<{_,_,_}{2}>>) {
|
||||
// CHECK-NEXT: %[[V4:.*]] = scf.for %[[Varg7:.*]] = %[[Vc0]] to %[[Vc15]] step %[[Vc1]] iter_args(%[[Varg8:.*]] = %[[Varg6]]) -> (tensor<100x4x15x15x!TFHE.glwe<{_,_,_}{2}>>) {
|
||||
// CHECK-NEXT: %[[V5:.*]] = scf.for %[[Varg9:.*]] = %[[Vc0]] to %[[Vc15]] step %[[Vc1]] iter_args(%[[Varg10:.*]] = %[[Varg8]]) -> (tensor<100x4x15x15x!TFHE.glwe<{_,_,_}{2}>>) {
|
||||
// CHECK-NEXT: %[[V0:.*]] = "TFHE.zero_tensor"() : () -> tensor<100x4x15x15x!TFHE.glwe<sk[?]>>
|
||||
// CHECK-NEXT: %[[V1:.*]] = scf.for %[[Varg3:.*]] = %[[Vc0]] to %[[Vc100]] step %[[Vc1]] iter_args(%[[Varg4:.*]] = %[[V0]]) -> (tensor<100x4x15x15x!TFHE.glwe<sk[?]>>) {
|
||||
// CHECK-NEXT: %[[V3:.*]] = scf.for %[[Varg5:.*]] = %[[Vc0]] to %[[Vc4]] step %[[Vc1]] iter_args(%[[Varg6:.*]] = %[[Varg4]]) -> (tensor<100x4x15x15x!TFHE.glwe<sk[?]>>) {
|
||||
// CHECK-NEXT: %[[V4:.*]] = scf.for %[[Varg7:.*]] = %[[Vc0]] to %[[Vc15]] step %[[Vc1]] iter_args(%[[Varg8:.*]] = %[[Varg6]]) -> (tensor<100x4x15x15x!TFHE.glwe<sk[?]>>) {
|
||||
// CHECK-NEXT: %[[V5:.*]] = scf.for %[[Varg9:.*]] = %[[Vc0]] to %[[Vc15]] step %[[Vc1]] iter_args(%[[Varg10:.*]] = %[[Varg8]]) -> (tensor<100x4x15x15x!TFHE.glwe<sk[?]>>) {
|
||||
// CHECK-NEXT: %[[Vextracted:.*]] = tensor.extract %[[Varg2]]{{\[}}%[[Varg5]]{{\]}} : tensor<4xi3>
|
||||
// CHECK-NEXT: %[[Vextracted_0:.*]] = tensor.extract %[[Varg10]]{{\[}}%[[Varg3]], %[[Varg5]], %[[Varg7]], %[[Varg9]]{{\]}} : tensor<100x4x15x15x!TFHE.glwe<{_,_,_}{2}>>
|
||||
// CHECK-NEXT: %[[Vextracted_0:.*]] = tensor.extract %[[Varg10]]{{\[}}%[[Varg3]], %[[Varg5]], %[[Varg7]], %[[Varg9]]{{\]}} : tensor<100x4x15x15x!TFHE.glwe<sk[?]>>
|
||||
// CHECK-NEXT: %[[V6:.*]] = arith.extsi %[[Vextracted]] : i3 to i64
|
||||
// CHECK-NEXT: %[[Vc61_i64:.*]] = arith.constant 61 : i64
|
||||
// CHECK-NEXT: %[[V7:.*]] = arith.shli %[[V6]], %[[Vc61_i64]] : i64
|
||||
// CHECK-NEXT: %[[V8:.*]] = "TFHE.add_glwe_int"(%[[Vextracted_0]], %[[V7]]) : (!TFHE.glwe<{_,_,_}{2}>, i64) -> !TFHE.glwe<{_,_,_}{2}>
|
||||
// CHECK-NEXT: %[[Vinserted:.*]] = tensor.insert %[[V8]] into %[[Varg10]]{{\[}}%[[Varg3]], %[[Varg5]], %[[Varg7]], %[[Varg9]]{{\]}} : tensor<100x4x15x15x!TFHE.glwe<{_,_,_}{2}>>
|
||||
// CHECK-NEXT: scf.yield %[[Vinserted]] : tensor<100x4x15x15x!TFHE.glwe<{_,_,_}{2}>>
|
||||
// CHECK-NEXT: %[[V8:.*]] = "TFHE.add_glwe_int"(%[[Vextracted_0]], %[[V7]]) : (!TFHE.glwe<sk[?]>, i64) -> !TFHE.glwe<sk[?]>
|
||||
// CHECK-NEXT: %[[Vinserted:.*]] = tensor.insert %[[V8]] into %[[Varg10]]{{\[}}%[[Varg3]], %[[Varg5]], %[[Varg7]], %[[Varg9]]{{\]}} : tensor<100x4x15x15x!TFHE.glwe<sk[?]>>
|
||||
// CHECK-NEXT: scf.yield %[[Vinserted]] : tensor<100x4x15x15x!TFHE.glwe<sk[?]>>
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: scf.yield %[[V5]] : tensor<100x4x15x15x!TFHE.glwe<{_,_,_}{2}>>
|
||||
// CHECK-NEXT: scf.yield %[[V5]] : tensor<100x4x15x15x!TFHE.glwe<sk[?]>>
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: scf.yield %[[V4]] : tensor<100x4x15x15x!TFHE.glwe<{_,_,_}{2}>>
|
||||
// CHECK-NEXT: scf.yield %[[V4]] : tensor<100x4x15x15x!TFHE.glwe<sk[?]>>
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: scf.yield %[[V3]] : tensor<100x4x15x15x!TFHE.glwe<{_,_,_}{2}>>
|
||||
// CHECK-NEXT: scf.yield %[[V3]] : tensor<100x4x15x15x!TFHE.glwe<sk[?]>>
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: %[[V2:.*]] = scf.for %[[Varg3:.*]] = %[[Vc0]] to %[[Vc100]] step %[[Vc1]] iter_args(%[[Varg4:.*]] = %[[V1]]) -> (tensor<100x4x15x15x!TFHE.glwe<{_,_,_}{2}>>) {
|
||||
// CHECK-NEXT: %[[V3:.*]] = scf.for %[[Varg5:.*]] = %[[Vc0]] to %[[Vc4]] step %[[Vc1]] iter_args(%[[Varg6:.*]] = %[[Varg4]]) -> (tensor<100x4x15x15x!TFHE.glwe<{_,_,_}{2}>>) {
|
||||
// CHECK-NEXT: %[[V4:.*]] = scf.for %[[Varg7:.*]] = %[[Vc0]] to %[[Vc15]] step %[[Vc1]] iter_args(%[[Varg8:.*]] = %[[Varg6]]) -> (tensor<100x4x15x15x!TFHE.glwe<{_,_,_}{2}>>) {
|
||||
// CHECK-NEXT: %[[V5:.*]] = scf.for %[[Varg9:.*]] = %[[Vc0]] to %[[Vc15]] step %[[Vc1]] iter_args(%[[Varg10:.*]] = %[[Varg8]]) -> (tensor<100x4x15x15x!TFHE.glwe<{_,_,_}{2}>>) {
|
||||
// CHECK-NEXT: %[[V6:.*]] = scf.for %[[Varg11:.*]] = %[[Vc0]] to %[[Vc3]] step %[[Vc1]] iter_args(%[[Varg12:.*]] = %[[Varg10]]) -> (tensor<100x4x15x15x!TFHE.glwe<{_,_,_}{2}>>) {
|
||||
// CHECK-NEXT: %[[V7:.*]] = scf.for %[[Varg13:.*]] = %[[Vc0]] to %[[Vc14]] step %[[Vc1]] iter_args(%[[Varg14:.*]] = %[[Varg12]]) -> (tensor<100x4x15x15x!TFHE.glwe<{_,_,_}{2}>>) {
|
||||
// CHECK-NEXT: %[[V8:.*]] = scf.for %[[Varg15:.*]] = %[[Vc0]] to %[[Vc14]] step %[[Vc1]] iter_args(%[[Varg16:.*]] = %[[Varg14]]) -> (tensor<100x4x15x15x!TFHE.glwe<{_,_,_}{2}>>) {
|
||||
// CHECK-NEXT: %[[V2:.*]] = scf.for %[[Varg3:.*]] = %[[Vc0]] to %[[Vc100]] step %[[Vc1]] iter_args(%[[Varg4:.*]] = %[[V1]]) -> (tensor<100x4x15x15x!TFHE.glwe<sk[?]>>) {
|
||||
// CHECK-NEXT: %[[V3:.*]] = scf.for %[[Varg5:.*]] = %[[Vc0]] to %[[Vc4]] step %[[Vc1]] iter_args(%[[Varg6:.*]] = %[[Varg4]]) -> (tensor<100x4x15x15x!TFHE.glwe<sk[?]>>) {
|
||||
// CHECK-NEXT: %[[V4:.*]] = scf.for %[[Varg7:.*]] = %[[Vc0]] to %[[Vc15]] step %[[Vc1]] iter_args(%[[Varg8:.*]] = %[[Varg6]]) -> (tensor<100x4x15x15x!TFHE.glwe<sk[?]>>) {
|
||||
// CHECK-NEXT: %[[V5:.*]] = scf.for %[[Varg9:.*]] = %[[Vc0]] to %[[Vc15]] step %[[Vc1]] iter_args(%[[Varg10:.*]] = %[[Varg8]]) -> (tensor<100x4x15x15x!TFHE.glwe<sk[?]>>) {
|
||||
// CHECK-NEXT: %[[V6:.*]] = scf.for %[[Varg11:.*]] = %[[Vc0]] to %[[Vc3]] step %[[Vc1]] iter_args(%[[Varg12:.*]] = %[[Varg10]]) -> (tensor<100x4x15x15x!TFHE.glwe<sk[?]>>) {
|
||||
// CHECK-NEXT: %[[V7:.*]] = scf.for %[[Varg13:.*]] = %[[Vc0]] to %[[Vc14]] step %[[Vc1]] iter_args(%[[Varg14:.*]] = %[[Varg12]]) -> (tensor<100x4x15x15x!TFHE.glwe<sk[?]>>) {
|
||||
// CHECK-NEXT: %[[V8:.*]] = scf.for %[[Varg15:.*]] = %[[Vc0]] to %[[Vc14]] step %[[Vc1]] iter_args(%[[Varg16:.*]] = %[[Varg14]]) -> (tensor<100x4x15x15x!TFHE.glwe<sk[?]>>) {
|
||||
// CHECK-NEXT: %[[V9:.*]] = affine.apply #map(%[[Varg7]], %[[Varg13]])
|
||||
// CHECK-NEXT: %[[V10:.*]] = affine.apply #map(%[[Varg9]], %[[Varg15]])
|
||||
// CHECK-NEXT: %[[Vextracted:.*]] = tensor.extract %[[Varg0]]{{\[}}%[[Varg3]], %[[Varg11]], %[[V9]], %[[V10]]{{\]}} : tensor<100x3x28x28x!TFHE.glwe<{_,_,_}{2}>>
|
||||
// CHECK-NEXT: %[[Vextracted:.*]] = tensor.extract %[[Varg0]]{{\[}}%[[Varg3]], %[[Varg11]], %[[V9]], %[[V10]]{{\]}} : tensor<100x3x28x28x!TFHE.glwe<sk[?]>>
|
||||
// CHECK-NEXT: %[[Vextracted_0:.*]] = tensor.extract %[[Varg1]]{{\[}}%[[Varg5]], %[[Varg11]], %[[Varg13]], %[[Varg15]]{{\]}} : tensor<4x3x14x14xi3>
|
||||
// CHECK-NEXT: %[[Vextracted_1:.*]] = tensor.extract %[[Varg16]]{{\[}}%[[Varg3]], %[[Varg5]], %[[Varg7]], %[[Varg9]]{{\]}} : tensor<100x4x15x15x!TFHE.glwe<{_,_,_}{2}>>
|
||||
// CHECK-NEXT: %[[Vextracted_1:.*]] = tensor.extract %[[Varg16]]{{\[}}%[[Varg3]], %[[Varg5]], %[[Varg7]], %[[Varg9]]{{\]}} : tensor<100x4x15x15x!TFHE.glwe<sk[?]>>
|
||||
// CHECK-NEXT: %[[V11:.*]] = arith.extsi %[[Vextracted_0]] : i3 to i64
|
||||
// CHECK-NEXT: %[[V12:.*]] = "TFHE.mul_glwe_int"(%[[Vextracted]], %[[V11]]) : (!TFHE.glwe<{_,_,_}{2}>, i64) -> !TFHE.glwe<{_,_,_}{2}>
|
||||
// CHECK-NEXT: %[[V13:.*]] = "TFHE.add_glwe"(%[[Vextracted_1]], %[[V12]]) : (!TFHE.glwe<{_,_,_}{2}>, !TFHE.glwe<{_,_,_}{2}>) -> !TFHE.glwe<{_,_,_}{2}>
|
||||
// CHECK-NEXT: %[[Vinserted:.*]] = tensor.insert %[[V13]] into %[[Varg16]]{{\[}}%[[Varg3]], %[[Varg5]], %[[Varg7]], %[[Varg9]]{{\]}} : tensor<100x4x15x15x!TFHE.glwe<{_,_,_}{2}>>
|
||||
// CHECK-NEXT: scf.yield %[[Vinserted]] : tensor<100x4x15x15x!TFHE.glwe<{_,_,_}{2}>>
|
||||
// CHECK-NEXT: %[[V12:.*]] = "TFHE.mul_glwe_int"(%[[Vextracted]], %[[V11]]) : (!TFHE.glwe<sk[?]>, i64) -> !TFHE.glwe<sk[?]>
|
||||
// CHECK-NEXT: %[[V13:.*]] = "TFHE.add_glwe"(%[[Vextracted_1]], %[[V12]]) : (!TFHE.glwe<sk[?]>, !TFHE.glwe<sk[?]>) -> !TFHE.glwe<sk[?]>
|
||||
// CHECK-NEXT: %[[Vinserted:.*]] = tensor.insert %[[V13]] into %[[Varg16]]{{\[}}%[[Varg3]], %[[Varg5]], %[[Varg7]], %[[Varg9]]{{\]}} : tensor<100x4x15x15x!TFHE.glwe<sk[?]>>
|
||||
// CHECK-NEXT: scf.yield %[[Vinserted]] : tensor<100x4x15x15x!TFHE.glwe<sk[?]>>
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: scf.yield %[[V8]] : tensor<100x4x15x15x!TFHE.glwe<{_,_,_}{2}>>
|
||||
// CHECK-NEXT: scf.yield %[[V8]] : tensor<100x4x15x15x!TFHE.glwe<sk[?]>>
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: scf.yield %[[V7]] : tensor<100x4x15x15x!TFHE.glwe<{_,_,_}{2}>>
|
||||
// CHECK-NEXT: scf.yield %[[V7]] : tensor<100x4x15x15x!TFHE.glwe<sk[?]>>
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: scf.yield %[[V6]] : tensor<100x4x15x15x!TFHE.glwe<{_,_,_}{2}>>
|
||||
// CHECK-NEXT: scf.yield %[[V6]] : tensor<100x4x15x15x!TFHE.glwe<sk[?]>>
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: scf.yield %[[V5]] : tensor<100x4x15x15x!TFHE.glwe<{_,_,_}{2}>>
|
||||
// CHECK-NEXT: scf.yield %[[V5]] : tensor<100x4x15x15x!TFHE.glwe<sk[?]>>
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: scf.yield %[[V4]] : tensor<100x4x15x15x!TFHE.glwe<{_,_,_}{2}>>
|
||||
// CHECK-NEXT: scf.yield %[[V4]] : tensor<100x4x15x15x!TFHE.glwe<sk[?]>>
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: scf.yield %[[V3]] : tensor<100x4x15x15x!TFHE.glwe<{_,_,_}{2}>>
|
||||
// CHECK-NEXT: scf.yield %[[V3]] : tensor<100x4x15x15x!TFHE.glwe<sk[?]>>
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: return %[[V2]] : tensor<100x4x15x15x!TFHE.glwe<{_,_,_}{2}>>
|
||||
// CHECK-NEXT: return %[[V2]] : tensor<100x4x15x15x!TFHE.glwe<sk[?]>>
|
||||
// CHECK-NEXT: }
|
||||
func.func @conv2d(%input: tensor<100x3x28x28x!FHE.eint<2>>, %weight: tensor<4x3x14x14xi3>, %bias: tensor<4xi3>) -> tensor<100x4x15x15x!FHE.eint<2>> {
|
||||
%1 = "FHELinalg.conv2d"(%input, %weight, %bias){strides = dense<[1,1]> : tensor<2xi64>, dilations = dense<[1,1]> : tensor<2xi64>, padding = dense<[0, 0, 0, 0]> : tensor<4xi64>}: (tensor<100x3x28x28x!FHE.eint<2>>, tensor<4x3x14x14xi3>, tensor<4xi3>) -> tensor<100x4x15x15x!FHE.eint<2>>
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
// RUN: concretecompiler %s --optimize-tfhe=false --action=dump-tfhe 2>&1| FileCheck %s
|
||||
|
||||
// CHECK-LABEL: func.func @mul_eint_int(%arg0: !TFHE.glwe<{_,_,_}{7}>) -> !TFHE.glwe<{_,_,_}{7}>
|
||||
// CHECK-LABEL: func.func @mul_eint_int(%arg0: !TFHE.glwe<sk[?]>) -> !TFHE.glwe<sk[?]>
|
||||
func.func @mul_eint_int(%arg0: !FHE.eint<7>) -> !FHE.eint<7> {
|
||||
// CHECK-NEXT: %c2_i8 = arith.constant 2 : i8
|
||||
// CHECK-NEXT: %0 = arith.extsi %c2_i8 : i8 to i64
|
||||
// CHECK-NEXT: %1 = "TFHE.mul_glwe_int"(%arg0, %0) : (!TFHE.glwe<{_,_,_}{7}>, i64) -> !TFHE.glwe<{_,_,_}{7}>
|
||||
// CHECK-NEXT: return %1 : !TFHE.glwe<{_,_,_}{7}>
|
||||
// CHECK-NEXT: %1 = "TFHE.mul_glwe_int"(%arg0, %0) : (!TFHE.glwe<sk[?]>, i64) -> !TFHE.glwe<sk[?]>
|
||||
// CHECK-NEXT: return %1 : !TFHE.glwe<sk[?]>
|
||||
|
||||
%0 = arith.constant 2 : i8
|
||||
%1 = "FHE.mul_eint_int"(%arg0, %0): (!FHE.eint<7>, i8) -> (!FHE.eint<7>)
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
// RUN: concretecompiler %s --optimize-tfhe=false --action=dump-tfhe 2>&1| FileCheck %s
|
||||
|
||||
// CHECK-LABEL: func.func @neg_eint(%arg0: !TFHE.glwe<{_,_,_}{7}>) -> !TFHE.glwe<{_,_,_}{7}>
|
||||
// CHECK-LABEL: func.func @neg_eint(%arg0: !TFHE.glwe<sk[?]>) -> !TFHE.glwe<sk[?]>
|
||||
func.func @neg_eint(%arg0: !FHE.eint<7>) -> !FHE.eint<7> {
|
||||
// CHECK-NEXT: %0 = "TFHE.neg_glwe"(%arg0) : (!TFHE.glwe<{_,_,_}{7}>) -> !TFHE.glwe<{_,_,_}{7}>
|
||||
// CHECK-NEXT: return %0 : !TFHE.glwe<{_,_,_}{7}>
|
||||
// CHECK-NEXT: %0 = "TFHE.neg_glwe"(%arg0) : (!TFHE.glwe<sk[?]>) -> !TFHE.glwe<sk[?]>
|
||||
// CHECK-NEXT: return %0 : !TFHE.glwe<sk[?]>
|
||||
|
||||
%1 = "FHE.neg_eint"(%arg0): (!FHE.eint<7>) -> (!FHE.eint<7>)
|
||||
return %1: !FHE.eint<7>
|
||||
}
|
||||
|
||||
// CHECK-LABEL: func.func @not(%arg0: !TFHE.glwe<{_,_,_}{2}>) -> !TFHE.glwe<{_,_,_}{2}>
|
||||
// CHECK-LABEL: func.func @not(%arg0: !TFHE.glwe<sk[?]>) -> !TFHE.glwe<sk[?]>
|
||||
func.func @not(%arg0: !FHE.ebool) -> !FHE.ebool {
|
||||
// CHECK-NEXT: %0 = "TFHE.neg_glwe"(%arg0) : (!TFHE.glwe<{_,_,_}{2}>) -> !TFHE.glwe<{_,_,_}{2}>
|
||||
// CHECK-NEXT: return %0 : !TFHE.glwe<{_,_,_}{2}>
|
||||
// CHECK-NEXT: %0 = "TFHE.neg_glwe"(%arg0) : (!TFHE.glwe<sk[?]>) -> !TFHE.glwe<sk[?]>
|
||||
// CHECK-NEXT: return %0 : !TFHE.glwe<sk[?]>
|
||||
%1 = "FHE.not"(%arg0) : (!FHE.ebool) -> !FHE.ebool
|
||||
return %1: !FHE.ebool
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
// RUN: concretecompiler %s --optimize-tfhe=false --action=dump-tfhe 2>&1| FileCheck %s
|
||||
|
||||
// CHECK-LABEL: func.func @sub_int_eint(%arg0: !TFHE.glwe<{_,_,_}{7}>) -> !TFHE.glwe<{_,_,_}{7}>
|
||||
// CHECK-LABEL: func.func @sub_int_eint(%arg0: !TFHE.glwe<sk[?]>) -> !TFHE.glwe<sk[?]>
|
||||
func.func @sub_int_eint(%arg0: !FHE.eint<7>) -> !FHE.eint<7> {
|
||||
// CHECK-NEXT: %c1_i8 = arith.constant 1 : i8
|
||||
// CHECK-NEXT: %0 = arith.extsi %c1_i8 : i8 to i64
|
||||
// CHECK-NEXT: %c56_i64 = arith.constant 56 : i64
|
||||
// CHECK-NEXT: %1 = arith.shli %0, %c56_i64 : i64
|
||||
// CHECK-NEXT: %2 = "TFHE.sub_int_glwe"(%1, %arg0) : (i64, !TFHE.glwe<{_,_,_}{7}>) -> !TFHE.glwe<{_,_,_}{7}>
|
||||
// CHECK-NEXT: return %2 : !TFHE.glwe<{_,_,_}{7}>
|
||||
// CHECK-NEXT: %2 = "TFHE.sub_int_glwe"(%1, %arg0) : (i64, !TFHE.glwe<sk[?]>) -> !TFHE.glwe<sk[?]>
|
||||
// CHECK-NEXT: return %2 : !TFHE.glwe<sk[?]>
|
||||
|
||||
%0 = arith.constant 1 : i8
|
||||
%1 = "FHE.sub_int_eint"(%0, %arg0): (i8, !FHE.eint<7>) -> (!FHE.eint<7>)
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
// RUN: concretecompiler --passes tfhe-global-parametrization --action=dump-std --optimizer-v0 --v0-parameter=2,10,750,1,23,3,4 --v0-constraint=4,0 %s 2>&1| FileCheck %s
|
||||
|
||||
//CHECK: func.func @main(%[[A0:.*]]: !TFHE.glwe<{2048,1,64}{4}>) -> !TFHE.glwe<{2048,1,64}{4}> {
|
||||
//CHECK: %cst = arith.constant dense<[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]> : tensor<16xi64>
|
||||
//CHECK: %[[V1:.*]] = "TFHE.keyswitch_glwe"(%[[A0]]) {baseLog = 4 : i32, level = 3 : i32} : (!TFHE.glwe<{2048,1,64}{4}>) -> !TFHE.glwe<{750,1,64}{4}>
|
||||
//CHECK: %[[V2:.*]] = "TFHE.bootstrap_glwe"(%[[V1]], %cst) {baseLog = 23 : i32, glweDimension = 2 : i32, level = 1 : i32, polySize = 1024 : i32} : (!TFHE.glwe<{750,1,64}{4}>, tensor<16xi64>) -> !TFHE.glwe<{2048,1,64}{4}>
|
||||
//CHECK: return %[[V2]] : !TFHE.glwe<{2048,1,64}{4}>
|
||||
//CHECK: }
|
||||
func.func @main(%arg0: !TFHE.glwe<{_,_,_}{4}>) -> !TFHE.glwe<{_,_,_}{4}> {
|
||||
//CHECK: func.func @main(%[[A0:.*]]: !TFHE.glwe<sk[1]<1,2048>>) -> !TFHE.glwe<sk[1]<1,2048>> {
|
||||
//CHECK-NEXT: %cst = arith.constant dense<[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]> : tensor<16xi64>
|
||||
//CHECK-NEXT: %[[V1:.*]] = "TFHE.keyswitch_glwe"(%[[A0]]) {key = #TFHE.ksk<sk[1]<1,2048>, sk[3]<1,750>, 3, 4>} : (!TFHE.glwe<sk[1]<1,2048>>) -> !TFHE.glwe<sk[3]<1,750>>
|
||||
//CHECK-NEXT: %[[V2:.*]] = "TFHE.bootstrap_glwe"(%[[V1]], %cst) {key = #TFHE.bsk<sk[3]<1,750>, sk[1]<1,2048>, 1024, 2, 1, 23>} : (!TFHE.glwe<sk[3]<1,750>>, tensor<16xi64>) -> !TFHE.glwe<sk[1]<1,2048>>
|
||||
//CHECK-NEXT: return %[[V2]] : !TFHE.glwe<sk[1]<1,2048>>
|
||||
//CHECK-NEXT: }
|
||||
func.func @main(%arg0: !TFHE.glwe<sk[?]>) -> !TFHE.glwe<sk[?]> {
|
||||
%cst = arith.constant dense<[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]> : tensor<16xi64>
|
||||
%1 = "TFHE.keyswitch_glwe"(%arg0) {baseLog = -1 : i32, level = -1 : i32} : (!TFHE.glwe<{_,_,_}{4}>) -> !TFHE.glwe<{_,_,_}{4}>
|
||||
%2 = "TFHE.bootstrap_glwe"(%1, %cst) {baseLog = -1 : i32, glweDimension = -1 : i32, level = -1 : i32, polySize = -1 : i32} : (!TFHE.glwe<{_,_,_}{4}>, tensor<16xi64>) -> !TFHE.glwe<{_,_,_}{4}>
|
||||
return %2 : !TFHE.glwe<{_,_,_}{4}>
|
||||
%1 = "TFHE.keyswitch_glwe"(%arg0) {key = #TFHE.ksk<sk[?], sk[?], -1, -1>} : (!TFHE.glwe<sk[?]>) -> !TFHE.glwe<sk[?]>
|
||||
%2 = "TFHE.bootstrap_glwe"(%1, %cst) {key = #TFHE.bsk<sk[?], sk[?], -1, -1, -1, -1>} : (!TFHE.glwe<sk[?]>, tensor<16xi64>) -> !TFHE.glwe<sk[?]>
|
||||
return %2 : !TFHE.glwe<sk[?]>
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// RUN: concretecompiler --passes tfhe-to-concrete --action=dump-concrete %s 2>&1| FileCheck %s
|
||||
|
||||
// CHECK-LABEL: func.func @add_glwe(%arg0: tensor<2049xi64>, %arg1: tensor<2049xi64>) -> tensor<2049xi64>
|
||||
func.func @add_glwe(%arg0: !TFHE.glwe<{2048,1,64}{7}>, %arg1: !TFHE.glwe<{2048,1,64}{7}>) -> !TFHE.glwe<{2048,1,64}{7}> {
|
||||
func.func @add_glwe(%arg0: !TFHE.glwe<sk[1]<1,2048>>, %arg1: !TFHE.glwe<sk[1]<1,2048>>) -> !TFHE.glwe<sk[1]<1,2048>> {
|
||||
// CHECK-NEXT: %[[V1:.*]] = "Concrete.add_lwe_tensor"(%arg0, %arg1) : (tensor<2049xi64>, tensor<2049xi64>) -> tensor<2049xi64>
|
||||
// CHECK-NEXT: return %[[V1]] : tensor<2049xi64>
|
||||
|
||||
%0 = "TFHE.add_glwe"(%arg0, %arg1): (!TFHE.glwe<{2048,1,64}{7}>, !TFHE.glwe<{2048,1,64}{7}>) -> (!TFHE.glwe<{2048,1,64}{7}>)
|
||||
return %0: !TFHE.glwe<{2048,1,64}{7}>
|
||||
%0 = "TFHE.add_glwe"(%arg0, %arg1): (!TFHE.glwe<sk[1]<1,2048>>, !TFHE.glwe<sk[1]<1,2048>>) -> (!TFHE.glwe<sk[1]<1,2048>>)
|
||||
return %0: !TFHE.glwe<sk[1]<1,2048>>
|
||||
}
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
//CHECK: %[[V0:.*]] = "Concrete.add_plaintext_lwe_tensor"(%[[A0]], %c1_i64) : (tensor<1025xi64>, i64) -> tensor<1025xi64>
|
||||
//CHECK: return %[[V0]] : tensor<1025xi64>
|
||||
//CHECK: }
|
||||
func.func @add_glwe_const_int(%arg0: !TFHE.glwe<{1024,1,64}{7}>) -> !TFHE.glwe<{1024,1,64}{7}> {
|
||||
func.func @add_glwe_const_int(%arg0: !TFHE.glwe<sk[1]<1,1024>>) -> !TFHE.glwe<sk[1]<1,1024>> {
|
||||
%0 = arith.constant 1 : i64
|
||||
%1 = "TFHE.add_glwe_int"(%arg0, %0): (!TFHE.glwe<{1024,1,64}{7}>, i64) -> (!TFHE.glwe<{1024,1,64}{7}>)
|
||||
return %1: !TFHE.glwe<{1024,1,64}{7}>
|
||||
%1 = "TFHE.add_glwe_int"(%arg0, %0): (!TFHE.glwe<sk[1]<1,1024>>, i64) -> (!TFHE.glwe<sk[1]<1,1024>>)
|
||||
return %1: !TFHE.glwe<sk[1]<1,1024>>
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ func.func @add_glwe_const_int(%arg0: !TFHE.glwe<{1024,1,64}{7}>) -> !TFHE.glwe<{
|
||||
//CHECK: %[[V0:.*]] = "Concrete.add_plaintext_lwe_tensor"(%[[A0]], %[[A1]]) : (tensor<1025xi64>, i64) -> tensor<1025xi64>
|
||||
//CHECK: return %[[V0]] : tensor<1025xi64>
|
||||
//CHECK: }
|
||||
func.func @add_glwe_int(%arg0: !TFHE.glwe<{1024,1,64}{4}>, %arg1: i64) -> !TFHE.glwe<{1024,1,64}{4}> {
|
||||
%1 = "TFHE.add_glwe_int"(%arg0, %arg1): (!TFHE.glwe<{1024,1,64}{4}>, i64) -> (!TFHE.glwe<{1024,1,64}{4}>)
|
||||
return %1: !TFHE.glwe<{1024,1,64}{4}>
|
||||
func.func @add_glwe_int(%arg0: !TFHE.glwe<sk[1]<1,1024>>, %arg1: i64) -> !TFHE.glwe<sk[1]<1,1024>> {
|
||||
%1 = "TFHE.add_glwe_int"(%arg0, %arg1): (!TFHE.glwe<sk[1]<1,1024>>, i64) -> (!TFHE.glwe<sk[1]<1,1024>>)
|
||||
return %1: !TFHE.glwe<sk[1]<1,1024>>
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// RUN: concretecompiler --passes tfhe-to-concrete --action=dump-concrete %s 2>&1| FileCheck %s
|
||||
|
||||
//CHECK: func.func @bootstrap_lwe(%[[A0:.*]]: tensor<601xi64>) -> tensor<1025xi64> {
|
||||
//CHECK: %cst = arith.constant dense<"0x00000000000000000100000000000000020000000000000003000000000000000400000000000000050000000000000006000000000000000700000000000000080000000000000009000000000000000A000000000000000B000000000000000C000000000000000D000000000000000E000000000000000F0000000000000010000000000000001100000000000000120000000000000013000000000000001400000000000000150000000000000016000000000000001700000000000000180000000000000019000000000000001A000000000000001B000000000000001C000000000000001D000000000000001E000000000000001F0000000000000020000000000000002100000000000000220000000000000023000000000000002400000000000000250000000000000026000000000000002700000000000000280000000000000029000000000000002A000000000000002B000000000000002C000000000000002D000000000000002E000000000000002F0000000000000030000000000000003100000000000000320000000000000033000000000000003400000000000000350000000000000036000000000000003700000000000000380000000000000039000000000000003A000000000000003B000000000000003C000000000000003D000000000000003E000000000000003F0000000000000040000000000000004100000000000000420000000000000043000000000000004400000000000000450000000000000046000000000000004700000000000000480000000000000049000000000000004A000000000000004B000000000000004C000000000000004D000000000000004E000000000000004F0000000000000050000000000000005100000000000000520000000000000053000000000000005400000000000000550000000000000056000000000000005700000000000000580000000000000059000000000000005A000000000000005B000000000000005C000000000000005D000000000000005E000000000000005F0000000000000060000000000000006100000000000000620000000000000063000000000000006400000000000000650000000000000066000000000000006700000000000000680000000000000069000000000000006A000000000000006B000000000000006C000000000000006D000000000000006E000000000000006F0000000000000070000000000000007100000000000000720000000000000073000000000000007400000000000000750000000000000076000000000000007700000000000000780000000000000079000000000000007A000000000000007B000000000000007C000000000000007D000000000000007E000000000000007F00000000000000"> : tensor<128xi64>
|
||||
//CHECK: %[[V1:.*]] = "Concrete.bootstrap_lwe_tensor"(%arg0, %cst) {baseLog = 1 : i32, glweDimension = 1 : i32, inputLweDim = 600 : i32, level = 3 : i32, polySize = 1024 : i32} : (tensor<601xi64>, tensor<128xi64>) -> tensor<1025xi64>
|
||||
//CHECK: return %[[V1]] : tensor<1025xi64>
|
||||
//CHECK: }
|
||||
func.func @bootstrap_lwe(%ciphertext: !TFHE.glwe<{600,1,64}{7}>) -> !TFHE.glwe<{1024,1,64}{4}> {
|
||||
//CHECK-NEXT: %cst = arith.constant dense<"0x00000000000000000100000000000000020000000000000003000000000000000400000000000000050000000000000006000000000000000700000000000000080000000000000009000000000000000A000000000000000B000000000000000C000000000000000D000000000000000E000000000000000F0000000000000010000000000000001100000000000000120000000000000013000000000000001400000000000000150000000000000016000000000000001700000000000000180000000000000019000000000000001A000000000000001B000000000000001C000000000000001D000000000000001E000000000000001F0000000000000020000000000000002100000000000000220000000000000023000000000000002400000000000000250000000000000026000000000000002700000000000000280000000000000029000000000000002A000000000000002B000000000000002C000000000000002D000000000000002E000000000000002F0000000000000030000000000000003100000000000000320000000000000033000000000000003400000000000000350000000000000036000000000000003700000000000000380000000000000039000000000000003A000000000000003B000000000000003C000000000000003D000000000000003E000000000000003F0000000000000040000000000000004100000000000000420000000000000043000000000000004400000000000000450000000000000046000000000000004700000000000000480000000000000049000000000000004A000000000000004B000000000000004C000000000000004D000000000000004E000000000000004F0000000000000050000000000000005100000000000000520000000000000053000000000000005400000000000000550000000000000056000000000000005700000000000000580000000000000059000000000000005A000000000000005B000000000000005C000000000000005D000000000000005E000000000000005F0000000000000060000000000000006100000000000000620000000000000063000000000000006400000000000000650000000000000066000000000000006700000000000000680000000000000069000000000000006A000000000000006B000000000000006C000000000000006D000000000000006E000000000000006F0000000000000070000000000000007100000000000000720000000000000073000000000000007400000000000000750000000000000076000000000000007700000000000000780000000000000079000000000000007A000000000000007B000000000000007C000000000000007D000000000000007E000000000000007F00000000000000"> : tensor<128xi64>
|
||||
//CHECK-NEXT: %[[V1:.*]] = "Concrete.bootstrap_lwe_tensor"(%arg0, %cst) {baseLog = 1 : i32, glweDimension = 1 : i32, inputLweDim = 600 : i32, level = 3 : i32, polySize = 1024 : i32} : (tensor<601xi64>, tensor<128xi64>) -> tensor<1025xi64>
|
||||
//CHECK-NEXT: return %[[V1]] : tensor<1025xi64>
|
||||
//CHECK-NEXT: }
|
||||
func.func @bootstrap_lwe(%ciphertext: !TFHE.glwe<sk[1]<1,600>>) -> !TFHE.glwe<sk[5]<1,1024>> {
|
||||
%cst = arith.constant dense<"0x00000000000000000100000000000000020000000000000003000000000000000400000000000000050000000000000006000000000000000700000000000000080000000000000009000000000000000A000000000000000B000000000000000C000000000000000D000000000000000E000000000000000F0000000000000010000000000000001100000000000000120000000000000013000000000000001400000000000000150000000000000016000000000000001700000000000000180000000000000019000000000000001A000000000000001B000000000000001C000000000000001D000000000000001E000000000000001F0000000000000020000000000000002100000000000000220000000000000023000000000000002400000000000000250000000000000026000000000000002700000000000000280000000000000029000000000000002A000000000000002B000000000000002C000000000000002D000000000000002E000000000000002F0000000000000030000000000000003100000000000000320000000000000033000000000000003400000000000000350000000000000036000000000000003700000000000000380000000000000039000000000000003A000000000000003B000000000000003C000000000000003D000000000000003E000000000000003F0000000000000040000000000000004100000000000000420000000000000043000000000000004400000000000000450000000000000046000000000000004700000000000000480000000000000049000000000000004A000000000000004B000000000000004C000000000000004D000000000000004E000000000000004F0000000000000050000000000000005100000000000000520000000000000053000000000000005400000000000000550000000000000056000000000000005700000000000000580000000000000059000000000000005A000000000000005B000000000000005C000000000000005D000000000000005E000000000000005F0000000000000060000000000000006100000000000000620000000000000063000000000000006400000000000000650000000000000066000000000000006700000000000000680000000000000069000000000000006A000000000000006B000000000000006C000000000000006D000000000000006E000000000000006F0000000000000070000000000000007100000000000000720000000000000073000000000000007400000000000000750000000000000076000000000000007700000000000000780000000000000079000000000000007A000000000000007B000000000000007C000000000000007D000000000000007E000000000000007F00000000000000"> : tensor<128xi64>
|
||||
%bootstraped = "TFHE.bootstrap_glwe"(%ciphertext, %cst) {baseLog = 1 : i32, glweDimension = 1 : i32, level = 3 : i32, polySize = 1024 : i32} : (!TFHE.glwe<{600,1,64}{7}>, tensor<128xi64>) -> !TFHE.glwe<{1024,1,64}{4}>
|
||||
return %bootstraped : !TFHE.glwe<{1024,1,64}{4}>
|
||||
%bootstraped = "TFHE.bootstrap_glwe"(%ciphertext, %cst) {key = #TFHE.bsk<sk[1]<1,600>, sk[1]<1,1024>, 1024, 1, 3, 1>}: (!TFHE.glwe<sk[1]<1,600>>, tensor<128xi64>) -> !TFHE.glwe<sk[5]<1,1024>>
|
||||
return %bootstraped : !TFHE.glwe<sk[5]<1,1024>>
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// CHECK-NEXT: %[[V0:.*]] = "Concrete.keyswitch_lwe_tensor"(%[[A0]]) {baseLog = 3 : i32, level = 2 : i32, lwe_dim_in = 1024 : i32, lwe_dim_out = 567 : i32} : (tensor<1025xi64>) -> tensor<568xi64>
|
||||
// CHECK-NEXT: return %[[V0]] : tensor<568xi64>
|
||||
// CHECK-NEXT: }
|
||||
func.func @keyswitch_glwe(%arg0: !TFHE.glwe<{1024,1,64}{2}>) -> !TFHE.glwe<{567,1,64}{2}> {
|
||||
%0 = "TFHE.keyswitch_glwe"(%arg0) {baseLog = 3 : i32, level = 2 : i32} : (!TFHE.glwe<{1024,1,64}{2}>) -> !TFHE.glwe<{567,1,64}{2}>
|
||||
return %0 : !TFHE.glwe<{567,1,64}{2}>
|
||||
func.func @keyswitch_glwe(%arg0: !TFHE.glwe<sk[1]<1,1024>>) -> !TFHE.glwe<sk[3]<1,567>> {
|
||||
%0 = "TFHE.keyswitch_glwe"(%arg0) {key = #TFHE.ksk<sk[1]<1,1024>, sk[3]<1,567>, 2, 3>} : (!TFHE.glwe<sk[1]<1,1024>>) -> !TFHE.glwe<sk[3]<1,567>>
|
||||
return %0 : !TFHE.glwe<sk[3]<1,567>>
|
||||
}
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
//CHECK: %[[V0:.*]] = "Concrete.mul_cleartext_lwe_tensor"(%[[A0]], %c1_i64) : (tensor<1025xi64>, i64) -> tensor<1025xi64>
|
||||
//CHECK: return %[[V0]] : tensor<1025xi64>
|
||||
//CHECK: }
|
||||
func.func @mul_glwe_const_int(%arg0: !TFHE.glwe<{1024,1,64}{7}>) -> !TFHE.glwe<{1024,1,64}{7}> {
|
||||
func.func @mul_glwe_const_int(%arg0: !TFHE.glwe<sk[1]<1,1024>>) -> !TFHE.glwe<sk[1]<1,1024>> {
|
||||
%0 = arith.constant 1 : i64
|
||||
%1 = "TFHE.mul_glwe_int"(%arg0, %0): (!TFHE.glwe<{1024,1,64}{7}>, i64) -> (!TFHE.glwe<{1024,1,64}{7}>)
|
||||
return %1: !TFHE.glwe<{1024,1,64}{7}>
|
||||
%1 = "TFHE.mul_glwe_int"(%arg0, %0): (!TFHE.glwe<sk[1]<1,1024>>, i64) -> (!TFHE.glwe<sk[1]<1,1024>>)
|
||||
return %1: !TFHE.glwe<sk[1]<1,1024>>
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ func.func @mul_glwe_const_int(%arg0: !TFHE.glwe<{1024,1,64}{7}>) -> !TFHE.glwe<{
|
||||
//CHECK: %[[V0:.*]] = "Concrete.mul_cleartext_lwe_tensor"(%[[A0]], %[[A1]]) : (tensor<1025xi64>, i64) -> tensor<1025xi64>
|
||||
//CHECK: return %[[V0]] : tensor<1025xi64>
|
||||
//CHECK: }
|
||||
func.func @mul_glwe_int(%arg0: !TFHE.glwe<{1024,1,64}{4}>, %arg1: i64) -> !TFHE.glwe<{1024,1,64}{4}> {
|
||||
%1 = "TFHE.mul_glwe_int"(%arg0, %arg1): (!TFHE.glwe<{1024,1,64}{4}>, i64) -> (!TFHE.glwe<{1024,1,64}{4}>)
|
||||
return %1: !TFHE.glwe<{1024,1,64}{4}>
|
||||
func.func @mul_glwe_int(%arg0: !TFHE.glwe<sk[1]<1,1024>>, %arg1: i64) -> !TFHE.glwe<sk[1]<1,1024>> {
|
||||
%1 = "TFHE.mul_glwe_int"(%arg0, %arg1): (!TFHE.glwe<sk[1]<1,1024>>, i64) -> (!TFHE.glwe<sk[1]<1,1024>>)
|
||||
return %1: !TFHE.glwe<sk[1]<1,1024>>
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// RUN: concretecompiler --passes tfhe-to-concrete --action=dump-concrete %s 2>&1| FileCheck %s
|
||||
|
||||
// CHECK-LABEL: func.func @neg_glwe(%arg0: tensor<1025xi64>) -> tensor<1025xi64>
|
||||
func.func @neg_glwe(%arg0: !TFHE.glwe<{1024,1,64}{4}>) -> !TFHE.glwe<{1024,1,64}{4}> {
|
||||
func.func @neg_glwe(%arg0: !TFHE.glwe<sk[1]<1,1024>>) -> !TFHE.glwe<sk[1]<1,1024>> {
|
||||
// CHECK-NEXT: %[[V1:.*]] = "Concrete.negate_lwe_tensor"(%arg0) : (tensor<1025xi64>) -> tensor<1025xi64>
|
||||
// CHECK-NEXT: return %[[V1]] : tensor<1025xi64>
|
||||
%1 = "TFHE.neg_glwe"(%arg0): (!TFHE.glwe<{1024,1,64}{4}>) -> (!TFHE.glwe<{1024,1,64}{4}>)
|
||||
return %1: !TFHE.glwe<{1024,1,64}{4}>
|
||||
%1 = "TFHE.neg_glwe"(%arg0): (!TFHE.glwe<sk[1]<1,1024>>) -> (!TFHE.glwe<sk[1]<1,1024>>)
|
||||
return %1: !TFHE.glwe<sk[1]<1,1024>>
|
||||
}
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
//CHECK: %[[V1:.*]] = "Concrete.add_plaintext_lwe_tensor"(%[[V0]], %c1_i64) : (tensor<1025xi64>, i64) -> tensor<1025xi64>
|
||||
//CHECK: return %[[V1]] : tensor<1025xi64>
|
||||
//CHECK: }
|
||||
func.func @sub_const_int_glwe(%arg0: !TFHE.glwe<{1024,1,64}{7}>) -> !TFHE.glwe<{1024,1,64}{7}> {
|
||||
func.func @sub_const_int_glwe(%arg0: !TFHE.glwe<sk[1]<1,1024>>) -> !TFHE.glwe<sk[1]<1,1024>> {
|
||||
%0 = arith.constant 1 : i64
|
||||
%1 = "TFHE.sub_int_glwe"(%0, %arg0): (i64, !TFHE.glwe<{1024,1,64}{7}>) -> (!TFHE.glwe<{1024,1,64}{7}>)
|
||||
return %1: !TFHE.glwe<{1024,1,64}{7}>
|
||||
%1 = "TFHE.sub_int_glwe"(%0, %arg0): (i64, !TFHE.glwe<sk[1]<1,1024>>) -> (!TFHE.glwe<sk[1]<1,1024>>)
|
||||
return %1: !TFHE.glwe<sk[1]<1,1024>>
|
||||
}
|
||||
|
||||
//CHECK: func.func @sub_int_glwe(%[[A0:.*]]: tensor<1025xi64>, %[[A1:.*]]: i64) -> tensor<1025xi64> {
|
||||
@@ -17,7 +17,7 @@ func.func @sub_const_int_glwe(%arg0: !TFHE.glwe<{1024,1,64}{7}>) -> !TFHE.glwe<{
|
||||
//CHECK: %[[V1:.*]] = "Concrete.add_plaintext_lwe_tensor"(%[[V0]], %[[A1]]) : (tensor<1025xi64>, i64) -> tensor<1025xi64>
|
||||
//CHECK: return %[[V1]] : tensor<1025xi64>
|
||||
//CHECK: }
|
||||
func.func @sub_int_glwe(%arg0: !TFHE.glwe<{1024,1,64}{4}>, %arg1: i64) -> !TFHE.glwe<{1024,1,64}{4}> {
|
||||
%1 = "TFHE.sub_int_glwe"(%arg1, %arg0): (i64, !TFHE.glwe<{1024,1,64}{4}>) -> (!TFHE.glwe<{1024,1,64}{4}>)
|
||||
return %1: !TFHE.glwe<{1024,1,64}{4}>
|
||||
func.func @sub_int_glwe(%arg0: !TFHE.glwe<sk[1]<1,1024>>, %arg1: i64) -> !TFHE.glwe<sk[1]<1,1024>> {
|
||||
%1 = "TFHE.sub_int_glwe"(%arg1, %arg0): (i64, !TFHE.glwe<sk[1]<1,1024>>) -> (!TFHE.glwe<sk[1]<1,1024>>)
|
||||
return %1: !TFHE.glwe<sk[1]<1,1024>>
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
//CHECK: %[[V0:.*]] = tensor.collapse_shape %[[A0]] [[_:\[\[0, 1, 2, 3, 4\], \[5\]\]]] : tensor<2x3x4x5x6x1025xi64> into tensor<720x1025xi64>
|
||||
//CHECK: return %[[V0]] : tensor<720x1025xi64>
|
||||
//CHECK: }
|
||||
func.func @tensor_collapse_shape(%arg0: tensor<2x3x4x5x6x!TFHE.glwe<{1024, 1, 64}{4}>>) -> tensor<720x!TFHE.glwe<{1024, 1, 64}{4}>> {
|
||||
%0 = tensor.collapse_shape %arg0 [[0, 1, 2, 3, 4]] {MANP = 1 : ui1}: tensor<2x3x4x5x6x!TFHE.glwe<{1024, 1, 64}{4}>> into tensor<720x!TFHE.glwe<{1024, 1, 64}{4}>>
|
||||
return %0 : tensor<720x!TFHE.glwe<{1024, 1, 64}{4}>>
|
||||
func.func @tensor_collapse_shape(%arg0: tensor<2x3x4x5x6x!TFHE.glwe<sk[1]<1,1024>>>) -> tensor<720x!TFHE.glwe<sk[1]<1,1024>>> {
|
||||
%0 = tensor.collapse_shape %arg0 [[0, 1, 2, 3, 4]] {MANP = 1 : ui1}: tensor<2x3x4x5x6x!TFHE.glwe<sk[1]<1,1024>>> into tensor<720x!TFHE.glwe<sk[1]<1,1024>>>
|
||||
return %0 : tensor<720x!TFHE.glwe<sk[1]<1,1024>>>
|
||||
}
|
||||
|
||||
// -----
|
||||
@@ -15,10 +15,10 @@ func.func @tensor_collapse_shape(%arg0: tensor<2x3x4x5x6x!TFHE.glwe<{1024, 1, 64
|
||||
//CHECK: %[[V1:.*]] = tensor.expand_shape %[[V0]] [[_:\[\[0, 1\], \[2\]\]]] : tensor<30x1025xi64> into tensor<5x6x1025xi64>
|
||||
//CHECK: return %[[V1]] : tensor<5x6x1025xi64>
|
||||
//CHECK: }
|
||||
func.func @tensor_collatenspse_shape(%arg0: tensor<2x3x5x!TFHE.glwe<{1024, 1, 64}{4}>>) -> tensor<5x6x!TFHE.glwe<{1024, 1, 64}{4}>> {
|
||||
%0 = tensor.collapse_shape %arg0 [[0, 1, 2]] {MANP = 1 : ui1}: tensor<2x3x5x!TFHE.glwe<{1024, 1, 64}{4}>> into tensor<30x!TFHE.glwe<{1024, 1, 64}{4}>>
|
||||
%1 = tensor.expand_shape %0 [[0, 1]] {MANP = 1 : ui1}: tensor<30x!TFHE.glwe<{1024, 1, 64}{4}>> into tensor<5x6x!TFHE.glwe<{1024, 1, 64}{4}>>
|
||||
return %1 : tensor<5x6x!TFHE.glwe<{1024, 1, 64}{4}>>
|
||||
func.func @tensor_collatenspse_shape(%arg0: tensor<2x3x5x!TFHE.glwe<sk[1]<1,1024>>>) -> tensor<5x6x!TFHE.glwe<sk[1]<1,1024>>> {
|
||||
%0 = tensor.collapse_shape %arg0 [[0, 1, 2]] {MANP = 1 : ui1}: tensor<2x3x5x!TFHE.glwe<sk[1]<1,1024>>> into tensor<30x!TFHE.glwe<sk[1]<1,1024>>>
|
||||
%1 = tensor.expand_shape %0 [[0, 1]] {MANP = 1 : ui1}: tensor<30x!TFHE.glwe<sk[1]<1,1024>>> into tensor<5x6x!TFHE.glwe<sk[1]<1,1024>>>
|
||||
return %1 : tensor<5x6x!TFHE.glwe<sk[1]<1,1024>>>
|
||||
}
|
||||
|
||||
// -----
|
||||
@@ -26,9 +26,9 @@ func.func @tensor_collatenspse_shape(%arg0: tensor<2x3x5x!TFHE.glwe<{1024, 1, 64
|
||||
//CHECK: %[[V0:.*]] = tensor.collapse_shape %[[A0]] [[_:\[\[0, 1\], \[2\], \[3, 4\], \[5\]\]]] : tensor<2x3x2x3x4x1025xi64> into tensor<6x2x12x1025xi64>
|
||||
//CHECK: return %[[V0]] : tensor<6x2x12x1025xi64>
|
||||
//CHECK: }
|
||||
func.func @tensor_collatenspse_shape(%arg0: tensor<2x3x2x3x4x!TFHE.glwe<{1024, 1, 64}{4}>>) -> tensor<6x2x12x!TFHE.glwe<{1024, 1, 64}{4}>> {
|
||||
%0 = tensor.collapse_shape %arg0 [[0, 1], [2], [3, 4]] {MANP = 1 : ui1}: tensor<2x3x2x3x4x!TFHE.glwe<{1024, 1, 64}{4}>> into tensor<6x2x12x!TFHE.glwe<{1024, 1, 64}{4}>>
|
||||
return %0 : tensor<6x2x12x!TFHE.glwe<{1024, 1, 64}{4}>>
|
||||
func.func @tensor_collatenspse_shape(%arg0: tensor<2x3x2x3x4x!TFHE.glwe<sk[1]<1,1024>>>) -> tensor<6x2x12x!TFHE.glwe<sk[1]<1,1024>>> {
|
||||
%0 = tensor.collapse_shape %arg0 [[0, 1], [2], [3, 4]] {MANP = 1 : ui1}: tensor<2x3x2x3x4x!TFHE.glwe<sk[1]<1,1024>>> into tensor<6x2x12x!TFHE.glwe<sk[1]<1,1024>>>
|
||||
return %0 : tensor<6x2x12x!TFHE.glwe<sk[1]<1,1024>>>
|
||||
}
|
||||
|
||||
// -----
|
||||
@@ -36,7 +36,7 @@ func.func @tensor_collatenspse_shape(%arg0: tensor<2x3x2x3x4x!TFHE.glwe<{1024, 1
|
||||
//CHECK: %[[V0:.*]] = tensor.expand_shape %[[A0]] [[_:\[\[0, 1\], \[2\]\]]] : tensor<30x1025xi64> into tensor<5x6x1025xi64>
|
||||
//CHECK: return %[[V0]] : tensor<5x6x1025xi64>
|
||||
//CHECK: }
|
||||
func.func @tensor_expand_shape_crt(%arg0: tensor<30x!TFHE.glwe<{1024, 1, 64}{4}>>) -> tensor<5x6x!TFHE.glwe<{1024, 1, 64}{4}>> {
|
||||
%0 = tensor.expand_shape %arg0 [[0, 1]] {MANP = 1 : ui1}: tensor<30x!TFHE.glwe<{1024, 1, 64}{4}>> into tensor<5x6x!TFHE.glwe<{1024, 1, 64}{4}>>
|
||||
return %0 : tensor<5x6x!TFHE.glwe<{1024, 1, 64}{4}>>
|
||||
func.func @tensor_expand_shape_crt(%arg0: tensor<30x!TFHE.glwe<sk[1]<1,1024>>>) -> tensor<5x6x!TFHE.glwe<sk[1]<1,1024>>> {
|
||||
%0 = tensor.expand_shape %arg0 [[0, 1]] {MANP = 1 : ui1}: tensor<30x!TFHE.glwe<sk[1]<1,1024>>> into tensor<5x6x!TFHE.glwe<sk[1]<1,1024>>>
|
||||
return %0 : tensor<5x6x!TFHE.glwe<sk[1]<1,1024>>>
|
||||
}
|
||||
|
||||
@@ -10,9 +10,9 @@
|
||||
// CHECK: %[[V6:.*]] = tensor.insert_slice %[[A5]] into %[[V5]][5, 0] [1, 2049] [1, 1] : tensor<2049xi64> into tensor<6x2049xi64>
|
||||
// CHECK: return %[[V6]] : tensor<6x2049xi64>
|
||||
// CHECK: }
|
||||
func.func @main(%arg0 : !TFHE.glwe<{2048, 1, 64}{4}>, %arg1 : !TFHE.glwe<{2048, 1, 64}{4}>, %arg2 : !TFHE.glwe<{2048, 1, 64}{4}>, %arg3 : !TFHE.glwe<{2048, 1, 64}{4}>, %arg4 : !TFHE.glwe<{2048, 1, 64}{4}>, %arg5 : !TFHE.glwe<{2048, 1, 64}{4}>) -> tensor<6x!TFHE.glwe<{2048, 1, 64}{4}>> {
|
||||
%0 = tensor.from_elements %arg0, %arg1, %arg2, %arg3, %arg4, %arg5 : tensor<6x!TFHE.glwe<{2048, 1, 64}{4}>>
|
||||
return %0 : tensor<6x!TFHE.glwe<{2048, 1, 64}{4}>>
|
||||
func.func @main(%arg0 : !TFHE.glwe<sk[1]<1,2048>>, %arg1 : !TFHE.glwe<sk[1]<1,2048>>, %arg2 : !TFHE.glwe<sk[1]<1,2048>>, %arg3 : !TFHE.glwe<sk[1]<1,2048>>, %arg4 : !TFHE.glwe<sk[1]<1,2048>>, %arg5 : !TFHE.glwe<sk[1]<1,2048>>) -> tensor<6x!TFHE.glwe<sk[1]<1,2048>>> {
|
||||
%0 = tensor.from_elements %arg0, %arg1, %arg2, %arg3, %arg4, %arg5 : tensor<6x!TFHE.glwe<sk[1]<1,2048>>>
|
||||
return %0 : tensor<6x!TFHE.glwe<sk[1]<1,2048>>>
|
||||
}
|
||||
|
||||
// -----
|
||||
@@ -27,7 +27,7 @@ func.func @main(%arg0 : !TFHE.glwe<{2048, 1, 64}{4}>, %arg1 : !TFHE.glwe<{2048,
|
||||
// CHECK: %[[V6:.*]] = tensor.insert_slice %[[A5]] into %[[V5]][1, 2, 0] [1, 1, 2049] [1, 1, 1] : tensor<2049xi64> into tensor<2x3x2049xi64>
|
||||
// CHECK: return %[[V6]] : tensor<2x3x2049xi64>
|
||||
// CHECK: }
|
||||
func.func @main(%arg0 : !TFHE.glwe<{2048, 1, 64}{4}>, %arg1 : !TFHE.glwe<{2048, 1, 64}{4}>, %arg2 : !TFHE.glwe<{2048, 1, 64}{4}>, %arg3 : !TFHE.glwe<{2048, 1, 64}{4}>, %arg4 : !TFHE.glwe<{2048, 1, 64}{4}>, %arg5 : !TFHE.glwe<{2048, 1, 64}{4}>) -> tensor<2x3x!TFHE.glwe<{2048, 1, 64}{4}>> {
|
||||
%0 = tensor.from_elements %arg0, %arg1, %arg2, %arg3, %arg4, %arg5 : tensor<2x3x!TFHE.glwe<{2048, 1, 64}{4}>>
|
||||
return %0 : tensor<2x3x!TFHE.glwe<{2048, 1, 64}{4}>>
|
||||
func.func @main(%arg0 : !TFHE.glwe<sk[1]<1,2048>>, %arg1 : !TFHE.glwe<sk[1]<1,2048>>, %arg2 : !TFHE.glwe<sk[1]<1,2048>>, %arg3 : !TFHE.glwe<sk[1]<1,2048>>, %arg4 : !TFHE.glwe<sk[1]<1,2048>>, %arg5 : !TFHE.glwe<sk[1]<1,2048>>) -> tensor<2x3x!TFHE.glwe<sk[1]<1,2048>>> {
|
||||
%0 = tensor.from_elements %arg0, %arg1, %arg2, %arg3, %arg4, %arg5 : tensor<2x3x!TFHE.glwe<sk[1]<1,2048>>>
|
||||
return %0 : tensor<2x3x!TFHE.glwe<sk[1]<1,2048>>>
|
||||
}
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
// CHECK: func.func @tensor_identity(%arg0: tensor<2x3x4x1025xi64>) -> tensor<2x3x4x1025xi64> {
|
||||
// CHECK-NEXT: return %arg0 : tensor<2x3x4x1025xi64>
|
||||
// CHECK-NEXT: }
|
||||
func.func @tensor_identity(%arg0: tensor<2x3x4x!TFHE.glwe<{1024, 1, 64}{7}>>) -> tensor<2x3x4x!TFHE.glwe<{1024, 1, 64}{7}>> {
|
||||
return %arg0 : tensor<2x3x4x!TFHE.glwe<{1024, 1, 64}{7}>>
|
||||
func.func @tensor_identity(%arg0: tensor<2x3x4x!TFHE.glwe<sk[1]<1,1024>>>) -> tensor<2x3x4x!TFHE.glwe<sk[1]<1,1024>>> {
|
||||
return %arg0 : tensor<2x3x4x!TFHE.glwe<sk[1]<1,1024>>>
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// RUN: concretecompiler --passes tfhe-optimization --optimize-tfhe=false --action=dump-tfhe %s 2>&1| FileCheck %s
|
||||
|
||||
//CHECK: func.func @mul_cleartext_glwe_ciphertext_0(%[[A0:.*]]: !TFHE.glwe<{1,527,64}{7}>) -> !TFHE.glwe<{1,527,64}{7}> {
|
||||
//CHECK: func.func @mul_cleartext_glwe_ciphertext_0(%[[A0:.*]]: !TFHE.glwe<sk[1]<527,1>>) -> !TFHE.glwe<sk[1]<527,1>> {
|
||||
//CHECK: %c0_i64 = arith.constant 0 : i64
|
||||
//CHECK: %[[V0:.*]] = "TFHE.mul_glwe_int"(%[[A0]], %c0_i64) : (!TFHE.glwe<{1,527,64}{7}>, i64) -> !TFHE.glwe<{1,527,64}{7}>
|
||||
//CHECK: return %[[V0]] : !TFHE.glwe<{1,527,64}{7}>
|
||||
//CHECK: %[[V0:.*]] = "TFHE.mul_glwe_int"(%[[A0]], %c0_i64) : (!TFHE.glwe<sk[1]<527,1>>, i64) -> !TFHE.glwe<sk[1]<527,1>>
|
||||
//CHECK: return %[[V0]] : !TFHE.glwe<sk[1]<527,1>>
|
||||
//CHECK: }
|
||||
func.func @mul_cleartext_glwe_ciphertext_0(%arg0: !TFHE.glwe<{1,527,64}{7}>) -> !TFHE.glwe<{1,527,64}{7}> {
|
||||
func.func @mul_cleartext_glwe_ciphertext_0(%arg0: !TFHE.glwe<sk[1]<527,1>>) -> !TFHE.glwe<sk[1]<527,1>> {
|
||||
%0 = arith.constant 0 : i64
|
||||
%2 = "TFHE.mul_glwe_int"(%arg0, %0): (!TFHE.glwe<{1,527,64}{7}>, i64) -> (!TFHE.glwe<{1,527,64}{7}>)
|
||||
return %2: !TFHE.glwe<{1,527,64}{7}>
|
||||
%2 = "TFHE.mul_glwe_int"(%arg0, %0): (!TFHE.glwe<sk[1]<527,1>>, i64) -> (!TFHE.glwe<sk[1]<527,1>>)
|
||||
return %2: !TFHE.glwe<sk[1]<527,1>>
|
||||
}
|
||||
|
||||
@@ -1,35 +1,35 @@
|
||||
// RUN: concretecompiler --split-input-file --verify-diagnostics --action=roundtrip %s
|
||||
|
||||
// GLWE dimension parameter result
|
||||
func.func @add_glwe(%arg0: !TFHE.glwe<{1024,12,64}{7}>, %arg1: !TFHE.glwe<{1024,12,64}{7}>) -> !TFHE.glwe<{512,12,64}{7}> {
|
||||
// expected-error @+1 {{'TFHE.add_glwe' op should have the same GLWE 'dimension' parameter}}
|
||||
%1 = "TFHE.add_glwe"(%arg0, %arg1): (!TFHE.glwe<{1024,12,64}{7}>, !TFHE.glwe<{1024,12,64}{7}>) -> (!TFHE.glwe<{512,12,64}{7}>)
|
||||
return %1: !TFHE.glwe<{512,12,64}{7}>
|
||||
func.func @add_glwe(%arg0: !TFHE.glwe<sk[1]<12,1024>>, %arg1: !TFHE.glwe<sk[1]<12,1024>>) -> !TFHE.glwe<sk[1]<12,512>> {
|
||||
// expected-error @+1 {{'TFHE.add_glwe' op should have the same GLWE Secret Key}}
|
||||
%1 = "TFHE.add_glwe"(%arg0, %arg1): (!TFHE.glwe<sk[1]<12,1024>>, !TFHE.glwe<sk[1]<12,1024>>) -> (!TFHE.glwe<sk[1]<12,512>>)
|
||||
return %1: !TFHE.glwe<sk[1]<12,512>>
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
// GLWE dimension parameter inputs
|
||||
func.func @add_glwe(%arg0: !TFHE.glwe<{1024,12,64}{7}>, %arg1: !TFHE.glwe<{512,12,64}{7}>) -> !TFHE.glwe<{1024,12,64}{7}> {
|
||||
// expected-error @+1 {{'TFHE.add_glwe' op should have the same GLWE 'dimension' parameter}}
|
||||
%1 = "TFHE.add_glwe"(%arg0, %arg1): (!TFHE.glwe<{1024,12,64}{7}>, !TFHE.glwe<{512,12,64}{7}>) -> (!TFHE.glwe<{1024,12,64}{7}>)
|
||||
return %1: !TFHE.glwe<{1024,12,64}{7}>
|
||||
func.func @add_glwe(%arg0: !TFHE.glwe<sk[1]<12,1024>>, %arg1: !TFHE.glwe<sk[1]<12,512>>) -> !TFHE.glwe<sk[1]<12,1024>> {
|
||||
// expected-error @+1 {{'TFHE.add_glwe' op should have the same GLWE Secret Key}}
|
||||
%1 = "TFHE.add_glwe"(%arg0, %arg1): (!TFHE.glwe<sk[1]<12,1024>>, !TFHE.glwe<sk[1]<12,512>>) -> (!TFHE.glwe<sk[1]<12,1024>>)
|
||||
return %1: !TFHE.glwe<sk[1]<12,1024>>
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
// GLWE polynomialSize parameter result
|
||||
func.func @add_glwe(%arg0: !TFHE.glwe<{1024,12,64}{7}>, %arg1: !TFHE.glwe<{1024,12,64}{7}>) -> !TFHE.glwe<{1024,11,64}{7}> {
|
||||
// expected-error @+1 {{'TFHE.add_glwe' op should have the same GLWE 'polynomialSize' parameter}}
|
||||
%1 = "TFHE.add_glwe"(%arg0, %arg1): (!TFHE.glwe<{1024,12,64}{7}>, !TFHE.glwe<{1024,12,64}{7}>) -> (!TFHE.glwe<{1024,11,64}{7}>)
|
||||
return %1: !TFHE.glwe<{1024,11,64}{7}>
|
||||
func.func @add_glwe(%arg0: !TFHE.glwe<sk[1]<12,1024>>, %arg1: !TFHE.glwe<sk[1]<12,1024>>) -> !TFHE.glwe<sk[1]<11,1024>> {
|
||||
// expected-error @+1 {{'TFHE.add_glwe' op should have the same GLWE Secret Key}}
|
||||
%1 = "TFHE.add_glwe"(%arg0, %arg1): (!TFHE.glwe<sk[1]<12,1024>>, !TFHE.glwe<sk[1]<12,1024>>) -> (!TFHE.glwe<sk[1]<11,1024>>)
|
||||
return %1: !TFHE.glwe<sk[1]<11,1024>>
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
// GLWE polynomialSize parameter inputs
|
||||
func.func @add_glwe(%arg0: !TFHE.glwe<{1024,12,64}{7}>, %arg1: !TFHE.glwe<{1024,11,64}{7}>) -> !TFHE.glwe<{1024,12,64}{7}> {
|
||||
// expected-error @+1 {{'TFHE.add_glwe' op should have the same GLWE 'polynomialSize' parameter}}
|
||||
%1 = "TFHE.add_glwe"(%arg0, %arg1): (!TFHE.glwe<{1024,12,64}{7}>, !TFHE.glwe<{1024,11,64}{7}>) -> (!TFHE.glwe<{1024,12,64}{7}>)
|
||||
return %1: !TFHE.glwe<{1024,12,64}{7}>
|
||||
func.func @add_glwe(%arg0: !TFHE.glwe<sk[1]<12,1024>>, %arg1: !TFHE.glwe<sk[1]<11,1024>>) -> !TFHE.glwe<sk[1]<12,1024>> {
|
||||
// expected-error @+1 {{'TFHE.add_glwe' op should have the same GLWE Secret Key}}
|
||||
%1 = "TFHE.add_glwe"(%arg0, %arg1): (!TFHE.glwe<sk[1]<12,1024>>, !TFHE.glwe<sk[1]<11,1024>>) -> (!TFHE.glwe<sk[1]<12,1024>>)
|
||||
return %1: !TFHE.glwe<sk[1]<12,1024>>
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// RUN: concretecompiler --action=roundtrip %s 2>&1| FileCheck %s
|
||||
|
||||
// CHECK-LABEL: func.func @add_glwe(%arg0: !TFHE.glwe<{1024,12,64}{7}>, %arg1: !TFHE.glwe<{1024,12,64}{7}>) -> !TFHE.glwe<{1024,12,64}{7}>
|
||||
func.func @add_glwe(%arg0: !TFHE.glwe<{1024,12,64}{7}>, %arg1: !TFHE.glwe<{1024,12,64}{7}>) -> !TFHE.glwe<{1024,12,64}{7}> {
|
||||
// CHECK-NEXT: %[[V1:.*]] = "TFHE.add_glwe"(%arg0, %arg1) : (!TFHE.glwe<{1024,12,64}{7}>, !TFHE.glwe<{1024,12,64}{7}>) -> !TFHE.glwe<{1024,12,64}{7}>
|
||||
// CHECK-NEXT: return %[[V1]] : !TFHE.glwe<{1024,12,64}{7}>
|
||||
// CHECK-LABEL: func.func @add_glwe(%arg0: !TFHE.glwe<sk[1]<12,1024>>, %arg1: !TFHE.glwe<sk[1]<12,1024>>) -> !TFHE.glwe<sk[1]<12,1024>>
|
||||
func.func @add_glwe(%arg0: !TFHE.glwe<sk[1]<12,1024>>, %arg1: !TFHE.glwe<sk[1]<12,1024>>) -> !TFHE.glwe<sk[1]<12,1024>> {
|
||||
// CHECK-NEXT: %[[V1:.*]] = "TFHE.add_glwe"(%arg0, %arg1) : (!TFHE.glwe<sk[1]<12,1024>>, !TFHE.glwe<sk[1]<12,1024>>) -> !TFHE.glwe<sk[1]<12,1024>>
|
||||
// CHECK-NEXT: return %[[V1]] : !TFHE.glwe<sk[1]<12,1024>>
|
||||
|
||||
%0 = "TFHE.add_glwe"(%arg0, %arg1): (!TFHE.glwe<{1024,12,64}{7}>, !TFHE.glwe<{1024,12,64}{7}>) -> (!TFHE.glwe<{1024,12,64}{7}>)
|
||||
return %0: !TFHE.glwe<{1024,12,64}{7}>
|
||||
%0 = "TFHE.add_glwe"(%arg0, %arg1): (!TFHE.glwe<sk[1]<12,1024>>, !TFHE.glwe<sk[1]<12,1024>>) -> (!TFHE.glwe<sk[1]<12,1024>>)
|
||||
return %0: !TFHE.glwe<sk[1]<12,1024>>
|
||||
}
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
// RUN: concretecompiler --split-input-file --verify-diagnostics --action=roundtrip %s
|
||||
|
||||
// GLWE p parameter
|
||||
func.func @add_glwe_int(%arg0: !TFHE.glwe<{1024,12,64}{7}>) -> !TFHE.glwe<{1024,12,64}{6}> {
|
||||
// GLWE id parameter
|
||||
func.func @add_glwe_int(%arg0: !TFHE.glwe<sk[1]<12,1024>>) -> !TFHE.glwe<sk[2]<12,1024>> {
|
||||
%0 = arith.constant 1 : i8
|
||||
// expected-error @+1 {{'TFHE.add_glwe_int' op should have the same GLWE 'p' parameter}}
|
||||
%1 = "TFHE.add_glwe_int"(%arg0, %0): (!TFHE.glwe<{1024,12,64}{7}>, i8) -> (!TFHE.glwe<{1024,12,64}{6}>)
|
||||
return %1: !TFHE.glwe<{1024,12,64}{6}>
|
||||
// expected-error @+1 {{'TFHE.add_glwe_int' op should have the same GLWE Secret Key}}
|
||||
%1 = "TFHE.add_glwe_int"(%arg0, %0): (!TFHE.glwe<sk[1]<12,1024>>, i8) -> (!TFHE.glwe<sk[2]<12,1024>>)
|
||||
return %1: !TFHE.glwe<sk[2]<12,1024>>
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
// GLWE dimension parameter
|
||||
func.func @add_glwe_int(%arg0: !TFHE.glwe<{1024,12,64}{7}>) -> !TFHE.glwe<{512,12,64}{7}> {
|
||||
func.func @add_glwe_int(%arg0: !TFHE.glwe<sk[1]<12,1024>>) -> !TFHE.glwe<sk[1]<12,512>> {
|
||||
%0 = arith.constant 1 : i8
|
||||
// expected-error @+1 {{'TFHE.add_glwe_int' op should have the same GLWE 'dimension' parameter}}
|
||||
%1 = "TFHE.add_glwe_int"(%arg0, %0): (!TFHE.glwe<{1024,12,64}{7}>, i8) -> (!TFHE.glwe<{512,12,64}{7}>)
|
||||
return %1: !TFHE.glwe<{512,12,64}{7}>
|
||||
// expected-error @+1 {{'TFHE.add_glwe_int' op should have the same GLWE Secret Key}}
|
||||
%1 = "TFHE.add_glwe_int"(%arg0, %0): (!TFHE.glwe<sk[1]<12,1024>>, i8) -> (!TFHE.glwe<sk[1]<12,512>>)
|
||||
return %1: !TFHE.glwe<sk[1]<12,512>>
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
// GLWE polynomialSize parameter
|
||||
func.func @add_glwe_int(%arg0: !TFHE.glwe<{1024,12,64}{7}>) -> !TFHE.glwe<{1024,11,64}{7}> {
|
||||
func.func @add_glwe_int(%arg0: !TFHE.glwe<sk[1]<12,1024>>) -> !TFHE.glwe<sk[1]<11,1024>> {
|
||||
%0 = arith.constant 1 : i8
|
||||
// expected-error @+1 {{'TFHE.add_glwe_int' op should have the same GLWE 'polynomialSize' parameter}}
|
||||
%1 = "TFHE.add_glwe_int"(%arg0, %0): (!TFHE.glwe<{1024,12,64}{7}>, i8) -> (!TFHE.glwe<{1024,11,64}{7}>)
|
||||
return %1: !TFHE.glwe<{1024,11,64}{7}>
|
||||
// expected-error @+1 {{'TFHE.add_glwe_int' op should have the same GLWE Secret Key}}
|
||||
%1 = "TFHE.add_glwe_int"(%arg0, %0): (!TFHE.glwe<sk[1]<12,1024>>, i8) -> (!TFHE.glwe<sk[1]<11,1024>>)
|
||||
return %1: !TFHE.glwe<sk[1]<11,1024>>
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// RUN: concretecompiler --action=roundtrip %s 2>&1| FileCheck %s
|
||||
|
||||
// CHECK-LABEL: func.func @add_glwe_int(%arg0: !TFHE.glwe<{1024,12,64}{7}>) -> !TFHE.glwe<{1024,12,64}{7}>
|
||||
func.func @add_glwe_int(%arg0: !TFHE.glwe<{1024,12,64}{7}>) -> !TFHE.glwe<{1024,12,64}{7}> {
|
||||
// CHECK-LABEL: func.func @add_glwe_int(%arg0: !TFHE.glwe<sk[1]<12,1024>>) -> !TFHE.glwe<sk[1]<12,1024>>
|
||||
func.func @add_glwe_int(%arg0: !TFHE.glwe<sk[1]<12,1024>>) -> !TFHE.glwe<sk[1]<12,1024>> {
|
||||
// CHECK-NEXT: %[[V1:.*]] = arith.constant 1 : i64
|
||||
// CHECK-NEXT: %[[V2:.*]] = "TFHE.add_glwe_int"(%arg0, %[[V1]]) : (!TFHE.glwe<{1024,12,64}{7}>, i64) -> !TFHE.glwe<{1024,12,64}{7}>
|
||||
// CHECK-NEXT: return %[[V2]] : !TFHE.glwe<{1024,12,64}{7}>
|
||||
// CHECK-NEXT: %[[V2:.*]] = "TFHE.add_glwe_int"(%arg0, %[[V1]]) : (!TFHE.glwe<sk[1]<12,1024>>, i64) -> !TFHE.glwe<sk[1]<12,1024>>
|
||||
// CHECK-NEXT: return %[[V2]] : !TFHE.glwe<sk[1]<12,1024>>
|
||||
|
||||
%0 = arith.constant 1 : i64
|
||||
%1 = "TFHE.add_glwe_int"(%arg0, %0): (!TFHE.glwe<{1024,12,64}{7}>, i64) -> (!TFHE.glwe<{1024,12,64}{7}>)
|
||||
return %1: !TFHE.glwe<{1024,12,64}{7}>
|
||||
%1 = "TFHE.add_glwe_int"(%arg0, %0): (!TFHE.glwe<sk[1]<12,1024>>, i64) -> (!TFHE.glwe<sk[1]<12,1024>>)
|
||||
return %1: !TFHE.glwe<sk[1]<12,1024>>
|
||||
}
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
// RUN: concretecompiler --split-input-file --verify-diagnostics --action=roundtrip %s
|
||||
|
||||
// GLWE p parameter
|
||||
func.func @mul_glwe_int(%arg0: !TFHE.glwe<{1024,12,64}{7}>) -> !TFHE.glwe<{1024,12,64}{6}> {
|
||||
func.func @mul_glwe_int(%arg0: !TFHE.glwe<sk[1]<12,1024>>) -> !TFHE.glwe<sk[2]<12,1024>> {
|
||||
%0 = arith.constant 1 : i8
|
||||
// expected-error @+1 {{'TFHE.mul_glwe_int' op should have the same GLWE 'p' parameter}}
|
||||
%1 = "TFHE.mul_glwe_int"(%arg0, %0): (!TFHE.glwe<{1024,12,64}{7}>, i8) -> (!TFHE.glwe<{1024,12,64}{6}>)
|
||||
return %1: !TFHE.glwe<{1024,12,64}{6}>
|
||||
// expected-error @+1 {{'TFHE.mul_glwe_int' op should have the same GLWE Secret Key}}
|
||||
%1 = "TFHE.mul_glwe_int"(%arg0, %0): (!TFHE.glwe<sk[1]<12,1024>>, i8) -> (!TFHE.glwe<sk[2]<12,1024>>)
|
||||
return %1: !TFHE.glwe<sk[2]<12,1024>>
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
// GLWE dimension parameter
|
||||
func.func @mul_glwe_int(%arg0: !TFHE.glwe<{1024,12,64}{7}>) -> !TFHE.glwe<{512,12,64}{7}> {
|
||||
func.func @mul_glwe_int(%arg0: !TFHE.glwe<sk[1]<12,1024>>) -> !TFHE.glwe<sk[1]<12,512>> {
|
||||
%0 = arith.constant 1 : i8
|
||||
// expected-error @+1 {{'TFHE.mul_glwe_int' op should have the same GLWE 'dimension' parameter}}
|
||||
%1 = "TFHE.mul_glwe_int"(%arg0, %0): (!TFHE.glwe<{1024,12,64}{7}>, i8) -> (!TFHE.glwe<{512,12,64}{7}>)
|
||||
return %1: !TFHE.glwe<{512,12,64}{7}>
|
||||
// expected-error @+1 {{'TFHE.mul_glwe_int' op should have the same GLWE Secret Key}}
|
||||
%1 = "TFHE.mul_glwe_int"(%arg0, %0): (!TFHE.glwe<sk[1]<12,1024>>, i8) -> (!TFHE.glwe<sk[1]<12,512>>)
|
||||
return %1: !TFHE.glwe<sk[1]<12,512>>
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
// GLWE polynomialSize parameter
|
||||
func.func @mul_glwe_int(%arg0: !TFHE.glwe<{1024,12,64}{7}>) -> !TFHE.glwe<{1024,11,64}{7}> {
|
||||
func.func @mul_glwe_int(%arg0: !TFHE.glwe<sk[1]<12,1024>>) -> !TFHE.glwe<sk[1]<11,1024>> {
|
||||
%0 = arith.constant 1 : i8
|
||||
// expected-error @+1 {{'TFHE.mul_glwe_int' op should have the same GLWE 'polynomialSize' parameter}}
|
||||
%1 = "TFHE.mul_glwe_int"(%arg0, %0): (!TFHE.glwe<{1024,12,64}{7}>, i8) -> (!TFHE.glwe<{1024,11,64}{7}>)
|
||||
return %1: !TFHE.glwe<{1024,11,64}{7}>
|
||||
// expected-error @+1 {{'TFHE.mul_glwe_int' op should have the same GLWE Secret Key}}
|
||||
%1 = "TFHE.mul_glwe_int"(%arg0, %0): (!TFHE.glwe<sk[1]<12,1024>>, i8) -> (!TFHE.glwe<sk[1]<11,1024>>)
|
||||
return %1: !TFHE.glwe<sk[1]<11,1024>>
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// RUN: concretecompiler --action=roundtrip %s 2>&1| FileCheck %s
|
||||
|
||||
// CHECK-LABEL: func.func @mul_glwe_int(%arg0: !TFHE.glwe<{1024,12,64}{7}>) -> !TFHE.glwe<{1024,12,64}{7}>
|
||||
func.func @mul_glwe_int(%arg0: !TFHE.glwe<{1024,12,64}{7}>) -> !TFHE.glwe<{1024,12,64}{7}> {
|
||||
// CHECK-LABEL: func.func @mul_glwe_int(%arg0: !TFHE.glwe<sk[1]<12,1024>>) -> !TFHE.glwe<sk[1]<12,1024>>
|
||||
func.func @mul_glwe_int(%arg0: !TFHE.glwe<sk[1]<12,1024>>) -> !TFHE.glwe<sk[1]<12,1024>> {
|
||||
// CHECK-NEXT: %[[V1:.*]] = arith.constant 1 : i64
|
||||
// CHECK-NEXT: %[[V2:.*]] = "TFHE.mul_glwe_int"(%arg0, %[[V1]]) : (!TFHE.glwe<{1024,12,64}{7}>, i64) -> !TFHE.glwe<{1024,12,64}{7}>
|
||||
// CHECK-NEXT: return %[[V2]] : !TFHE.glwe<{1024,12,64}{7}>
|
||||
// CHECK-NEXT: %[[V2:.*]] = "TFHE.mul_glwe_int"(%arg0, %[[V1]]) : (!TFHE.glwe<sk[1]<12,1024>>, i64) -> !TFHE.glwe<sk[1]<12,1024>>
|
||||
// CHECK-NEXT: return %[[V2]] : !TFHE.glwe<sk[1]<12,1024>>
|
||||
|
||||
%0 = arith.constant 1 : i64
|
||||
%1 = "TFHE.mul_glwe_int"(%arg0, %0): (!TFHE.glwe<{1024,12,64}{7}>, i64) -> (!TFHE.glwe<{1024,12,64}{7}>)
|
||||
return %1: !TFHE.glwe<{1024,12,64}{7}>
|
||||
%1 = "TFHE.mul_glwe_int"(%arg0, %0): (!TFHE.glwe<sk[1]<12,1024>>, i64) -> (!TFHE.glwe<sk[1]<12,1024>>)
|
||||
return %1: !TFHE.glwe<sk[1]<12,1024>>
|
||||
}
|
||||
|
||||
@@ -1,36 +1,26 @@
|
||||
// RUN: concretecompiler --split-input-file --verify-diagnostics --action=roundtrip %s
|
||||
|
||||
// GLWE p parameter
|
||||
func.func @neg_glwe(%arg0: !TFHE.glwe<{1024,12,64}{7}>) -> !TFHE.glwe<{1024,12,64}{6}> {
|
||||
// expected-error @+1 {{'TFHE.neg_glwe' op should have the same GLWE 'p' parameter}}
|
||||
%1 = "TFHE.neg_glwe"(%arg0): (!TFHE.glwe<{1024,12,64}{7}>) -> (!TFHE.glwe<{1024,12,64}{6}>)
|
||||
return %1: !TFHE.glwe<{1024,12,64}{6}>
|
||||
// GLWE id parameter
|
||||
func.func @neg_glwe(%arg0: !TFHE.glwe<sk[1]<12,1024>>) -> !TFHE.glwe<sk[2]<12,1024>> {
|
||||
// expected-error @+1 {{'TFHE.neg_glwe' op should have the same GLWE Secret Key}}
|
||||
%1 = "TFHE.neg_glwe"(%arg0): (!TFHE.glwe<sk[1]<12,1024>>) -> (!TFHE.glwe<sk[2]<12,1024>>)
|
||||
return %1: !TFHE.glwe<sk[2]<12,1024>>
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
// GLWE dimension parameter
|
||||
func.func @neg_glwe(%arg0: !TFHE.glwe<{1024,12,64}{7}>) -> !TFHE.glwe<{512,12,64}{7}> {
|
||||
// expected-error @+1 {{'TFHE.neg_glwe' op should have the same GLWE 'dimension' parameter}}
|
||||
%1 = "TFHE.neg_glwe"(%arg0): (!TFHE.glwe<{1024,12,64}{7}>) -> (!TFHE.glwe<{512,12,64}{7}>)
|
||||
return %1: !TFHE.glwe<{512,12,64}{7}>
|
||||
func.func @neg_glwe(%arg0: !TFHE.glwe<sk[1]<12,1024>>) -> !TFHE.glwe<sk[1]<12,512>> {
|
||||
// expected-error @+1 {{'TFHE.neg_glwe' op should have the same GLWE Secret Key}}
|
||||
%1 = "TFHE.neg_glwe"(%arg0): (!TFHE.glwe<sk[1]<12,1024>>) -> (!TFHE.glwe<sk[1]<12,512>>)
|
||||
return %1: !TFHE.glwe<sk[1]<12,512>>
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
// GLWE polynomialSize parameter
|
||||
func.func @neg_glwe(%arg0: !TFHE.glwe<{1024,12,64}{7}>) -> !TFHE.glwe<{1024,11,64}{7}> {
|
||||
// expected-error @+1 {{'TFHE.neg_glwe' op should have the same GLWE 'polynomialSize' parameter}}
|
||||
%1 = "TFHE.neg_glwe"(%arg0): (!TFHE.glwe<{1024,12,64}{7}>) -> (!TFHE.glwe<{1024,11,64}{7}>)
|
||||
return %1: !TFHE.glwe<{1024,11,64}{7}>
|
||||
func.func @neg_glwe(%arg0: !TFHE.glwe<sk[1]<12,1024>>) -> !TFHE.glwe<sk[1]<11,1024>> {
|
||||
// expected-error @+1 {{'TFHE.neg_glwe' op should have the same GLWE Secret Key}}
|
||||
%1 = "TFHE.neg_glwe"(%arg0): (!TFHE.glwe<sk[1]<12,1024>>) -> (!TFHE.glwe<sk[1]<11,1024>>)
|
||||
return %1: !TFHE.glwe<sk[1]<11,1024>>
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
// integer width doesn't match GLWE parameter
|
||||
func.func @neg_glwe(%arg0: !TFHE.glwe<{1024,12,64}{7}>) -> !TFHE.glwe<{1024,11,64}{7}> {
|
||||
// expected-error @+1 {{'TFHE.neg_glwe' op should have the same GLWE 'polynomialSize' parameter}}
|
||||
%1 = "TFHE.neg_glwe"(%arg0): (!TFHE.glwe<{1024,12,64}{7}>) -> (!TFHE.glwe<{1024,11,64}{7}>)
|
||||
return %1: !TFHE.glwe<{1024,11,64}{7}>
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// RUN: concretecompiler --action=roundtrip %s 2>&1| FileCheck %s
|
||||
|
||||
// CHECK-LABEL: func.func @neg_glwe(%arg0: !TFHE.glwe<{1024,12,64}{7}>) -> !TFHE.glwe<{1024,12,64}{7}>
|
||||
func.func @neg_glwe(%arg0: !TFHE.glwe<{1024,12,64}{7}>) -> !TFHE.glwe<{1024,12,64}{7}> {
|
||||
// CHECK-NEXT: %[[V1:.*]] = "TFHE.neg_glwe"(%arg0) : (!TFHE.glwe<{1024,12,64}{7}>) -> !TFHE.glwe<{1024,12,64}{7}>
|
||||
// CHECK-NEXT: return %[[V1]] : !TFHE.glwe<{1024,12,64}{7}>
|
||||
// CHECK-LABEL: func.func @neg_glwe(%arg0: !TFHE.glwe<sk[1]<12,1024>>) -> !TFHE.glwe<sk[1]<12,1024>>
|
||||
func.func @neg_glwe(%arg0: !TFHE.glwe<sk[1]<12,1024>>) -> !TFHE.glwe<sk[1]<12,1024>> {
|
||||
// CHECK-NEXT: %[[V1:.*]] = "TFHE.neg_glwe"(%arg0) : (!TFHE.glwe<sk[1]<12,1024>>) -> !TFHE.glwe<sk[1]<12,1024>>
|
||||
// CHECK-NEXT: return %[[V1]] : !TFHE.glwe<sk[1]<12,1024>>
|
||||
|
||||
%1 = "TFHE.neg_glwe"(%arg0): (!TFHE.glwe<{1024,12,64}{7}>) -> (!TFHE.glwe<{1024,12,64}{7}>)
|
||||
return %1: !TFHE.glwe<{1024,12,64}{7}>
|
||||
%1 = "TFHE.neg_glwe"(%arg0): (!TFHE.glwe<sk[1]<12,1024>>) -> (!TFHE.glwe<sk[1]<12,1024>>)
|
||||
return %1: !TFHE.glwe<sk[1]<12,1024>>
|
||||
}
|
||||
|
||||
@@ -1,41 +1,30 @@
|
||||
// RUN: concretecompiler --split-input-file --verify-diagnostics --action=roundtrip %s
|
||||
|
||||
// GLWE p parameter
|
||||
func.func @sub_int_glwe(%arg0: !TFHE.glwe<{1024,12,64}{7}>) -> !TFHE.glwe<{1024,12,64}{6}> {
|
||||
// GLWE id parameter
|
||||
func.func @sub_int_glwe(%arg0: !TFHE.glwe<sk[1]<12,1024>>) -> !TFHE.glwe<sk[2]<12,1024>> {
|
||||
%0 = arith.constant 1 : i8
|
||||
// expected-error @+1 {{'TFHE.sub_int_glwe' op should have the same GLWE 'p' parameter}}
|
||||
%1 = "TFHE.sub_int_glwe"(%0, %arg0): (i8, !TFHE.glwe<{1024,12,64}{7}>) -> (!TFHE.glwe<{1024,12,64}{6}>)
|
||||
return %1: !TFHE.glwe<{1024,12,64}{6}>
|
||||
// expected-error @+1 {{'TFHE.sub_int_glwe' op should have the same GLWE Secret Key}}
|
||||
%1 = "TFHE.sub_int_glwe"(%0, %arg0): (i8, !TFHE.glwe<sk[1]<12,1024>>) -> (!TFHE.glwe<sk[2]<12,1024>>)
|
||||
return %1: !TFHE.glwe<sk[2]<12,1024>>
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
// GLWE dimension parameter
|
||||
func.func @sub_int_glwe(%arg0: !TFHE.glwe<{1024,12,64}{7}>) -> !TFHE.glwe<{512,12,64}{7}> {
|
||||
func.func @sub_int_glwe(%arg0: !TFHE.glwe<sk[1]<12,1024>>) -> !TFHE.glwe<sk[1]<12,512>> {
|
||||
%0 = arith.constant 1 : i8
|
||||
// expected-error @+1 {{'TFHE.sub_int_glwe' op should have the same GLWE 'dimension' parameter}}
|
||||
%1 = "TFHE.sub_int_glwe"(%0, %arg0): (i8, !TFHE.glwe<{1024,12,64}{7}>) -> (!TFHE.glwe<{512,12,64}{7}>)
|
||||
return %1: !TFHE.glwe<{512,12,64}{7}>
|
||||
// expected-error @+1 {{'TFHE.sub_int_glwe' op should have the same GLWE Secret Key}}
|
||||
%1 = "TFHE.sub_int_glwe"(%0, %arg0): (i8, !TFHE.glwe<sk[1]<12,1024>>) -> (!TFHE.glwe<sk[1]<12,512>>)
|
||||
return %1: !TFHE.glwe<sk[1]<12,512>>
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
// GLWE polynomialSize parameter
|
||||
func.func @sub_int_glwe(%arg0: !TFHE.glwe<{1024,12,64}{7}>) -> !TFHE.glwe<{1024,11,64}{7}> {
|
||||
func.func @sub_int_glwe(%arg0: !TFHE.glwe<sk[1]<12,1024>>) -> !TFHE.glwe<sk[1]<11,1024>> {
|
||||
%0 = arith.constant 1 : i8
|
||||
// expected-error @+1 {{'TFHE.sub_int_glwe' op should have the same GLWE 'polynomialSize' parameter}}
|
||||
%1 = "TFHE.sub_int_glwe"(%0, %arg0): (i8, !TFHE.glwe<{1024,12,64}{7}>) -> (!TFHE.glwe<{1024,11,64}{7}>)
|
||||
return %1: !TFHE.glwe<{1024,11,64}{7}>
|
||||
}
|
||||
|
||||
|
||||
// -----
|
||||
|
||||
// integer width doesn't match GLWE parameter
|
||||
func.func @sub_int_glwe(%arg0: !TFHE.glwe<{1024,12,64}{7}>) -> !TFHE.glwe<{1024,11,64}{7}> {
|
||||
%0 = arith.constant 1 : i8
|
||||
// expected-error @+1 {{'TFHE.sub_int_glwe' op should have the same GLWE 'polynomialSize' parameter}}
|
||||
%1 = "TFHE.sub_int_glwe"(%0, %arg0): (i8, !TFHE.glwe<{1024,12,64}{7}>) -> (!TFHE.glwe<{1024,11,64}{7}>)
|
||||
return %1: !TFHE.glwe<{1024,11,64}{7}>
|
||||
// expected-error @+1 {{'TFHE.sub_int_glwe' op should have the same GLWE Secret Key}}
|
||||
%1 = "TFHE.sub_int_glwe"(%0, %arg0): (i8, !TFHE.glwe<sk[1]<12,1024>>) -> (!TFHE.glwe<sk[1]<11,1024>>)
|
||||
return %1: !TFHE.glwe<sk[1]<11,1024>>
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// RUN: concretecompiler --action=roundtrip %s 2>&1| FileCheck %s
|
||||
|
||||
// CHECK-LABEL: func.func @sub_int_glwe(%arg0: !TFHE.glwe<{1024,12,64}{7}>) -> !TFHE.glwe<{1024,12,64}{7}>
|
||||
func.func @sub_int_glwe(%arg0: !TFHE.glwe<{1024,12,64}{7}>) -> !TFHE.glwe<{1024,12,64}{7}> {
|
||||
// CHECK-LABEL: func.func @sub_int_glwe(%arg0: !TFHE.glwe<sk[1]<12,1024>>) -> !TFHE.glwe<sk[1]<12,1024>>
|
||||
func.func @sub_int_glwe(%arg0: !TFHE.glwe<sk[1]<12,1024>>) -> !TFHE.glwe<sk[1]<12,1024>> {
|
||||
// CHECK-NEXT: %[[V1:.*]] = arith.constant 1 : i64
|
||||
// CHECK-NEXT: %[[V2:.*]] = "TFHE.sub_int_glwe"(%[[V1]], %arg0) : (i64, !TFHE.glwe<{1024,12,64}{7}>) -> !TFHE.glwe<{1024,12,64}{7}>
|
||||
// CHECK-NEXT: return %[[V2]] : !TFHE.glwe<{1024,12,64}{7}>
|
||||
// CHECK-NEXT: %[[V2:.*]] = "TFHE.sub_int_glwe"(%[[V1]], %arg0) : (i64, !TFHE.glwe<sk[1]<12,1024>>) -> !TFHE.glwe<sk[1]<12,1024>>
|
||||
// CHECK-NEXT: return %[[V2]] : !TFHE.glwe<sk[1]<12,1024>>
|
||||
|
||||
%0 = arith.constant 1 : i64
|
||||
%1 = "TFHE.sub_int_glwe"(%0, %arg0): (i64, !TFHE.glwe<{1024,12,64}{7}>) -> (!TFHE.glwe<{1024,12,64}{7}>)
|
||||
return %1: !TFHE.glwe<{1024,12,64}{7}>
|
||||
%1 = "TFHE.sub_int_glwe"(%0, %arg0): (i64, !TFHE.glwe<sk[1]<12,1024>>) -> (!TFHE.glwe<sk[1]<12,1024>>)
|
||||
return %1: !TFHE.glwe<sk[1]<12,1024>>
|
||||
}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
// RUN: concretecompiler --action=roundtrip %s 2>&1| FileCheck %s
|
||||
|
||||
// CHECK: func.func @keyswitch_glwe(%[[A0:.*]]: !TFHE.glwe<{1,1024,64}{7}>) -> !TFHE.glwe<{1,527,64}{7}>
|
||||
func.func @keyswitch_glwe(%arg0: !TFHE.glwe<{1,1024,64}{7}>) -> !TFHE.glwe<{1,527,64}{7}> {
|
||||
// CHECK-NEXT: %[[V0:.*]] = "TFHE.keyswitch_glwe"(%[[A0]]) {baseLog = 2 : i32, level = 3 : i32} : (!TFHE.glwe<{1,1024,64}{7}>) -> !TFHE.glwe<{1,527,64}{7}>
|
||||
// CHECK-NEXT: return %[[V0]] : !TFHE.glwe<{1,527,64}{7}
|
||||
%0 = "TFHE.keyswitch_glwe"(%arg0) {baseLog = 2 : i32, level = 3 : i32} : (!TFHE.glwe<{1,1024,64}{7}>) -> !TFHE.glwe<{1,527,64}{7}>
|
||||
return %0: !TFHE.glwe<{1,527,64}{7}>
|
||||
// CHECK: func.func @keyswitch_glwe(%[[A0:.*]]: !TFHE.glwe<sk[1]<1024,1>>) -> !TFHE.glwe<sk[1]<527,1>> {
|
||||
func.func @keyswitch_glwe(%arg0: !TFHE.glwe<sk[1]<1024,1>>) -> !TFHE.glwe<sk[1]<527,1>> {
|
||||
// CHECK-NEXT: %[[V0:.*]] = "TFHE.keyswitch_glwe"(%[[A0]]) {key = #TFHE.ksk<sk[1]<1024,1>, sk[1]<527,1>, 4, 4>} : (!TFHE.glwe<sk[1]<1024,1>>) -> !TFHE.glwe<sk[1]<527,1>>
|
||||
// CHECK-NEXT: return %[[V0]] : !TFHE.glwe<sk[1]<527,1>>
|
||||
%0 = "TFHE.keyswitch_glwe"(%arg0) {key=#TFHE.ksk<sk[1]<1024,1>,sk[1]<527,1>,4,4>} : (!TFHE.glwe<sk[1]<1024,1>>) -> !TFHE.glwe<sk[1]<527,1>>
|
||||
return %0: !TFHE.glwe<sk[1]<527,1>>
|
||||
}
|
||||
|
||||
// CHECK: func.func @bootstrap_glwe(%[[GLWE:.*]]: !TFHE.glwe<{1,527,64}{7}>, %[[LUT:.*]]: tensor<128xi64>) -> !TFHE.glwe<{1,1024,64}{7}>
|
||||
func.func @bootstrap_glwe(%glwe: !TFHE.glwe<{1,527,64}{7}>, %lut: tensor<128xi64>) -> !TFHE.glwe<{1,1024,64}{7}> {
|
||||
// CHECK-NEXT: %[[V0:.*]] = "TFHE.bootstrap_glwe"(%[[GLWE]], %[[LUT]]) {baseLog = 2 : i32, glweDimension = 1 : i32, inputLweDim = 527 : i32, level = 3 : i32, polySize = 2048 : i32} : (!TFHE.glwe<{1,527,64}{7}>, tensor<128xi64>) -> !TFHE.glwe<{1,1024,64}{7}>
|
||||
// CHECK-NEXT: return %[[V0]] : !TFHE.glwe<{1,1024,64}{7}>
|
||||
%0 = "TFHE.bootstrap_glwe"(%glwe, %lut) {baseLog = 2 : i32, glweDimension = 1 : i32, inputLweDim = 527 : i32, level = 3 : i32, polySize = 2048 : i32} : (!TFHE.glwe<{1,527,64}{7}>, tensor<128xi64>) -> !TFHE.glwe<{1,1024,64}{7}>
|
||||
return %0 : !TFHE.glwe<{1,1024,64}{7}>
|
||||
// CHECK: func.func @bootstrap_glwe(%[[GLWE:.*]]: !TFHE.glwe<sk[1]<527,1>>, %[[LUT:.*]]: tensor<128xi64>) -> !TFHE.glwe<sk[1]<1024,1>> {
|
||||
func.func @bootstrap_glwe(%glwe: !TFHE.glwe<sk[1]<527,1>>, %lut: tensor<128xi64>) -> !TFHE.glwe<sk[1]<1024,1>> {
|
||||
// CHECK-NEXT: %[[V0:.*]] = "TFHE.bootstrap_glwe"(%[[GLWE]], %[[LUT]]) {key = #TFHE.bsk<sk[1]<527,1>, sk[1]<1024,1>, 512, 2, 4, 4>} : (!TFHE.glwe<sk[1]<527,1>>, tensor<128xi64>) -> !TFHE.glwe<sk[1]<1024,1>>
|
||||
// CHECK-NEXT: return %[[V0]] : !TFHE.glwe<sk[1]<1024,1>>
|
||||
%0 = "TFHE.bootstrap_glwe"(%glwe, %lut) {key=#TFHE.bsk<sk[1]<527,1>,sk[1]<1024,1>,512,2,4,4>} : (!TFHE.glwe<sk[1]<527,1>>, tensor<128xi64>) -> !TFHE.glwe<sk[1]<1024,1>>
|
||||
return %0 : !TFHE.glwe<sk[1]<1024,1>>
|
||||
}
|
||||
|
||||
|
||||
@@ -1,31 +1,31 @@
|
||||
// RUN: concretecompiler --passes tfhe-optimization --action=dump-tfhe %s 2>&1| FileCheck %s
|
||||
|
||||
|
||||
// CHECK-LABEL: func.func @mul_cleartext_lwe_ciphertext(%arg0: !TFHE.glwe<{1,527,64}{7}>, %arg1: i64) -> !TFHE.glwe<{1,527,64}{7}>
|
||||
func.func @mul_cleartext_lwe_ciphertext(%arg0: !TFHE.glwe<{1,527,64}{7}>, %arg1: i64) -> !TFHE.glwe<{1,527,64}{7}> {
|
||||
// CHECK-NEXT: %[[V1:.*]] = "TFHE.mul_glwe_int"(%arg0, %arg1) : (!TFHE.glwe<{1,527,64}{7}>, i64) -> !TFHE.glwe<{1,527,64}{7}>
|
||||
// CHECK-NEXT: return %[[V1]] : !TFHE.glwe<{1,527,64}{7}>
|
||||
// CHECK-LABEL: func.func @mul_cleartext_lwe_ciphertext(%arg0: !TFHE.glwe<sk[1]<527,1>>, %arg1: i64) -> !TFHE.glwe<sk[1]<527,1>>
|
||||
func.func @mul_cleartext_lwe_ciphertext(%arg0: !TFHE.glwe<sk[1]<527,1>>, %arg1: i64) -> !TFHE.glwe<sk[1]<527,1>> {
|
||||
// CHECK-NEXT: %[[V1:.*]] = "TFHE.mul_glwe_int"(%arg0, %arg1) : (!TFHE.glwe<sk[1]<527,1>>, i64) -> !TFHE.glwe<sk[1]<527,1>>
|
||||
// CHECK-NEXT: return %[[V1]] : !TFHE.glwe<sk[1]<527,1>>
|
||||
|
||||
%1 = "TFHE.mul_glwe_int"(%arg0, %arg1): (!TFHE.glwe<{1,527,64}{7}>, i64) -> (!TFHE.glwe<{1,527,64}{7}>)
|
||||
return %1: !TFHE.glwe<{1,527,64}{7}>
|
||||
%1 = "TFHE.mul_glwe_int"(%arg0, %arg1): (!TFHE.glwe<sk[1]<527,1>>, i64) -> (!TFHE.glwe<sk[1]<527,1>>)
|
||||
return %1: !TFHE.glwe<sk[1]<527,1>>
|
||||
}
|
||||
|
||||
// CHECK-LABEL: func.func @mul_cleartext_lwe_ciphertext_0(%arg0: !TFHE.glwe<{1,527,64}{7}>) -> !TFHE.glwe<{1,527,64}{7}>
|
||||
func.func @mul_cleartext_lwe_ciphertext_0(%arg0: !TFHE.glwe<{1,527,64}{7}>) -> !TFHE.glwe<{1,527,64}{7}> {
|
||||
// CHECK-NEXT: %[[V1:.*]] = "TFHE.zero"() : () -> !TFHE.glwe<{1,527,64}{7}>
|
||||
// CHECK-NEXT: return %[[V1]] : !TFHE.glwe<{1,527,64}{7}>
|
||||
// CHECK-LABEL: func.func @mul_cleartext_lwe_ciphertext_0(%arg0: !TFHE.glwe<sk[1]<527,1>>) -> !TFHE.glwe<sk[1]<527,1>>
|
||||
func.func @mul_cleartext_lwe_ciphertext_0(%arg0: !TFHE.glwe<sk[1]<527,1>>) -> !TFHE.glwe<sk[1]<527,1>> {
|
||||
// CHECK-NEXT: %[[V1:.*]] = "TFHE.zero"() : () -> !TFHE.glwe<sk[1]<527,1>>
|
||||
// CHECK-NEXT: return %[[V1]] : !TFHE.glwe<sk[1]<527,1>>
|
||||
|
||||
%0 = arith.constant 0 : i64
|
||||
%2 = "TFHE.mul_glwe_int"(%arg0, %0): (!TFHE.glwe<{1,527,64}{7}>, i64) -> (!TFHE.glwe<{1,527,64}{7}>)
|
||||
return %2: !TFHE.glwe<{1,527,64}{7}>
|
||||
%2 = "TFHE.mul_glwe_int"(%arg0, %0): (!TFHE.glwe<sk[1]<527,1>>, i64) -> (!TFHE.glwe<sk[1]<527,1>>)
|
||||
return %2: !TFHE.glwe<sk[1]<527,1>>
|
||||
}
|
||||
|
||||
// CHECK-LABEL: func.func @mul_cleartext_lwe_ciphertext_minus_1(%arg0: !TFHE.glwe<{1,527,64}{7}>) -> !TFHE.glwe<{1,527,64}{7}>
|
||||
func.func @mul_cleartext_lwe_ciphertext_minus_1(%arg0: !TFHE.glwe<{1,527,64}{7}>) -> !TFHE.glwe<{1,527,64}{7}> {
|
||||
// CHECK-NEXT: %[[V1:.*]] = "TFHE.neg_glwe"(%arg0) : (!TFHE.glwe<{1,527,64}{7}>) -> !TFHE.glwe<{1,527,64}{7}>
|
||||
// CHECK-NEXT: return %[[V1]] : !TFHE.glwe<{1,527,64}{7}>
|
||||
// CHECK-LABEL: func.func @mul_cleartext_lwe_ciphertext_minus_1(%arg0: !TFHE.glwe<sk[1]<527,1>>) -> !TFHE.glwe<sk[1]<527,1>>
|
||||
func.func @mul_cleartext_lwe_ciphertext_minus_1(%arg0: !TFHE.glwe<sk[1]<527,1>>) -> !TFHE.glwe<sk[1]<527,1>> {
|
||||
// CHECK-NEXT: %[[V1:.*]] = "TFHE.neg_glwe"(%arg0) : (!TFHE.glwe<sk[1]<527,1>>) -> !TFHE.glwe<sk[1]<527,1>>
|
||||
// CHECK-NEXT: return %[[V1]] : !TFHE.glwe<sk[1]<527,1>>
|
||||
|
||||
%0 = arith.constant -1 : i64
|
||||
%2 = "TFHE.mul_glwe_int"(%arg0, %0): (!TFHE.glwe<{1,527,64}{7}>, i64) -> (!TFHE.glwe<{1,527,64}{7}>)
|
||||
return %2: !TFHE.glwe<{1,527,64}{7}>
|
||||
%2 = "TFHE.mul_glwe_int"(%arg0, %0): (!TFHE.glwe<sk[1]<527,1>>, i64) -> (!TFHE.glwe<sk[1]<527,1>>)
|
||||
return %2: !TFHE.glwe<sk[1]<527,1>>
|
||||
}
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
// RUN: concretecompiler %s --action=roundtrip 2>&1| FileCheck %s
|
||||
|
||||
// CHECK-LABEL: func.func @glwe_0(%arg0: !TFHE.glwe<{1024,12,64}{7}>) -> !TFHE.glwe<{1024,12,64}{7}>
|
||||
func.func @glwe_0(%arg0: !TFHE.glwe<{1024,12,64}{7}>) -> !TFHE.glwe<{1024,12,64}{7}> {
|
||||
// CHECK-LABEL: return %arg0 : !TFHE.glwe<{1024,12,64}{7}>
|
||||
return %arg0: !TFHE.glwe<{1024,12,64}{7}>
|
||||
// CHECK-LABEL: func.func @glwe_0(%arg0: !TFHE.glwe<sk[1]<12,1024>>) -> !TFHE.glwe<sk[1]<12,1024>>
|
||||
func.func @glwe_0(%arg0: !TFHE.glwe<sk[1]<12,1024>>) -> !TFHE.glwe<sk[1]<12,1024>> {
|
||||
// CHECK-LABEL: return %arg0 : !TFHE.glwe<sk[1]<12,1024>>
|
||||
return %arg0: !TFHE.glwe<sk[1]<12,1024>>
|
||||
}
|
||||
|
||||
// CHECK-LABEL: func.func @glwe_1(%arg0: !TFHE.glwe<{_,_,_}{7}>) -> !TFHE.glwe<{_,_,_}{7}>
|
||||
func.func @glwe_1(%arg0: !TFHE.glwe<{_,_,_}{7}>) -> !TFHE.glwe<{_,_,_}{7}> {
|
||||
// CHECK-LABEL: return %arg0 : !TFHE.glwe<{_,_,_}{7}>
|
||||
return %arg0: !TFHE.glwe<{_,_,_}{7}>
|
||||
// -----
|
||||
|
||||
// CHECK-LABEL: func.func @glwe_1(%arg0: !TFHE.glwe<sk[?]>) -> !TFHE.glwe<sk[?]>
|
||||
func.func @glwe_1(%arg0: !TFHE.glwe<sk[?]>) -> !TFHE.glwe<sk[?]> {
|
||||
// CHECK-LABEL: return %arg0 : !TFHE.glwe<sk[?]>
|
||||
return %arg0: !TFHE.glwe<sk[?]>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user