[Mlir-commits] [mlir] [mlir][spirv] Enable (de)serialization of TensorARM to/from OpConstan… (PR #151485)

Mohammadreza Ameri Mahabadian llvmlistbot at llvm.org
Fri Aug 1 04:48:27 PDT 2025


================
@@ -69,6 +69,25 @@ static Block *getPhiIncomingBlock(Block *block) {
   return block;
 }
 
+static bool isZeroValue(Attribute attr) {
+  if (auto floatAttr = dyn_cast<FloatAttr>(attr)) {
+    return floatAttr.getValue().isZero();
+  }
+  if (auto boolAttr = dyn_cast<BoolAttr>(attr)) {
+    return !boolAttr.getValue();
+  }
+  if (auto intAttr = dyn_cast<IntegerAttr>(attr)) {
+    return intAttr.getValue().isZero();
+  }
+  if (auto splatElemAttr = dyn_cast<SplatElementsAttr>(attr)) {
+    return isZeroValue(splatElemAttr.getSplatValue<Attribute>());
+  }
+  if (auto denseElemAttr = dyn_cast<DenseElementsAttr>(attr)) {
+    return all_of(denseElemAttr.getValues<Attribute>(), isZeroValue);
+  }
+  return false;
----------------
mahabadm wrote:

Good learning, thanks for your note.

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


More information about the Mlir-commits mailing list