This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Reintroduce API for creating operations with a DictionaryAttr
ClosedPublic

Authored by Mogball on Feb 16 2023, 10:45 AM.

Details

Summary

This patch reintroduces an API to create operations with a pre-existing
DictionaryAttr. This API does not populate the attributes with any
default attributes the operation may have, like the API that takes a
NamedAttrList does. NamedAttrList is effective at not re-hashing the
attributes if no default attributes were added, but this new API speeds
up clone-heavy workloads slightly (~5%).

Diff Detail

Event Timeline

Mogball created this revision.Feb 16 2023, 10:45 AM
Mogball requested review of this revision.Feb 16 2023, 10:45 AM
rriddle accepted this revision.Feb 16 2023, 3:06 PM
This revision is now accepted and ready to land.Feb 16 2023, 3:06 PM
mehdi_amini added inline comments.Feb 26 2023, 7:52 AM
mlir/include/mlir/IR/Operation.h
86

I'm a bit concerned about the discrepancy of behavior between the two APIs with respect to default attributes. We have now two method with the same name, differing only by taking a NamedAttrList vs a DictionaryAttr, but with a subtle difference that isn't well conveyed in the API.

I don't believe it is common in the code base that we use NamedAttrList vs a DictionaryAttr to signal semantics difference, do we?

Mogball added inline comments.Mar 8 2023, 11:56 PM
mlir/include/mlir/IR/Operation.h
86

I don't believe it is common in the code base that we use NamedAttrList vs a DictionaryAttr to signal semantics difference, do we?

It isn't. Would it be better to rename the methods? createWithDefaultAttrs for the former?