[MLIR] Ensuring NamedAttributes propagate through pass pipeline

Hi all,

In the first custom pass of my project, I am adding a NamedAttribute attribute to each constant operation. If I run my compiler with --print-ir-after-all, it shows that this attribute disappears in the second and subsequent passes. Is there a way to ensure that this attribute is respected and passed down by my custom passes? Or do I have to manually propagate this attribute through myself?

Thanks

In general, no.

These attributes are called discardable for a reason: passes are free to discard them at any time. If you control the pass pipeline, you can ensure that the passes you run preserve the attributes that you want.

Arbitrary attribute propagation is a known and very hard problem. There have been several attempts at tackling it, but no satisfiable solution. The version you have sounds very simple. The general case is not: what happens when an op with an attribute is replaced by several ops? some of which don’t allow for the attribute? the op is erased or “fused” with other ops? the pass is written in a way that makes op-to-op mapping impractical or impossible?

2 Likes