This is an archive of the discontinued LLVM Phabricator instance.

[mlir][linalg] Downscale 2D pooling with unit dimensions for height to 1D pooling
ClosedPublic

Authored by vmurali on Dec 15 2022, 9:11 PM.

Diff Detail

Event Timeline

vmurali created this revision.Dec 15 2022, 9:11 PM
vmurali requested review of this revision.Dec 15 2022, 9:11 PM
rsuderman accepted this revision.Dec 16 2022, 10:58 AM

This one feels good to me but Nicolas should probably double check.

This revision is now accepted and ready to land.Dec 16 2022, 10:58 AM
hanchung added inline comments.Dec 16 2022, 2:38 PM
mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
71–77

Can we try to make it simpler? They all share same logic to me, and we don't want dup a lot of code. E.g., can we try MACRO way or are there other better ways?

I know that we use MACRO to simplify logic in ArithToSPIRV conversion: https://github.com/llvm/llvm-project/blob/27249c06b775c73b7fa9f2d8e48cac1a85169481/mlir/lib/Conversion/ArithToSPIRV/ArithToSPIRV.cpp#L845-L867

hanchung added inline comments.Dec 16 2022, 4:42 PM
mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
615–646

maybe we can simplify this using std::tuple. E.g.,

std::tie(khIndex, kwIndex, ohIndex, owIndex) = TypeSwitch<Operation *, std::tuple<int64_t, int64_t, int64_t, int64_t>(convOp)
 ...
.Case([&](linalg::PoolingNchwSumOp op) {
        return std::make_tuple(0, 1, 2, 3);
      })

and maybe plus using structured binding:

auto [khIndex, kwIndex, ohIndex, owIndex] = TypeSwitch<Operation *, std::tuple<int64_t, int64_t, int64_t, int64_t>(convOp)
...
vmurali updated this revision to Diff 483715.Dec 16 2022, 7:16 PM

Addressing Hanhan's comments

vmurali marked 2 inline comments as done.Dec 16 2022, 7:17 PM
hanchung accepted this revision.Dec 19 2022, 2:21 PM

overall looks good to me

mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
71–77

can you use one macro, not three?

This revision was landed with ongoing or failed builds.Dec 19 2022, 2:35 PM
This revision was automatically updated to reflect the committed changes.