This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Fix inconsistency with SparseElementsAttr indices type
AbandonedPublic

Authored by jfurtek on Jun 13 2022, 2:40 PM.

Details

Reviewers
rriddle
Summary

This diff fixes the inconsistency between the parameters of the
SparseElementsAttr type and the arguments to the custom builder.

The previous implementation used assert() calls in the builder to ensure
that the indices argument (of type DenseElementsAttr) had an underlying
integer type. This diff changes the builder to use the DenseIntElementsAttr
type for the argument, instead of DenseElementsAttr, making the requirement
on the argument explicit to code that creates the SparseElementsAttr
attribute.

(This was uncovered during a separate effort to add attribute/type parameter
verification, but these changes are independent.)

Diff Detail

Event Timeline

jfurtek created this revision.Jun 13 2022, 2:40 PM
Herald added a project: Restricted Project. · View Herald Transcript
jfurtek requested review of this revision.Jun 13 2022, 2:40 PM
rriddle accepted this revision.Jun 13 2022, 3:01 PM
rriddle added inline comments.
mlir/lib/Parser/AttributeParser.cpp
961

cast already asserts that it succeeds (i.e. it never returns nullptr), dyn_cast is the one that is failable.

This revision is now accepted and ready to land.Jun 13 2022, 3:01 PM
jfurtek updated this revision to Diff 436773.Jun 14 2022, 7:19 AM
  • Remove redundant assert on attribute cast<>()
jfurtek abandoned this revision.Jun 30 2022, 11:06 AM

Abandoning - these (trivial) changes have been folded in to the diff below, making this diff redundant.

https://reviews.llvm.org/D126428