This is an archive of the discontinued LLVM Phabricator instance.

[mlir][toy] Fix ConstantOp::parse in Ch2
AbandonedPublic

Authored by ggladilov on Mar 9 2023, 9:26 AM.

Details

Summary

parser.parseAttribute is called after parser.parseOptionalAttrDict and
by that moment attribute dictionary is already parsed, so it fails with
"error: expected attribute value".

It is not an option to leave parser.parseAttribute call only (remove
parser.parseOptionalAttrDict), because in this case it will parse
attribute dictionary as a whole, so resulting attribute would be
mlir::DictionaryAttr vs expected mlir::DenseElementsAttr deduced from
the first argument and fail with "error: custom op 'toy.constant'
invalid kind of attribute specified".

Signed-off-by: Gladilov, Gleb <gleb.gladilov@gmail.com>

Diff Detail

Event Timeline

ggladilov created this revision.Mar 9 2023, 9:26 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 9 2023, 9:26 AM
ggladilov requested review of this revision.Mar 9 2023, 9:26 AM
ggladilov updated this revision to Diff 503847.Mar 9 2023, 10:42 AM
This comment was removed by ggladilov.
ggladilov updated this revision to Diff 503849.Mar 9 2023, 10:48 AM

Get rid of FileCheck call, toy.func and CHECK as successful parsing is
enough to make sure bug is not reproducible again.

rriddle requested changes to this revision.Mar 12 2023, 11:53 PM
rriddle added inline comments.
mlir/test/Examples/Toy/Ch2/constant.mlir
3 ↗(On Diff #503849)

In which situations is IR like this being created? The custom format of toy.constant should never place the value attribute in the dictionary, it should always be handled separately. The attribute dictionary handling is there to process other, non-explicitly specified, attributes.

This revision now requires changes to proceed.Mar 12 2023, 11:53 PM
ggladilov added inline comments.Mar 14 2023, 2:15 PM
mlir/test/Examples/Toy/Ch2/constant.mlir
3 ↗(On Diff #503849)

In which situations is IR like this being created?

It was manually written by me. I was attempting to conduct roundtrip testing (to better understand print & parse logic - unfortunately it is not explained in details) when I wrote some simple Toy IR, emitted MLIR and read it back again, but MLIR I was using on the last step I, for some reason, wrote manually.

Now I retried the procedure, but using MLIR generated from reading Toy IR and see everything works as is (and does not work with my changes).

Thanks for your help reviewing, now understand a bit more ;)

ggladilov abandoned this revision.Mar 14 2023, 2:17 PM

Filed by mistake