This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Vector] Add a masked vectorization of tensor.pad
ClosedPublic

Authored by nicolasvasilache on Apr 13 2023, 11:14 AM.

Details

Summary

This revision takes advantage of masking support to introduce a vectorized
version of pad that does not require lowering to lower-level form.

Lowering to lower-level form (if/else + generate + fill + copy + insert_slice)
creates unnecessary complexity that can be completely sidestepped by using
masked vectorization properly.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald Transcript
nicolasvasilache requested review of this revision.Apr 13 2023, 11:14 AM
ThomasRaoux accepted this revision.Apr 13 2023, 1:16 PM
ThomasRaoux added inline comments.
mlir/test/Dialect/Linalg/vectorization.mlir
2761

nit: extra line

This revision is now accepted and ready to land.Apr 13 2023, 1:16 PM
This revision was landed with ongoing or failed builds.Apr 13 2023, 1:20 PM
This revision was automatically updated to reflect the committed changes.

Just happened to stumble upon this. I dont see why this is in Linalg dialect. Everything here seems related to tensor dialect....

Just happened to stumble upon this. I dont see why this is in Linalg dialect. Everything here seems related to tensor dialect....

After studying more codes, I think there is a reason to put it here. There is a struct about vectorization state and a method to retrieve an existing mask value. Today, it will always create a new mask. I wonder if we can extend the maskedVectorize to retrieve an existing mask value using VectorizationState. Is it on anyone's TODO list?

I missed this patch as well.

Just happened to stumble upon this. I dont see why this is in Linalg dialect. Everything here seems related to tensor dialect....

I guess because it's supposed to eventually integrate with the main vectorization path. Tensor and Linalg are really close so I'm not surprised about it. Actually, if there is no way to represent a tensor.pad using linalg.generic, it would be great if we could have a linalg.pad that implements the LinalgOp interface. That would simplify integration a lot.

After studying more codes, I think there is a reason to put it here. There is a struct about vectorization state and a method to retrieve an existing mask value. Today, it will always create a new mask. I wonder if we can extend the maskedVectorize to retrieve an existing mask value using VectorizationState. Is it on anyone's TODO list?

Yep, that's what I mean when talking about making tensor.pad go through the main vectorization path. Most of the code in maskedVectorize is duplicated/ad-hoc. I think a first step would be to unify maskedVectorize and vectorize into a single public API that can handle an Operation *, even if this public interface just dispatches to the existing maskedVectorize and vectorize initially. Then we can think about how to move tensor.pad support into the main vectorization path that uses the vectorization state, etc. This is not in my TODO list but in my wish list :). It would be great if you take a stab at it!