While working on ⚙ D109418 [mlir][MemRef] Compute unused dimensions of a rank-reducing subviews using strides as well., I found a use case for having a way to cache some information that might be needed from the op, but would be expensive to compute using the operation operands/attributes. It would be very useful to have a way to compute that information once and store it on the op using an attribute.
One issues there is that adding this as an attribute that is part of the
ins list in the Ops ODS definition would result in this attribute being part of build methods of the operation. That is better avoided since this information can be computed from existing operands/attributes.
Another issue is that these attributes should not be parsed/printed. They are essentially “hidden” attributes that are just caching information. I am mostly thinking of the
assemblyFormat route of parser/printers where we can have an interface for operations that allow operations to specify a list of such attributes which the parser/printer generator can pick up.
There are a few options I have preliminarily looked at. Would like to first get an idea of
- Is this a good idea
- Some suggestions about how to go about implementing this.