[Mlir-commits] [mlir] 27a431f - [mlir][bufferization][NFC] Move sparse_tensor.release to bufferization dialect

Matthias Springer llvmlistbot at llvm.org
Tue Jul 19 00:19:01 PDT 2022


Author: Matthias Springer
Date: 2022-07-19T09:18:19+02:00
New Revision: 27a431f5e9811553d833ef62f64eb95374cf8793

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

LOG: [mlir][bufferization][NFC] Move sparse_tensor.release to bufferization dialect

This op used to belong to the sparse dialect, but there are use cases for dense bufferization as well. (E.g., when a tensor alloc is returned from a function and should be deallocated at the call site.) This change moves the op to the bufferization dialect, which now has an `alloc_tensor` and a `dealloc_tensor` op.

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

Added: 
    

Modified: 
    mlir/include/mlir/Dialect/Bufferization/IR/BufferizationOps.td
    mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorOps.td
    mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp
    mlir/lib/Dialect/SparseTensor/Transforms/BufferizableOpInterfaceImpl.cpp
    mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp
    mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorPasses.cpp
    mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp
    mlir/test/Dialect/Bufferization/ops.mlir
    mlir/test/Dialect/SparseTensor/conversion.mlir
    mlir/test/Dialect/SparseTensor/invalid.mlir
    mlir/test/Dialect/SparseTensor/roundtrip.mlir
    mlir/test/Dialect/SparseTensor/sparse_transpose.mlir
    mlir/test/Integration/Dialect/SparseTensor/CPU/dense_output.mlir
    mlir/test/Integration/Dialect/SparseTensor/CPU/dense_output_bf16.mlir
    mlir/test/Integration/Dialect/SparseTensor/CPU/dense_output_f16.mlir
    mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_binary.mlir
    mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_cast.mlir
    mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_complex32.mlir
    mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_complex64.mlir
    mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_complex_ops.mlir
    mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_constant_to_sparse_tensor.mlir
    mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_conversion.mlir
    mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_conversion_dyn.mlir
    mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_conversion_ptr.mlir
    mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_conversion_sparse2dense.mlir
    mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_conversion_sparse2sparse.mlir
    mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_dot.mlir
    mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_filter_conv2d.mlir
    mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_flatten.mlir
    mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_index.mlir
    mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_index_dense.mlir
    mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_matmul.mlir
    mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_matrix_ops.mlir
    mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_matvec.mlir
    mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_mttkrp.mlir
    mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_out_mult_elt.mlir
    mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_out_reduction.mlir
    mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_out_simple.mlir
    mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_quantized_matmul.mlir
    mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_re_im.mlir
    mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_reductions.mlir
    mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_reshape.mlir
    mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_sampled_matmul.mlir
    mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_sampled_mm_fusion.mlir
    mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_scale.mlir
    mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_sign.mlir
    mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_spmm.mlir
    mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_storage.mlir
    mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_sum.mlir
    mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_sum_bf16.mlir
    mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_sum_c32.mlir
    mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_sum_f16.mlir
    mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_tanh.mlir
    mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_tensor_mul.mlir
    mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_tensor_ops.mlir
    mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_transpose.mlir
    mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_unary.mlir
    mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_vector_ops.mlir
    mlir/test/Integration/Dialect/SparseTensor/python/test_stress.py

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Dialect/Bufferization/IR/BufferizationOps.td b/mlir/include/mlir/Dialect/Bufferization/IR/BufferizationOps.td
index e2825b8695743..33f61aa56a010 100644
--- a/mlir/include/mlir/Dialect/Bufferization/IR/BufferizationOps.td
+++ b/mlir/include/mlir/Dialect/Bufferization/IR/BufferizationOps.td
@@ -186,6 +186,64 @@ def Bufferization_CloneOp : Bufferization_Op<"clone", [
   let hasFolder = 1;
   let hasCanonicalizer = 1;
 }
+
+//===----------------------------------------------------------------------===//
+// DeallocTensorOp
+//===----------------------------------------------------------------------===//
+
+def Bufferization_DeallocTensorOp : Bufferization_Op<"dealloc_tensor",
+    [BufferizableOpInterface]> {
+  string summary = "Releases underlying sparse storage format of given tensor";
+  string description = [{
+    `bufferization.dealloc_tensor` is a buffer deallocation in tensor land. This
+    op can be used for manual buffer deallocation. Some bufferizations (such as
+    One-Shot Bufferize) take care of buffer deallocation, in which case this op
+    is usually not needed. Details can be found in the documentation of the
+    respective bufferization passes.
+
+    In case of a dense tensor, this op lowers to a `memref.dealloc` op during
+    bufferization.
+
+    In case of a sparse tensor, this op releases the underlying sparse storage
+    format for a tensor that materialized earlier through a `new` operation, a
+    `convert` operation with annotated destination tensor type (unless the
+    convert is folded away), or a `bufferization.alloc_tensor` operation. The
+    release operation should only be called once for any materialized tensor.
+    After this operation, any subsequent `memref` querying operation on the
+    tensor returns undefined results.
+
+    Example:
+
+    ```mlir
+    bufferization.dealloc_tensor %tensor : tensor<1024x1024xf64, #CSR>
+    ```
+  }];
+
+  let arguments = (ins AnyTensor:$tensor);
+  let results = (outs);
+  let assemblyFormat = "$tensor attr-dict `:` type($tensor)";
+
+  let extraClassDeclaration = [{
+    bool bufferizesToMemoryRead(OpOperand &opOperand,
+                                const AnalysisState &state) const {
+      return false;
+    }
+
+    bool bufferizesToMemoryWrite(OpOperand &opOperand,
+                                 const AnalysisState &state) const {
+      return false;
+    }
+
+    SmallVector<OpResult> getAliasingOpResult(
+        OpOperand &opOperand, const AnalysisState &state) const {
+      return {};
+    }
+
+    LogicalResult bufferize(RewriterBase &rewriter,
+                            const BufferizationOptions &options);
+  }];
+}
+
 //===----------------------------------------------------------------------===//
 // ToTensorOp
 //===----------------------------------------------------------------------===//

diff  --git a/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorOps.td b/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorOps.td
index db6b656670bee..9f99b52291177 100644
--- a/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorOps.td
+++ b/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorOps.td
@@ -306,31 +306,6 @@ def SparseTensor_LoadOp : SparseTensor_Op<"load", [SameOperandsAndResultType]>,
   let assemblyFormat = "$tensor (`hasInserts` $hasInserts^)? attr-dict `:` type($tensor)";
 }
 
-def SparseTensor_ReleaseOp : SparseTensor_Op<"release", []>,
-    Arguments<(ins AnySparseTensor:$tensor)> {
-  string summary = "Releases underlying sparse storage format of given tensor";
-  string description = [{
-    Releases the underlying sparse storage format for a tensor that
-    materialized earlier through a `new` operation, a `convert` operation
-    with annotated destination tensor type (unless the convert is folded
-    away), or a `bufferization.alloc_tensor` operation. The release operation
-    should only be called once for any materialized tensor. After this
-    operation, any subsequent `memref` querying operation on the tensor
-    returns undefined results.
-
-    Note that this operation is "impure" in the sense that its behavior
-    is solely defined by side-effects and not SSA values. The semantics
-    may be refined over time as our sparse abstractions evolve.
-
-    Example:
-
-    ```mlir
-    sparse_tensor.release %tensor : tensor<1024x1024xf64, #CSR>
-    ```
-  }];
-  let assemblyFormat = "$tensor attr-dict `:` type($tensor)";
-}
-
 def SparseTensor_OutOp : SparseTensor_Op<"out", []>,
     Arguments<(ins AnySparseTensor:$tensor, AnyType:$dest)> {
   string summary = "Outputs a sparse tensor to the given destination";

diff  --git a/mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp b/mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp
index 696c6bfb8014e..467710a173960 100644
--- a/mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp
+++ b/mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp
@@ -524,6 +524,21 @@ void CloneOp::getCanonicalizationPatterns(RewritePatternSet &results,
   results.add<SimplifyClones>(context);
 }
 
+//===----------------------------------------------------------------------===//
+// DeallocTensorOp
+//===----------------------------------------------------------------------===//
+
+LogicalResult DeallocTensorOp::bufferize(RewriterBase &rewriter,
+                                         const BufferizationOptions &options) {
+  FailureOr<Value> buffer = getBuffer(rewriter, getTensor(), options);
+  if (failed(buffer))
+    return failure();
+  if (failed(options.createDealloc(rewriter, getLoc(), *buffer)))
+    return failure();
+  rewriter.eraseOp(getOperation());
+  return success();
+}
+
 //===----------------------------------------------------------------------===//
 // ToTensorOp
 //===----------------------------------------------------------------------===//

diff  --git a/mlir/lib/Dialect/SparseTensor/Transforms/BufferizableOpInterfaceImpl.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/BufferizableOpInterfaceImpl.cpp
index 7785a20b473c7..aa6c6e9870cce 100644
--- a/mlir/lib/Dialect/SparseTensor/Transforms/BufferizableOpInterfaceImpl.cpp
+++ b/mlir/lib/Dialect/SparseTensor/Transforms/BufferizableOpInterfaceImpl.cpp
@@ -94,25 +94,6 @@ struct NewOpInterface
   }
 };
 
-struct ReleaseOpInterface
-    : public BufferizableOpInterface::ExternalModel<ReleaseOpInterface,
-                                                    sparse_tensor::ReleaseOp> {
-  bool bufferizesToMemoryRead(Operation *op, OpOperand &opOperand,
-                              const AnalysisState &state) const {
-    return false;
-  }
-
-  bool bufferizesToMemoryWrite(Operation *op, OpOperand &opOperand,
-                               const AnalysisState &state) const {
-    return false;
-  }
-
-  SmallVector<OpResult> getAliasingOpResult(Operation *op, OpOperand &opOperand,
-                                            const AnalysisState &state) const {
-    return {};
-  }
-};
-
 } // namespace
 } // namespace sparse_tensor
 } // namespace mlir
@@ -124,6 +105,5 @@ void mlir::sparse_tensor::registerBufferizableOpInterfaceExternalModels(
         sparse_tensor::ConvertOp::attachInterface<ConvertOpInterface>(*ctx);
         sparse_tensor::LoadOp::attachInterface<LoadOpInterface>(*ctx);
         sparse_tensor::NewOp::attachInterface<NewOpInterface>(*ctx);
-        sparse_tensor::ReleaseOp::attachInterface<ReleaseOpInterface>(*ctx);
       });
 }

diff  --git a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp
index 5c8696332673c..b37703ad73ef2 100644
--- a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp
+++ b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp
@@ -868,13 +868,17 @@ class SparseTensorConvertConverter : public OpConversionPattern<ConvertOp> {
   SparseTensorConversionOptions options;
 };
 
-/// Sparse conversion rule for the release operator.
-class SparseTensorReleaseConverter : public OpConversionPattern<ReleaseOp> {
+/// Sparse conversion rule for the dealloc operator.
+class SparseTensorDeallocConverter
+    : public OpConversionPattern<bufferization::DeallocTensorOp> {
 public:
   using OpConversionPattern::OpConversionPattern;
   LogicalResult
-  matchAndRewrite(ReleaseOp op, OpAdaptor adaptor,
+  matchAndRewrite(bufferization::DeallocTensorOp op, OpAdaptor adaptor,
                   ConversionPatternRewriter &rewriter) const override {
+    auto enc = getSparseTensorEncoding(op.getTensor().getType());
+    if (!enc)
+      return failure();
     StringRef name = "delSparseTensor";
     TypeRange noTp;
     createFuncCall(rewriter, op, name, noTp, adaptor.getOperands(),
@@ -1100,7 +1104,7 @@ void mlir::populateSparseTensorConversionPatterns(
                SparseCastConverter, SparseTensorNewConverter,
                SparseReshapeConverter<tensor::ExpandShapeOp>,
                SparseReshapeConverter<tensor::CollapseShapeOp>,
-               SparseTensorAllocConverter, SparseTensorReleaseConverter,
+               SparseTensorAllocConverter, SparseTensorDeallocConverter,
                SparseTensorToPointersConverter, SparseTensorToIndicesConverter,
                SparseTensorToValuesConverter, SparseTensorLoadConverter,
                SparseTensorLexInsertConverter, SparseTensorExpandConverter,

diff  --git a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorPasses.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorPasses.cpp
index 5fcb44a98de3a..2265989301ea6 100644
--- a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorPasses.cpp
+++ b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorPasses.cpp
@@ -129,6 +129,10 @@ struct SparseTensorConversionPass
         [&](bufferization::AllocTensorOp op) {
           return converter.isLegal(op.getType());
         });
+    target.addDynamicallyLegalOp<bufferization::DeallocTensorOp>(
+        [&](bufferization::DeallocTensorOp op) {
+          return converter.isLegal(op.getTensor().getType());
+        });
     // The following operations and dialects may be introduced by the
     // rewriting rules, and are therefore marked as legal.
     target.addLegalOp<bufferization::ToMemrefOp, bufferization::ToTensorOp,
@@ -137,11 +141,6 @@ struct SparseTensorConversionPass
     target.addLegalDialect<
         arith::ArithmeticDialect, bufferization::BufferizationDialect,
         LLVM::LLVMDialect, memref::MemRefDialect, scf::SCFDialect>();
-    target.addDynamicallyLegalOp<bufferization::AllocTensorOp>(
-        [&](bufferization::AllocTensorOp op) {
-          // Dense tensors are legal, sparse tensors are not.
-          return !static_cast<bool>(op.getType().getEncoding());
-        });
     // Translate strategy flags to strategy options.
     SparseTensorConversionOptions options(
         sparseToSparseConversionStrategy(sparseToSparse));

diff  --git a/mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp
index 7121438ddad6b..39048350a02a9 100644
--- a/mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp
+++ b/mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp
@@ -1790,7 +1790,7 @@ struct GenericOpSparsifier : public OpRewritePattern<linalg::GenericOp> {
       auto convert = rewriter.create<ConvertOp>(tval.getLoc(), dstTp, tval);
       op->setOperand(tensor, convert);
       rewriter.setInsertionPointAfter(op);
-      rewriter.create<ReleaseOp>(tval.getLoc(), convert);
+      rewriter.create<bufferization::DeallocTensorOp>(tval.getLoc(), convert);
       return success();
     }
     // Cannot be resolved with a single conversion.

diff  --git a/mlir/test/Dialect/Bufferization/ops.mlir b/mlir/test/Dialect/Bufferization/ops.mlir
index 393c9ae8ddb63..72edef3069393 100644
--- a/mlir/test/Dialect/Bufferization/ops.mlir
+++ b/mlir/test/Dialect/Bufferization/ops.mlir
@@ -41,3 +41,10 @@ func.func @test_alloc_tensor_op(%t: tensor<?x5xf32>, %sz: index)
   %5 = bufferization.alloc_tensor() copy(%t) {escape = false} : tensor<?x5xf32>
   return %1 : tensor<?x5xf32>
 }
+
+// CHECK-LABEL: func @test_dealloc_tensor_op
+func.func @test_dealloc_tensor_op(%arg0: tensor<4xi32>) {
+  // CHECK: bufferization.dealloc_tensor {{.*}} : tensor<4xi32>
+  bufferization.dealloc_tensor %arg0 : tensor<4xi32>
+  return
+}

diff  --git a/mlir/test/Dialect/SparseTensor/conversion.mlir b/mlir/test/Dialect/SparseTensor/conversion.mlir
index 950452ebee487..80cd2f0cec639 100644
--- a/mlir/test/Dialect/SparseTensor/conversion.mlir
+++ b/mlir/test/Dialect/SparseTensor/conversion.mlir
@@ -145,7 +145,7 @@ func.func @sparse_init(%arg0: index, %arg1: index) -> tensor<?x?xf64, #SparseMat
 //       CHECK: call @delSparseTensor(%[[A]]) : (!llvm.ptr<i8>) -> ()
 //       CHECK: return
 func.func @sparse_release(%arg0: tensor<128xf64, #SparseVector>) {
-  sparse_tensor.release %arg0 : tensor<128xf64, #SparseVector>
+  bufferization.dealloc_tensor %arg0 : tensor<128xf64, #SparseVector>
   return
 }
 

diff  --git a/mlir/test/Dialect/SparseTensor/invalid.mlir b/mlir/test/Dialect/SparseTensor/invalid.mlir
index 0bae3a95fc80e..31f5654f63580 100644
--- a/mlir/test/Dialect/SparseTensor/invalid.mlir
+++ b/mlir/test/Dialect/SparseTensor/invalid.mlir
@@ -8,14 +8,6 @@ func.func @invalid_new_dense(%arg0: !llvm.ptr<i8>) -> tensor<32xf32> {
 
 // -----
 
-func.func @invalid_release_dense(%arg0: tensor<4xi32>) {
-  // expected-error at +1 {{'sparse_tensor.release' op operand #0 must be sparse tensor of any type values, but got 'tensor<4xi32>'}}
-  sparse_tensor.release %arg0 : tensor<4xi32>
-  return
-}
-
-// -----
-
 func.func @invalid_pointers_dense(%arg0: tensor<128xf64>) -> memref<?xindex> {
   %c = arith.constant 0 : index
   // expected-error at +1 {{'sparse_tensor.pointers' op operand #0 must be sparse tensor of any type values, but got 'tensor<128xf64>'}}

diff  --git a/mlir/test/Dialect/SparseTensor/roundtrip.mlir b/mlir/test/Dialect/SparseTensor/roundtrip.mlir
index 7539b1a8de74b..75fc964a32ce0 100644
--- a/mlir/test/Dialect/SparseTensor/roundtrip.mlir
+++ b/mlir/test/Dialect/SparseTensor/roundtrip.mlir
@@ -15,12 +15,12 @@ func.func @sparse_new(%arg0: !llvm.ptr<i8>) -> tensor<128xf64, #SparseVector> {
 
 #SparseVector = #sparse_tensor.encoding<{dimLevelType = ["compressed"]}>
 
-// CHECK-LABEL: func @sparse_release(
+// CHECK-LABEL: func @sparse_dealloc(
 // CHECK-SAME: %[[A:.*]]: tensor<128xf64, #{{.*}}>
-//       CHECK: sparse_tensor.release %[[A]] : tensor<128xf64, #{{.*}}>
+//       CHECK: bufferization.dealloc_tensor %[[A]] : tensor<128xf64, #{{.*}}>
 //       CHECK: return
-func.func @sparse_release(%arg0: tensor<128xf64, #SparseVector>) {
-  sparse_tensor.release %arg0 : tensor<128xf64, #SparseVector>
+func.func @sparse_dealloc(%arg0: tensor<128xf64, #SparseVector>) {
+  bufferization.dealloc_tensor %arg0 : tensor<128xf64, #SparseVector>
   return
 }
 

diff  --git a/mlir/test/Dialect/SparseTensor/sparse_transpose.mlir b/mlir/test/Dialect/SparseTensor/sparse_transpose.mlir
index 88505179da6bb..f155fd89e793b 100644
--- a/mlir/test/Dialect/SparseTensor/sparse_transpose.mlir
+++ b/mlir/test/Dialect/SparseTensor/sparse_transpose.mlir
@@ -46,7 +46,7 @@
 // CHECK:             }
 // CHECK:           }
 // CHECK:           %[[VAL_23:.*]] = sparse_tensor.load %[[VAL_4]] hasInserts : tensor<4x3xf64, #sparse_tensor.encoding<{ dimLevelType = [ "compressed", "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>>
-// CHECK:           sparse_tensor.release %[[VAL_5]] : tensor<3x4xf64, #sparse_tensor.encoding<{ dimLevelType = [ "compressed", "compressed" ], dimOrdering = affine_map<(d0, d1) -> (d1, d0)>, pointerBitWidth = 0, indexBitWidth = 0 }>>
+// CHECK:           bufferization.dealloc_tensor %[[VAL_5]] : tensor<3x4xf64, #sparse_tensor.encoding<{ dimLevelType = [ "compressed", "compressed" ], dimOrdering = affine_map<(d0, d1) -> (d1, d0)>, pointerBitWidth = 0, indexBitWidth = 0 }>>
 // CHECK:           return %[[VAL_23]] : tensor<4x3xf64, #sparse_tensor.encoding<{ dimLevelType = [ "compressed", "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>>
 // CHECK:         }
 func.func @sparse_transpose_auto(%arga: tensor<3x4xf64, #DCSR>)

diff  --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/dense_output.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/dense_output.mlir
index ca02b4073aba9..e07cf6d498099 100644
--- a/mlir/test/Integration/Dialect/SparseTensor/CPU/dense_output.mlir
+++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/dense_output.mlir
@@ -88,8 +88,8 @@ module {
     vector.print %v : vector<25xf64>
 
     // Release the resources.
-    sparse_tensor.release %a : tensor<?x?xf64, #SparseMatrix>
-    sparse_tensor.release %0 : tensor<?x?xf64, #DenseMatrix>
+    bufferization.dealloc_tensor %a : tensor<?x?xf64, #SparseMatrix>
+    bufferization.dealloc_tensor %0 : tensor<?x?xf64, #DenseMatrix>
 
     return
   }

diff  --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/dense_output_bf16.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/dense_output_bf16.mlir
index f2c595eb35d9a..f776a3d1b8a09 100644
--- a/mlir/test/Integration/Dialect/SparseTensor/CPU/dense_output_bf16.mlir
+++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/dense_output_bf16.mlir
@@ -82,9 +82,9 @@ module {
     call @dump_vec(%0) : (tensor<?xbf16, #DenseVector>) -> ()
 
     // Release the resources.
-    sparse_tensor.release %sv1 : tensor<?xbf16, #SparseVector>
-    sparse_tensor.release %sv2 : tensor<?xbf16, #SparseVector>
-    sparse_tensor.release %0 : tensor<?xbf16, #DenseVector>
+    bufferization.dealloc_tensor %sv1 : tensor<?xbf16, #SparseVector>
+    bufferization.dealloc_tensor %sv2 : tensor<?xbf16, #SparseVector>
+    bufferization.dealloc_tensor %0 : tensor<?xbf16, #DenseVector>
     return
   }
 }

diff  --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/dense_output_f16.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/dense_output_f16.mlir
index ec15477bb5800..13967a9c9fe81 100644
--- a/mlir/test/Integration/Dialect/SparseTensor/CPU/dense_output_f16.mlir
+++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/dense_output_f16.mlir
@@ -82,9 +82,9 @@ module {
     call @dump_vec(%0) : (tensor<?xf16, #DenseVector>) -> ()
 
     // Release the resources.
-    sparse_tensor.release %sv1 : tensor<?xf16, #SparseVector>
-    sparse_tensor.release %sv2 : tensor<?xf16, #SparseVector>
-    sparse_tensor.release %0 : tensor<?xf16, #DenseVector>
+    bufferization.dealloc_tensor %sv1 : tensor<?xf16, #SparseVector>
+    bufferization.dealloc_tensor %sv2 : tensor<?xf16, #SparseVector>
+    bufferization.dealloc_tensor %0 : tensor<?xf16, #DenseVector>
     return
   }
 }

diff  --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_binary.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_binary.mlir
index de412bc0c0627..e29cb36a735ca 100644
--- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_binary.mlir
+++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_binary.mlir
@@ -531,23 +531,23 @@ module {
     call @dump_mat_4x4(%11) : (tensor<4x4xf64, #DCSR>) -> ()
 
     // Release the resources.
-    sparse_tensor.release %sv1 : tensor<?xf64, #SparseVector>
-    sparse_tensor.release %sv2 : tensor<?xf64, #SparseVector>
-    sparse_tensor.release %sm1 : tensor<?x?xf64, #DCSR>
-    sparse_tensor.release %sm2 : tensor<?x?xf64, #DCSR>
-    sparse_tensor.release %sm3 : tensor<4x4xf64, #DCSR>
-    sparse_tensor.release %sm4 : tensor<4x4xf64, #DCSR>
-    sparse_tensor.release %0 : tensor<?xf64, #SparseVector>
-    sparse_tensor.release %1 : tensor<?xf64, #SparseVector>
-    sparse_tensor.release %2 : tensor<?xf64, #SparseVector>
-    sparse_tensor.release %3 : tensor<?xi32, #SparseVector>
-    sparse_tensor.release %5 : tensor<?x?xf64, #DCSR>
-    sparse_tensor.release %6 : tensor<4x4xf64, #DCSR>
-    sparse_tensor.release %7 : tensor<4x4xf64, #DCSR>
-    sparse_tensor.release %8 : tensor<4x4xf64, #DCSR>
-    sparse_tensor.release %9 : tensor<4x4xf64, #DCSR>
-    sparse_tensor.release %10 : tensor<4x4xi8, #DCSR>
-    sparse_tensor.release %11 : tensor<4x4xf64, #DCSR>
+    bufferization.dealloc_tensor %sv1 : tensor<?xf64, #SparseVector>
+    bufferization.dealloc_tensor %sv2 : tensor<?xf64, #SparseVector>
+    bufferization.dealloc_tensor %sm1 : tensor<?x?xf64, #DCSR>
+    bufferization.dealloc_tensor %sm2 : tensor<?x?xf64, #DCSR>
+    bufferization.dealloc_tensor %sm3 : tensor<4x4xf64, #DCSR>
+    bufferization.dealloc_tensor %sm4 : tensor<4x4xf64, #DCSR>
+    bufferization.dealloc_tensor %0 : tensor<?xf64, #SparseVector>
+    bufferization.dealloc_tensor %1 : tensor<?xf64, #SparseVector>
+    bufferization.dealloc_tensor %2 : tensor<?xf64, #SparseVector>
+    bufferization.dealloc_tensor %3 : tensor<?xi32, #SparseVector>
+    bufferization.dealloc_tensor %5 : tensor<?x?xf64, #DCSR>
+    bufferization.dealloc_tensor %6 : tensor<4x4xf64, #DCSR>
+    bufferization.dealloc_tensor %7 : tensor<4x4xf64, #DCSR>
+    bufferization.dealloc_tensor %8 : tensor<4x4xf64, #DCSR>
+    bufferization.dealloc_tensor %9 : tensor<4x4xf64, #DCSR>
+    bufferization.dealloc_tensor %10 : tensor<4x4xi8, #DCSR>
+    bufferization.dealloc_tensor %11 : tensor<4x4xf64, #DCSR>
     return
   }
 }

diff  --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_cast.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_cast.mlir
index b5c56e9a39a7b..569d8b122fc98 100644
--- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_cast.mlir
+++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_cast.mlir
@@ -257,10 +257,10 @@ module {
     vector.print %v9 : vector<10xi32>
 
     // Release the resources.
-    sparse_tensor.release %1 : tensor<10xi32, #SV>
-    sparse_tensor.release %3 : tensor<10xf32, #SV>
-    sparse_tensor.release %5 : tensor<10xf64, #SV>
-    sparse_tensor.release %7 : tensor<10xf64, #SV>
+    bufferization.dealloc_tensor %1 : tensor<10xi32, #SV>
+    bufferization.dealloc_tensor %3 : tensor<10xf32, #SV>
+    bufferization.dealloc_tensor %5 : tensor<10xf64, #SV>
+    bufferization.dealloc_tensor %7 : tensor<10xf64, #SV>
 
     return
   }

diff  --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_complex32.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_complex32.mlir
index 82a00591ecf2c..255e8d084e50c 100644
--- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_complex32.mlir
+++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_complex32.mlir
@@ -107,10 +107,10 @@ module {
     call @dump(%1, %d2) : (tensor<?xcomplex<f32>, #SparseVector>, index) -> ()
 
     // Release the resources.
-    sparse_tensor.release %sv1 : tensor<?xcomplex<f32>, #SparseVector>
-    sparse_tensor.release %sv2 : tensor<?xcomplex<f32>, #SparseVector>
-    sparse_tensor.release %0 : tensor<?xcomplex<f32>, #SparseVector>
-    sparse_tensor.release %1 : tensor<?xcomplex<f32>, #SparseVector>
+    bufferization.dealloc_tensor %sv1 : tensor<?xcomplex<f32>, #SparseVector>
+    bufferization.dealloc_tensor %sv2 : tensor<?xcomplex<f32>, #SparseVector>
+    bufferization.dealloc_tensor %0 : tensor<?xcomplex<f32>, #SparseVector>
+    bufferization.dealloc_tensor %1 : tensor<?xcomplex<f32>, #SparseVector>
     return
   }
 }

diff  --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_complex64.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_complex64.mlir
index 700c4336f3730..95842ed165a32 100644
--- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_complex64.mlir
+++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_complex64.mlir
@@ -107,10 +107,10 @@ module {
     call @dump(%1, %d2) : (tensor<?xcomplex<f64>, #SparseVector>, index) -> ()
 
     // Release the resources.
-    sparse_tensor.release %sv1 : tensor<?xcomplex<f64>, #SparseVector>
-    sparse_tensor.release %sv2 : tensor<?xcomplex<f64>, #SparseVector>
-    sparse_tensor.release %0 : tensor<?xcomplex<f64>, #SparseVector>
-    sparse_tensor.release %1 : tensor<?xcomplex<f64>, #SparseVector>
+    bufferization.dealloc_tensor %sv1 : tensor<?xcomplex<f64>, #SparseVector>
+    bufferization.dealloc_tensor %sv2 : tensor<?xcomplex<f64>, #SparseVector>
+    bufferization.dealloc_tensor %0 : tensor<?xcomplex<f64>, #SparseVector>
+    bufferization.dealloc_tensor %1 : tensor<?xcomplex<f64>, #SparseVector>
     return
   }
 }

diff  --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_complex_ops.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_complex_ops.mlir
index ba13e1df10b31..3aacad4e543a5 100644
--- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_complex_ops.mlir
+++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_complex_ops.mlir
@@ -241,15 +241,15 @@ module {
     call @dumpf(%6) : (tensor<?xf64, #SparseVector>) -> ()
 
     // Release the resources.
-    sparse_tensor.release %sv1 : tensor<?xcomplex<f64>, #SparseVector>
-    sparse_tensor.release %sv2 : tensor<?xcomplex<f64>, #SparseVector>
-    sparse_tensor.release %0 : tensor<?xcomplex<f64>, #SparseVector>
-    sparse_tensor.release %1 : tensor<?xcomplex<f64>, #SparseVector>
-    sparse_tensor.release %2 : tensor<?xcomplex<f64>, #SparseVector>
-    sparse_tensor.release %3 : tensor<?xcomplex<f64>, #SparseVector>
-    sparse_tensor.release %4 : tensor<?xcomplex<f64>, #SparseVector>
-    sparse_tensor.release %5 : tensor<?xcomplex<f64>, #SparseVector>
-    sparse_tensor.release %6 : tensor<?xf64, #SparseVector>
+    bufferization.dealloc_tensor %sv1 : tensor<?xcomplex<f64>, #SparseVector>
+    bufferization.dealloc_tensor %sv2 : tensor<?xcomplex<f64>, #SparseVector>
+    bufferization.dealloc_tensor %0 : tensor<?xcomplex<f64>, #SparseVector>
+    bufferization.dealloc_tensor %1 : tensor<?xcomplex<f64>, #SparseVector>
+    bufferization.dealloc_tensor %2 : tensor<?xcomplex<f64>, #SparseVector>
+    bufferization.dealloc_tensor %3 : tensor<?xcomplex<f64>, #SparseVector>
+    bufferization.dealloc_tensor %4 : tensor<?xcomplex<f64>, #SparseVector>
+    bufferization.dealloc_tensor %5 : tensor<?xcomplex<f64>, #SparseVector>
+    bufferization.dealloc_tensor %6 : tensor<?xf64, #SparseVector>
     return
   }
 }

diff  --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_constant_to_sparse_tensor.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_constant_to_sparse_tensor.mlir
index 27468c5791290..3128fc8a4e485 100644
--- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_constant_to_sparse_tensor.mlir
+++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_constant_to_sparse_tensor.mlir
@@ -41,7 +41,7 @@ module {
     vector.print %vr : vector<8xf64>
 
     // Release the resources.
-    sparse_tensor.release %ts : tensor<10x8xf64, #Tensor1>
+    bufferization.dealloc_tensor %ts : tensor<10x8xf64, #Tensor1>
 
     return
   }

diff  --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_conversion.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_conversion.mlir
index 9430bdf992429..9bdbde460b851 100644
--- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_conversion.mlir
+++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_conversion.mlir
@@ -249,15 +249,15 @@ module {
     call @dumpidx(%i32) : (memref<?xindex>) -> ()
 
     // Release the resources.
-    sparse_tensor.release %1 : tensor<2x3x4xf64, #Tensor1>
-    sparse_tensor.release %2 : tensor<2x3x4xf64, #Tensor2>
-    sparse_tensor.release %3 : tensor<2x3x4xf64, #Tensor3>
-    sparse_tensor.release %b : tensor<2x3x4xf64, #Tensor1>
-    sparse_tensor.release %c : tensor<2x3x4xf64, #Tensor1>
-    sparse_tensor.release %d : tensor<2x3x4xf64, #Tensor2>
-    sparse_tensor.release %f : tensor<2x3x4xf64, #Tensor2>
-    sparse_tensor.release %g : tensor<2x3x4xf64, #Tensor3>
-    sparse_tensor.release %h : tensor<2x3x4xf64, #Tensor3>
+    bufferization.dealloc_tensor %1 : tensor<2x3x4xf64, #Tensor1>
+    bufferization.dealloc_tensor %2 : tensor<2x3x4xf64, #Tensor2>
+    bufferization.dealloc_tensor %3 : tensor<2x3x4xf64, #Tensor3>
+    bufferization.dealloc_tensor %b : tensor<2x3x4xf64, #Tensor1>
+    bufferization.dealloc_tensor %c : tensor<2x3x4xf64, #Tensor1>
+    bufferization.dealloc_tensor %d : tensor<2x3x4xf64, #Tensor2>
+    bufferization.dealloc_tensor %f : tensor<2x3x4xf64, #Tensor2>
+    bufferization.dealloc_tensor %g : tensor<2x3x4xf64, #Tensor3>
+    bufferization.dealloc_tensor %h : tensor<2x3x4xf64, #Tensor3>
 
     return
   }

diff  --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_conversion_dyn.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_conversion_dyn.mlir
index 53f7b2b0aeb7a..2dfa3c40d0ecd 100644
--- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_conversion_dyn.mlir
+++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_conversion_dyn.mlir
@@ -72,12 +72,12 @@ module {
     call @dump(%m6) : (memref<?xf64>) -> ()
 
     // Release the resources.
-    sparse_tensor.release %1 : tensor<?x?xf64, #DCSR>
-    sparse_tensor.release %2 : tensor<?x?xf64, #DCSC>
-    sparse_tensor.release %3 : tensor<?x?xf64, #DCSR>
-    sparse_tensor.release %4 : tensor<?x?xf64, #DCSC>
-    sparse_tensor.release %5 : tensor<?x?xf64, #DCSC>
-    sparse_tensor.release %6 : tensor<?x?xf64, #DCSR>
+    bufferization.dealloc_tensor %1 : tensor<?x?xf64, #DCSR>
+    bufferization.dealloc_tensor %2 : tensor<?x?xf64, #DCSC>
+    bufferization.dealloc_tensor %3 : tensor<?x?xf64, #DCSR>
+    bufferization.dealloc_tensor %4 : tensor<?x?xf64, #DCSC>
+    bufferization.dealloc_tensor %5 : tensor<?x?xf64, #DCSC>
+    bufferization.dealloc_tensor %6 : tensor<?x?xf64, #DCSR>
 
     return
   }

diff  --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_conversion_ptr.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_conversion_ptr.mlir
index 8cf1bf98872d7..4c2ebbc3522d8 100644
--- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_conversion_ptr.mlir
+++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_conversion_ptr.mlir
@@ -128,12 +128,12 @@ module {
     call @dumpi08(%i6) : (memref<?xi08>) -> ()
 
     // Release the resources.
-    sparse_tensor.release %1 : tensor<32x64xf64, #DCSR>
-    sparse_tensor.release %2 : tensor<32x64xf64, #DCSC>
-    sparse_tensor.release %3 : tensor<32x64xf64, #CSC>
-    sparse_tensor.release %4 : tensor<32x64xf64, #DCSC>
-    sparse_tensor.release %5 : tensor<32x64xf64, #DCSR>
-    sparse_tensor.release %6 : tensor<32x64xf64, #DCSR>
+    bufferization.dealloc_tensor %1 : tensor<32x64xf64, #DCSR>
+    bufferization.dealloc_tensor %2 : tensor<32x64xf64, #DCSC>
+    bufferization.dealloc_tensor %3 : tensor<32x64xf64, #CSC>
+    bufferization.dealloc_tensor %4 : tensor<32x64xf64, #DCSC>
+    bufferization.dealloc_tensor %5 : tensor<32x64xf64, #DCSR>
+    bufferization.dealloc_tensor %6 : tensor<32x64xf64, #DCSR>
 
     return
   }

diff  --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_conversion_sparse2dense.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_conversion_sparse2dense.mlir
index 6dd9ce96574bc..d06fff44e7790 100644
--- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_conversion_sparse2dense.mlir
+++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_conversion_sparse2dense.mlir
@@ -197,24 +197,24 @@ module {
     //
     // Release sparse tensors.
     //
-    sparse_tensor.release %s2341 : tensor<2x3x4xf64, #Tensor1>
-    sparse_tensor.release %s2342 : tensor<2x3x4xf64, #Tensor2>
-    sparse_tensor.release %s2343 : tensor<2x3x4xf64, #Tensor3>
-    sparse_tensor.release %s2344 : tensor<2x3x4xf64, #Tensor4>
-    sparse_tensor.release %s2345 : tensor<2x3x4xf64, #Tensor5>
-    sparse_tensor.release %s2346 : tensor<2x3x4xf64, #Tensor6>
-    sparse_tensor.release %sp344 : tensor<?x3x4xf64, #Tensor4>
-    sparse_tensor.release %sp345 : tensor<?x3x4xf64, #Tensor5>
-    sparse_tensor.release %sp346 : tensor<?x3x4xf64, #Tensor6>
-    sparse_tensor.release %s2p44 : tensor<2x?x4xf64, #Tensor4>
-    sparse_tensor.release %s2p45 : tensor<2x?x4xf64, #Tensor5>
-    sparse_tensor.release %s2p46 : tensor<2x?x4xf64, #Tensor6>
-    sparse_tensor.release %s23p4 : tensor<2x3x?xf64, #Tensor4>
-    sparse_tensor.release %s23p5 : tensor<2x3x?xf64, #Tensor5>
-    sparse_tensor.release %s23p6 : tensor<2x3x?xf64, #Tensor6>
-    sparse_tensor.release %s2pp4 : tensor<2x?x?xf64, #Tensor4>
-    sparse_tensor.release %s2pp5 : tensor<2x?x?xf64, #Tensor5>
-    sparse_tensor.release %s2pp6 : tensor<2x?x?xf64, #Tensor6>
+    bufferization.dealloc_tensor %s2341 : tensor<2x3x4xf64, #Tensor1>
+    bufferization.dealloc_tensor %s2342 : tensor<2x3x4xf64, #Tensor2>
+    bufferization.dealloc_tensor %s2343 : tensor<2x3x4xf64, #Tensor3>
+    bufferization.dealloc_tensor %s2344 : tensor<2x3x4xf64, #Tensor4>
+    bufferization.dealloc_tensor %s2345 : tensor<2x3x4xf64, #Tensor5>
+    bufferization.dealloc_tensor %s2346 : tensor<2x3x4xf64, #Tensor6>
+    bufferization.dealloc_tensor %sp344 : tensor<?x3x4xf64, #Tensor4>
+    bufferization.dealloc_tensor %sp345 : tensor<?x3x4xf64, #Tensor5>
+    bufferization.dealloc_tensor %sp346 : tensor<?x3x4xf64, #Tensor6>
+    bufferization.dealloc_tensor %s2p44 : tensor<2x?x4xf64, #Tensor4>
+    bufferization.dealloc_tensor %s2p45 : tensor<2x?x4xf64, #Tensor5>
+    bufferization.dealloc_tensor %s2p46 : tensor<2x?x4xf64, #Tensor6>
+    bufferization.dealloc_tensor %s23p4 : tensor<2x3x?xf64, #Tensor4>
+    bufferization.dealloc_tensor %s23p5 : tensor<2x3x?xf64, #Tensor5>
+    bufferization.dealloc_tensor %s23p6 : tensor<2x3x?xf64, #Tensor6>
+    bufferization.dealloc_tensor %s2pp4 : tensor<2x?x?xf64, #Tensor4>
+    bufferization.dealloc_tensor %s2pp5 : tensor<2x?x?xf64, #Tensor5>
+    bufferization.dealloc_tensor %s2pp6 : tensor<2x?x?xf64, #Tensor6>
 
     return
   }

diff  --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_conversion_sparse2sparse.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_conversion_sparse2sparse.mlir
index 50a798e297f62..61090ce726c5f 100644
--- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_conversion_sparse2sparse.mlir
+++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_conversion_sparse2sparse.mlir
@@ -87,13 +87,13 @@ module {
     //
     // Release sparse tensors.
     //
-    sparse_tensor.release %t13 : tensor<2x3x4xf64, #Tensor3>
-    sparse_tensor.release %t21 : tensor<2x3x4xf64, #Tensor1>
-    sparse_tensor.release %t23 : tensor<2x3x4xf64, #Tensor3>
-    sparse_tensor.release %t31 : tensor<2x3x4xf64, #Tensor1>
-    sparse_tensor.release %s1 : tensor<2x3x4xf64, #Tensor1>
-    sparse_tensor.release %s2 : tensor<2x3x4xf64, #Tensor2>
-    sparse_tensor.release %s3 : tensor<2x3x4xf64, #Tensor3>
+    bufferization.dealloc_tensor %t13 : tensor<2x3x4xf64, #Tensor3>
+    bufferization.dealloc_tensor %t21 : tensor<2x3x4xf64, #Tensor1>
+    bufferization.dealloc_tensor %t23 : tensor<2x3x4xf64, #Tensor3>
+    bufferization.dealloc_tensor %t31 : tensor<2x3x4xf64, #Tensor1>
+    bufferization.dealloc_tensor %s1 : tensor<2x3x4xf64, #Tensor1>
+    bufferization.dealloc_tensor %s2 : tensor<2x3x4xf64, #Tensor2>
+    bufferization.dealloc_tensor %s3 : tensor<2x3x4xf64, #Tensor3>
 
     return
   }

diff  --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_dot.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_dot.mlir
index 84c5c0a4ae3bc..edc1b01480157 100644
--- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_dot.mlir
+++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_dot.mlir
@@ -47,8 +47,8 @@ module {
     vector.print %1 : f32
 
     // Release the resources.
-    sparse_tensor.release %s1 : tensor<1024xf32, #SparseVector>
-    sparse_tensor.release %s2 : tensor<1024xf32, #SparseVector>
+    bufferization.dealloc_tensor %s1 : tensor<1024xf32, #SparseVector>
+    bufferization.dealloc_tensor %s2 : tensor<1024xf32, #SparseVector>
 
     return
   }

diff  --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_filter_conv2d.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_filter_conv2d.mlir
index 336173ad6c329..52b8400b81acf 100644
--- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_filter_conv2d.mlir
+++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_filter_conv2d.mlir
@@ -68,7 +68,7 @@ module {
     vector.print %v : vector<6x6xi32>
 
     // Release the resources.
-    sparse_tensor.release %sparse_filter : tensor<3x3xi32, #DCSR>
+    bufferization.dealloc_tensor %sparse_filter : tensor<3x3xi32, #DCSR>
 
     return
   }

diff  --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_flatten.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_flatten.mlir
index 9b2095f67f48c..cb79f75cb462b 100644
--- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_flatten.mlir
+++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_flatten.mlir
@@ -104,7 +104,7 @@ module {
 
     // Release the resources.
     memref.dealloc %xdata : memref<7x3xf64>
-    sparse_tensor.release %a : tensor<7x3x3x3x3x3x5x3xf64, #SparseTensor>
+    bufferization.dealloc_tensor %a : tensor<7x3x3x3x3x3x5x3xf64, #SparseTensor>
 
     return
   }

diff  --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_index.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_index.mlir
index 3abc138ed6ec7..b8eee3f4f2882 100644
--- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_index.mlir
+++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_index.mlir
@@ -215,18 +215,18 @@ module {
     vector.print %23 : vector<12xi64>
 
     // Release resources.
-    sparse_tensor.release %sv : tensor<8xi64, #SparseVector>
-    sparse_tensor.release %dv : tensor<8xi64, #SparseVector>
-    sparse_tensor.release %0 : tensor<8xi64, #SparseVector>
-    sparse_tensor.release %1 : tensor<8xi64, #SparseVector>
-    sparse_tensor.release %2 : tensor<8xi64, #SparseVector>
-    sparse_tensor.release %3 : tensor<8xi64, #SparseVector>
-    sparse_tensor.release %sm : tensor<3x4xi64, #SparseMatrix>
-    sparse_tensor.release %dm : tensor<3x4xi64, #SparseMatrix>
-    sparse_tensor.release %4 : tensor<3x4xi64, #SparseMatrix>
-    sparse_tensor.release %5 : tensor<3x4xi64, #SparseMatrix>
-    sparse_tensor.release %6 : tensor<3x4xi64, #SparseMatrix>
-    sparse_tensor.release %7 : tensor<3x4xi64, #SparseMatrix>
+    bufferization.dealloc_tensor %sv : tensor<8xi64, #SparseVector>
+    bufferization.dealloc_tensor %dv : tensor<8xi64, #SparseVector>
+    bufferization.dealloc_tensor %0 : tensor<8xi64, #SparseVector>
+    bufferization.dealloc_tensor %1 : tensor<8xi64, #SparseVector>
+    bufferization.dealloc_tensor %2 : tensor<8xi64, #SparseVector>
+    bufferization.dealloc_tensor %3 : tensor<8xi64, #SparseVector>
+    bufferization.dealloc_tensor %sm : tensor<3x4xi64, #SparseMatrix>
+    bufferization.dealloc_tensor %dm : tensor<3x4xi64, #SparseMatrix>
+    bufferization.dealloc_tensor %4 : tensor<3x4xi64, #SparseMatrix>
+    bufferization.dealloc_tensor %5 : tensor<3x4xi64, #SparseMatrix>
+    bufferization.dealloc_tensor %6 : tensor<3x4xi64, #SparseMatrix>
+    bufferization.dealloc_tensor %7 : tensor<3x4xi64, #SparseMatrix>
 
     //
     // Call the f32 kernel, verify the result, release the resources.
@@ -238,8 +238,8 @@ module {
     %101 = sparse_tensor.values %100 : tensor<2x3xf32, #SparseMatrix> to memref<?xf32>
     %102 = vector.transfer_read %101[%c0], %df: memref<?xf32>, vector<6xf32>
     vector.print %102 : vector<6xf32>
-    sparse_tensor.release %sf32 : tensor<2x3xf32, #SparseMatrix>
-    sparse_tensor.release %100 : tensor<2x3xf32, #SparseMatrix>
+    bufferization.dealloc_tensor %sf32 : tensor<2x3xf32, #SparseMatrix>
+    bufferization.dealloc_tensor %100 : tensor<2x3xf32, #SparseMatrix>
 
     return
   }

diff  --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_index_dense.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_index_dense.mlir
index b0da613a17ce5..6ecfd81859dd5 100644
--- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_index_dense.mlir
+++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_index_dense.mlir
@@ -190,10 +190,10 @@ module {
     vector.print %vv7 : vector<3x4xi64>
 
     // Release resources.
-    sparse_tensor.release %sv : tensor<8xi64, #SparseVector>
-    sparse_tensor.release %dv : tensor<8xi64, #SparseVector>
-    sparse_tensor.release %sm : tensor<3x4xi64, #SparseMatrix>
-    sparse_tensor.release %dm : tensor<3x4xi64, #SparseMatrix>
+    bufferization.dealloc_tensor %sv : tensor<8xi64, #SparseVector>
+    bufferization.dealloc_tensor %dv : tensor<8xi64, #SparseVector>
+    bufferization.dealloc_tensor %sm : tensor<3x4xi64, #SparseMatrix>
+    bufferization.dealloc_tensor %dm : tensor<3x4xi64, #SparseMatrix>
     memref.dealloc %mem0 : memref<8xi64>
     memref.dealloc %mem1 : memref<8xi64>
     memref.dealloc %mem2 : memref<8xi64>

diff  --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_matmul.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_matmul.mlir
index bbe820f8db39c..e77ef4ccf4e7e 100644
--- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_matmul.mlir
+++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_matmul.mlir
@@ -224,20 +224,20 @@ module {
     vector.print %nz8 : vector<8xf64>
 
     // Release the resources.
-    sparse_tensor.release %a1 : tensor<4x8xf64, #CSR>
-    sparse_tensor.release %a2 : tensor<4x8xf64, #DCSR>
-    sparse_tensor.release %a3 : tensor<4x8xf64, #CSR>
-    sparse_tensor.release %a4 : tensor<4x8xf64, #DCSR>
-    sparse_tensor.release %b1 : tensor<8x4xf64, #CSR>
-    sparse_tensor.release %b2 : tensor<8x4xf64, #DCSR>
-    sparse_tensor.release %b3 : tensor<8x4xf64, #CSR>
-    sparse_tensor.release %b4 : tensor<8x4xf64, #DCSR>
-    sparse_tensor.release %1 : tensor<4x4xf64, #CSR>
-    sparse_tensor.release %2 : tensor<4x4xf64, #DCSR>
-    sparse_tensor.release %4 : tensor<4x4xf64, #CSR>
-    sparse_tensor.release %5 : tensor<4x4xf64, #DCSR>
-    sparse_tensor.release %7 : tensor<4x4xf64, #CSR>
-    sparse_tensor.release %8 : tensor<4x4xf64, #DCSR>
+    bufferization.dealloc_tensor %a1 : tensor<4x8xf64, #CSR>
+    bufferization.dealloc_tensor %a2 : tensor<4x8xf64, #DCSR>
+    bufferization.dealloc_tensor %a3 : tensor<4x8xf64, #CSR>
+    bufferization.dealloc_tensor %a4 : tensor<4x8xf64, #DCSR>
+    bufferization.dealloc_tensor %b1 : tensor<8x4xf64, #CSR>
+    bufferization.dealloc_tensor %b2 : tensor<8x4xf64, #DCSR>
+    bufferization.dealloc_tensor %b3 : tensor<8x4xf64, #CSR>
+    bufferization.dealloc_tensor %b4 : tensor<8x4xf64, #DCSR>
+    bufferization.dealloc_tensor %1 : tensor<4x4xf64, #CSR>
+    bufferization.dealloc_tensor %2 : tensor<4x4xf64, #DCSR>
+    bufferization.dealloc_tensor %4 : tensor<4x4xf64, #CSR>
+    bufferization.dealloc_tensor %5 : tensor<4x4xf64, #DCSR>
+    bufferization.dealloc_tensor %7 : tensor<4x4xf64, #CSR>
+    bufferization.dealloc_tensor %8 : tensor<4x4xf64, #DCSR>
 
     return
   }

diff  --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_matrix_ops.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_matrix_ops.mlir
index dabecaec9f7fa..f81024aecf1e8 100644
--- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_matrix_ops.mlir
+++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_matrix_ops.mlir
@@ -158,12 +158,12 @@ module {
     call @dump(%3) : (tensor<?x?xf64, #DCSR>) -> ()
 
     // Release the resources.
-    sparse_tensor.release %sm1 : tensor<?x?xf64, #DCSR>
-    sparse_tensor.release %sm1_dup : tensor<?x?xf64, #DCSR>
-    sparse_tensor.release %sm2 : tensor<?x?xf64, #DCSR>
-    sparse_tensor.release %0 : tensor<?x?xf64, #DCSR>
-    sparse_tensor.release %2 : tensor<?x?xf64, #DCSR>
-    sparse_tensor.release %3 : tensor<?x?xf64, #DCSR>
+    bufferization.dealloc_tensor %sm1 : tensor<?x?xf64, #DCSR>
+    bufferization.dealloc_tensor %sm1_dup : tensor<?x?xf64, #DCSR>
+    bufferization.dealloc_tensor %sm2 : tensor<?x?xf64, #DCSR>
+    bufferization.dealloc_tensor %0 : tensor<?x?xf64, #DCSR>
+    bufferization.dealloc_tensor %2 : tensor<?x?xf64, #DCSR>
+    bufferization.dealloc_tensor %3 : tensor<?x?xf64, #DCSR>
     return
   }
 }

diff  --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_matvec.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_matvec.mlir
index 2bfc58f7cf28f..8c69d7f5106df 100644
--- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_matvec.mlir
+++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_matvec.mlir
@@ -103,7 +103,7 @@ module {
     // Release the resources.
     memref.dealloc %bdata : memref<?xi32>
     memref.dealloc %xdata : memref<?xi32>
-    sparse_tensor.release %a : tensor<?x?xi32, #SparseMatrix>
+    bufferization.dealloc_tensor %a : tensor<?x?xi32, #SparseMatrix>
 
     return
   }

diff  --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_mttkrp.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_mttkrp.mlir
index db49380828a82..f2ffe818aa636 100644
--- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_mttkrp.mlir
+++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_mttkrp.mlir
@@ -135,7 +135,7 @@ module {
     memref.dealloc %adata : memref<?x?xf64>
     memref.dealloc %cdata : memref<?x?xf64>
     memref.dealloc %ddata : memref<?x?xf64>
-    sparse_tensor.release %b : tensor<?x?x?xf64, #SparseTensor>
+    bufferization.dealloc_tensor %b : tensor<?x?x?xf64, #SparseTensor>
 
     return
   }

diff  --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_out_mult_elt.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_out_mult_elt.mlir
index c79d7badd632f..6213bf09e38f8 100644
--- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_out_mult_elt.mlir
+++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_out_mult_elt.mlir
@@ -65,9 +65,9 @@ module {
     vector.print %vv : vector<4xf32>
 
     // Release the resources.
-    sparse_tensor.release %sta : tensor<32x16xf32, #DCSR>
-    sparse_tensor.release %stb : tensor<32x16xf32, #DCSR>
-    sparse_tensor.release %0   : tensor<32x16xf32, #DCSR>
+    bufferization.dealloc_tensor %sta : tensor<32x16xf32, #DCSR>
+    bufferization.dealloc_tensor %stb : tensor<32x16xf32, #DCSR>
+    bufferization.dealloc_tensor %0   : tensor<32x16xf32, #DCSR>
     return
   }
 }

diff  --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_out_reduction.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_out_reduction.mlir
index 9d1960329b0e7..d4abe014ed9d4 100644
--- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_out_reduction.mlir
+++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_out_reduction.mlir
@@ -81,9 +81,9 @@ module {
     vector.print %vm : vector<3x3xi32>
 
     // Release the resources.
-    sparse_tensor.release %st1 : tensor<?x?x?xi32, #SparseTensor>
-    sparse_tensor.release %st2 : tensor<?x?x?xi32, #SparseTensor>
-    sparse_tensor.release %0 : tensor<?x?xi32, #SparseMatrix>
+    bufferization.dealloc_tensor %st1 : tensor<?x?x?xi32, #SparseTensor>
+    bufferization.dealloc_tensor %st2 : tensor<?x?x?xi32, #SparseTensor>
+    bufferization.dealloc_tensor %0 : tensor<?x?xi32, #SparseMatrix>
     return
   }
 }

diff  --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_out_simple.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_out_simple.mlir
index d279f134e1cb4..8bd0133c874de 100644
--- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_out_simple.mlir
+++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_out_simple.mlir
@@ -77,7 +77,7 @@ module {
     vector.print %v : vector<9xf64>
 
     // Release the resources.
-    sparse_tensor.release %x : tensor<?x?xf64, #DCSR>
+    bufferization.dealloc_tensor %x : tensor<?x?xf64, #DCSR>
 
     return
   }

diff  --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_quantized_matmul.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_quantized_matmul.mlir
index fba1c0cb07643..94ab5e4fdfecc 100644
--- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_quantized_matmul.mlir
+++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_quantized_matmul.mlir
@@ -70,7 +70,7 @@ module {
     vector.print %v : vector<5x6xi32>
 
     // Release the resources.
-    sparse_tensor.release %sparse_input2 : tensor<3x6xi8, #DCSR>
+    bufferization.dealloc_tensor %sparse_input2 : tensor<3x6xi8, #DCSR>
 
     return
   }

diff  --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_re_im.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_re_im.mlir
index 76cad83bb8ae3..8a094826ecdf5 100644
--- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_re_im.mlir
+++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_re_im.mlir
@@ -85,9 +85,9 @@ module {
     call @dump(%1) : (tensor<?xf32, #SparseVector>) -> ()
 
     // Release the resources.
-    sparse_tensor.release %sv1 : tensor<?xcomplex<f32>, #SparseVector>
-    sparse_tensor.release %0 : tensor<?xf32, #SparseVector>
-    sparse_tensor.release %1 : tensor<?xf32, #SparseVector>
+    bufferization.dealloc_tensor %sv1 : tensor<?xcomplex<f32>, #SparseVector>
+    bufferization.dealloc_tensor %0 : tensor<?xf32, #SparseVector>
+    bufferization.dealloc_tensor %1 : tensor<?xf32, #SparseVector>
     return
   }
 }

diff  --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_reductions.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_reductions.mlir
index 0ae1f17be0bef..10a1859ee1453 100644
--- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_reductions.mlir
+++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_reductions.mlir
@@ -194,10 +194,10 @@ module {
     call @dump_i32(%6) : (tensor<i32>) -> ()
 
     // Release the resources.
-    sparse_tensor.release %sparse_input_i32 : tensor<32xi32, #SV>
-    sparse_tensor.release %sparse_input_f32 : tensor<32xf32, #SV>
-    sparse_tensor.release %dense_input_i32  : tensor<32xi32, #DV>
-    sparse_tensor.release %dense_input_f32  : tensor<32xf32, #DV>
+    bufferization.dealloc_tensor %sparse_input_i32 : tensor<32xi32, #SV>
+    bufferization.dealloc_tensor %sparse_input_f32 : tensor<32xf32, #SV>
+    bufferization.dealloc_tensor %dense_input_i32  : tensor<32xi32, #DV>
+    bufferization.dealloc_tensor %dense_input_f32  : tensor<32xf32, #DV>
 
     return
   }

diff  --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_reshape.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_reshape.mlir
index be539c3cd7c1b..8c7d4f56a7400 100755
--- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_reshape.mlir
+++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_reshape.mlir
@@ -121,12 +121,12 @@ module {
     vector.print %v3 : vector<16xf64>
 
     // Release sparse resources.
-    sparse_tensor.release %sv : tensor<12xf64, #SparseVector>
-    sparse_tensor.release %sm : tensor<3x4xf64, #SparseMatrix>
-    sparse_tensor.release %expand2 : tensor<3x4xf64, #SparseMatrix>
-    sparse_tensor.release %expand3 : tensor<3x4xf64, #SparseMatrix>
-    sparse_tensor.release %collapse2 : tensor<12xf64, #SparseVector>
-    sparse_tensor.release %collapse3 : tensor<12xf64, #SparseVector>
+    bufferization.dealloc_tensor %sv : tensor<12xf64, #SparseVector>
+    bufferization.dealloc_tensor %sm : tensor<3x4xf64, #SparseMatrix>
+    bufferization.dealloc_tensor %expand2 : tensor<3x4xf64, #SparseMatrix>
+    bufferization.dealloc_tensor %expand3 : tensor<3x4xf64, #SparseMatrix>
+    bufferization.dealloc_tensor %collapse2 : tensor<12xf64, #SparseVector>
+    bufferization.dealloc_tensor %collapse3 : tensor<12xf64, #SparseVector>
 
     // Release dense resources.
     // TODO(springerm): Replace these with a bufferization.release op (operating

diff  --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_sampled_matmul.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_sampled_matmul.mlir
index f43359482f9f7..aef65faa22652 100644
--- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_sampled_matmul.mlir
+++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_sampled_matmul.mlir
@@ -119,7 +119,7 @@ module {
     memref.dealloc %adata : memref<?x?xf32>
     memref.dealloc %bdata : memref<?x?xf32>
     memref.dealloc %xdata : memref<?x?xf32>
-    sparse_tensor.release %s : tensor<?x?xf32, #SparseMatrix>
+    bufferization.dealloc_tensor %s : tensor<?x?xf32, #SparseMatrix>
 
     return
   }

diff  --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_sampled_mm_fusion.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_sampled_mm_fusion.mlir
index ba76b65b49ac6..b280c80348bcb 100755
--- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_sampled_mm_fusion.mlir
+++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_sampled_mm_fusion.mlir
@@ -206,11 +206,11 @@ module {
     vector.print %v3 : vector<4xf64>
 
     // Release the resources.
-    sparse_tensor.release %s : tensor<8x8xf64, #SM>
+    bufferization.dealloc_tensor %s : tensor<8x8xf64, #SM>
     memref.dealloc %m0 : memref<8x8xf64>
     memref.dealloc %m1 : memref<8x8xf64>
-    sparse_tensor.release %2 : tensor<8x8xf64, #SM>
-    sparse_tensor.release %3 : tensor<8x8xf64, #SM>
+    bufferization.dealloc_tensor %2 : tensor<8x8xf64, #SM>
+    bufferization.dealloc_tensor %3 : tensor<8x8xf64, #SM>
 
     return
   }

diff  --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_scale.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_scale.mlir
index 79f7f8417ecfd..56507151dd4a2 100644
--- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_scale.mlir
+++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_scale.mlir
@@ -77,7 +77,7 @@ module {
     vector.print %v : vector<16xf32>
 
     // Release the resources.
-    sparse_tensor.release %1 : tensor<8x8xf32, #CSR>
+    bufferization.dealloc_tensor %1 : tensor<8x8xf32, #CSR>
 
     return
   }

diff  --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_sign.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_sign.mlir
index 8a8a71e576402..a41f31cc8e5c7 100644
--- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_sign.mlir
+++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_sign.mlir
@@ -91,8 +91,8 @@ module {
     vector.print %2 : vector<13xf64>
 
     // Release the resources.
-    sparse_tensor.release %sv1 : tensor<?xf64, #SparseVector>
-    sparse_tensor.release %0 : tensor<?xf64, #SparseVector>
+    bufferization.dealloc_tensor %sv1 : tensor<?xf64, #SparseVector>
+    bufferization.dealloc_tensor %0 : tensor<?xf64, #SparseVector>
     return
   }
 }

diff  --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_spmm.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_spmm.mlir
index f3a7cc9b77738..69af3dbacbff0 100644
--- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_spmm.mlir
+++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_spmm.mlir
@@ -105,7 +105,7 @@ module {
     // Release the resources.
     memref.dealloc %bdata : memref<?x?xf64>
     memref.dealloc %xdata : memref<?x?xf64>
-    sparse_tensor.release %a : tensor<?x?xf64, #SparseMatrix>
+    bufferization.dealloc_tensor %a : tensor<?x?xf64, #SparseMatrix>
 
     return
   }

diff  --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_storage.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_storage.mlir
index 384ad8ed91c42..d5da7c0090a06 100644
--- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_storage.mlir
+++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_storage.mlir
@@ -246,13 +246,13 @@ module {
     vector.print %50 : vector<70xf64>
 
     // Release the resources.
-    sparse_tensor.release %0 : tensor<10x8xf64, #Dense>
-    sparse_tensor.release %1 : tensor<10x8xf64, #CSR>
-    sparse_tensor.release %2 : tensor<10x8xf64, #DCSR>
-    sparse_tensor.release %3 : tensor<10x8xf64, #CSC>
-    sparse_tensor.release %4 : tensor<10x8xf64, #DCSC>
-    sparse_tensor.release %x : tensor<10x8xf64, #BlockRow>
-    sparse_tensor.release %y : tensor<10x8xf64, #BlockCol>
+    bufferization.dealloc_tensor %0 : tensor<10x8xf64, #Dense>
+    bufferization.dealloc_tensor %1 : tensor<10x8xf64, #CSR>
+    bufferization.dealloc_tensor %2 : tensor<10x8xf64, #DCSR>
+    bufferization.dealloc_tensor %3 : tensor<10x8xf64, #CSC>
+    bufferization.dealloc_tensor %4 : tensor<10x8xf64, #DCSC>
+    bufferization.dealloc_tensor %x : tensor<10x8xf64, #BlockRow>
+    bufferization.dealloc_tensor %y : tensor<10x8xf64, #BlockCol>
 
     return
   }

diff  --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_sum.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_sum.mlir
index 0e27da8cdeee4..1c29f8cb47817 100644
--- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_sum.mlir
+++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_sum.mlir
@@ -79,7 +79,7 @@ module {
     vector.print %v : f64
 
     // Release the resources.
-    sparse_tensor.release %a : tensor<?x?xf64, #SparseMatrix>
+    bufferization.dealloc_tensor %a : tensor<?x?xf64, #SparseMatrix>
 
     return
   }

diff  --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_sum_bf16.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_sum_bf16.mlir
index 5863b43ffdd9a..3b09a4603a636 100644
--- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_sum_bf16.mlir
+++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_sum_bf16.mlir
@@ -71,7 +71,7 @@ module {
 
     // Release the resources.
     memref.dealloc %xdata : memref<bf16>
-    sparse_tensor.release %a : tensor<?x?xbf16, #SparseMatrix>
+    bufferization.dealloc_tensor %a : tensor<?x?xbf16, #SparseMatrix>
 
     return
   }

diff  --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_sum_c32.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_sum_c32.mlir
index 793ddefd02751..7e39cc7ca6253 100644
--- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_sum_c32.mlir
+++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_sum_c32.mlir
@@ -77,7 +77,7 @@ module {
     vector.print %imag : f64
 
     // Release the resources.
-    sparse_tensor.release %a : tensor<?x?xcomplex<f64>, #SparseMatrix>
+    bufferization.dealloc_tensor %a : tensor<?x?xcomplex<f64>, #SparseMatrix>
 
     return
   }

diff  --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_sum_f16.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_sum_f16.mlir
index a50f2e0b66617..b5f5a88fd0e5f 100644
--- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_sum_f16.mlir
+++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_sum_f16.mlir
@@ -71,7 +71,7 @@ module {
 
     // Release the resources.
     memref.dealloc %xdata : memref<f16>
-    sparse_tensor.release %a : tensor<?x?xf16, #SparseMatrix>
+    bufferization.dealloc_tensor %a : tensor<?x?xf16, #SparseMatrix>
 
     return
   }

diff  --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_tanh.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_tanh.mlir
index dab12bed7a75b..acc8e8514d0dd 100644
--- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_tanh.mlir
+++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_tanh.mlir
@@ -67,7 +67,7 @@ module {
     call @dump_vec_f64(%0) : (tensor<?xf64, #SparseVector>) -> ()
 
     // Release the resources.
-    sparse_tensor.release %sv1 : tensor<?xf64, #SparseVector>
+    bufferization.dealloc_tensor %sv1 : tensor<?xf64, #SparseVector>
     return
   }
 }

diff  --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_tensor_mul.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_tensor_mul.mlir
index 34807b439b831..fa8eb3ed36ba4 100644
--- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_tensor_mul.mlir
+++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_tensor_mul.mlir
@@ -94,9 +94,9 @@ module {
     vector.print %v2 : vector<3x3x5xf64>
 
     // Release the resources.
-    sparse_tensor.release %sta : tensor<?x?x?xf64, #ST>
-    sparse_tensor.release %stb : tensor<?x?x?xf64, #ST>
-    sparse_tensor.release %0  : tensor<?x?x?xf64, #ST>
+    bufferization.dealloc_tensor %sta : tensor<?x?x?xf64, #ST>
+    bufferization.dealloc_tensor %stb : tensor<?x?x?xf64, #ST>
+    bufferization.dealloc_tensor %0  : tensor<?x?x?xf64, #ST>
     return
   }
 }

diff  --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_tensor_ops.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_tensor_ops.mlir
index bd528bd56f34b..d3807226fa9f7 100644
--- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_tensor_ops.mlir
+++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_tensor_ops.mlir
@@ -76,8 +76,8 @@ module {
     vector.print %v2 : vector<32xf64>
 
     // Release the resources.
-    sparse_tensor.release %st : tensor<?x?x?xf64, #ST1>
-    sparse_tensor.release %0  : tensor<?x?x?xf64, #ST2>
+    bufferization.dealloc_tensor %st : tensor<?x?x?xf64, #ST1>
+    bufferization.dealloc_tensor %0  : tensor<?x?x?xf64, #ST2>
     return
   }
 }

diff  --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_transpose.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_transpose.mlir
index 4ce6f1cabfbab..b0fc6316e30d8 100644
--- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_transpose.mlir
+++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_transpose.mlir
@@ -42,7 +42,7 @@ module {
          linalg.yield %a : f64
     } -> tensor<4x3xf64, #DCSR>
 
-    sparse_tensor.release %t : tensor<3x4xf64, #DCSC>
+    bufferization.dealloc_tensor %t : tensor<3x4xf64, #DCSC>
 
     return %0 : tensor<4x3xf64, #DCSR>
   }
@@ -111,9 +111,9 @@ module {
     }
 
     // Release resources.
-    sparse_tensor.release %a : tensor<3x4xf64, #DCSR>
-    sparse_tensor.release %0 : tensor<4x3xf64, #DCSR>
-    sparse_tensor.release %1 : tensor<4x3xf64, #DCSR>
+    bufferization.dealloc_tensor %a : tensor<3x4xf64, #DCSR>
+    bufferization.dealloc_tensor %0 : tensor<4x3xf64, #DCSR>
+    bufferization.dealloc_tensor %1 : tensor<4x3xf64, #DCSR>
 
     return
   }

diff  --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_unary.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_unary.mlir
index 607cb238f6636..0eba82662f82d 100644
--- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_unary.mlir
+++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_unary.mlir
@@ -255,13 +255,13 @@ module {
     call @dump_mat(%4) : (tensor<?x?xf64, #DCSR>) -> ()
 
     // Release the resources.
-    sparse_tensor.release %sv1 : tensor<?xf64, #SparseVector>
-    sparse_tensor.release %sm1 : tensor<?x?xf64, #DCSR>
-    sparse_tensor.release %0 : tensor<?xi32, #SparseVector>
-    sparse_tensor.release %1 : tensor<?xf64, #SparseVector>
-    sparse_tensor.release %2 : tensor<?xf64, #SparseVector>
-    sparse_tensor.release %3 : tensor<?x?xf64, #DCSR>
-    sparse_tensor.release %4 : tensor<?x?xf64, #DCSR>
+    bufferization.dealloc_tensor %sv1 : tensor<?xf64, #SparseVector>
+    bufferization.dealloc_tensor %sm1 : tensor<?x?xf64, #DCSR>
+    bufferization.dealloc_tensor %0 : tensor<?xi32, #SparseVector>
+    bufferization.dealloc_tensor %1 : tensor<?xf64, #SparseVector>
+    bufferization.dealloc_tensor %2 : tensor<?xf64, #SparseVector>
+    bufferization.dealloc_tensor %3 : tensor<?x?xf64, #DCSR>
+    bufferization.dealloc_tensor %4 : tensor<?x?xf64, #DCSR>
     return
   }
 }

diff  --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_vector_ops.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_vector_ops.mlir
index eef2a0d146c54..28da832102809 100644
--- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_vector_ops.mlir
+++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_vector_ops.mlir
@@ -224,13 +224,13 @@ module {
     vector.print %v5 : f64
 
     // Release the resources.
-    sparse_tensor.release %sv1 : tensor<?xf64, #SparseVector>
-    sparse_tensor.release %sv1_dup : tensor<?xf64, #SparseVector>
-    sparse_tensor.release %sv2 : tensor<?xf64, #SparseVector>
-    sparse_tensor.release %0 : tensor<?xf64, #SparseVector>
-    sparse_tensor.release %2 : tensor<?xf64, #SparseVector>
-    sparse_tensor.release %3 : tensor<?xf64, #SparseVector>
-    sparse_tensor.release %4 : tensor<?xf64, #DenseVector>
+    bufferization.dealloc_tensor %sv1 : tensor<?xf64, #SparseVector>
+    bufferization.dealloc_tensor %sv1_dup : tensor<?xf64, #SparseVector>
+    bufferization.dealloc_tensor %sv2 : tensor<?xf64, #SparseVector>
+    bufferization.dealloc_tensor %0 : tensor<?xf64, #SparseVector>
+    bufferization.dealloc_tensor %2 : tensor<?xf64, #SparseVector>
+    bufferization.dealloc_tensor %3 : tensor<?xf64, #SparseVector>
+    bufferization.dealloc_tensor %4 : tensor<?xf64, #DenseVector>
     return
   }
 }

diff  --git a/mlir/test/Integration/Dialect/SparseTensor/python/test_stress.py b/mlir/test/Integration/Dialect/SparseTensor/python/test_stress.py
index bdb36625af19c..a030643dcc18b 100644
--- a/mlir/test/Integration/Dialect/SparseTensor/python/test_stress.py
+++ b/mlir/test/Integration/Dialect/SparseTensor/python/test_stress.py
@@ -14,6 +14,7 @@
 from mlir import ir
 from mlir import runtime as rt
 
+from mlir.dialects import bufferization
 from mlir.dialects import builtin
 from mlir.dialects import func
 from mlir.dialects import sparse_tensor as st
@@ -118,7 +119,7 @@ def build(self, types: List[ir.Type]):
         for tp in types:
           w = st.ConvertOp(tp, v)
           # Release intermediate tensors before they fall out of scope.
-          st.ReleaseOp(v.result)
+          bufferization.DeallocTensorOp(v.result)
           v = w
         self._assertEqualsRoundtripTp(v.result.type)
         func.ReturnOp(v)


        


More information about the Mlir-commits mailing list