This is an archive of the discontinued LLVM Phabricator instance.

[mlir][linalg][transform][python] Improve mix-in for PadOp.
ClosedPublic

Authored by ingomueller-net on Aug 12 2023, 10:12 AM.

Details

Summary

In particular:

  • Fix and extend the support for constructing possibly nested ArrayAttrs from lists of Python ints. This can probably be generalized further and used in many more places.
  • Add arguments for pad_to_multiple_of and copy_back_op.
  • Format with black and reorder (keyword-only) arguments to match tablegen and (*_gen.py) order.
  • Extend tests for new features.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptAug 12 2023, 10:12 AM
ingomueller-net requested review of this revision.Aug 12 2023, 10:12 AM
  • Fix unit test.
springerm added inline comments.Aug 14 2023, 12:51 AM
mlir/python/mlir/dialects/_structured_transform_ops_ext.py
113

why is this needed?

130–131

What happens if values does not contain integers but other Attributes?

mlir/python/mlir/dialects/_structured_transform_ops_ext.py
113

It may not be in this context. The attribute builders probably allow for lists that contain attributes, so I might be able to just forward those. However, I found that it is easier to understand to convert first everything to Python and then to MLIR attributes, plus the conversion to Python may be of independent use. What do you think?

130–131

This should work for values that contain any instance of TypedAttribute, i.e., with a value property. For other attributes, the function fails; and for non-integer TypedAttributes, the op constructor will fail. So if I am not mistaken, this doesn't change *whether or not* any possible input fails; it only changes *where* the failure occurs for some of them.

I don't know what the best strategy here is: add an additional test and an explicit exception here or rely on lower levels to fail?

springerm accepted this revision.Aug 21 2023, 5:49 AM
This revision is now accepted and ready to land.Aug 21 2023, 5:49 AM