Skip to content

Commit

Permalink
[mlir][sparse] emergency fix after constant -> arith.constant change
Browse files Browse the repository at this point in the history
Reviewed By: Mogball

Differential Revision: https://reviews.llvm.org/D111743
  • Loading branch information
aartbik committed Oct 13, 2021
1 parent 92bec0e commit a652e5b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp
Expand Up @@ -225,9 +225,9 @@ static LogicalResult verify(InitOp op) {
for (unsigned i = 0; i < rank; i++) {
if (shape[i] == ShapedType::kDynamicSize)
continue;
auto constantOp = op.sizes()[i].getDefiningOp<ConstantOp>();
auto constantOp = op.sizes()[i].getDefiningOp<arith::ConstantOp>();
if (!constantOp ||
constantOp.getValue().cast<IntegerAttr>().getInt() != shape[i])
constantOp.value().cast<IntegerAttr>().getInt() != shape[i])
return op.emitError("unexpected mismatch with static dimension size ")
<< shape[i];
}
Expand Down
4 changes: 2 additions & 2 deletions mlir/test/Dialect/SparseTensor/invalid.mlir
Expand Up @@ -37,8 +37,8 @@ func @invalid_init_rank(%arg0: index) -> tensor<?xf32, #SparseVector> {
#SparseMatrix = #sparse_tensor.encoding<{dimLevelType = ["compressed", "compressed"]}>

func @invalid_init_size() -> tensor<?x10xf32, #SparseMatrix> {
%c10 = constant 10 : index
%c20 = constant 20 : index
%c10 = arith.constant 10 : index
%c20 = arith.constant 20 : index
// expected-error@+1 {{unexpected mismatch with static dimension size 10}}
%0 = sparse_tensor.init [%c10, %c20] : tensor<?x10xf32, #SparseMatrix>
return %0 : tensor<?x10xf32, #SparseMatrix>
Expand Down
8 changes: 4 additions & 4 deletions mlir/test/Dialect/SparseTensor/roundtrip.mlir
Expand Up @@ -16,13 +16,13 @@ func @sparse_new(%arg0: !llvm.ptr<i8>) -> tensor<128xf64, #SparseVector> {
#SparseMatrix = #sparse_tensor.encoding<{dimLevelType = ["compressed", "compressed"]}>

// CHECK-LABEL: func @sparse_init()
// CHECK-DAG: %[[C16:.*]] = constant 16 : index
// CHECK-DAG: %[[C32:.*]] = constant 32 : index
// CHECK-DAG: %[[C16:.*]] = arith.constant 16 : index
// CHECK-DAG: %[[C32:.*]] = arith.constant 32 : index
// CHECK: %[[T:.*]] = sparse_tensor.init[%[[C16]], %[[C32]]] : tensor<?x32xf64, #{{.*}}>
// CHECK: return %[[T]] : tensor<?x32xf64, #{{.*}}>
func @sparse_init() -> tensor<?x32xf64, #SparseMatrix> {
%d1 = constant 16 : index
%d2 = constant 32 : index
%d1 = arith.constant 16 : index
%d2 = arith.constant 32 : index
%0 = sparse_tensor.init [%d1, %d2] : tensor<?x32xf64, #SparseMatrix>
return %0 : tensor<?x32xf64, #SparseMatrix>
}
Expand Down

0 comments on commit a652e5b

Please sign in to comment.