This is an archive of the discontinued LLVM Phabricator instance.

Useful error when input dim is unused by LHS/RHS.
ClosedPublic

Authored by Benoit on Jun 30 2022, 8:57 AM.

Diff Detail

Event Timeline

Benoit created this revision.Jun 30 2022, 8:57 AM
Benoit requested review of this revision.Jun 30 2022, 8:57 AM
Benoit updated this revision to Diff 441422.Jun 30 2022, 9:00 AM

better message

Benoit added a comment.EditedJun 30 2022, 9:01 AM

Generates this message:

benoitjacob@cloud:~/mlir-build$ cmake --build . --target mlir-opt && bin/mlir-opt /tmp/x.mlir
[6/6] Linking CXX executable bin/mlir-opt
/tmp/x.mlir:2:13: error: 'vector.contract' op expected all input dimensions to be used by either the LHS or the RHS.
  %result = vector.contract {
            ^
/tmp/x.mlir:2:13: note: see current operation: %0 = "vector.contract"(%arg0, %arg1, %arg2) {indexing_maps = [affine_map<(d0, d1, d2) -> (d0, d2)>, affine_map<(d0, d1, d2) -> (d2)>, affine_map<(d0, d1, d2) -> (d1)>], iterator_types = ["reduction", "parallel", "reduction"], kind = #vector.kind<add>} : (vector<1x2xi32>, vector<2xi32>, vector<1xi32>) -> vector<1xi32>

On this testcase:

benoitjacob@cloud:~/mlir-build$ cat /tmp/x.mlir
func.func @bad_broadcast(%arg0 : vector<1x2xi32>, %arg1 : vector<2xi32>, %arg2 : vector<1xi32>) -> vector<1xi32> {
  %result = vector.contract {
    indexing_maps = [
      affine_map<(d0, d1, d2) -> (d0, d2)>,
      affine_map<(d0, d1, d2) -> (d2)>,
      affine_map<(d0, d1, d2) -> (d1)>
    ],
    iterator_types = ["reduction", "parallel", "reduction"],
    kind = #vector.kind<add>} %arg0, %arg1, %arg2 : vector<1x2xi32>, vector<2xi32> into vector<1xi32>
  return  %result : vector<1xi32>
}
jpienaar added inline comments.
mlir/lib/Dialect/Vector/IR/VectorOps.cpp
702

Convention for error message are sentence fragments (no capitalization at start and no punctuation at end), https://llvm.org/docs/CodingStandards.html#error-and-warning-messages

Is it helpful to say which input dimension are unused?

nicolasvasilache accepted this revision.Jun 30 2022, 9:02 AM

thanks! please also add a test to invalid.mlir to test we report this.

This revision is now accepted and ready to land.Jun 30 2022, 9:02 AM
Benoit updated this revision to Diff 441430.Jun 30 2022, 9:10 AM

review comments, test, lint

Benoit added inline comments.Jun 30 2022, 9:11 AM
mlir/lib/Dialect/Vector/IR/VectorOps.cpp
702

The unused input dimension is plain to see in the op dump which follows this error message, see example in this review's comment thread.

ThomasRaoux accepted this revision.Jun 30 2022, 9:15 AM
This revision was landed with ongoing or failed builds.Jun 30 2022, 10:46 AM
This revision was automatically updated to reflect the committed changes.