[Mlir-commits] [mlir] [polynomial] Move primitive root attribute to ntt/intt ops. (PR #93227)

Oleksandr Alex Zinenko llvmlistbot at llvm.org
Thu May 30 06:50:09 PDT 2024


================
@@ -157,33 +159,30 @@ static LogicalResult verifyNTTOp(Operation *op, RingAttr ring,
     return diag;
   }
 
-  if (!ring.getPrimitiveRoot()) {
-    return op->emitOpError()
-           << "ring type " << ring << " does not provide a primitive root "
-           << "of unity, which is required to express an NTT";
-  }
-
-  if (!isPrimitiveNthRootOfUnity(ring.getPrimitiveRoot().getValue(), polyDegree,
-                                 ring.getCoefficientModulus().getValue())) {
-    return op->emitOpError()
-           << "ring type " << ring << " has a primitiveRoot attribute '"
-           << ring.getPrimitiveRoot()
-           << "' that is not a primitive root of the coefficient ring";
+  if (root.has_value()) {
+    APInt rootValue = root.value().getValue().getValue();
+    APInt rootDegree = root.value().getDegree().getValue();
+    APInt cmod = ring.getCoefficientModulus().getValue();
+    if (!isPrimitiveNthRootOfUnity(rootValue, rootDegree, cmod)) {
----------------
ftynse wrote:

It is indeed questionable, I usually lean towards having braces for multi-line bodies even if there is a single statement.

https://github.com/llvm/llvm-project/pull/93227


More information about the Mlir-commits mailing list