[Mlir-commits] [mlir] [mlir] NamedAttribute utility generator (PR #75118)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Tue Dec 12 14:36:00 PST 2023


sjw36 wrote:

Thanks for the feedback @joker-eph . 

In short, it is a wrapper that is does 2 things:
1. Named lookup on objects depending on inherentness and Value Type
2. Get/Set the Typed Value for consistency 

> 1. In terms of performance, we'd want to use StringAttr as much as possible to avoid string hashing and string comparisons everywhere. But I don't think you're achieving this right now?

No, that is true but most usages are StringLiteral except when copying from a NamedAttribute. It is complicated since it is context dependent. Do you have any suggestion?

> 2. In terms of correctness, there is the question of inherent vs discardable attributes. However this is an individual property of each operation, and the way you try to "infer" this does not seem right to me: if I have a dialect `NamedAttribute` that I intend to be `mydialect.foo`, I shouldn't lookup the inherent attribute of an operation to see if `foo` is a valid key before preprinting the `mydialect.` prefix: they are two different things!

Perhaps that is a bridge too far. We have scenarios where an inherent attribute on an op is copied to the enclosing func or module and should then be dialect-qualified. I could live with a DialectNamedAttrDef and an NamedAttrDef (unqualified).

https://github.com/llvm/llvm-project/pull/75118


More information about the Mlir-commits mailing list