Page MenuHomePhabricator

[mlir][Standard] Allow select to use an i1 for vector and tensor values
ClosedPublic

Authored by rriddle on Apr 22 2020, 8:15 PM.

Details

Summary

It currently requires that the condition match the shape of the selected value, but this is only really useful for things like masks. This revision allows for the use of i1 to mean that all of the vector/tensor is selected. This also matches the behavior of LLVM select. A benefit of this change is that transformations that want to generate selects, like those on the CFG, don't have to special case vector/tensor. Previously the only way to generate a select from an i1 was to use a splat, but that doesn't support dynamically shaped/unranked tensors.

Depends On D78683

Diff Detail

Event Timeline

rriddle created this revision.Apr 22 2020, 8:15 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 22 2020, 8:15 PM
rriddle updated this revision to Diff 259464.Apr 22 2020, 8:20 PM

Remove unnecessary test

benvanik accepted this revision.Apr 22 2020, 8:23 PM
This revision is now accepted and ready to land.Apr 22 2020, 8:23 PM
mehdi_amini added inline comments.Apr 22 2020, 8:28 PM
mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
1940

I would expect that you don't need the i1 here right? Or I misunderstand why you don't need the i1 in the "full vector selection" case below.

1946

It almost seems like an entirely different operation to me compared to the simple selection of one input or the other. Should we have a vselect or something?

rriddle updated this revision to Diff 259467.Apr 22 2020, 8:47 PM
rriddle marked 4 inline comments as done.

Resolve comments

mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
1940

Yep, thanks. Forgot to change this.

1946

vselect sounds weird given that it also supports tensors, but I agree that the semantics are kind of different. The optional predication is the only thing that removes this from solely being a "simple" select.

This revision was automatically updated to reflect the committed changes.
mehdi_amini added inline comments.Apr 23 2020, 10:23 PM
mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
1946

Do you plan to followup on looking into splitting this in two different ops?

silvas added a subscriber: silvas.Apr 27 2020, 8:33 PM
silvas added inline comments.
mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
1946

+1. maybe select_value for the one that is not describable as a pure elementwise vector/tensor op?