[Mlir-commits] [mlir] Upstream polynomial.ntt and polynomial.intt (PR #90992)
Jeremy Kun
llvmlistbot at llvm.org
Sat May 4 18:11:27 PDT 2024
================
@@ -104,3 +104,80 @@ LogicalResult MulScalarOp::verify() {
return success();
}
+
+// Test if a value is a primitive nth root of unity modulo cmod
+bool isPrimitiveNthRootOfUnity(const APInt &root, const unsigned n,
+ const APInt &cmod) {
+ // root bitwidth may be 1 less then cmod
+ APInt r = APInt(root).zext(cmod.getBitWidth());
+ assert(r.ule(cmod) && "root must be less than cmod");
+
+ APInt a = r;
+ for (size_t k = 1; k < n; k++) {
+ if (a.isOne())
+ return false;
+ a = (a * r).urem(cmod);
+ }
+ return a.isOne();
+}
+
+static LogicalResult verifyNTTOp(Operation *op, RingAttr ring,
+ RankedTensorType tensorType) {
+ auto encoding = tensorType.getEncoding();
----------------
j2kun wrote:
Fixed in e0a06ba2aef
https://github.com/llvm/llvm-project/pull/90992
More information about the Mlir-commits
mailing list