[Mlir-commits] [mlir] [mlir][spirv] Enable (de)serialization of TensorARM to/from OpConstan… (PR #151485)
Jakub Kuderski
llvmlistbot at llvm.org
Fri Aug 1 04:14:59 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;
----------------
kuhar wrote:
As a side note, `llvm::TypeSwitch` would also work here but I don't think it would save us much complexity in this instance.
https://github.com/llvm/llvm-project/pull/151485
More information about the Mlir-commits
mailing list