diff --git a/mlir/include/mlir/Dialect/Bufferization/IR/BufferizationOps.td b/mlir/include/mlir/Dialect/Bufferization/IR/BufferizationOps.td --- a/mlir/include/mlir/Dialect/Bufferization/IR/BufferizationOps.td +++ b/mlir/include/mlir/Dialect/Bufferization/IR/BufferizationOps.td @@ -186,6 +186,64 @@ 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 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 --- a/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorOps.td +++ b/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorOps.td @@ -306,31 +306,6 @@ 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 --- a/mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp +++ b/mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp @@ -524,6 +524,21 @@ results.add(context); } +//===----------------------------------------------------------------------===// +// DeallocTensorOp +//===----------------------------------------------------------------------===// + +LogicalResult DeallocTensorOp::bufferize(RewriterBase &rewriter, + const BufferizationOptions &options) { + FailureOr 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 --- a/mlir/lib/Dialect/SparseTensor/Transforms/BufferizableOpInterfaceImpl.cpp +++ b/mlir/lib/Dialect/SparseTensor/Transforms/BufferizableOpInterfaceImpl.cpp @@ -94,25 +94,6 @@ } }; -struct ReleaseOpInterface - : public BufferizableOpInterface::ExternalModel { - 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 getAliasingOpResult(Operation *op, OpOperand &opOperand, - const AnalysisState &state) const { - return {}; - } -}; - } // namespace } // namespace sparse_tensor } // namespace mlir @@ -124,6 +105,5 @@ sparse_tensor::ConvertOp::attachInterface(*ctx); sparse_tensor::LoadOp::attachInterface(*ctx); sparse_tensor::NewOp::attachInterface(*ctx); - sparse_tensor::ReleaseOp::attachInterface(*ctx); }); } diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp --- a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp +++ b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp @@ -870,13 +870,17 @@ SparseTensorConversionOptions options; }; -/// Sparse conversion rule for the release operator. -class SparseTensorReleaseConverter : public OpConversionPattern { +/// Sparse conversion rule for the dealloc operator. +class SparseTensorDeallocConverter + : public OpConversionPattern { 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(), @@ -1102,7 +1106,7 @@ SparseCastConverter, SparseTensorNewConverter, SparseReshapeConverter, SparseReshapeConverter, - 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 --- a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorPasses.cpp +++ b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorPasses.cpp @@ -125,6 +125,10 @@ [&](bufferization::AllocTensorOp op) { return converter.isLegal(op.getType()); }); + target.addDynamicallyLegalOp( + [&](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::AllocTensorOp op) { // Dense tensors are legal, sparse tensors are not. - return !static_cast(op.getType().getEncoding()); + return !getSparseTensorEncoding(op.getType()); + }); + target.addDynamicallyLegalOp( + [&](bufferization::DeallocTensorOp op) { + // Dense tensors are legal, sparse tensors are not. + return !getSparseTensorEncoding(op.getTensor().getType()); }); // Translate strategy flags to strategy options. SparseTensorConversionOptions options( diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp --- a/mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp +++ b/mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp @@ -1790,7 +1790,7 @@ auto convert = rewriter.create(tval.getLoc(), dstTp, tval); op->setOperand(tensor, convert); rewriter.setInsertionPointAfter(op); - rewriter.create(tval.getLoc(), convert); + rewriter.create(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 --- a/mlir/test/Dialect/Bufferization/ops.mlir +++ b/mlir/test/Dialect/Bufferization/ops.mlir @@ -41,3 +41,10 @@ %5 = bufferization.alloc_tensor() copy(%t) {escape = false} : tensor return %1 : tensor } + +// 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 --- a/mlir/test/Dialect/SparseTensor/conversion.mlir +++ b/mlir/test/Dialect/SparseTensor/conversion.mlir @@ -145,7 +145,7 @@ // CHECK: call @delSparseTensor(%[[A]]) : (!llvm.ptr) -> () // 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 --- a/mlir/test/Dialect/SparseTensor/invalid.mlir +++ b/mlir/test/Dialect/SparseTensor/invalid.mlir @@ -8,14 +8,6 @@ // ----- -func.func @invalid_release_dense(%arg0: tensor<4xi32>) { - // expected-error@+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 { %c = arith.constant 0 : index // expected-error@+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 --- a/mlir/test/Dialect/SparseTensor/roundtrip.mlir +++ b/mlir/test/Dialect/SparseTensor/roundtrip.mlir @@ -15,12 +15,12 @@ #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 --- 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 --- a/mlir/test/Integration/Dialect/SparseTensor/CPU/dense_output.mlir +++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/dense_output.mlir @@ -88,8 +88,8 @@ vector.print %v : vector<25xf64> // Release the resources. - sparse_tensor.release %a : tensor - sparse_tensor.release %0 : tensor + bufferization.dealloc_tensor %a : tensor + bufferization.dealloc_tensor %0 : tensor 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 --- 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 @@ call @dump_vec(%0) : (tensor) -> () // Release the resources. - sparse_tensor.release %sv1 : tensor - sparse_tensor.release %sv2 : tensor - sparse_tensor.release %0 : tensor + bufferization.dealloc_tensor %sv1 : tensor + bufferization.dealloc_tensor %sv2 : tensor + bufferization.dealloc_tensor %0 : tensor 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 --- 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 @@ call @dump_vec(%0) : (tensor) -> () // Release the resources. - sparse_tensor.release %sv1 : tensor - sparse_tensor.release %sv2 : tensor - sparse_tensor.release %0 : tensor + bufferization.dealloc_tensor %sv1 : tensor + bufferization.dealloc_tensor %sv2 : tensor + bufferization.dealloc_tensor %0 : tensor return } } diff --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_binary.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_binary.mlir --- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_binary.mlir +++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_binary.mlir @@ -531,23 +531,23 @@ call @dump_mat_4x4(%11) : (tensor<4x4xf64, #DCSR>) -> () // Release the resources. - sparse_tensor.release %sv1 : tensor - sparse_tensor.release %sv2 : tensor - sparse_tensor.release %sm1 : tensor - sparse_tensor.release %sm2 : tensor - sparse_tensor.release %sm3 : tensor<4x4xf64, #DCSR> - sparse_tensor.release %sm4 : tensor<4x4xf64, #DCSR> - sparse_tensor.release %0 : tensor - sparse_tensor.release %1 : tensor - sparse_tensor.release %2 : tensor - sparse_tensor.release %3 : tensor - sparse_tensor.release %5 : tensor - 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 + bufferization.dealloc_tensor %sv2 : tensor + bufferization.dealloc_tensor %sm1 : tensor + bufferization.dealloc_tensor %sm2 : tensor + bufferization.dealloc_tensor %sm3 : tensor<4x4xf64, #DCSR> + bufferization.dealloc_tensor %sm4 : tensor<4x4xf64, #DCSR> + bufferization.dealloc_tensor %0 : tensor + bufferization.dealloc_tensor %1 : tensor + bufferization.dealloc_tensor %2 : tensor + bufferization.dealloc_tensor %3 : tensor + bufferization.dealloc_tensor %5 : tensor + 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 --- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_cast.mlir +++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_cast.mlir @@ -257,10 +257,10 @@ 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 --- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_complex32.mlir +++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_complex32.mlir @@ -107,10 +107,10 @@ call @dump(%1, %d2) : (tensor, #SparseVector>, index) -> () // Release the resources. - sparse_tensor.release %sv1 : tensor, #SparseVector> - sparse_tensor.release %sv2 : tensor, #SparseVector> - sparse_tensor.release %0 : tensor, #SparseVector> - sparse_tensor.release %1 : tensor, #SparseVector> + bufferization.dealloc_tensor %sv1 : tensor, #SparseVector> + bufferization.dealloc_tensor %sv2 : tensor, #SparseVector> + bufferization.dealloc_tensor %0 : tensor, #SparseVector> + bufferization.dealloc_tensor %1 : tensor, #SparseVector> return } } diff --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_complex64.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_complex64.mlir --- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_complex64.mlir +++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_complex64.mlir @@ -107,10 +107,10 @@ call @dump(%1, %d2) : (tensor, #SparseVector>, index) -> () // Release the resources. - sparse_tensor.release %sv1 : tensor, #SparseVector> - sparse_tensor.release %sv2 : tensor, #SparseVector> - sparse_tensor.release %0 : tensor, #SparseVector> - sparse_tensor.release %1 : tensor, #SparseVector> + bufferization.dealloc_tensor %sv1 : tensor, #SparseVector> + bufferization.dealloc_tensor %sv2 : tensor, #SparseVector> + bufferization.dealloc_tensor %0 : tensor, #SparseVector> + bufferization.dealloc_tensor %1 : tensor, #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 --- 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 @@ call @dumpf(%6) : (tensor) -> () // Release the resources. - sparse_tensor.release %sv1 : tensor, #SparseVector> - sparse_tensor.release %sv2 : tensor, #SparseVector> - sparse_tensor.release %0 : tensor, #SparseVector> - sparse_tensor.release %1 : tensor, #SparseVector> - sparse_tensor.release %2 : tensor, #SparseVector> - sparse_tensor.release %3 : tensor, #SparseVector> - sparse_tensor.release %4 : tensor, #SparseVector> - sparse_tensor.release %5 : tensor, #SparseVector> - sparse_tensor.release %6 : tensor + bufferization.dealloc_tensor %sv1 : tensor, #SparseVector> + bufferization.dealloc_tensor %sv2 : tensor, #SparseVector> + bufferization.dealloc_tensor %0 : tensor, #SparseVector> + bufferization.dealloc_tensor %1 : tensor, #SparseVector> + bufferization.dealloc_tensor %2 : tensor, #SparseVector> + bufferization.dealloc_tensor %3 : tensor, #SparseVector> + bufferization.dealloc_tensor %4 : tensor, #SparseVector> + bufferization.dealloc_tensor %5 : tensor, #SparseVector> + bufferization.dealloc_tensor %6 : tensor 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 --- 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 @@ 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 --- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_conversion.mlir +++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_conversion.mlir @@ -249,15 +249,15 @@ call @dumpidx(%i32) : (memref) -> () // 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 --- 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 @@ call @dump(%m6) : (memref) -> () // Release the resources. - sparse_tensor.release %1 : tensor - sparse_tensor.release %2 : tensor - sparse_tensor.release %3 : tensor - sparse_tensor.release %4 : tensor - sparse_tensor.release %5 : tensor - sparse_tensor.release %6 : tensor + bufferization.dealloc_tensor %1 : tensor + bufferization.dealloc_tensor %2 : tensor + bufferization.dealloc_tensor %3 : tensor + bufferization.dealloc_tensor %4 : tensor + bufferization.dealloc_tensor %5 : tensor + bufferization.dealloc_tensor %6 : tensor 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 --- 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 @@ call @dumpi08(%i6) : (memref) -> () // 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 --- 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 @@ // // 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 - sparse_tensor.release %sp345 : tensor - sparse_tensor.release %sp346 : tensor - 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 + bufferization.dealloc_tensor %sp345 : tensor + bufferization.dealloc_tensor %sp346 : tensor + 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 --- 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 @@ // // 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 --- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_dot.mlir +++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_dot.mlir @@ -47,8 +47,8 @@ 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 --- 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 @@ 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 --- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_flatten.mlir +++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_flatten.mlir @@ -104,7 +104,7 @@ // 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 --- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_index.mlir +++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_index.mlir @@ -215,18 +215,18 @@ 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 @@ %101 = sparse_tensor.values %100 : tensor<2x3xf32, #SparseMatrix> to memref %102 = vector.transfer_read %101[%c0], %df: memref, 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 --- 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 @@ 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 --- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_matmul.mlir +++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_matmul.mlir @@ -224,20 +224,20 @@ 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 --- 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 @@ call @dump(%3) : (tensor) -> () // Release the resources. - sparse_tensor.release %sm1 : tensor - sparse_tensor.release %sm1_dup : tensor - sparse_tensor.release %sm2 : tensor - sparse_tensor.release %0 : tensor - sparse_tensor.release %2 : tensor - sparse_tensor.release %3 : tensor + bufferization.dealloc_tensor %sm1 : tensor + bufferization.dealloc_tensor %sm1_dup : tensor + bufferization.dealloc_tensor %sm2 : tensor + bufferization.dealloc_tensor %0 : tensor + bufferization.dealloc_tensor %2 : tensor + bufferization.dealloc_tensor %3 : tensor return } } diff --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_matvec.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_matvec.mlir --- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_matvec.mlir +++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_matvec.mlir @@ -103,7 +103,7 @@ // Release the resources. memref.dealloc %bdata : memref memref.dealloc %xdata : memref - sparse_tensor.release %a : tensor + bufferization.dealloc_tensor %a : tensor return } diff --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_mttkrp.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_mttkrp.mlir --- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_mttkrp.mlir +++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_mttkrp.mlir @@ -135,7 +135,7 @@ memref.dealloc %adata : memref memref.dealloc %cdata : memref memref.dealloc %ddata : memref - sparse_tensor.release %b : tensor + bufferization.dealloc_tensor %b : tensor 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 --- 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 @@ 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 --- 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 @@ vector.print %vm : vector<3x3xi32> // Release the resources. - sparse_tensor.release %st1 : tensor - sparse_tensor.release %st2 : tensor - sparse_tensor.release %0 : tensor + bufferization.dealloc_tensor %st1 : tensor + bufferization.dealloc_tensor %st2 : tensor + bufferization.dealloc_tensor %0 : tensor 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 --- 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 @@ vector.print %v : vector<9xf64> // Release the resources. - sparse_tensor.release %x : tensor + bufferization.dealloc_tensor %x : tensor 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 --- 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 @@ 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 --- 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 @@ call @dump(%1) : (tensor) -> () // Release the resources. - sparse_tensor.release %sv1 : tensor, #SparseVector> - sparse_tensor.release %0 : tensor - sparse_tensor.release %1 : tensor + bufferization.dealloc_tensor %sv1 : tensor, #SparseVector> + bufferization.dealloc_tensor %0 : tensor + bufferization.dealloc_tensor %1 : tensor return } } diff --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_reductions.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_reductions.mlir --- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_reductions.mlir +++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_reductions.mlir @@ -194,10 +194,10 @@ call @dump_i32(%6) : (tensor) -> () // 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 --- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_reshape.mlir +++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_reshape.mlir @@ -121,12 +121,12 @@ 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 --- 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 @@ memref.dealloc %adata : memref memref.dealloc %bdata : memref memref.dealloc %xdata : memref - sparse_tensor.release %s : tensor + bufferization.dealloc_tensor %s : tensor 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 --- 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 @@ 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 --- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_scale.mlir +++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_scale.mlir @@ -77,7 +77,7 @@ 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 --- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_sign.mlir +++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_sign.mlir @@ -91,8 +91,8 @@ vector.print %2 : vector<13xf64> // Release the resources. - sparse_tensor.release %sv1 : tensor - sparse_tensor.release %0 : tensor + bufferization.dealloc_tensor %sv1 : tensor + bufferization.dealloc_tensor %0 : tensor return } } diff --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_spmm.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_spmm.mlir --- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_spmm.mlir +++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_spmm.mlir @@ -105,7 +105,7 @@ // Release the resources. memref.dealloc %bdata : memref memref.dealloc %xdata : memref - sparse_tensor.release %a : tensor + bufferization.dealloc_tensor %a : tensor return } diff --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_storage.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_storage.mlir --- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_storage.mlir +++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_storage.mlir @@ -246,13 +246,13 @@ 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 --- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_sum.mlir +++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_sum.mlir @@ -79,7 +79,7 @@ vector.print %v : f64 // Release the resources. - sparse_tensor.release %a : tensor + bufferization.dealloc_tensor %a : tensor 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 --- 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 @@ // Release the resources. memref.dealloc %xdata : memref - sparse_tensor.release %a : tensor + bufferization.dealloc_tensor %a : tensor 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 --- 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 @@ vector.print %imag : f64 // Release the resources. - sparse_tensor.release %a : tensor, #SparseMatrix> + bufferization.dealloc_tensor %a : tensor, #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 --- 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 @@ // Release the resources. memref.dealloc %xdata : memref - sparse_tensor.release %a : tensor + bufferization.dealloc_tensor %a : tensor return } diff --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_tanh.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_tanh.mlir --- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_tanh.mlir +++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_tanh.mlir @@ -67,7 +67,7 @@ call @dump_vec_f64(%0) : (tensor) -> () // Release the resources. - sparse_tensor.release %sv1 : tensor + bufferization.dealloc_tensor %sv1 : tensor 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 --- 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 @@ vector.print %v2 : vector<32xf64> // Release the resources. - sparse_tensor.release %st : tensor - sparse_tensor.release %0 : tensor + bufferization.dealloc_tensor %st : tensor + bufferization.dealloc_tensor %0 : tensor return } } diff --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_transpose.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_transpose.mlir --- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_transpose.mlir +++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_transpose.mlir @@ -42,7 +42,7 @@ 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 @@ } // 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 --- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_unary.mlir +++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_unary.mlir @@ -255,13 +255,13 @@ call @dump_mat(%4) : (tensor) -> () // Release the resources. - sparse_tensor.release %sv1 : tensor - sparse_tensor.release %sm1 : tensor - sparse_tensor.release %0 : tensor - sparse_tensor.release %1 : tensor - sparse_tensor.release %2 : tensor - sparse_tensor.release %3 : tensor - sparse_tensor.release %4 : tensor + bufferization.dealloc_tensor %sv1 : tensor + bufferization.dealloc_tensor %sm1 : tensor + bufferization.dealloc_tensor %0 : tensor + bufferization.dealloc_tensor %1 : tensor + bufferization.dealloc_tensor %2 : tensor + bufferization.dealloc_tensor %3 : tensor + bufferization.dealloc_tensor %4 : tensor 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 --- 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 @@ vector.print %v5 : f64 // Release the resources. - sparse_tensor.release %sv1 : tensor - sparse_tensor.release %sv1_dup : tensor - sparse_tensor.release %sv2 : tensor - sparse_tensor.release %0 : tensor - sparse_tensor.release %2 : tensor - sparse_tensor.release %3 : tensor - sparse_tensor.release %4 : tensor + bufferization.dealloc_tensor %sv1 : tensor + bufferization.dealloc_tensor %sv1_dup : tensor + bufferization.dealloc_tensor %sv2 : tensor + bufferization.dealloc_tensor %0 : tensor + bufferization.dealloc_tensor %2 : tensor + bufferization.dealloc_tensor %3 : tensor + bufferization.dealloc_tensor %4 : tensor return } } diff --git a/mlir/test/Integration/Dialect/SparseTensor/python/test_stress.py b/mlir/test/Integration/Dialect/SparseTensor/python/test_stress.py --- 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 @@ 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)