This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Vector] Add folding of vector transfers from/into tensor producing ops.
ClosedPublic

Authored by nicolasvasilache on Mar 4 2021, 4:53 AM.

Details

Summary

Add a folder to rewrite a sequence such as:

%v = vector.transfer_read %t0[%c0...], {masked = [false...]} :
  tensor<static_sizesxf32>, vector<static_sizesxf32>
%t1 = side_effect_free_tensor_producing_op : tensor<static_sizesxf32>
%t2 = vector.transfer_write %v, %t1[%c0...] {masked = [false...]} :
  vector<static_sizesxf32>, tensor<static_sizesxf32>

into just t0.

Diff Detail

Event Timeline

nicolasvasilache requested review of this revision.Mar 4 2021, 4:53 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 4 2021, 4:53 AM
ftynse added inline comments.Mar 4 2021, 5:20 AM
mlir/lib/Dialect/Vector/VectorOps.cpp
2609

Just drop the argument if it is not used

2618–2620

the doc says the producer is side-effect-free, but there's no check for this

mlir/lib/Dialect/Vector/VectorOps.cpp
2618–2620

Is there a way to make a custom op that does not have side effects ?
The issue I have right now is that I don't want a cyclic dependence on tensor ops and I would prefer to not create a special interface for this immediately.

ftynse added inline comments.Mar 4 2021, 5:33 AM
mlir/lib/Dialect/Vector/VectorOps.cpp
2618–2620

If by "custom" you mean unregistered, then no. But you can put an op in the test dialect (or maybe there's already one).

mlir/lib/Dialect/Vector/VectorOps.cpp
2618–2620

Thanks! Actually @gysit remarked offline that side effects are orthogonal here.
So is the fact that init is coming from an op at all..

Address review.

ftynse accepted this revision.Mar 4 2021, 6:16 AM
This revision is now accepted and ready to land.Mar 4 2021, 6:16 AM
This revision was landed with ongoing or failed builds.Mar 4 2021, 6:22 AM
This revision was automatically updated to reflect the committed changes.