How to add new attr to all Linalg op

Now, I found that only Linalg.generic op has the “library_call” attr. so how to add a "library_call " attr to all linalg Ops, especially to linalg.pooling_ndhwc_max , linalg.pooling_ndhwc_min, linalg.pooling_ndhwc_sum and so on.

There is a pass that converts named operations, such as the pooling operations you mention, to function calls (-convert-linalg-to-std). It uses the name of the operation and mangles it with the operand types to generate the function call signature used to replace the operation.

Technically you could also annotate the named operations using custom attributes. But since they already carry all the information needed to generate a library call signature the pass approach seems favorable.

Thank you very much, “library_call” attr is just a example, I want to add another attr to all Linalg Operations, so can I add the new attr to the base op : LinalgOp? If I can,how?Thank you very much

You can add an attribute to any MLIR op. Each op has a dictionary of attributes and you can add an entry to that dictionary using setAttr. You dont need to change the definition of the op. If you want to add an attribute to the Linalg Op definition, then its a “special” attribute that is carrying some semantic information w.r.t to the op. Thats a pretty invasive change and needs to have a strong motivation.