This is an archive of the discontinued LLVM Phabricator instance.

[mlir][vector] Support multiple result types in vector.mask
ClosedPublic

Authored by springerm on Jan 13 2023, 5:44 AM.

Details

Summary

The verifier already had support for multiple result types, but the op definition assumed a single, optional result.

Diff Detail

Event Timeline

springerm created this revision.Jan 13 2023, 5:44 AM
Herald added a project: Restricted Project. · View Herald Transcript
springerm requested review of this revision.Jan 13 2023, 5:44 AM
Herald added a project: Restricted Project. · View Herald Transcript
nicolasvasilache accepted this revision.Jan 13 2023, 7:49 AM
This revision is now accepted and ready to land.Jan 13 2023, 7:49 AM
dcaballe reopened this revision.Jan 13 2023, 11:46 AM

Thanks for extending this! I would've loved to have time to review this before landing. Limiting vector.mask to single result ops was intentional. To support maskable ops with multiple results we also have to allow multiple passthru values. We have to verify that results and passthru values match both in number and type. Could you also add a test with multiple results? You can use an operation from the test dialect, I guess. That's mostly why I didn't add it in first place: I couldn't find a actual use case.

This revision is now accepted and ready to land.Jan 13 2023, 11:46 AM
springerm added a comment.EditedJan 15 2023, 3:02 AM

Thanks for extending this! I would've loved to have time to review this before landing. Limiting vector.mask to single result ops was intentional. To support maskable ops with multiple results we also have to allow multiple passthru values. We have to verify that results and passthru values match both in number and type. Could you also add a test with multiple results? You can use an operation from the test dialect, I guess. That's mostly why I didn't add it in first place: I couldn't find a actual use case.

I don't have a use case for multiple vector results. But this op should return all results of the masked operation. In particular, for bufferization purposes, we need any tensor values that are returned by the masked op.

Imagine a hypothetical vector op that reads a vector, writes a new vector to the location, then returns the original vector.

%r = vector.mask { "vector.read_update_and_write"(%v) : (tensor<?xf32>, vector<5xf32>) -> (vector<5xf32>, tensor<?xf32>) }

Now we have two return values. But only one vector result. I didn't think about the mask, passthru values when making this change. How about we limit the number of vector results to 1 for now? https://reviews.llvm.org/D141786

Yep, I couldn't find a use case or way to test it either so that's way I didn't add it. Also didn't want to deal with the multi-passthrough case. The mask should still be one for multi return cases, I hope.
Yep, it sounds good. We could support multiple results in the API and restrict to one in the verifier. In that way the API is more ergonomic. Thanks for doing this!

springerm closed this revision.Jan 18 2023, 6:55 AM