This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Change DenseArrayAttr to TensorType
ClosedPublic

Authored by Mogball on Aug 1 2022, 11:23 AM.

Details

Summary

Previously, DenseArrayAttr used VectorType for its shaped type.
VectorType is problematic for arrays because it doesn't support zero
dimensions, meaning that an empty array would have vector<i32> as its
type. ElementsAttr would think that an empty dense array is size 1, not
0. This patch switches over to TensorType, which does support zero
dimensions.

Fixes #56860

Diff Detail

Event Timeline

Mogball created this revision.Aug 1 2022, 11:23 AM
Herald added a project: Restricted Project. · View Herald Transcript
Mogball requested review of this revision.Aug 1 2022, 11:23 AM
Mogball edited the summary of this revision. (Show Details)Aug 1 2022, 11:23 AM
mehdi_amini accepted this revision.Aug 1 2022, 11:47 AM
This revision is now accepted and ready to land.Aug 1 2022, 11:47 AM
This revision was landed with ongoing or failed builds.Aug 1 2022, 7:17 PM
This revision was automatically updated to reflect the committed changes.
lattner added a subscriber: lattner.Aug 7 2022, 6:21 PM

Out of curiosity, why does DenseArrayAttr conform to ShapedType? That seems really specific to multidimensional things, why not just have an array-like getSize() interface like ArrayAttr?

It's required by ElementsAttr interface. Whether DenseArrayAttr needs to conform to that interface is up for discussion, but it does provide a lot of the machinery for querying the underlying values.

It's required by ElementsAttr interface. Whether DenseArrayAttr needs to conform to that interface is up for discussion, but it does provide a lot of the machinery for querying the underlying values.

Got it, thanks!