[MLIR] Make structured op tests permutation invariant
authorGeoffrey Martin-Noble <gcmn@google.com>
Thu, 18 Feb 2021 20:56:42 +0000 (12:56 -0800)
committerGeoffrey Martin-Noble <gcmn@google.com>
Thu, 18 Feb 2021 22:36:07 +0000 (14:36 -0800)
commitb9ff67099ad6da931976e66f1510c5af2558a86e
tree9b0f8902b1b51b3f23ffd9133d115fe8cbd3eb58
parent5fbd1a333aa1a0b70903d036b98ea56c51ae5224
[MLIR] Make structured op tests permutation invariant

Extracts the relevant dimensions from the map under test to build up the
maps to test against in a permutation-invariant way.

This also includes a fix to the indexing maps used by
isColumnMajorMatmul. The maps as currently written do not describe a
column-major matmul. The linalg named op column_major_matmul has the
correct maps (and notably fails the current test).

If `C = matmul(A, B)` we want an operation that given A in column major
format and B in column major format produces C in column major format.
Given that for a matrix, faux column major is just transpose.
`column_major_matmul(transpose(A), transpose(B)) = transpose(C)`. If
`A` is `NxK` and `B` is `KxM`, then `C` is `NxM`, so `transpose(A)` is
`KxN`, `transpose(B)` is `MxK` and `transpose(C)` is `MxN`, not `NxM`
as these maps currently have.

Reviewed By: nicolasvasilache

Differential Revision: https://reviews.llvm.org/D96984
mlir/include/mlir/Dialect/Utils/StructuredOpsUtils.h
mlir/lib/Dialect/CMakeLists.txt
mlir/lib/Dialect/Utils/CMakeLists.txt [new file with mode: 0644]
mlir/lib/Dialect/Utils/StructuredOpsUtils.cpp [new file with mode: 0644]
mlir/lib/Dialect/Vector/CMakeLists.txt
mlir/unittests/Dialect/Utils/CMakeLists.txt [new file with mode: 0644]
mlir/unittests/Dialect/Utils/StructuredOpsUtilsTest.cpp [new file with mode: 0644]