[Mlir-commits] [mlir] 4e9a7c8 - [mlir][DenseStringElementsAttr] Fix AttributeElementIterator in the case of a splat.

River Riddle llvmlistbot at llvm.org
Tue May 5 12:46:45 PDT 2020


Author: River Riddle
Date: 2020-05-05T12:42:37-07:00
New Revision: 4e9a7c8f5c527e7493394ab7869f38ca7c6b8903

URL: https://github.com/llvm/llvm-project/commit/4e9a7c8f5c527e7493394ab7869f38ca7c6b8903
DIFF: https://github.com/llvm/llvm-project/commit/4e9a7c8f5c527e7493394ab7869f38ca7c6b8903.diff

LOG: [mlir][DenseStringElementsAttr] Fix AttributeElementIterator in the case of a splat.

Added: 
    

Modified: 
    mlir/lib/IR/Attributes.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/IR/Attributes.cpp b/mlir/lib/IR/Attributes.cpp
index a150fcd4d323..f47f80ca4066 100644
--- a/mlir/lib/IR/Attributes.cpp
+++ b/mlir/lib/IR/Attributes.cpp
@@ -639,8 +639,10 @@ Attribute DenseElementsAttr::AttributeElementIterator::operator*() const {
     FloatElementIterator floatIt(floatEltTy.getFloatSemantics(), intIt);
     return FloatAttr::get(eltTy, *floatIt);
   }
-  if (owner.isa<DenseStringElementsAttr>())
-    return StringAttr::get(owner.getRawStringData()[index], eltTy);
+  if (owner.isa<DenseStringElementsAttr>()) {
+    ArrayRef<StringRef> vals = owner.getRawStringData();
+    return StringAttr::get(owner.isSplat() ? vals.front() : vals[index], eltTy);
+  }
   llvm_unreachable("unexpected element type");
 }
 


        


More information about the Mlir-commits mailing list