diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp index 4419c39c69927..8a0ec1c149283 100644 --- a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp +++ b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp @@ -705,6 +705,7 @@ class SparseCastConverter : public OpConversionPattern { }; /// Sparse codegen rule for the alloc operator. +/// TODO(springerm): remove when bufferization.alloc_tensor is gone class SparseTensorAllocConverter : public OpConversionPattern { public: @@ -764,6 +765,46 @@ class SparseTensorAllocConverter bool enableBufferInitialization; }; +/// Sparse codegen rule for the empty tensor operator. +/// TODO(springerm): remove when bufferization.alloc_tensor is gone +class SparseTensorEmptyConverter : public OpConversionPattern { +public: + using OpConversionPattern::OpConversionPattern; + SparseTensorEmptyConverter(TypeConverter &typeConverter, MLIRContext *context, + bool enableInit) + : OpConversionPattern(typeConverter, context), + enableBufferInitialization(enableInit) {} + + LogicalResult + matchAndRewrite(tensor::EmptyOp op, OpAdaptor adaptor, + ConversionPatternRewriter &rewriter) const override { + const auto resType = getSparseTensorType(op); + if (!resType.hasEncoding()) + return failure(); + + // Construct allocation for each field. + const Location loc = op.getLoc(); + const Value sizeHint; // none + const ValueRange dynSizes = adaptor.getDynamicSizes(); + const size_t found = dynSizes.size(); + const int64_t expected = resType.getNumDynamicDims(); + if (found != static_cast(expected)) + return rewriter.notifyMatchFailure( + op, llvm::formatv( + "Got wrong number of dynamic sizes: Found={0}, Expected={1}", + found, expected)); + SmallVector fields; + createAllocFields(rewriter, loc, resType, dynSizes, + enableBufferInitialization, fields, sizeHint); + // Replace operation with resulting memrefs. + rewriter.replaceOp(op, genTuple(rewriter, loc, resType, fields)); + return success(); + } + +private: + bool enableBufferInitialization; +}; + /// Sparse codegen rule for the dealloc operator. class SparseTensorDeallocConverter : public OpConversionPattern { @@ -1546,6 +1587,6 @@ void mlir::populateSparseTensorCodegenPatterns( patterns.getContext()); patterns.add( typeConverter, patterns.getContext(), createSparseDeallocs); - patterns.add(typeConverter, patterns.getContext(), - enableBufferInitialization); + patterns.add( + typeConverter, patterns.getContext(), enableBufferInitialization); } diff --git a/mlir/test/Dialect/SparseTensor/GPU/gpu_spgemm_lib.mlir b/mlir/test/Dialect/SparseTensor/GPU/gpu_spgemm_lib.mlir index 1bb51f4fcf518..147e8132c92e4 100644 --- a/mlir/test/Dialect/SparseTensor/GPU/gpu_spgemm_lib.mlir +++ b/mlir/test/Dialect/SparseTensor/GPU/gpu_spgemm_lib.mlir @@ -9,7 +9,6 @@ // CHECK: %[[VAL_2:.*]] = arith.constant 8 : index // CHECK: %[[VAL_3:.*]] = arith.constant 0 : index // CHECK: %[[VAL_4:.*]] = arith.constant 9 : index -// CHECK: %[[VAL_5:.*]] = bufferization.alloc_tensor() : tensor<8x8xf32, #{{.*}}> // CHECK: %[[VAL_6:.*]] = sparse_tensor.number_of_entries %[[VAL_0]] : tensor<8x8xf32, #{{.*}}> // CHECK: %[[VAL_7:.*]] = sparse_tensor.number_of_entries %[[VAL_1]] : tensor<8x8xf32, #{{.*}}> // CHECK: %[[VAL_8:.*]] = sparse_tensor.positions %[[VAL_0]] {level = 1 : index} : tensor<8x8xf32, #{{.*}}> @@ -92,7 +91,7 @@ // CHECK: } func.func @matmulCSR(%A: tensor<8x8xf32, #CSR>, %B: tensor<8x8xf32, #CSR>) -> tensor<8x8xf32, #CSR> { - %init = bufferization.alloc_tensor() : tensor<8x8xf32, #CSR> + %init = tensor.empty() : tensor<8x8xf32, #CSR> %C = linalg.matmul ins(%A, %B: tensor<8x8xf32, #CSR>, tensor<8x8xf32, #CSR>) diff --git a/mlir/test/Dialect/SparseTensor/codegen.mlir b/mlir/test/Dialect/SparseTensor/codegen.mlir index ea11a98b76ec6..67a80640e3b4a 100644 --- a/mlir/test/Dialect/SparseTensor/codegen.mlir +++ b/mlir/test/Dialect/SparseTensor/codegen.mlir @@ -329,7 +329,7 @@ func.func @sparse_dealloc_csr(%arg0: tensor) { // CHECK: %[[A26:.*]] = sparse_tensor.storage_specifier.set %[[A18]] pos_mem_sz at 1 with %[[A25]] : !sparse_tensor.storage_specifier // CHECK: return %[[A23]], %[[A6]], %[[A8]], %[[A26]] : memref, memref, memref, !sparse_tensor.storage_specifier func.func @sparse_alloc_csc(%arg0: index) -> tensor<10x?xf64, #CSC> { - %0 = bufferization.alloc_tensor(%arg0) : tensor<10x?xf64, #CSC> + %0 = tensor.empty(%arg0) : tensor<10x?xf64, #CSC> %1 = sparse_tensor.load %0 : tensor<10x?xf64, #CSC> return %1 : tensor<10x?xf64, #CSC> } @@ -351,24 +351,11 @@ func.func @sparse_alloc_csc(%arg0: index) -> tensor<10x?xf64, #CSC> { // CHECK: %[[A16:.*]] = sparse_tensor.storage_specifier.set %[[A10]] val_mem_sz with %[[A14]] : !sparse_tensor.storage_specifier // CHECK: return %[[A15]], %[[A16]] : memref, !sparse_tensor.storage_specifier func.func @sparse_alloc_3d() -> tensor<10x20x30xf64, #Dense3D> { - %0 = bufferization.alloc_tensor() : tensor<10x20x30xf64, #Dense3D> + %0 = tensor.empty() : tensor<10x20x30xf64, #Dense3D> %1 = sparse_tensor.load %0 : tensor<10x20x30xf64, #Dense3D> return %1 : tensor<10x20x30xf64, #Dense3D> } -// CHECK-LABEL: func.func @sparse_alloc_coo_with_size_hint( -// CHECK-SAME: %[[HINT:.*]]: index) -// CHECK: %[[C2:.*]] = arith.constant 2 : index -// CHECK: %[[M2:.*]] = arith.muli %[[HINT]], %c2 : index -// CHECK: %[[A1:.*]] = memref.alloc() : memref<2xindex> -// CHECK: %[[A2:.*]] = memref.alloc(%[[M2]]) : memref -// CHECK: %[[A3:.*]] = memref.alloc(%[[HINT]]) : memref -func.func @sparse_alloc_coo_with_size_hint(%arg0: index) -> tensor<10x20xf64, #Coo> { - %0 = bufferization.alloc_tensor() size_hint=%arg0 : tensor<10x20xf64, #Coo> - %1 = sparse_tensor.load %0 : tensor<10x20xf64, #Coo> - return %1 : tensor<10x20xf64, #Coo> -} - // CHECK-LABEL: func.func @sparse_expansion1() // CHECK: %[[A:.*]] = memref.alloc() : memref<8xf64> // CHECK: %[[B:.*]] = memref.alloc() : memref<8xi1> @@ -378,7 +365,7 @@ func.func @sparse_alloc_coo_with_size_hint(%arg0: index) -> tensor<10x20xf64, #C // CHECK-DAG: linalg.fill ins(%{{.*}} : i1) outs(%[[B]] : memref<8xi1>) // CHECK: return %[[D]] : memref func.func @sparse_expansion1() -> memref { - %0 = bufferization.alloc_tensor() : tensor<4x8xf64, #CSR> + %0 = tensor.empty() : tensor<4x8xf64, #CSR> %values, %filled, %added, %count = sparse_tensor.expand %0 : tensor<4x8xf64, #CSR> to memref, memref, memref return %added : memref @@ -393,7 +380,7 @@ func.func @sparse_expansion1() -> memref { // CHECK-DAG: linalg.fill ins(%{{.*}} : i1) outs(%[[B]] : memref<4xi1>) // CHECK: return %[[D]] : memref func.func @sparse_expansion2() -> memref { - %0 = bufferization.alloc_tensor() : tensor<4x8xf64, #CSC> + %0 = tensor.empty() : tensor<4x8xf64, #CSC> %values, %filled, %added, %count = sparse_tensor.expand %0 : tensor<4x8xf64, #CSC> to memref, memref, memref return %added : memref @@ -409,7 +396,7 @@ func.func @sparse_expansion2() -> memref { // CHECK: linalg.fill ins(%{{.*}} : i1) outs(%[[B]] : memref) // CHECK: return %[[D]] : memref func.func @sparse_expansion3(%arg0: index, %arg1: index) -> memref { - %0 = bufferization.alloc_tensor(%arg0, %arg1) : tensor + %0 = tensor.empty(%arg0, %arg1) : tensor %values, %filled, %added, %count = sparse_tensor.expand %0 : tensor to memref, memref, memref return %added : memref diff --git a/mlir/test/Dialect/SparseTensor/codegen_buffer_initialization.mlir b/mlir/test/Dialect/SparseTensor/codegen_buffer_initialization.mlir index 640d0f56a0f94..14a8f0e43d35a 100644 --- a/mlir/test/Dialect/SparseTensor/codegen_buffer_initialization.mlir +++ b/mlir/test/Dialect/SparseTensor/codegen_buffer_initialization.mlir @@ -2,7 +2,7 @@ #SV = #sparse_tensor.encoding<{ map = (d0) -> (d0 : compressed) }> -// CHECK-LABEL: func.func @sparse_alloc_sparse_vector( +// CHECK-LABEL: func.func @empty_sparse_vector( // CHECK-SAME: %[[VAL_0:.*]]: index) -> (memref, memref, memref, !sparse_tensor.storage_specifier // CHECK: %[[VAL_1:.*]] = arith.constant 1 : index // CHECK: %[[VAL_2:.*]] = arith.constant 0.000000e+00 : f64 @@ -24,8 +24,8 @@ // CHECK: %[[VAL_19:.*]], %[[VAL_21:.*]] = sparse_tensor.push_back %[[VAL_17]], %[[VAL_15]], %[[VAL_3]], %[[VAL_1]] : index, memref, index, index // CHECK: %[[VAL_22:.*]] = sparse_tensor.storage_specifier.set %[[VAL_18]] pos_mem_sz at 0 with %[[VAL_21]] : !sparse_tensor.storage_specifier // CHECK: return %[[VAL_19]], %[[VAL_7]], %[[VAL_9]], %[[VAL_22]] : memref, memref, memref, !sparse_tensor.storage_specifier -func.func @sparse_alloc_sparse_vector(%arg0: index) -> tensor { - %0 = bufferization.alloc_tensor(%arg0) : tensor +func.func @empty_sparse_vector(%arg0: index) -> tensor { + %0 = tensor.empty(%arg0) : tensor %1 = sparse_tensor.load %0 : tensor return %1 : tensor } diff --git a/mlir/test/Dialect/SparseTensor/conversion.mlir b/mlir/test/Dialect/SparseTensor/conversion.mlir index 64f66c5cb65eb..9cc5cc01544cc 100644 --- a/mlir/test/Dialect/SparseTensor/conversion.mlir +++ b/mlir/test/Dialect/SparseTensor/conversion.mlir @@ -150,7 +150,7 @@ func.func @sparse_new3d(%arg0: !llvm.ptr) -> tensor func.func @sparse_init(%arg0: index, %arg1: index) -> tensor { - %0 = bufferization.alloc_tensor(%arg0, %arg1) : tensor + %0 = tensor.empty(%arg0, %arg1) : tensor %1 = sparse_tensor.load %0 : tensor return %1 : tensor } @@ -334,7 +334,7 @@ func.func @sparse_insert(%arg0: tensor<128xf32, #SparseVector>, // CHECK-DAG: linalg.fill ins(%{{.*}} : i1) outs(%[[B]] : memref<8xi1>) // CHECK: return %[[D]] : memref func.func @sparse_expansion1() -> memref { - %0 = bufferization.alloc_tensor() : tensor<4x8xf64, #CSR> + %0 = tensor.empty() : tensor<4x8xf64, #CSR> %values, %filled, %added, %count = sparse_tensor.expand %0 : tensor<4x8xf64, #CSR> to memref, memref, memref return %added : memref @@ -350,7 +350,7 @@ func.func @sparse_expansion1() -> memref { // CHECK-DAG: linalg.fill ins(%{{.*}} : i1) outs(%[[B]] : memref<4xi1>) // CHECK: return %[[D]] : memref func.func @sparse_expansion2() -> memref { - %0 = bufferization.alloc_tensor() : tensor<4x8xf64, #CSC> + %0 = tensor.empty() : tensor<4x8xf64, #CSC> %values, %filled, %added, %count = sparse_tensor.expand %0 : tensor<4x8xf64, #CSC> to memref, memref, memref return %added : memref @@ -367,7 +367,7 @@ func.func @sparse_expansion2() -> memref { // CHECK-DAG: linalg.fill ins(%{{.*}} : i1) outs(%[[B]] : memref) // CHECK: return %[[C]] : memref func.func @sparse_expansion3(%arg0: index, %arg1: index) -> memref { - %0 = bufferization.alloc_tensor(%arg0, %arg1) : tensor + %0 = tensor.empty(%arg0, %arg1) : tensor %values, %filled, %added, %count = sparse_tensor.expand %0 : tensor to memref, memref, memref return %added : memref @@ -430,12 +430,12 @@ func.func @sparse_out2(%arg0: tensor, %arg1: !llvm.ptr // CHECK-LABEL: func @sparse_and_dense_init( // CHECK: %[[S:.*]] = call @newSparseTensor -// CHECK: %[[D:.*]] = bufferization.alloc_tensor +// CHECK: %[[D:.*]] = tensor.empty // CHECK: return %[[S]], %[[D]] : !llvm.ptr, tensor func.func @sparse_and_dense_init(%arg0: index, %arg1: index) -> (tensor, tensor) { - %0 = bufferization.alloc_tensor(%arg0, %arg1) : tensor + %0 = tensor.empty(%arg0, %arg1) : tensor %1 = sparse_tensor.load %0 : tensor - %2 = bufferization.alloc_tensor(%arg0, %arg1) : tensor + %2 = tensor.empty(%arg0, %arg1) : tensor return %1, %2 : tensor, tensor } diff --git a/mlir/test/Dialect/SparseTensor/pre_rewriting.mlir b/mlir/test/Dialect/SparseTensor/pre_rewriting.mlir index 5aa4acaf86393..ac20ec1b950c2 100644 --- a/mlir/test/Dialect/SparseTensor/pre_rewriting.mlir +++ b/mlir/test/Dialect/SparseTensor/pre_rewriting.mlir @@ -63,7 +63,7 @@ func.func @sparse_fuse_slice(%a : tensor<2x3xi64, #SortedCOO>) -> tensor<1x3xi64 // CHECK-SAME: %[[VAL_1:.*]]: tensor<4x4xf64, #sparse_tensor.encoding<{{.*}}>>, // CHECK-SAME: %[[VAL_2:.*]]: tensor<4x4xf64, #sparse_tensor.encoding<{{.*}}>>) -> tensor<4x4xf64, #sparse_tensor.encoding<{{.*}}>> { // CHECK-DAG: %[[VAL_3:.*]] = arith.constant 0.000000e+00 : f64 -// CHECK-DAG: %[[VAL_4:.*]] = bufferization.alloc_tensor() : tensor<4x4xf64, #sparse_tensor.encoding<{{.*}}>> +// CHECK-DAG: %[[VAL_4:.*]] = tensor.empty() : tensor<4x4xf64, #sparse_tensor.encoding<{{.*}}>> // CHECK-NEXT: %[[VAL_5:.*]] = linalg.generic {indexing_maps = [#map, #map, #map, #map], iterator_types = ["parallel", "parallel"]} // CHECK-SAME: ins(%[[VAL_0]], %[[VAL_1]], %[[VAL_2]] // CHECK-NEXT: ^bb0(%[[VAL_6:.*]]: i1, %[[VAL_7:.*]]: f64, %[[VAL_8:.*]]: f64, %[[VAL_9:.*]]: f64): @@ -90,7 +90,7 @@ func.func @sparse_fuse_slice(%a : tensor<2x3xi64, #SortedCOO>) -> tensor<1x3xi64 func.func @sparse_select(%cond: tensor<4x4xi1>, %arga: tensor<4x4xf64, #DCSR>, %argb: tensor<4x4xf64, #DCSR>) -> tensor<4x4xf64, #DCSR> { - %xv = bufferization.alloc_tensor() : tensor<4x4xf64, #DCSR> + %xv = tensor.empty() : tensor<4x4xf64, #DCSR> %0 = linalg.generic #sel_trait ins(%cond, %arga, %argb: tensor<4x4xi1>, tensor<4x4xf64, #DCSR>, tensor<4x4xf64, #DCSR>) outs(%xv: tensor<4x4xf64, #DCSR>) { diff --git a/mlir/test/Dialect/SparseTensor/sparse_2d.mlir b/mlir/test/Dialect/SparseTensor/sparse_2d.mlir index 00bf4ea440628..56f966e903912 100644 --- a/mlir/test/Dialect/SparseTensor/sparse_2d.mlir +++ b/mlir/test/Dialect/SparseTensor/sparse_2d.mlir @@ -1058,7 +1058,7 @@ func.func @cmp_ss_ss(%arga: tensor<32x16xf32, #Tss>, %argb: tensor<32x16xf32, #T // CHECK-DAG: %[[VAL_2:.*]] = arith.constant 2 : index // CHECK-DAG: %[[VAL_3:.*]] = arith.constant 0 : index // CHECK-DAG: %[[VAL_4:.*]] = arith.constant 1 : index -// CHECK-DAG: %[[VAL_5:.*]] = bufferization.alloc_tensor() : tensor<2x3xf64, #{{.*}}>> +// CHECK-DAG: %[[VAL_5:.*]] = tensor.empty() : tensor<2x3xf64, #{{.*}}>> // CHECK-DAG: %[[VAL_6:.*]] = sparse_tensor.positions %[[VAL_0]] {level = 1 : index} : tensor<2x3xf64, #{{.*}}>> to memref // CHECK-DAG: %[[VAL_7:.*]] = sparse_tensor.coordinates %[[VAL_0]] {level = 1 : index} : tensor<2x3xf64, #{{.*}}>> to memref // CHECK-DAG: %[[VAL_8:.*]] = sparse_tensor.values %[[VAL_0]] : tensor<2x3xf64, #{{.*}}>> to memref @@ -1142,7 +1142,7 @@ func.func @cmp_ss_ss(%arga: tensor<32x16xf32, #Tss>, %argb: tensor<32x16xf32, #T // CHECK: } func.func @sub_ss_batched(%0: tensor<2x3xf64, #BatchedVector>, %1: tensor<2x3xf64, #BatchedVector>) -> tensor<2x3xf64, #BatchedVector> { - %2 = bufferization.alloc_tensor() : tensor<2x3xf64, #BatchedVector> + %2 = tensor.empty() : tensor<2x3xf64, #BatchedVector> %3 = linalg.generic #trait2 ins(%0, %1 : tensor<2x3xf64, #BatchedVector>, tensor<2x3xf64, #BatchedVector>) outs(%2 : tensor<2x3xf64, #BatchedVector>) { diff --git a/mlir/test/Dialect/SparseTensor/sparse_conv_2d_slice_based.mlir b/mlir/test/Dialect/SparseTensor/sparse_conv_2d_slice_based.mlir index 23360dac26a49..b13e7a389b619 100644 --- a/mlir/test/Dialect/SparseTensor/sparse_conv_2d_slice_based.mlir +++ b/mlir/test/Dialect/SparseTensor/sparse_conv_2d_slice_based.mlir @@ -19,7 +19,7 @@ // CHECK-DAG: %[[VAL_9:.*]] = arith.constant 4 : index // CHECK-DAG: %[[VAL_10:.*]] = arith.constant 0 : i32 // CHECK-DAG: %[[VAL_11:.*]] = arith.constant false -// CHECK-DAG: %[[VAL_12:.*]] = bufferization.alloc_tensor() : tensor<6x6xi32, #sparse_tensor.encoding<{{.*}}>> +// CHECK-DAG: %[[VAL_12:.*]] = tensor.empty() : tensor<6x6xi32, #sparse_tensor.encoding<{{.*}}>> // CHECK-DAG: %[[VAL_13:.*]] = sparse_tensor.positions %[[VAL_0]] {level = 0 : index} : tensor<8x8xi32, #sparse_tensor.encoding<{{.*}}>> to memref // CHECK-DAG: %[[VAL_14:.*]] = sparse_tensor.coordinates %[[VAL_0]] {level = 0 : index} : tensor<8x8xi32, #sparse_tensor.encoding<{{.*}}>> to memref // CHECK-DAG: %[[VAL_15:.*]] = sparse_tensor.positions %[[VAL_0]] {level = 1 : index} : tensor<8x8xi32, #sparse_tensor.encoding<{{.*}}>> to memref @@ -261,7 +261,7 @@ // CHECK: } func.func @conv2d_all_sparse_CSR(%arg0: tensor<8x8xi32, #DCSR>, %arg1: tensor<3x3xi32>) -> tensor<6x6xi32, #DCSR> { - %0 = bufferization.alloc_tensor() : tensor<6x6xi32, #DCSR> + %0 = tensor.empty() : tensor<6x6xi32, #DCSR> %1 = linalg.generic { indexing_maps = [#map, #map1, #map2], iterator_types = ["parallel", "parallel", "reduction", "reduction"]} diff --git a/mlir/test/Dialect/SparseTensor/sparse_fill_zero.mlir b/mlir/test/Dialect/SparseTensor/sparse_fill_zero.mlir index db7bef05e11bd..7a4989304b5be 100644 --- a/mlir/test/Dialect/SparseTensor/sparse_fill_zero.mlir +++ b/mlir/test/Dialect/SparseTensor/sparse_fill_zero.mlir @@ -121,7 +121,7 @@ // CHECK: } func.func @fill_zero_after_alloc(%arg0: tensor<100x200xf64, #DCSR>, %arg1: tensor<200x300xf64, #DCSR>) -> tensor<100x300xf64, #DCSR> { - %0 = bufferization.alloc_tensor() : tensor<100x300xf64, #DCSR> + %0 = tensor.empty() : tensor<100x300xf64, #DCSR> %cst = arith.constant 0.000000e+00 : f64 %1 = linalg.fill ins(%cst : f64) outs(%0 : tensor<100x300xf64, #DCSR>) -> tensor<100x300xf64, #DCSR> diff --git a/mlir/test/Dialect/SparseTensor/sparse_index.mlir b/mlir/test/Dialect/SparseTensor/sparse_index.mlir index bdd0225dc41c3..674225b9e9359 100644 --- a/mlir/test/Dialect/SparseTensor/sparse_index.mlir +++ b/mlir/test/Dialect/SparseTensor/sparse_index.mlir @@ -23,7 +23,7 @@ // CHECK-DAG: %[[VAL_2:.*]] = arith.constant 1 : index // CHECK-DAG: %[[VAL_3:.*]] = tensor.dim %[[VAL_0]], %[[VAL_1]] : tensor) %c1 = arith.constant 0 : index %0 = tensor.dim %arga, %c0 : tensor %1 = tensor.dim %arga, %c1 : tensor - %init = bufferization.alloc_tensor(%0, %1) : tensor + %init = tensor.empty(%0, %1) : tensor %r = linalg.generic #trait ins(%arga: tensor) outs(%init: tensor) { @@ -75,7 +75,7 @@ func.func @dense_index(%arga: tensor) // CHECK-DAG: %[[VAL_2:.*]] = arith.constant 1 : index // CHECK-DAG: %[[VAL_3:.*]] = tensor.dim %[[VAL_0]], %[[VAL_1]] : tensor) %c1 = arith.constant 0 : index %0 = tensor.dim %arga, %c0 : tensor %1 = tensor.dim %arga, %c1 : tensor - %init = bufferization.alloc_tensor(%0, %1) : tensor + %init = tensor.empty(%0, %1) : tensor %r = linalg.generic #trait ins(%arga: tensor) outs(%init: tensor) { diff --git a/mlir/test/Dialect/SparseTensor/sparse_matmul_codegen.mlir b/mlir/test/Dialect/SparseTensor/sparse_matmul_codegen.mlir index 5c308dc3c5623..4fbd36906eacf 100644 --- a/mlir/test/Dialect/SparseTensor/sparse_matmul_codegen.mlir +++ b/mlir/test/Dialect/SparseTensor/sparse_matmul_codegen.mlir @@ -144,7 +144,7 @@ // CHECK: return %[[VAL_77]]#0, %[[VAL_77]]#1, %[[VAL_77]]#2, %[[VAL_77]]#3 : memref, memref, memref, !sparse_tensor.storage_specifier func.func @matmul(%A: tensor<4x8xf64, #CSR>, %B: tensor<8x4xf64, #CSR>) -> tensor<4x4xf64, #CSR> { - %C = bufferization.alloc_tensor() : tensor<4x4xf64, #CSR> + %C = tensor.empty() : tensor<4x4xf64, #CSR> %D = linalg.matmul ins(%A, %B: tensor<4x8xf64, #CSR>, tensor<8x4xf64, #CSR>) outs(%C: tensor<4x4xf64, #CSR>) -> tensor<4x4xf64, #CSR> diff --git a/mlir/test/Dialect/SparseTensor/sparse_outbuf.mlir b/mlir/test/Dialect/SparseTensor/sparse_outbuf.mlir index d6677e0a8ff15..7dbb1c7d94908 100644 --- a/mlir/test/Dialect/SparseTensor/sparse_outbuf.mlir +++ b/mlir/test/Dialect/SparseTensor/sparse_outbuf.mlir @@ -49,7 +49,7 @@ func.func @allout_inplace(%arga: tensor<10xi32, #SV>, // CHECK-DAG: %[[VAL_1:.*]] = arith.constant 0 : index // CHECK-DAG: %[[VAL_2:.*]] = arith.constant 0.000000e+00 : f32 // CHECK-DAG: %[[VAL_3:.*]] = arith.constant 1 : index -// CHECK: %[[VAL_4:.*]] = bufferization.alloc_tensor() : tensor<10xf32> +// CHECK: %[[VAL_4:.*]] = tensor.empty() : tensor<10xf32> // CHECK: %[[VAL_5:.*]] = sparse_tensor.positions %[[VAL_0]] {level = 0 : index} : tensor<10xi32, #{{.*}}> to memref // CHECK: %[[VAL_6:.*]] = sparse_tensor.coordinates %[[VAL_0]] {level = 0 : index} : tensor<10xi32, #{{.*}}> to memref // CHECK: %[[VAL_7:.*]] = sparse_tensor.values %[[VAL_0]] : tensor<10xi32, #{{.*}}> to memref @@ -67,7 +67,7 @@ func.func @allout_inplace(%arga: tensor<10xi32, #SV>, // CHECK: return %[[VAL_15]] : tensor<10xf32> // CHECK: } func.func @allout_materialize(%arga: tensor<10xi32, #SV>) -> tensor<10xf32> { - %m = bufferization.alloc_tensor() : tensor<10xf32> + %m = tensor.empty() : tensor<10xf32> %0 = linalg.generic #trait ins(%arga: tensor<10xi32, #SV>) outs(%m: tensor<10xf32>) { diff --git a/mlir/test/Dialect/SparseTensor/sparse_sddmm_org.mlir b/mlir/test/Dialect/SparseTensor/sparse_sddmm_org.mlir index e6bbc565b01e0..2275015c6b94c 100644 --- a/mlir/test/Dialect/SparseTensor/sparse_sddmm_org.mlir +++ b/mlir/test/Dialect/SparseTensor/sparse_sddmm_org.mlir @@ -29,7 +29,7 @@ // CHECK-DAG: %[[VAL_5:.*]] = arith.constant 1 : index // CHECK-DAG: %[[VAL_6:.*]] = arith.constant false // CHECK-DAG: %[[VAL_7:.*]] = arith.constant true -// CHECK: %[[VAL_8:.*]] = bufferization.alloc_tensor() : tensor<8x8xf64, #sparse_tensor.encoding<{ lvlTypes = [ "compressed", "compressed" ] }>> +// CHECK: %[[VAL_8:.*]] = tensor.empty() : tensor<8x8xf64, #sparse_tensor.encoding<{ lvlTypes = [ "compressed", "compressed" ] }>> // CHECK: %[[VAL_9:.*]] = bufferization.to_memref %[[VAL_1]] : memref<8x8xf64> // CHECK: %[[VAL_10:.*]] = bufferization.to_memref %[[VAL_2]] : memref<8x8xf64> // CHECK: %[[VAL_11:.*]] = sparse_tensor.positions %[[VAL_0]] {level = 0 : index} : tensor<8x8xf64, #sparse_tensor.encoding<{ lvlTypes = [ "compressed", "compressed" ] }>> to memref @@ -90,7 +90,7 @@ func.func @sparse_sampled_dd_unfused(%args: tensor<8x8xf64, #SM>, linalg.yield %q : f64 } -> tensor<8x8xf64> // Sample the result with elements-wise multiplication with sparse matrix. - %3 = bufferization.alloc_tensor() : tensor<8x8xf64, #SM> + %3 = tensor.empty() : tensor<8x8xf64, #SM> %4 = linalg.generic #trait_scale ins(%2, %args : tensor<8x8xf64>, tensor<8x8xf64, #SM>) outs(%3 : tensor<8x8xf64, #SM>) { diff --git a/mlir/test/Dialect/SparseTensor/sparse_transpose.mlir b/mlir/test/Dialect/SparseTensor/sparse_transpose.mlir index e43d77dfd8479..40368408a11a5 100644 --- a/mlir/test/Dialect/SparseTensor/sparse_transpose.mlir +++ b/mlir/test/Dialect/SparseTensor/sparse_transpose.mlir @@ -19,7 +19,7 @@ // CHECK-SAME: %[[VAL_0:.*]]: tensor<3x4xf64, #sparse_tensor.encoding<{ lvlTypes = [ "compressed", "compressed" ] }>>) -> tensor<4x3xf64, #sparse_tensor.encoding<{ lvlTypes = [ "compressed", "compressed" ] }>> { // CHECK-DAG: %[[VAL_1:.*]] = arith.constant 0 : index // CHECK-DAG: %[[VAL_2:.*]] = arith.constant 1 : index -// CHECK-DAG: %[[VAL_3:.*]] = bufferization.alloc_tensor() : tensor<4x3xf64, #sparse_tensor.encoding<{ lvlTypes = [ "compressed", "compressed" ] }>> +// CHECK-DAG: %[[VAL_3:.*]] = tensor.empty() : tensor<4x3xf64, #sparse_tensor.encoding<{ lvlTypes = [ "compressed", "compressed" ] }>> // CHECK-DAG: %[[VAL_4:.*]] = sparse_tensor.convert %[[VAL_0]] : tensor<3x4xf64, #sparse_tensor.encoding<{ lvlTypes = [ "compressed", "compressed" ] }>> to tensor<3x4xf64, #sparse_tensor.encoding<{ lvlTypes = [ "compressed", "compressed" ], dimToLvl = affine_map<(d0, d1) -> (d1, d0)> }>> // CHECK-DAG: %[[VAL_5:.*]] = sparse_tensor.positions %[[VAL_4]] {level = 0 : index} : tensor<3x4xf64, #sparse_tensor.encoding<{ lvlTypes = [ "compressed", "compressed" ], dimToLvl = affine_map<(d0, d1) -> (d1, d0)> }>> to memref // CHECK-DAG: %[[VAL_6:.*]] = sparse_tensor.coordinates %[[VAL_4]] {level = 0 : index} : tensor<3x4xf64, #sparse_tensor.encoding<{ lvlTypes = [ "compressed", "compressed" ], dimToLvl = affine_map<(d0, d1) -> (d1, d0)> }>> to memref @@ -47,7 +47,7 @@ // CHECK: } func.func @sparse_transpose_auto(%arga: tensor<3x4xf64, #DCSR>) -> tensor<4x3xf64, #DCSR> { - %i = bufferization.alloc_tensor() : tensor<4x3xf64, #DCSR> + %i = tensor.empty() : tensor<4x3xf64, #DCSR> %0 = linalg.generic #transpose_trait ins(%arga: tensor<3x4xf64, #DCSR>) outs(%i: tensor<4x3xf64, #DCSR>) {