This is an archive of the discontinued LLVM Phabricator instance.

[mlir][vector] Fix illegal vector.transfer + tensor.insert/extract_slice folding
ClosedPublic

Authored by nicolasvasilache on Dec 30 2021, 5:24 AM.

Details

Summary

vector.transfer operations do not have rank-reducing semantics.

Bail on illegal rank-reduction: we need to check that the rank-reduced
dims are exactly the leading dims. I.e. the following is illegal:

%0 = vector.transfer_write %v, %t[0,0], %cst :
  vector<2x4xf32>, tensor<2x4xf32>
%1 = tensor.insert_slice %0 into %tt[0,0,0][2,1,4][1,1,1] :
  tensor<2x4xf32> into tensor<2x1x4xf32>

Cannot fold into:

%0 = vector.transfer_write %v, %t[0,0,0], %cst :
  vector<2x4xf32>, tensor<2x1x4xf32>

For this, check the trailing vectorRank dims of the insert_slice result
tensor match the trailing dims of the inferred result tensor.

Diff Detail