[Mlir-commits] [mlir] d9a2f89 - [mlir][sparse] Adjusting error message wording, to better match new field names

wren romano llvmlistbot at llvm.org
Thu May 18 15:02:16 PDT 2023


Author: wren romano
Date: 2023-05-18T15:02:08-07:00
New Revision: d9a2f89beeaea67f7906795b5be2d3de80dc9e3c

URL: https://github.com/llvm/llvm-project/commit/d9a2f89beeaea67f7906795b5be2d3de80dc9e3c
DIFF: https://github.com/llvm/llvm-project/commit/d9a2f89beeaea67f7906795b5be2d3de80dc9e3c.diff

LOG: [mlir][sparse] Adjusting error message wording, to better match new field names

This is a followup to D150330, split out because it's not purely mechanical.

Depends On D150330

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D150409

Added: 
    

Modified: 
    mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp
    mlir/test/Dialect/SparseTensor/invalid_encoding.mlir

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp b/mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp
index f8e7e2df3a95d..93845f17a77d8 100644
--- a/mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp
+++ b/mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp
@@ -394,16 +394,15 @@ Attribute SparseTensorEncodingAttr::parse(AsmParser &parser, Type type) {
       Attribute attr;
       RETURN_ON_FAIL(parser.parseAttribute(attr));
       auto arrayAttr = llvm::dyn_cast<ArrayAttr>(attr);
-      ERROR_IF(!arrayAttr, "expected an array for dimension level types")
+      ERROR_IF(!arrayAttr, "expected an array for lvlTypes")
       for (auto i : arrayAttr) {
         auto strAttr = llvm::dyn_cast<StringAttr>(i);
-        ERROR_IF(!strAttr, "expected a string value in dimension level types")
+        ERROR_IF(!strAttr, "expected a string value in lvlTypes")
         auto strVal = strAttr.getValue();
         if (auto optDLT = parseDLT(strVal)) {
           lvlTypes.push_back(optDLT.value());
         } else {
-          parser.emitError(parser.getNameLoc(),
-                           "unexpected dimension level type: ")
+          parser.emitError(parser.getNameLoc(), "unexpected level-type: ")
               << strVal;
           return {};
         }
@@ -512,14 +511,14 @@ LogicalResult SparseTensorEncodingAttr::verify(
   // use that same source-of-truth here.
   const Level lvlRank = lvlTypes.size();
   if (lvlRank == 0)
-    return emitError() << "expected a non-empty array for level types";
+    return emitError() << "expected a non-empty array for lvlTypes";
   if (dimOrdering) {
     if (!dimOrdering.isPermutation())
       return emitError()
              << "expected a permutation affine map for dimension ordering";
     if (dimOrdering.getNumResults() != lvlRank)
-      return emitError() << "unexpected mismatch in ordering and dimension "
-                            "level types size";
+      return emitError()
+             << "level-rank mismatch between dimOrdering and lvlTypes";
   }
   if (higherOrdering) {
     if (higherOrdering.getNumDims() >= higherOrdering.getNumResults())
@@ -527,12 +526,11 @@ LogicalResult SparseTensorEncodingAttr::verify(
                          << higherOrdering.getNumDims() << " to "
                          << higherOrdering.getNumResults();
     if (higherOrdering.getNumResults() != lvlRank)
-      return emitError() << "unexpected mismatch in higher ordering and "
-                            "dimension level types size";
+      return emitError()
+             << "level-rank mismatch between higherOrdering and lvlTypes";
   }
   if (!dimSlices.empty() && dimSlices.size() != lvlRank) {
-    return emitError() << "unexpected mismatch in dimension slices and "
-                          "dimension level type size";
+    return emitError() << "level-rank mismatch between dimSlices and lvlTypes";
   }
   return success();
 }
@@ -563,7 +561,7 @@ LogicalResult SparseTensorEncodingAttr::verifyEncoding(
     // TODO: verification of higher ordering contents
   } else if (dimRank != getLvlRank()) {
     return emitError() << "expected an array of size " << dimRank
-                       << " for dimension level types";
+                       << " for lvlTypes";
   }
   return success();
 }

diff  --git a/mlir/test/Dialect/SparseTensor/invalid_encoding.mlir b/mlir/test/Dialect/SparseTensor/invalid_encoding.mlir
index 61c0366d02767..5d6f34f4e0697 100644
--- a/mlir/test/Dialect/SparseTensor/invalid_encoding.mlir
+++ b/mlir/test/Dialect/SparseTensor/invalid_encoding.mlir
@@ -1,27 +1,27 @@
 // RUN: mlir-opt %s -split-input-file -verify-diagnostics
 
-// expected-error at +1 {{expected a non-empty array for level types}}
+// expected-error at +1 {{expected a non-empty array for lvlTypes}}
 #a = #sparse_tensor.encoding<{lvlTypes = []}>
 func.func private @scalar(%arg0: tensor<f64, #a>) -> ()
 
 // -----
 
 #a = #sparse_tensor.encoding<{lvlTypes = ["dense", "compressed"]}>
-func.func private @tensor_dimlevel_size_mismatch(%arg0: tensor<8xi32, #a>) -> () // expected-error {{expected an array of size 1 for dimension level types}}
+func.func private @tensor_dimlevel_size_mismatch(%arg0: tensor<8xi32, #a>) -> () // expected-error {{expected an array of size 1 for lvlTypes}}
 
 // -----
 
-#a = #sparse_tensor.encoding<{lvlTypes = ["dense", "compressed"], dimOrdering = affine_map<(i) -> (i)>}> // expected-error {{unexpected mismatch in ordering and dimension level types size}}
+#a = #sparse_tensor.encoding<{lvlTypes = ["dense", "compressed"], dimOrdering = affine_map<(i) -> (i)>}> // expected-error {{level-rank mismatch between dimOrdering and lvlTypes}}
 func.func private @tensor_sizes_mismatch(%arg0: tensor<8xi32, #a>) -> ()
 
 // -----
 
-#a = #sparse_tensor.encoding<{lvlTypes = [1]}> // expected-error {{expected a string value in dimension level types}}
+#a = #sparse_tensor.encoding<{lvlTypes = [1]}> // expected-error {{expected a string value in lvlTypes}}
 func.func private @tensor_type_mismatch(%arg0: tensor<8xi32, #a>) -> ()
 
 // -----
 
-#a = #sparse_tensor.encoding<{lvlTypes = ["strange"]}> // expected-error {{unexpected dimension level type: strange}}
+#a = #sparse_tensor.encoding<{lvlTypes = ["strange"]}> // expected-error {{unexpected level-type: strange}}
 func.func private @tensor_value_mismatch(%arg0: tensor<8xi32, #a>) -> ()
 
 // -----


        


More information about the Mlir-commits mailing list