This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Linalg] Add pooling_nchw_sum op.
ClosedPublic

Authored by vivekkhandelwal1 on Apr 4 2022, 12:43 AM.

Details

Summary

This commit adds pooling_nchw_sum as a yaml op.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptApr 4 2022, 12:43 AM
vivekkhandelwal1 requested review of this revision.Apr 4 2022, 12:43 AM
cathyzhyi requested changes to this revision.Apr 4 2022, 12:29 PM
cathyzhyi added a subscriber: cathyzhyi.
cathyzhyi added inline comments.
mlir/python/mlir/dialects/linalg/opdsl/ops/core_named_ops.py
546

Can you add comments for layout similarly to the conv ops here https://github.com/llvm/llvm-project/blob/8361c5da30588d3d4a48eae648f53be1feb5cfad/mlir/python/mlir/dialects/linalg/opdsl/ops/core_named_ops.py#L333-L335? Also, for the existing pooling_nhwc_sum op

This revision now requires changes to proceed.Apr 4 2022, 12:29 PM

add layout comments

cathyzhyi requested changes to this revision.Apr 5 2022, 7:43 AM
cathyzhyi added inline comments.
mlir/include/mlir/Dialect/Linalg/IR/LinalgNamedStructuredOps.yaml
2269

I think the yaml file need to be updated after the change in doc.

This revision now requires changes to proceed.Apr 5 2022, 7:43 AM
vivekkhandelwal1 marked an inline comment as done.

fix yaml file comment

cathyzhyi accepted this revision.Apr 7 2022, 8:28 AM

LGTM. Thanks for the patch!
@gysit Could you help to double check?

This revision is now accepted and ready to land.Apr 7 2022, 8:28 AM
gysit accepted this revision.Apr 7 2022, 9:00 AM

LGTM!

There is also the option to make the reduction function / casting function used configurable to have one pooling operation that does max, min, and sum pooling. We have an example in the tests:

https://github.com/llvm/llvm-project/blob/09c2b7c35af8c4bad39f03e9f60df8bd07323028/mlir/test/python/dialects/linalg/opdsl/emit_pooling.py#L15

This is not relevant for this revision since none of the operations are using this! Just wanted to advertise the feature :).

This revision was automatically updated to reflect the committed changes.