From: Jie Fu Date: Wed, 15 Feb 2023 03:56:40 +0000 (+0800) Subject: [mlir] Fix -Wsign-compare in SparseTensorRewriting.cpp and Sparsification.cpp (NFC) X-Git-Tag: upstream/17.0.6~17463 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=71251e8d4f3f26acb8692e5e1f23488d271f60e2;p=platform%2Fupstream%2Fllvm.git [mlir] Fix -Wsign-compare in SparseTensorRewriting.cpp and Sparsification.cpp (NFC) /home/jiefu/llvm-project/mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp:279:33: error: comparison of integers of different signs: 'int64_t' (aka 'long') and 'const mlir::sparse_tensor::Level' (aka 'const unsigned long') [-Werror,-Wsign-compare] assert(env.op().getRank(&t) == lvlRank); ~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~ /usr/include/assert.h:93:27: note: expanded from macro 'assert' (static_cast (expr) \ ^~~~ 1 error generated. /home/jiefu/llvm-project/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp:788:29: error: comparison of integers of different signs: 'int64_t' (aka 'long') and 'const mlir::sparse_tensor::Dimension' (aka 'const unsigned long') [-Werror,-Wsign-compare] assert(srcRTT.getRank() == dimRank); ~~~~~~~~~~~~~~~~ ^ ~~~~~~~ /usr/include/assert.h:93:27: note: expanded from macro 'assert' (static_cast (expr) \ ^~~~ /home/jiefu/llvm-project/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp:810:31: error: comparison of integers of different signs: 'int64_t' (aka 'long') and 'const mlir::sparse_tensor::Dimension' (aka 'const unsigned long') [-Werror,-Wsign-compare] assert(srcRTT.getRank() == dimRank); ~~~~~~~~~~~~~~~~ ^ ~~~~~~~ /usr/include/assert.h:93:27: note: expanded from macro 'assert' (static_cast (expr) \ ^~~~ 2 errors generated. --- diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp index f6ef4cf..9ec1d7c 100644 --- a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp +++ b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp @@ -785,7 +785,7 @@ private: const Dimension dimRank = dstTp.getDimRank(); // This assertion should be guaranteed by validity of the op, // but just for paranoia's sake. - assert(srcRTT.getRank() == dimRank); + assert(static_cast(srcRTT.getRank()) == dimRank); SmallVector srcSizes; sizesForTensor(rewriter, srcSizes, loc, srcRTT, src); @@ -807,7 +807,7 @@ private: srcRTT = getUnorderedCOOFromTypeWithOrdering(srcRTT, dstTp.getDimToLvlMap()); // Ensure that mutating `srcRTT` didn't invalidate `dimRank`. - assert(srcRTT.getRank() == dimRank); + assert(static_cast(srcRTT.getRank()) == dimRank); tmpCoo = rewriter .create(loc, srcRTT, dynSrcSizes, Value(), /*sizeHint=*/nnz, Attribute()) diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp index 3555873..7f88c6a 100644 --- a/mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp +++ b/mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp @@ -276,7 +276,7 @@ static bool findSparseAnnotations(CodegenEnv &env) { annotated = true; const Level lvlRank = map.getNumResults(); assert(!enc || lvlRank == enc.getLvlRank()); - assert(env.op().getRank(&t) == lvlRank); + assert(static_cast(env.op().getRank(&t)) == lvlRank); for (Level l = 0; l < lvlRank; l++) { const unsigned tensor = t.getOperandNumber(); // FIXME: `toOrigDim` is deprecated.