<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/55185>55185</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [IR Core] DenseElementsAttr::getFromRawBuffer doesn't work with 0D tensors
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            mlir:core
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          lattner
      </td>
    </tr>
</table>

<pre>
    DenseElementsAttr::getFromRawBuffer crashes with a zero-d tensor (which has a single element) when the `isSplatBuffer` argument is false.  I get a stack trace like this:

```
Assertion failed: (numElements != 1 && "splat of 1 element should already be detected"), function getKey, file AttributeDetail.h, line 114.
$ bt
* thread #1, queue = 'com.apple.main-thread', stop reason = hit program assert
    frame #0: 0x000000019a8d8db8 libsystem_kernel.dylib`__pthread_kill + 8
    frame #1: 0x000000019a90dee0 libsystem_pthread.dylib`pthread_kill + 288
    frame #2: 0x000000019a848340 libsystem_c.dylib`abort + 168
    frame #3: 0x000000019a847754 libsystem_c.dylib`__assert_rtn + 272
  * frame #4: 0x000000010030b860 translate`mlir::detail::DenseIntOrFPElementsAttrStorage::getKey(mlir::ShapedType, llvm::ArrayRef<char>, bool) (.cold.1) + 40
    frame #5: 0x000000010010f168 translate`mlir::detail::DenseIntOrFPElementsAttrStorage::getKey(mlir::ShapedType, llvm::ArrayRef<char>, bool) + 596
    frame #6: 0x000000010010ee10 translate`mlir::detail::DenseIntOrFPElementsAttrStorage* mlir::StorageUniquer::get<mlir::detail::DenseIntOrFPElementsAttrStorage, mlir::ShapedType&, llvm::ArrayRef<char>&, bool&>(llvm::function_ref<void (mlir::detail::DenseIntOrFPElementsAttrStorage*)>, mlir::TypeID, mlir::ShapedType&, llvm::ArrayRef<char>&, bool&) + 56
    frame #7: 0x000000010010eccc translate`std::__1::enable_if<!(std::is_same<mlir::DenseIntOrFPElementsAttr::ImplType, mlir::AttributeStorage>::value), mlir::DenseIntOrFPElementsAttr>::type mlir::detail::AttributeUniquer::get<mlir::DenseIntOrFPElementsAttr, mlir::ShapedType&, llvm::ArrayRef<char>&, bool&>(mlir::MLIRContext*, mlir::ShapedType&, llvm::ArrayRef<char>&, bool&) + 108
    frame #8: 0x00000001000f0600 tfl-translate`mlir::DenseIntOrFPElementsAttr::getRaw(mlir::ShapedType, llvm::ArrayRef<char>, bool) + 256
```

I don't know what the assertion is trying to do, I think it can just be removed?

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzNVttu4zYQ_Rr5ZRCDoi1ZfvBDEieA0RYtkvZZoMSRxTUluiQVr_v1HUq-5KLdLhZ5qCFYIjk6c-ZC6hRGHldrbB0-aGyw9e7WexvNbunaon-0pnkSh7uuqtBCaYWr0cFB-RoE_IPW3Ejw9LaxEPHsUKuyhlo4WnSq3WoEHFAjvoRDjS34GiFKmXLPey38gEtjEHbbBUNQDiqhHU4BNkAMApQX5Q68FSWCVjskEOUCRbaO2Pk_ZaerH946h9Yr0xKY0ijJOhBsu-YcJg3jaLaGmB5SuujGXeAEpqLJE29wtem0BKEtCnmEAkGix9ITJOcUVcTvoerasvdFdH_BYz9FTiFkUhWdxzV6YjGtw4pWLUIcz6cn3nwOhT8_31JowRGRmcXB-u8OO0oY8Yz4ojTNVOz3GqeNUO3NYErzwdB5swcaO6IRzGvlYW_N1ooGRJ-MwQfQr6JJDC5YSAv7yoZfvBSZzGSREcfCHZ3HJt-hbVFP5ZGmKLl5vh-85julNUHcQTaCG7_HXTKJyF7hnmAuwB9geTYGzD8Qnmez-Wvg8gIpCmN9jxWnY1izj1iLRTIfxcrzIYe59e1Ab8HPkKFqF9D5W1DGZqzIqL2peVtHzYUE1mh12mCy74vhud-Dm9b_bh__eL0Vn72xYouXHdk3WHbFeK7FHuWfxz323aVfmmH-1lpxfMIqmt2XtSDjh7BeGKPDXiSIaWm0nMbD6A7mbCRHyftwYlZRNv-H4dxBsk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