This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Linalg] Generalize the definition of a Linalg contraction.
ClosedPublic

Authored by nicolasvasilache on Feb 3 2021, 4:51 AM.

Details

Summary

This revision defines a Linalg contraction in general terms:

  1. Has 2 input and 1 output shapes.
  2. Has at least one reduction dimension.
  3. Has only projected permutation indexing maps.
  4. its body computes u5(u1(c) + u2(u3(a) * u4(b))) on some field (AddOpType, MulOpType), where u1, u2, u3, u4 and u5 represent scalar unary operations that may change the type (e.g. for mixed-precision).

As a consequence, when vectorization of such an op occurs, the only special
behavior is that the (unique) MulOpType is vectorized into a
vector.contract. All other ops are handled in a generic fashion.

In the future, we may wish to allow more input arguments and elementwise and
constant operations that do not involve the reduction dimension(s).

A test is added to demonstrate the proper vectorization of matmul_i8_i8_i32.

Diff Detail

Event Timeline

nicolasvasilache requested review of this revision.Feb 3 2021, 4:51 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 3 2021, 4:51 AM
bkramer accepted this revision.Feb 3 2021, 6:50 AM
bkramer added inline comments.
mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp
46

Nit: I'd use while (v != form) here instead of the infinite loop and early exit.

428

boundary is not a verb.

This revision is now accepted and ready to land.Feb 3 2021, 6:50 AM

Address review.

Fix missing brace.

Drop spurious semicolumn.

This revision was landed with ongoing or failed builds.Feb 3 2021, 11:55 PM
This revision was automatically updated to reflect the committed changes.