This is an archive of the discontinued LLVM Phabricator instance.

[mlir][linalg] Refine `tensor.extract` vectorisation
AbandonedPublic

Authored by awarzynski on Apr 13 2023, 12:54 PM.

Details

Summary

Prevent vectoristation of N-D tensor.extract when one of the indices
is calculated based on another tensor.extract Op from same
linalg.generic Op.

The test case is based on https://github.com/openxla/iree/issues/13036.

Diff Detail

Event Timeline

awarzynski created this revision.Apr 13 2023, 12:54 PM
Herald added a project: Restricted Project. · View Herald Transcript
awarzynski requested review of this revision.Apr 13 2023, 12:54 PM
dcaballe added inline comments.Apr 13 2023, 3:56 PM
mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp
780

Not sure I follow this check/comment. we'd have to analyse its indices to be certain. it which sense? Isn't the code right after this one doing so? Perhaps you want to move this to isContiguousLoadIdx?

To be more specific, if an extract op is part of the address computation of any memory access, the access would be contiguous if the extract op is loop invariant/uniform to the vectorized dimensions. Otherwise, we would have an indirect access, (e.g., a[f(b[i])], where i` is the vectorized dimension), that should lead to a gather.

awarzynski added inline comments.Apr 17 2023, 8:43 AM
mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp
780

Isn't the code right after this one doing so?

That's exactly what the code below does, yes :) Thanks, great catch! It's a lesson for me not to debug code past bed time :(

This fix is just incorrect. Let me close this PR and upload an actual fix.