diff --git a/mlir/include/mlir/Dialect/SparseTensor/Pipelines/Passes.h b/mlir/include/mlir/Dialect/SparseTensor/Pipelines/Passes.h --- a/mlir/include/mlir/Dialect/SparseTensor/Pipelines/Passes.h +++ b/mlir/include/mlir/Dialect/SparseTensor/Pipelines/Passes.h @@ -44,6 +44,9 @@ PassOptions::Option enableVLAVectorization{ *this, "enable-vla-vectorization", desc("Enable vector length agnostic vectorization"), init(false)}; + PassOptions::Option testBufferizationAnalysisOnly{ + *this, "test-bufferization-analysis-only", + desc("Run only the inplacability analysis"), init(false)}; /// Projects out the options for `createSparsificationPass`. SparsificationOptions sparsificationOptions() const { diff --git a/mlir/include/mlir/Dialect/SparseTensor/Transforms/Passes.h b/mlir/include/mlir/Dialect/SparseTensor/Transforms/Passes.h --- a/mlir/include/mlir/Dialect/SparseTensor/Transforms/Passes.h +++ b/mlir/include/mlir/Dialect/SparseTensor/Transforms/Passes.h @@ -23,6 +23,9 @@ #include "mlir/Pass/Pass.h" namespace mlir { +namespace bufferization { +struct OneShotBufferizationOptions; +} // namespace bufferization // Forward. class TypeConverter; @@ -131,6 +134,8 @@ const SparseTensorConversionOptions &options = SparseTensorConversionOptions()); +std::unique_ptr createDenseBufferizationPass( + const bufferization::OneShotBufferizationOptions &options); std::unique_ptr createSparseTensorConversionPass(); std::unique_ptr createSparseTensorConversionPass(const SparseTensorConversionOptions &options); diff --git a/mlir/lib/Dialect/SparseTensor/Pipelines/SparseTensorPipelines.cpp b/mlir/lib/Dialect/SparseTensor/Pipelines/SparseTensorPipelines.cpp --- a/mlir/lib/Dialect/SparseTensor/Pipelines/SparseTensorPipelines.cpp +++ b/mlir/lib/Dialect/SparseTensor/Pipelines/SparseTensorPipelines.cpp @@ -9,20 +9,37 @@ #include "mlir/Dialect/SparseTensor/Pipelines/Passes.h" #include "mlir/Conversion/Passes.h" -#include "mlir/Dialect/Arithmetic/Transforms/Passes.h" +#include "mlir/Dialect/Bufferization/Transforms/Bufferize.h" +#include "mlir/Dialect/Bufferization/Transforms/OneShotAnalysis.h" #include "mlir/Dialect/Bufferization/Transforms/Passes.h" #include "mlir/Dialect/Func/IR/FuncOps.h" -#include "mlir/Dialect/Func/Transforms/Passes.h" #include "mlir/Dialect/Linalg/Passes.h" #include "mlir/Dialect/SparseTensor/IR/SparseTensor.h" #include "mlir/Dialect/SparseTensor/Transforms/Passes.h" -#include "mlir/Dialect/Tensor/Transforms/Passes.h" -#include "mlir/Dialect/Vector/Transforms/Passes.h" #include "mlir/Pass/PassManager.h" using namespace mlir; using namespace mlir::sparse_tensor; +/// Return configuration options for One-Shot Bufferize. +static bufferization::OneShotBufferizationOptions +getBufferizationOptions(bool analysisOnly) { + bufferization::OneShotBufferizationOptions options; + options.bufferizeFunctionBoundaries = true; + // TODO(springerm): To spot memory leaks more easily, returning dense allocs + // should be disallowed. + options.allowReturnAllocs = true; + options.functionBoundaryTypeConversion = + bufferization::BufferizationOptions::LayoutMapOption::IdentityLayoutMap; + options.unknownTypeConversion = + bufferization::BufferizationOptions::LayoutMapOption::IdentityLayoutMap; + if (analysisOnly) { + options.testAnalysisOnly = true; + options.printConflicts = true; + } + return options; +} + //===----------------------------------------------------------------------===// // Pipeline implementation. //===----------------------------------------------------------------------===// @@ -32,19 +49,23 @@ // TODO(wrengr): ensure the original `pm` is for ModuleOp pm.addNestedPass(createLinalgGeneralizationPass()); pm.addPass(createLinalgElementwiseOpFusionPass()); + pm.addPass( + bufferization::createTensorCopyInsertionPass(getBufferizationOptions( + /*analysisOnly=*/options.testBufferizationAnalysisOnly))); + if (options.testBufferizationAnalysisOnly) + return; pm.addPass(createSparsificationPass(options.sparsificationOptions())); pm.addPass(createSparseTensorConversionPass( options.sparseTensorConversionOptions())); - pm.addNestedPass(createLinalgBufferizePass()); - pm.addNestedPass(vector::createVectorBufferizePass()); + pm.addPass(createDenseBufferizationPass( + getBufferizationOptions(/*analysisOnly=*/false))); + pm.addNestedPass( + mlir::bufferization::createFinalizingBufferizePass()); + // TODO(springerm): Add sparse support to the BufferDeallocation pass and add + // it to this pipeline. pm.addNestedPass(createConvertLinalgToLoopsPass()); pm.addNestedPass(createConvertVectorToSCFPass()); pm.addNestedPass(createConvertSCFToCFPass()); - pm.addPass(func::createFuncBufferizePass()); - pm.addPass(arith::createConstantBufferizePass()); - pm.addNestedPass(createTensorBufferizePass()); - pm.addNestedPass( - mlir::bufferization::createFinalizingBufferizePass()); pm.addPass(createLowerAffinePass()); pm.addPass(createConvertVectorToLLVMPass(options.lowerVectorToLLVMOptions())); pm.addPass(createMemRefToLLVMPass()); diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/DenseBufferizationPass.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/DenseBufferizationPass.cpp new file mode 100644 --- /dev/null +++ b/mlir/lib/Dialect/SparseTensor/Transforms/DenseBufferizationPass.cpp @@ -0,0 +1,70 @@ +//===- DenseBufferizationPass.cpp - Dense bufferization pass --------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "mlir/Dialect/SparseTensor/Transforms/Passes.h" + +#include "mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h" +#include "mlir/Dialect/Bufferization/Transforms/Bufferize.h" +#include "mlir/Dialect/Bufferization/Transforms/OneShotAnalysis.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" +#include "mlir/Dialect/SparseTensor/IR/SparseTensor.h" + +using namespace mlir; +using namespace mlir::func; + +namespace mlir { +namespace sparse_tensor { +/// A pass that bufferizes only dense tensor ops and ignores all sparse tensor +/// ops. No buffer copies are inserted. All tensor OpOperands must be +/// inplacable. +class BufferizeDenseOpsPass + : public PassWrapper> { +public: + BufferizeDenseOpsPass( + const bufferization::OneShotBufferizationOptions &options) + : PassWrapper>(), + options(options) {} + + void runOnOperation() override { + // Disallow all dense tensor ops. + bufferization::OpFilter opFilter; + opFilter.allowOperation([](Operation *op) { + for (Value value : op->getOperands()) + if (static_cast(getSparseTensorEncoding(value.getType()))) + return false; + for (Value value : op->getResults()) + if (static_cast(getSparseTensorEncoding(value.getType()))) + return false; + if (auto funcOp = dyn_cast(op)) { + FunctionType funcType = funcOp.getFunctionType(); + for (Type t : funcType.getInputs()) + if (static_cast(getSparseTensorEncoding(t))) + return false; + for (Type t : funcType.getResults()) + if (static_cast(getSparseTensorEncoding(t))) + return false; + } + return true; + }); + + if (failed(bufferization::bufferizeOp(getOperation(), options, + /*copyBeforeWrite=*/false, + &opFilter))) + signalPassFailure(); + } + +private: + bufferization::OneShotBufferizationOptions options; +}; +} // namespace sparse_tensor +} // namespace mlir + +std::unique_ptr mlir::createDenseBufferizationPass( + const bufferization::OneShotBufferizationOptions &options) { + return std::make_unique(options); +} 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 @@ -16,6 +16,7 @@ #include "CodegenUtils.h" +#include "mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h" #include "mlir/Dialect/Bufferization/IR/Bufferization.h" #include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/LLVMIR/LLVMDialect.h" @@ -30,6 +31,8 @@ using namespace mlir; using namespace mlir::sparse_tensor; +using mlir::bufferization::BufferizableOpInterface; +using mlir::bufferization::BufferizationDialect; namespace { @@ -47,6 +50,23 @@ return LLVM::LLVMPointerType::get(builder.getI8Type()); } +/// Return `true` if the allocation of the given op is guaranteed to not escape +/// the containing block. +static bool allocationDoesNotEscape(OpResult opResult) { +#ifndef NDEBUG + auto bufferizableOp = opResult.getDefiningOp(); + assert(bufferizableOp && bufferizableOp.bufferizesToAllocation(opResult) && + "expected op that bufferizes to an allocation"); +#endif // NDEBUG + + Operation *op = opResult.getDefiningOp(); + if (!op->hasAttr(BufferizationDialect::kEscapeAttrName)) + return false; + auto attr = + op->getAttrOfType(BufferizationDialect::kEscapeAttrName); + return !attr[opResult.getResultNumber()].cast().getValue(); +} + /// Returns a function reference (first hit also inserts into module). Sets /// the "_emit_c_interface" on the function declaration when requested, /// so that LLVM lowering generates a wrapper function that takes care @@ -320,7 +340,7 @@ return builder.create(loc, values, ivs[0]); } -/// Generates code to allocate a tensor of the given type, and zero +/// Generates code to allocate a buffer of the given type, and zero /// initialize it. If the tensor type has any dynamic sizes, then the /// `sizes` parameter should be as filled by sizesFromPtr(); that way /// we can reuse the genDimSizeCall() results generated by sizesFromPtr(). @@ -340,6 +360,11 @@ return mem; } +/// Generates code to deallocate a dense buffer. +static void deallocDenseTensor(OpBuilder &builder, Location loc, Value buffer) { + builder.create(loc, buffer); +} + /// Inserts the element returned by genGetNextCall(_, ind, elemPtr) into /// the tensor created by allocDenseTensor(). The `rank` is the rank /// of the `tensor` and the length of `ind`. @@ -467,6 +492,9 @@ LogicalResult matchAndRewrite(bufferization::AllocTensorOp op, OpAdaptor adaptor, ConversionPatternRewriter &rewriter) const override { + if (op.getCopy()) + return rewriter.notifyMatchFailure(op, + "sparse tensor copy not implemented"); RankedTensorType resType = op.getType(); auto enc = getSparseTensorEncoding(resType); if (!enc) @@ -595,6 +623,9 @@ Value iter = genNewCall(rewriter, op, params); Value ind = genAlloca(rewriter, loc, rank, rewriter.getIndexType()); Value elemPtr = genAllocaScalar(rewriter, loc, elemTp); + Block *insertionBlock = rewriter.getInsertionBlock(); + // TODO: Dense buffers should be allocated/deallocated via the callback + // in BufferizationOptions. Value dst = allocDenseTensor(rewriter, loc, dstTensorTp, sizes); SmallVector noArgs; SmallVector noTypes; @@ -610,6 +641,11 @@ rewriter.setInsertionPointAfter(whileOp); genDelCOOCall(rewriter, op, elemTp, iter); rewriter.replaceOpWithNewOp(op, resType, dst); + // Deallocate the buffer. + if (allocationDoesNotEscape(op->getOpResult(0))) { + rewriter.setInsertionPoint(insertionBlock->getTerminator()); + deallocDenseTensor(rewriter, loc, dst); + } return success(); } if (!encDst && !encSrc) { 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 @@ -117,12 +117,17 @@ // The following operations and dialects may be introduced by the // rewriting rules, and are therefore marked as legal. target.addLegalOp(); - target - .addLegalDialect(); + target.addLegalDialect(); + target.addDynamicallyLegalOp( + [&](bufferization::AllocTensorOp op) { + // Dense tensors are legal, sparse tensors are not. + return !static_cast(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 --- a/mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp +++ b/mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp @@ -307,17 +307,6 @@ return true; } -/// Returns true if tensor has an in-place annotation. -static bool isInPlace(Value val) { - if (auto arg = val.dyn_cast()) - if (auto funcOp = dyn_cast(arg.getOwner()->getParentOp())) - if (auto attr = funcOp.getArgAttrOfType( - arg.getArgNumber(), - bufferization::BufferizableOpInterface::kInplaceableAttrName)) - return attr.getValue(); - return false; -} - /// Returns true if tensor materializes uninitialized into the computation. static bool isMaterializing(Value val) { return val.getDefiningOp() || @@ -356,7 +345,7 @@ // but not its nonzero structure, an operation called "simply dynamic" in // [Bik96,Ch9], is also admissable without special codegen, provided // the tensor's underlying sparse storage scheme can be modified in-place. - if (merger.isSingleCondition(tensor, exp) && isInPlace(lhs->get())) + if (merger.isSingleCondition(tensor, exp)) return true; // Accept "truly dynamic" if the output tensor materializes uninitialized // into the computation and insertions occur in lexicographic index order. @@ -492,30 +481,12 @@ // out the buffer to enforce the assumption above, which may negatively // impact running complexity (viz. O(n^2 + nnz) vs. O(nnz) for matrices). // TODO: use better analysis to avoid zeroing out the buffer? - if (isInPlace(tensor)) { - Value init = - builder.create(loc, denseTp, tensor); - if (!isInit) { - Value zero = constantZero(builder, loc, denseTp.getElementType()); - builder.create(loc, ValueRange{zero}, ValueRange{init}); - } - return init; - } - // By default, a new buffer is allocated which is either set to zero (when - // no updates occur or the tensor materializes into this computation) or - // initialized to the value of the tensor defined in the outs() clause. - // This is always correct (since it enforces all assumptions above) but - // may negatively impact running complexity as explained above. - Value alloc = builder.create(loc, denseTp, args); - if (!isInit || isMaterializing(tensor)) { + Value init = builder.create(loc, denseTp, tensor); + if (!isInit) { Value zero = constantZero(builder, loc, denseTp.getElementType()); - builder.create(loc, ValueRange{zero}, ValueRange{alloc}); - } else { - Value init = - builder.create(loc, denseTp, tensor); - builder.create(loc, init, alloc); + builder.create(loc, ValueRange{zero}, ValueRange{init}); } - return alloc; + return init; } /// Local bufferization of all dense and sparse data structures. diff --git a/mlir/test/Dialect/SparseTensor/dense.mlir b/mlir/test/Dialect/SparseTensor/dense.mlir --- a/mlir/test/Dialect/SparseTensor/dense.mlir +++ b/mlir/test/Dialect/SparseTensor/dense.mlir @@ -29,55 +29,11 @@ // // Test with an all-dense-annotated "sparse" matrix as input and -// a non-annotated dense matrix as output that is not inplacable. -// This results in an explicit allocation to facilitate output. -// -// CHECK-LABEL: func @dense1( -// CHECK-SAME: %[[VAL_0:.*]]: tensor<32x16xf32, #sparse_tensor.encoding<{{.*}}>>, -// CHECK-SAME: %[[VAL_1:.*]]: tensor<32x16xf32> {linalg.inplaceable = false}) -> tensor<32x16xf32> { -// CHECK-DAG: %[[ZERO:.*]] = arith.constant 0.000000e+00 : f32 -// CHECK-DAG: %[[VAL_2:.*]] = arith.constant 1.000000e+00 : f32 -// CHECK-DAG: %[[VAL_3:.*]] = arith.constant 32 : index -// CHECK-DAG: %[[VAL_4:.*]] = arith.constant 16 : index -// CHECK-DAG: %[[VAL_5:.*]] = arith.constant 0 : index -// CHECK-DAG: %[[VAL_6:.*]] = arith.constant 1 : index -// CHECK-DAG: %[[VAL_7:.*]] = sparse_tensor.values %[[VAL_0]] : tensor<32x16xf32, #sparse_tensor.encoding<{{.*}}>> to memref -// CHECK-DAG: %[[VAL_9:.*]] = memref.alloc() : memref<32x16xf32> -// CHECK: linalg.fill ins(%[[ZERO]] : f32) outs(%[[VAL_9]] : memref<32x16xf32>) -// CHECK: scf.for %[[VAL_10:.*]] = %[[VAL_5]] to %[[VAL_3]] step %[[VAL_6]] { -// CHECK: scf.for %[[VAL_11:.*]] = %[[VAL_5]] to %[[VAL_4]] step %[[VAL_6]] { -// CHECK: %[[VAL_12:.*]] = arith.muli %[[VAL_10]], %[[VAL_4]] : index -// CHECK: %[[VAL_13:.*]] = arith.addi %[[VAL_12]], %[[VAL_11]] : index -// CHECK: %[[VAL_14:.*]] = memref.load %[[VAL_7]]{{\[}}%[[VAL_13]]] : memref -// CHECK: %[[VAL_15:.*]] = arith.addf %[[VAL_14]], %[[VAL_2]] : f32 -// CHECK: memref.store %[[VAL_15]], %[[VAL_9]]{{\[}}%[[VAL_10]], %[[VAL_11]]] : memref<32x16xf32> -// CHECK: } -// CHECK: } -// CHECK: %[[VAL_16:.*]] = bufferization.to_tensor %[[VAL_9]] : memref<32x16xf32> -// CHECK: return %[[VAL_16]] : tensor<32x16xf32> -// CHECK: } -func.func @dense1(%arga: tensor<32x16xf32, #DenseMatrix>, - %argx: tensor<32x16xf32> {linalg.inplaceable = false}) - -> tensor<32x16xf32> { - %c = arith.constant 1.0 : f32 - %0 = linalg.generic #trait_2d - ins(%arga: tensor<32x16xf32, #DenseMatrix>) - outs(%argx: tensor<32x16xf32>) { - ^bb(%a: f32, %x: f32): - %1 = arith.addf %a, %c : f32 - linalg.yield %1 : f32 - } -> tensor<32x16xf32> - return %0 : tensor<32x16xf32> -} - -// -// Test with an all-dense-annotated "sparse" matrix as input and -// a non-annotated dense matrix as output that is inplacable. -// This allows updating the dense output in place. +// a non-annotated dense matrix as output. // // CHECK-LABEL: func @dense2( // CHECK-SAME: %[[VAL_0:.*]]: tensor<32x16xf32, #sparse_tensor.encoding<{{.*}}>>, -// CHECK-SAME: %[[VAL_1:.*]]: tensor<32x16xf32> {linalg.inplaceable = true}) -> tensor<32x16xf32> { +// CHECK-SAME: %[[VAL_1:.*]]: tensor<32x16xf32>) -> tensor<32x16xf32> { // CHECK-DAG: %[[VAL_2:.*]] = arith.constant 1.000000e+00 : f32 // CHECK-DAG: %[[VAL_3:.*]] = arith.constant 32 : index // CHECK-DAG: %[[VAL_4:.*]] = arith.constant 16 : index @@ -98,7 +54,7 @@ // CHECK: return %[[VAL_15]] : tensor<32x16xf32> // CHECK: } func.func @dense2(%arga: tensor<32x16xf32, #DenseMatrix>, - %argx: tensor<32x16xf32> {linalg.inplaceable = true}) + %argx: tensor<32x16xf32>) -> tensor<32x16xf32> { %c = arith.constant 1.0 : f32 %0 = linalg.generic #trait_2d @@ -114,11 +70,10 @@ // // Test with a non-annotated dense matrix as input and // an all-dense annotated "sparse" matrix as output. -// The rewriting would fail if argx was not in-placeable. // // CHECK-LABEL: func @dense3( // CHECK-SAME: %[[VAL_0:.*]]: tensor<32x16xf32>, -// CHECK-SAME: %[[VAL_1:.*]]: tensor<32x16xf32, #sparse_tensor.encoding<{{.*}}>> {linalg.inplaceable = true}) -> tensor<32x16xf32, #sparse_tensor.encoding<{{.*}}>> { +// CHECK-SAME: %[[VAL_1:.*]]: tensor<32x16xf32, #sparse_tensor.encoding<{{.*}}>>) -> tensor<32x16xf32, #sparse_tensor.encoding<{{.*}}>> { // CHECK-DAG: %[[VAL_2:.*]] = arith.constant 1.000000e+00 : f32 // CHECK-DAG: %[[VAL_3:.*]] = arith.constant 32 : index // CHECK-DAG: %[[VAL_4:.*]] = arith.constant 16 : index @@ -139,7 +94,7 @@ // CHECK: return %[[VAL_15]] : tensor<32x16xf32, #sparse_tensor.encoding<{{.*}}>> // CHECK: } func.func @dense3(%arga: tensor<32x16xf32>, - %argx: tensor<32x16xf32, #DenseMatrix> {linalg.inplaceable = true}) + %argx: tensor<32x16xf32, #DenseMatrix>) -> tensor<32x16xf32, #DenseMatrix> { %c = arith.constant 1.0 : f32 %0 = linalg.generic #trait_2d @@ -156,13 +111,12 @@ // // Test with a non-annotated dense matrix as input and // an all-dense annotated "sparse" matrix as output. -// The rewriting would fail if argx was not in-placeable. // The missing innermost "k" index (due to a reduction) is accounted // for by scalarizing the reduction operation for the output tensor. // // CHECK-LABEL: func @dense4( // CHECK-SAME: %[[VAL_0:.*]]: tensor<32x16x8xf32>, -// CHECK-SAME: %[[VAL_1:.*]]: tensor<32x16xf32, #sparse_tensor.encoding<{{.*}}>> {linalg.inplaceable = true}) -> tensor<32x16xf32, #sparse_tensor.encoding<{{.*}}>> { +// CHECK-SAME: %[[VAL_1:.*]]: tensor<32x16xf32, #sparse_tensor.encoding<{{.*}}>>) -> tensor<32x16xf32, #sparse_tensor.encoding<{{.*}}>> { // CHECK-DAG: %[[VAL_2:.*]] = arith.constant 8 : index // CHECK-DAG: %[[VAL_3:.*]] = arith.constant 32 : index // CHECK-DAG: %[[VAL_4:.*]] = arith.constant 16 : index @@ -187,7 +141,7 @@ // CHECK: return %[[VAL_20]] : tensor<32x16xf32, #sparse_tensor.encoding<{{.*}}>> // CHECK: } func.func @dense4(%arga: tensor<32x16x8xf32>, - %argx: tensor<32x16xf32, #DenseMatrix> {linalg.inplaceable = true}) + %argx: tensor<32x16xf32, #DenseMatrix>) -> tensor<32x16xf32, #DenseMatrix> { %0 = linalg.generic #trait_3d ins(%arga: tensor<32x16x8xf32>) diff --git a/mlir/test/Dialect/SparseTensor/sparse_1d.mlir b/mlir/test/Dialect/SparseTensor/sparse_1d.mlir --- a/mlir/test/Dialect/SparseTensor/sparse_1d.mlir +++ b/mlir/test/Dialect/SparseTensor/sparse_1d.mlir @@ -21,7 +21,7 @@ // CHECK-DAG: %[[VAL_4:.*]] = arith.constant 0 : index // CHECK-DAG: %[[VAL_5:.*]] = arith.constant 1 : index // CHECK-DAG: %[[VAL_6:.*]] = sparse_tensor.values %[[VAL_0]] : tensor<32xf32, #sparse_tensor.encoding<{ dimLevelType = [ "dense" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref -// CHECK-DAG: %[[VAL_8:.*]] = memref.alloc() : memref<32xf32> +// CHECK-DAG: %[[VAL_8:.*]] = bufferization.to_memref %[[VAL_2]] // CHECK: linalg.fill ins(%{{.*}} : f32) outs(%[[VAL_8]] : memref<32xf32>) // CHECK: scf.for %[[VAL_9:.*]] = %[[VAL_4]] to %[[VAL_3]] step %[[VAL_5]] { // CHECK: %[[VAL_10:.*]] = memref.load %[[VAL_6]]{{\[}}%[[VAL_9]]] : memref @@ -49,8 +49,9 @@ // CHECK: %[[VAL_3:.*]] = arith.constant 0.000000e+00 : f32 // CHECK: %[[VAL_4:.*]] = arith.constant 0 : index // CHECK: %[[VAL_5:.*]] = arith.constant 1 : index +// CHECK: %[[VAL_INITTENSOR:.*]] = linalg.init_tensor [32] : tensor<32xf32> // CHECK: %[[VAL_6:.*]] = sparse_tensor.values %[[VAL_0]] : tensor<32xf32, #sparse_tensor.encoding<{ dimLevelType = [ "dense" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref -// CHECK: %[[VAL_7:.*]] = memref.alloc() : memref<32xf32> +// CHECK: %[[VAL_7:.*]] = bufferization.to_memref %[[VAL_INITTENSOR]] : memref<32xf32> // CHECK: linalg.fill ins(%[[VAL_3]] : f32) outs(%[[VAL_7]] : memref<32xf32>) // CHECK: scf.for %[[VAL_8:.*]] = %[[VAL_4]] to %[[VAL_2]] step %[[VAL_5]] { // CHECK: %[[VAL_9:.*]] = memref.load %[[VAL_6]]{{\[}}%[[VAL_8]]] : memref @@ -80,7 +81,7 @@ // CHECK-DAG: %[[VAL_4:.*]] = arith.constant 0 : index // CHECK-DAG: %[[VAL_5:.*]] = arith.constant 1 : index // CHECK-DAG: %[[VAL_6:.*]] = sparse_tensor.values %[[VAL_0]] : tensor<32xf32, #sparse_tensor.encoding<{ dimLevelType = [ "dense" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref -// CHECK-DAG: %[[VAL_8:.*]] = memref.alloc() : memref<32xf32> +// CHECK-DAG: %[[VAL_8:.*]] = bufferization.to_memref %[[VAL_2]] // CHECK: linalg.fill ins(%{{.*}} : f32) outs(%[[VAL_8]] : memref<32xf32>) // CHECK: scf.for %[[VAL_9:.*]] = %[[VAL_4]] to %[[VAL_3]] step %[[VAL_5]] { // CHECK: %[[VAL_10:.*]] = memref.load %[[VAL_6]]{{\[}}%[[VAL_9]]] : memref @@ -112,7 +113,7 @@ // CHECK-DAG: %[[VAL_7:.*]] = sparse_tensor.pointers %[[VAL_0]], %[[VAL_4]] : tensor<32xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_8:.*]] = sparse_tensor.indices %[[VAL_0]], %[[VAL_4]] : tensor<32xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_9:.*]] = sparse_tensor.values %[[VAL_0]] : tensor<32xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref -// CHECK-DAG: %[[VAL_11:.*]] = memref.alloc() : memref<32xf32> +// CHECK-DAG: %[[VAL_11:.*]] = bufferization.to_memref %[[VAL_2]] // CHECK: linalg.fill ins(%{{.*}} : f32) outs(%[[VAL_11]] : memref<32xf32>) // CHECK: %[[VAL_12:.*]] = memref.load %[[VAL_7]]{{\[}}%[[VAL_4]]] : memref // CHECK: %[[VAL_13:.*]] = memref.load %[[VAL_7]]{{\[}}%[[VAL_6]]] : memref @@ -164,7 +165,7 @@ // CHECK-DAG: %[[VAL_4:.*]] = sparse_tensor.pointers %[[VAL_0]], %[[VAL_2]] : tensor<32xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_5:.*]] = sparse_tensor.indices %[[VAL_0]], %[[VAL_2]] : tensor<32xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_6:.*]] = sparse_tensor.values %[[VAL_0]] : tensor<32xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref -// CHECK-DAG: %[[VAL_8:.*]] = memref.alloc() : memref<32xf32> +// CHECK-DAG: %[[VAL_8:.*]] = bufferization.to_memref %[[VAL_1]] // CHECK: linalg.fill ins(%{{.*}} : f32) outs(%[[VAL_8]] : memref<32xf32>) // CHECK: %[[VAL_9:.*]] = memref.load %[[VAL_4]]{{\[}}%[[VAL_2]]] : memref // CHECK: %[[VAL_10:.*]] = memref.load %[[VAL_4]]{{\[}}%[[VAL_3]]] : memref @@ -204,7 +205,7 @@ // CHECK-DAG: %[[VAL_5:.*]] = sparse_tensor.pointers %[[VAL_0]], %[[VAL_3]] : tensor<32xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_6:.*]] = sparse_tensor.indices %[[VAL_0]], %[[VAL_3]] : tensor<32xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_7:.*]] = sparse_tensor.values %[[VAL_0]] : tensor<32xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref -// CHECK-DAG: %[[VAL_9:.*]] = memref.alloc() : memref<32xf32> +// CHECK-DAG: %[[VAL_9:.*]] = bufferization.to_memref %[[VAL_2]] // CHECK: linalg.fill ins(%{{.*}} : f32) outs(%[[VAL_9]] : memref<32xf32>) // CHECK: %[[VAL_10:.*]] = memref.load %[[VAL_5]]{{\[}}%[[VAL_3]]] : memref // CHECK: %[[VAL_11:.*]] = memref.load %[[VAL_5]]{{\[}}%[[VAL_4]]] : memref @@ -247,7 +248,7 @@ // CHECK-DAG: %[[VAL_5:.*]] = arith.constant 1 : index // CHECK-DAG: %[[VAL_6:.*]] = sparse_tensor.values %[[VAL_0]] : tensor<32xf32, #sparse_tensor.encoding<{ dimLevelType = [ "dense" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_7:.*]] = bufferization.to_memref %[[VAL_1]] : memref<32xf32> -// CHECK-DAG: %[[VAL_9:.*]] = memref.alloc() : memref<32xf32> +// CHECK-DAG: %[[VAL_9:.*]] = bufferization.to_memref %[[VAL_2]] // CHECK: linalg.fill ins(%{{.*}} : f32) outs(%[[VAL_9]] : memref<32xf32>) // CHECK: scf.for %[[VAL_10:.*]] = %[[VAL_4]] to %[[VAL_3]] step %[[VAL_5]] { // CHECK: %[[VAL_11:.*]] = memref.load %[[VAL_6]]{{\[}}%[[VAL_10]]] : memref @@ -278,7 +279,7 @@ // CHECK-DAG: %[[VAL_5:.*]] = arith.constant 1 : index // CHECK-DAG: %[[VAL_6:.*]] = sparse_tensor.values %[[VAL_0]] : tensor<32xf32, #sparse_tensor.encoding<{ dimLevelType = [ "dense" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_7:.*]] = bufferization.to_memref %[[VAL_1]] : memref<32xf32> -// CHECK-DAG: %[[VAL_9:.*]] = memref.alloc() : memref<32xf32> +// CHECK-DAG: %[[VAL_9:.*]] = bufferization.to_memref %[[VAL_2]] // CHECK: linalg.fill ins(%{{.*}} : f32) outs(%[[VAL_9]] : memref<32xf32>) // CHECK: scf.for %[[VAL_10:.*]] = %[[VAL_4]] to %[[VAL_3]] step %[[VAL_5]] { // CHECK: %[[VAL_11:.*]] = memref.load %[[VAL_6]]{{\[}}%[[VAL_10]]] : memref @@ -312,7 +313,7 @@ // CHECK-DAG: %[[VAL_8:.*]] = sparse_tensor.pointers %[[VAL_1]], %[[VAL_4]] : tensor<32xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_9:.*]] = sparse_tensor.indices %[[VAL_1]], %[[VAL_4]] : tensor<32xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_10:.*]] = sparse_tensor.values %[[VAL_1]] : tensor<32xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref -// CHECK-DAG: %[[VAL_12:.*]] = memref.alloc() : memref<32xf32> +// CHECK-DAG: %[[VAL_12:.*]] = bufferization.to_memref %[[VAL_2]] // CHECK: linalg.fill ins(%{{.*}} : f32) outs(%[[VAL_12]] : memref<32xf32>) // CHECK: %[[VAL_13:.*]] = memref.load %[[VAL_8]]{{\[}}%[[VAL_4]]] : memref // CHECK: %[[VAL_14:.*]] = memref.load %[[VAL_8]]{{\[}}%[[VAL_6]]] : memref @@ -369,7 +370,7 @@ // CHECK-DAG: %[[VAL_6:.*]] = sparse_tensor.pointers %[[VAL_1]], %[[VAL_3]] : tensor<32xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_7:.*]] = sparse_tensor.indices %[[VAL_1]], %[[VAL_3]] : tensor<32xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_8:.*]] = sparse_tensor.values %[[VAL_1]] : tensor<32xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref -// CHECK-DAG: %[[VAL_10:.*]] = memref.alloc() : memref<32xf32> +// CHECK-DAG: %[[VAL_10:.*]] = bufferization.to_memref %[[VAL_2]] // CHECK: linalg.fill ins(%{{.*}} : f32) outs(%[[VAL_10]] : memref<32xf32>) // CHECK: %[[VAL_11:.*]] = memref.load %[[VAL_6]]{{\[}}%[[VAL_3]]] : memref // CHECK: %[[VAL_12:.*]] = memref.load %[[VAL_6]]{{\[}}%[[VAL_4]]] : memref @@ -406,7 +407,7 @@ // CHECK-DAG: %[[VAL_8:.*]] = sparse_tensor.indices %[[VAL_0]], %[[VAL_4]] : tensor<32xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_9:.*]] = sparse_tensor.values %[[VAL_0]] : tensor<32xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_10:.*]] = bufferization.to_memref %[[VAL_1]] : memref<32xf32> -// CHECK-DAG: %[[VAL_12:.*]] = memref.alloc() : memref<32xf32> +// CHECK-DAG: %[[VAL_12:.*]] = bufferization.to_memref %[[VAL_2]] // CHECK: linalg.fill ins(%{{.*}} : f32) outs(%[[VAL_12]] : memref<32xf32>) // CHECK: %[[VAL_13:.*]] = memref.load %[[VAL_7]]{{\[}}%[[VAL_4]]] : memref // CHECK: %[[VAL_14:.*]] = memref.load %[[VAL_7]]{{\[}}%[[VAL_6]]] : memref @@ -463,7 +464,7 @@ // CHECK-DAG: %[[VAL_6:.*]] = sparse_tensor.indices %[[VAL_0]], %[[VAL_3]] : tensor<32xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_7:.*]] = sparse_tensor.values %[[VAL_0]] : tensor<32xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_8:.*]] = bufferization.to_memref %[[VAL_1]] : memref<32xf32> -// CHECK-DAG: %[[VAL_10:.*]] = memref.alloc() : memref<32xf32> +// CHECK-DAG: %[[VAL_10:.*]] = bufferization.to_memref %[[VAL_2]] // CHECK: linalg.fill ins(%{{.*}} : f32) outs(%[[VAL_10]] : memref<32xf32>) // CHECK: %[[VAL_11:.*]] = memref.load %[[VAL_5]]{{\[}}%[[VAL_3]]] : memref // CHECK: %[[VAL_12:.*]] = memref.load %[[VAL_5]]{{\[}}%[[VAL_4]]] : memref @@ -500,7 +501,7 @@ // CHECK-DAG: %[[VAL_8:.*]] = sparse_tensor.pointers %[[VAL_1]], %[[VAL_3]] : tensor<32xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_9:.*]] = sparse_tensor.indices %[[VAL_1]], %[[VAL_3]] : tensor<32xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_10:.*]] = sparse_tensor.values %[[VAL_1]] : tensor<32xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref -// CHECK-DAG: %[[VAL_12:.*]] = memref.alloc() : memref<32xf32> +// CHECK-DAG: %[[VAL_12:.*]] = bufferization.to_memref %[[VAL_2]] // CHECK: linalg.fill ins(%{{.*}} : f32) outs(%[[VAL_12]] : memref<32xf32>) // CHECK: %[[VAL_13:.*]] = memref.load %[[VAL_5]]{{\[}}%[[VAL_3]]] : memref // CHECK: %[[VAL_14:.*]] = memref.load %[[VAL_5]]{{\[}}%[[VAL_4]]] : memref @@ -583,7 +584,7 @@ // CHECK-DAG: %[[VAL_8:.*]] = sparse_tensor.pointers %[[VAL_1]], %[[VAL_3]] : tensor<32xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_9:.*]] = sparse_tensor.indices %[[VAL_1]], %[[VAL_3]] : tensor<32xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_10:.*]] = sparse_tensor.values %[[VAL_1]] : tensor<32xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref -// CHECK-DAG: %[[VAL_12:.*]] = memref.alloc() : memref<32xf32> +// CHECK-DAG: %[[VAL_12:.*]] = bufferization.to_memref %[[VAL_2]] // CHECK: linalg.fill ins(%{{.*}} : f32) outs(%[[VAL_12]] : memref<32xf32>) // CHECK: %[[VAL_13:.*]] = memref.load %[[VAL_5]]{{\[}}%[[VAL_3]]] : memref // CHECK: %[[VAL_14:.*]] = memref.load %[[VAL_5]]{{\[}}%[[VAL_4]]] : memref @@ -645,7 +646,7 @@ // CHECK-DAG: %[[VAL_9:.*]] = sparse_tensor.pointers %[[VAL_1]], %[[VAL_4]] : tensor<16xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_10:.*]] = sparse_tensor.indices %[[VAL_1]], %[[VAL_4]] : tensor<16xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_11:.*]] = sparse_tensor.values %[[VAL_1]] : tensor<16xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref -// CHECK-DAG: %[[VAL_13:.*]] = memref.alloc() : memref<16xf32> +// CHECK-DAG: %[[VAL_13:.*]] = bufferization.to_memref %[[VAL_3]] // CHECK: linalg.fill ins(%{{.*}} : f32) outs(%[[VAL_13]] : memref<16xf32>) // CHECK: %[[VAL_14:.*]] = memref.load %[[VAL_6]]{{\[}}%[[VAL_4]]] : memref // CHECK: %[[VAL_15:.*]] = memref.load %[[VAL_6]]{{\[}}%[[VAL_5]]] : memref @@ -738,7 +739,7 @@ // CHECK-DAG: %[[VAL_9:.*]] = sparse_tensor.pointers %[[VAL_1]], %[[VAL_4]] : tensor<16xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_10:.*]] = sparse_tensor.indices %[[VAL_1]], %[[VAL_4]] : tensor<16xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_11:.*]] = sparse_tensor.values %[[VAL_1]] : tensor<16xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref -// CHECK-DAG: %[[VAL_13:.*]] = memref.alloc() : memref<16xf32> +// CHECK-DAG: %[[VAL_13:.*]] = bufferization.to_memref %[[VAL_3]] // CHECK: linalg.fill ins(%{{.*}} : f32) outs(%[[VAL_13]] : memref<16xf32>) // CHECK: %[[VAL_14:.*]] = memref.load %[[VAL_6]]{{\[}}%[[VAL_4]]] : memref // CHECK: %[[VAL_15:.*]] = memref.load %[[VAL_6]]{{\[}}%[[VAL_5]]] : memref @@ -834,18 +835,16 @@ // CHECK-DAG: %[[VAL_4:.*]] = sparse_tensor.pointers %[[VAL_0]], %[[VAL_2]] : tensor> to memref // CHECK-DAG: %[[VAL_5:.*]] = sparse_tensor.values %[[VAL_0]] : tensor> to memref // CHECK-DAG: %[[VAL_6:.*]] = bufferization.to_memref %[[VAL_1]] : memref -// CHECK-DAG: %[[VAL_7:.*]] = memref.alloc() : memref -// CHECK: memref.copy %[[VAL_6]], %[[VAL_7]] : memref to memref // CHECK-DAG: %[[VAL_8:.*]] = memref.load %[[VAL_4]]{{\[}}%[[VAL_2]]] : memref // CHECK-DAG: %[[VAL_9:.*]] = memref.load %[[VAL_4]]{{\[}}%[[VAL_3]]] : memref -// CHECK-DAG: %[[VAL_10:.*]] = memref.load %[[VAL_7]][] : memref +// CHECK-DAG: %[[VAL_10:.*]] = memref.load %[[VAL_6]][] : memref // CHECK: %[[VAL_11:.*]] = scf.for %[[VAL_12:.*]] = %[[VAL_8]] to %[[VAL_9]] step %[[VAL_3]] iter_args(%[[VAL_13:.*]] = %[[VAL_10]]) -> (f32) { // CHECK: %[[VAL_14:.*]] = memref.load %[[VAL_5]]{{\[}}%[[VAL_12]]] : memref // CHECK: %[[VAL_15:.*]] = arith.addf %[[VAL_13]], %[[VAL_14]] : f32 // CHECK: scf.yield %[[VAL_15]] : f32 // CHECK: } -// CHECK: memref.store %[[VAL_11]], %[[VAL_7]][] : memref -// CHECK: %[[VAL_17:.*]] = bufferization.to_tensor %[[VAL_7]] : memref +// CHECK: memref.store %[[VAL_11]], %[[VAL_6]][] : memref +// CHECK: %[[VAL_17:.*]] = bufferization.to_tensor %[[VAL_6]] : memref // CHECK: return %[[VAL_17]] : tensor // CHECK: } func.func @sum_reduction(%arga: tensor, %argx: tensor) -> tensor { @@ -882,9 +881,7 @@ // CHECK-DAG: %[[VAL_9:.*]] = sparse_tensor.indices %[[VAL_1]], %[[VAL_3]] : tensor<16xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_10:.*]] = sparse_tensor.values %[[VAL_1]] : tensor<16xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_11:.*]] = bufferization.to_memref %[[VAL_2]] : memref -// CHECK-DAG: %[[VAL_12:.*]] = memref.alloc() : memref -// CHECK: memref.copy %[[VAL_11]], %[[VAL_12]] : memref to memref -// CHECK: %[[VAL_13:.*]] = memref.load %[[VAL_12]][] : memref +// CHECK: %[[VAL_13:.*]] = memref.load %[[VAL_11]][] : memref // CHECK: %[[VAL_14:.*]] = memref.load %[[VAL_5]]{{\[}}%[[VAL_3]]] : memref // CHECK: %[[VAL_15:.*]] = memref.load %[[VAL_5]]{{\[}}%[[VAL_4]]] : memref // CHECK: %[[VAL_16:.*]] = memref.load %[[VAL_8]]{{\[}}%[[VAL_3]]] : memref @@ -946,8 +943,8 @@ // CHECK: %[[VAL_69:.*]] = arith.addf %[[VAL_66]], %[[VAL_68]] : f32 // CHECK: scf.yield %[[VAL_69]] : f32 // CHECK: } -// CHECK: memref.store %[[VAL_70:.*]], %[[VAL_12]][] : memref -// CHECK: %[[VAL_71:.*]] = bufferization.to_tensor %[[VAL_12]] : memref +// CHECK: memref.store %[[VAL_70:.*]], %[[VAL_11]][] : memref +// CHECK: %[[VAL_71:.*]] = bufferization.to_tensor %[[VAL_11]] : memref // CHECK: return %[[VAL_71]] : tensor // CHECK: } func.func @sum_reduction_ss(%arga: tensor<16xf32, #SV>, @@ -992,9 +989,7 @@ // CHECK-DAG: %[[VAL_11:.*]] = sparse_tensor.indices %[[VAL_2]], %[[VAL_4]] : tensor<16xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_12:.*]] = sparse_tensor.values %[[VAL_2]] : tensor<16xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_13:.*]] = bufferization.to_memref %[[VAL_3]] : memref -// CHECK-DAG: %[[VAL_14:.*]] = memref.alloc() : memref -// CHECK: memref.copy %[[VAL_13]], %[[VAL_14]] : memref to memref -// CHECK: %[[VAL_15:.*]] = memref.load %[[VAL_14]][] : memref +// CHECK: %[[VAL_15:.*]] = memref.load %[[VAL_13]][] : memref // CHECK: %[[VAL_16:.*]] = memref.load %[[VAL_9]][] : memref // CHECK: %[[VAL_17:.*]] = memref.load %[[VAL_6]]{{\[}}%[[VAL_4]]] : memref // CHECK: %[[VAL_18:.*]] = memref.load %[[VAL_6]]{{\[}}%[[VAL_5]]] : memref @@ -1060,8 +1055,8 @@ // CHECK: %[[VAL_75:.*]] = arith.addf %[[VAL_72]], %[[VAL_74]] : f32 // CHECK: scf.yield %[[VAL_75]] : f32 // CHECK: } -// CHECK: memref.store %[[VAL_76:.*]], %[[VAL_14]][] : memref -// CHECK: %[[VAL_77:.*]] = bufferization.to_tensor %[[VAL_14]] : memref +// CHECK: memref.store %[[VAL_76:.*]], %[[VAL_13]][] : memref +// CHECK: %[[VAL_77:.*]] = bufferization.to_tensor %[[VAL_13]] : memref // CHECK: return %[[VAL_77]] : tensor // CHECK: } func.func @sum_reduction_inv(%arga: tensor<16xf32, #SV>, @@ -1112,7 +1107,7 @@ // CHECK-DAG: %[[VAL_14:.*]] = sparse_tensor.indices %[[VAL_3]], %[[VAL_5]] : tensor> to memref // CHECK-DAG: %[[VAL_15:.*]] = sparse_tensor.values %[[VAL_3]] : tensor> to memref // CHECK-DAG: %[[VAL_16:.*]] = tensor.dim %[[VAL_4]], %[[VAL_5]] : tensor -// CHECK-DAG: %[[VAL_18:.*]] = memref.alloc(%[[VAL_16]]) : memref +// CHECK-DAG: %[[VAL_18:.*]] = bufferization.to_memref %[[VAL_4]] // CHECK: linalg.fill ins(%{{.*}} : f64) outs(%[[VAL_18]] : memref) // CHECK: %[[VAL_19:.*]] = memref.load %[[VAL_9]]{{\[}}%[[VAL_5]]] : memref // CHECK: %[[VAL_20:.*]] = memref.load %[[VAL_9]]{{\[}}%[[VAL_7]]] : memref @@ -1289,9 +1284,7 @@ // CHECK-DAG: %[[VAL_13:.*]] = sparse_tensor.indices %[[VAL_2]], %[[VAL_4]] : tensor> to memref // CHECK-DAG: %[[VAL_14:.*]] = sparse_tensor.values %[[VAL_2]] : tensor> to memref // CHECK-DAG: %[[VAL_15:.*]] = bufferization.to_memref %[[VAL_3]] : memref -// CHECK-DAG: %[[VAL_16:.*]] = memref.alloc() : memref -// CHECK: memref.copy %[[VAL_15]], %[[VAL_16]] : memref to memref -// CHECK: %[[VAL_17:.*]] = memref.load %[[VAL_16]][] : memref +// CHECK: %[[VAL_17:.*]] = memref.load %[[VAL_15]][] : memref // CHECK: %[[VAL_18:.*]] = memref.load %[[VAL_6]]{{\[}}%[[VAL_4]]] : memref // CHECK: %[[VAL_19:.*]] = memref.load %[[VAL_6]]{{\[}}%[[VAL_5]]] : memref // CHECK: %[[VAL_20:.*]] = memref.load %[[VAL_9]]{{\[}}%[[VAL_4]]] : memref @@ -1557,8 +1550,8 @@ // CHECK: %[[VAL_250:.*]] = arith.addf %[[VAL_247]], %[[VAL_249]] : f64 // CHECK: scf.yield %[[VAL_250]] : f64 // CHECK: } -// CHECK: memref.store %[[VAL_251:.*]], %[[VAL_16]][] : memref -// CHECK: %[[VAL_252:.*]] = bufferization.to_tensor %[[VAL_16]] : memref +// CHECK: memref.store %[[VAL_251:.*]], %[[VAL_15]][] : memref +// CHECK: %[[VAL_252:.*]] = bufferization.to_tensor %[[VAL_15]] : memref // CHECK: return %[[VAL_252]] : tensor // CHECK: } func.func @red3s(%arga: tensor, diff --git a/mlir/test/Dialect/SparseTensor/sparse_2d.mlir b/mlir/test/Dialect/SparseTensor/sparse_2d.mlir --- a/mlir/test/Dialect/SparseTensor/sparse_2d.mlir +++ b/mlir/test/Dialect/SparseTensor/sparse_2d.mlir @@ -26,7 +26,7 @@ // CHECK-DAG: %[[VAL_6:.*]] = arith.constant 1 : index // CHECK-DAG: %[[VAL_7:.*]] = sparse_tensor.values %[[VAL_0]] : tensor<32x16xf32, #sparse_tensor.encoding<{ dimLevelType = [ "dense", "dense" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_8:.*]] = bufferization.to_memref %[[VAL_1]] : memref<32x16xf32> -// CHECK-DAG: %[[VAL_10:.*]] = memref.alloc() : memref<32x16xf32> +// CHECK-DAG: %[[VAL_10:.*]] = bufferization.to_memref %[[VAL_2]] : memref<32x16xf32> // CHECK: linalg.fill ins(%{{.*}} : f32) outs(%[[VAL_10]] : memref<32x16xf32>) // CHECK: scf.for %[[VAL_11:.*]] = %[[VAL_5]] to %[[VAL_3]] step %[[VAL_6]] { // CHECK: scf.for %[[VAL_12:.*]] = %[[VAL_5]] to %[[VAL_4]] step %[[VAL_6]] { @@ -62,7 +62,7 @@ // CHECK-DAG: %[[VAL_6:.*]] = arith.constant 1 : index // CHECK-DAG: %[[VAL_7:.*]] = sparse_tensor.values %[[VAL_0]] : tensor<32x16xf32, #sparse_tensor.encoding<{ dimLevelType = [ "dense", "dense" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_8:.*]] = bufferization.to_memref %[[VAL_1]] : memref<32x16xf32> -// CHECK-DAG: %[[VAL_10:.*]] = memref.alloc() : memref<32x16xf32> +// CHECK-DAG: %[[VAL_10:.*]] = bufferization.to_memref %[[VAL_2]] : memref<32x16xf32> // CHECK: linalg.fill ins(%{{.*}} : f32) outs(%[[VAL_10]] : memref<32x16xf32>) // CHECK: scf.for %[[VAL_11:.*]] = %[[VAL_5]] to %[[VAL_3]] step %[[VAL_6]] { // CHECK: scf.for %[[VAL_12:.*]] = %[[VAL_5]] to %[[VAL_4]] step %[[VAL_6]] { @@ -101,7 +101,7 @@ // CHECK-DAG: %[[VAL_9:.*]] = sparse_tensor.indices %[[VAL_0]], %[[VAL_7]] : tensor<32x16xf32, #sparse_tensor.encoding<{ dimLevelType = [ "dense", "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_10:.*]] = sparse_tensor.values %[[VAL_0]] : tensor<32x16xf32, #sparse_tensor.encoding<{ dimLevelType = [ "dense", "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_11:.*]] = bufferization.to_memref %[[VAL_1]] : memref<32x16xf32> -// CHECK-DAG: %[[VAL_13:.*]] = memref.alloc() : memref<32x16xf32> +// CHECK-DAG: %[[VAL_13:.*]] = bufferization.to_memref %[[VAL_2]] : memref<32x16xf32> // CHECK: linalg.fill ins(%{{.*}} : f32) outs(%[[VAL_13]] : memref<32x16xf32>) // CHECK: scf.for %[[VAL_14:.*]] = %[[VAL_5]] to %[[VAL_3]] step %[[VAL_7]] { // CHECK: %[[VAL_15:.*]] = memref.load %[[VAL_8]]{{\[}}%[[VAL_14]]] : memref @@ -162,7 +162,7 @@ // CHECK-DAG: %[[VAL_7:.*]] = sparse_tensor.indices %[[VAL_0]], %[[VAL_5]] : tensor<32x16xf32, #sparse_tensor.encoding<{ dimLevelType = [ "dense", "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_8:.*]] = sparse_tensor.values %[[VAL_0]] : tensor<32x16xf32, #sparse_tensor.encoding<{ dimLevelType = [ "dense", "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_9:.*]] = bufferization.to_memref %[[VAL_1]] : memref<32x16xf32> -// CHECK-DAG: %[[VAL_11:.*]] = memref.alloc() : memref<32x16xf32> +// CHECK-DAG: %[[VAL_11:.*]] = bufferization.to_memref %[[VAL_2]] : memref<32x16xf32> // CHECK: linalg.fill ins(%{{.*}} : f32) outs(%[[VAL_11]] : memref<32x16xf32>) // CHECK: scf.for %[[VAL_12:.*]] = %[[VAL_4]] to %[[VAL_3]] step %[[VAL_5]] { // CHECK: %[[VAL_13:.*]] = memref.load %[[VAL_6]]{{\[}}%[[VAL_12]]] : memref @@ -203,7 +203,7 @@ // CHECK-DAG: %[[VAL_9:.*]] = sparse_tensor.indices %[[VAL_0]], %[[VAL_6]] : tensor<32x16xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed", "dense" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_10:.*]] = sparse_tensor.values %[[VAL_0]] : tensor<32x16xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed", "dense" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_11:.*]] = bufferization.to_memref %[[VAL_1]] : memref<32x16xf32> -// CHECK-DAG: %[[VAL_13:.*]] = memref.alloc() : memref<32x16xf32> +// CHECK-DAG: %[[VAL_13:.*]] = bufferization.to_memref %[[VAL_2]] : memref<32x16xf32> // CHECK: linalg.fill ins(%{{.*}} : f32) outs(%[[VAL_13]] : memref<32x16xf32>) // CHECK: %[[VAL_14:.*]] = memref.load %[[VAL_8]]{{\[}}%[[VAL_6]]] : memref // CHECK: %[[VAL_15:.*]] = memref.load %[[VAL_8]]{{\[}}%[[VAL_7]]] : memref @@ -269,7 +269,7 @@ // CHECK-DAG: %[[VAL_7:.*]] = sparse_tensor.indices %[[VAL_0]], %[[VAL_4]] : tensor<32x16xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed", "dense" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_8:.*]] = sparse_tensor.values %[[VAL_0]] : tensor<32x16xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed", "dense" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_9:.*]] = bufferization.to_memref %[[VAL_1]] : memref<32x16xf32> -// CHECK-DAG: %[[VAL_11:.*]] = memref.alloc() : memref<32x16xf32> +// CHECK-DAG: %[[VAL_11:.*]] = bufferization.to_memref %[[VAL_2]] : memref<32x16xf32> // CHECK: linalg.fill ins(%{{.*}} : f32) outs(%[[VAL_11]] : memref<32x16xf32>) // CHECK: %[[VAL_12:.*]] = memref.load %[[VAL_6]]{{\[}}%[[VAL_4]]] : memref // CHECK: %[[VAL_13:.*]] = memref.load %[[VAL_6]]{{\[}}%[[VAL_5]]] : memref @@ -313,7 +313,7 @@ // CHECK-DAG: %[[VAL_11:.*]] = sparse_tensor.indices %[[VAL_0]], %[[VAL_7]] : tensor<32x16xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed", "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_12:.*]] = sparse_tensor.values %[[VAL_0]] : tensor<32x16xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed", "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_13:.*]] = bufferization.to_memref %[[VAL_1]] : memref<32x16xf32> -// CHECK-DAG: %[[VAL_15:.*]] = memref.alloc() : memref<32x16xf32> +// CHECK-DAG: %[[VAL_15:.*]] = bufferization.to_memref %[[VAL_2]] : memref<32x16xf32> // CHECK: linalg.fill ins(%{{.*}} : f32) outs(%[[VAL_15]] : memref<32x16xf32>) // CHECK: %[[VAL_16:.*]] = memref.load %[[VAL_8]]{{\[}}%[[VAL_6]]] : memref // CHECK: %[[VAL_17:.*]] = memref.load %[[VAL_8]]{{\[}}%[[VAL_7]]] : memref @@ -404,7 +404,7 @@ // CHECK-DAG: %[[VAL_8:.*]] = sparse_tensor.indices %[[VAL_0]], %[[VAL_4]] : tensor<32x16xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed", "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_9:.*]] = sparse_tensor.values %[[VAL_0]] : tensor<32x16xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed", "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_10:.*]] = bufferization.to_memref %[[VAL_1]] : memref<32x16xf32> -// CHECK-DAG: %[[VAL_12:.*]] = memref.alloc() : memref<32x16xf32> +// CHECK-DAG: %[[VAL_12:.*]] = bufferization.to_memref %[[VAL_2]] : memref<32x16xf32> // CHECK: linalg.fill ins(%{{.*}} : f32) outs(%[[VAL_12]] : memref<32x16xf32>) // CHECK: %[[VAL_13:.*]] = memref.load %[[VAL_5]]{{\[}}%[[VAL_3]]] : memref // CHECK: %[[VAL_14:.*]] = memref.load %[[VAL_5]]{{\[}}%[[VAL_4]]] : memref @@ -451,7 +451,7 @@ // CHECK-DAG: %[[VAL_12:.*]] = sparse_tensor.pointers %[[VAL_1]], %[[VAL_4]] : tensor<32x16xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed", "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_13:.*]] = sparse_tensor.indices %[[VAL_1]], %[[VAL_4]] : tensor<32x16xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed", "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_14:.*]] = sparse_tensor.values %[[VAL_1]] : tensor<32x16xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed", "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref -// CHECK-DAG: %[[VAL_16:.*]] = memref.alloc() : memref<32x16xf32> +// CHECK-DAG: %[[VAL_16:.*]] = bufferization.to_memref %[[VAL_2]] : memref<32x16xf32> // CHECK: linalg.fill ins(%{{.*}} : f32) outs(%[[VAL_16]] : memref<32x16xf32>) // CHECK: %[[VAL_17:.*]] = memref.load %[[VAL_5]]{{\[}}%[[VAL_3]]] : memref // CHECK: %[[VAL_18:.*]] = memref.load %[[VAL_5]]{{\[}}%[[VAL_4]]] : memref @@ -615,7 +615,7 @@ // CHECK-DAG: %[[VAL_12:.*]] = sparse_tensor.pointers %[[VAL_1]], %[[VAL_4]] : tensor<32x16xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed", "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_13:.*]] = sparse_tensor.indices %[[VAL_1]], %[[VAL_4]] : tensor<32x16xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed", "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_14:.*]] = sparse_tensor.values %[[VAL_1]] : tensor<32x16xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed", "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref -// CHECK-DAG: %[[VAL_16:.*]] = memref.alloc() : memref<32x16xf32> +// CHECK-DAG: %[[VAL_16:.*]] = bufferization.to_memref %[[VAL_2]] : memref<32x16xf32> // CHECK: linalg.fill ins(%{{.*}} : f32) outs(%[[VAL_16]] : memref<32x16xf32>) // CHECK: %[[VAL_17:.*]] = memref.load %[[VAL_5]]{{\[}}%[[VAL_3]]] : memref // CHECK: %[[VAL_18:.*]] = memref.load %[[VAL_5]]{{\[}}%[[VAL_4]]] : memref @@ -710,7 +710,7 @@ // CHECK-DAG: %[[VAL_11:.*]] = sparse_tensor.pointers %[[VAL_1]], %[[VAL_7]] : tensor<32x16xf32, #sparse_tensor.encoding<{ dimLevelType = [ "dense", "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_12:.*]] = sparse_tensor.indices %[[VAL_1]], %[[VAL_7]] : tensor<32x16xf32, #sparse_tensor.encoding<{ dimLevelType = [ "dense", "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_13:.*]] = sparse_tensor.values %[[VAL_1]] : tensor<32x16xf32, #sparse_tensor.encoding<{ dimLevelType = [ "dense", "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref -// CHECK-DAG: %[[VAL_15:.*]] = memref.alloc() : memref<32x16xf32> +// CHECK-DAG: %[[VAL_15:.*]] = bufferization.to_memref %[[VAL_2]] : memref<32x16xf32> // CHECK: linalg.fill ins(%{{.*}} : f32) outs(%[[VAL_15]] : memref<32x16xf32>) // CHECK: %[[VAL_16:.*]] = memref.load %[[VAL_8]]{{\[}}%[[VAL_5]]] : memref // CHECK: %[[VAL_17:.*]] = memref.load %[[VAL_8]]{{\[}}%[[VAL_7]]] : memref @@ -814,7 +814,7 @@ // CHECK-DAG: %[[VAL_9:.*]] = sparse_tensor.pointers %[[VAL_1]], %[[VAL_5]] : tensor<32x16xf32, #sparse_tensor.encoding<{ dimLevelType = [ "dense", "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_10:.*]] = sparse_tensor.indices %[[VAL_1]], %[[VAL_5]] : tensor<32x16xf32, #sparse_tensor.encoding<{ dimLevelType = [ "dense", "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_11:.*]] = sparse_tensor.values %[[VAL_1]] : tensor<32x16xf32, #sparse_tensor.encoding<{ dimLevelType = [ "dense", "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref -// CHECK-DAG: %[[VAL_13:.*]] = memref.alloc() : memref<32x16xf32> +// CHECK-DAG: %[[VAL_13:.*]] = bufferization.to_memref %[[VAL_2]] : memref<32x16xf32> // CHECK: linalg.fill ins(%{{.*}} : f32) outs(%[[VAL_13]] : memref<32x16xf32>) // CHECK: %[[VAL_14:.*]] = memref.load %[[VAL_6]]{{\[}}%[[VAL_4]]] : memref // CHECK: %[[VAL_15:.*]] = memref.load %[[VAL_6]]{{\[}}%[[VAL_5]]] : memref @@ -868,9 +868,7 @@ // CHECK-DAG: %[[VAL_7:.*]] = sparse_tensor.indices %[[VAL_0]], %[[VAL_5]] : tensor<16x32xf32, #sparse_tensor.encoding<{ dimLevelType = [ "dense", "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_8:.*]] = sparse_tensor.values %[[VAL_0]] : tensor<16x32xf32, #sparse_tensor.encoding<{ dimLevelType = [ "dense", "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_9:.*]] = bufferization.to_memref %[[VAL_1]] : memref<32xf32> -// CHECK-DAG: %[[VAL_10:.*]] = bufferization.to_memref %[[VAL_2]] : memref<16xf32> -// CHECK-DAG: %[[VAL_11:.*]] = memref.alloc() : memref<16xf32> -// CHECK: memref.copy %[[VAL_10]], %[[VAL_11]] : memref<16xf32> to memref<16xf32> +// CHECK-DAG: %[[VAL_11:.*]] = bufferization.to_memref %[[VAL_2]] : memref<16xf32> // CHECK: scf.for %[[VAL_12:.*]] = %[[VAL_4]] to %[[VAL_3]] step %[[VAL_5]] { // CHECK-DAG: %[[VAL_13:.*]] = memref.load %[[VAL_6]]{{\[}}%[[VAL_12]]] : memref // CHECK-DAG: %[[VAL_14:.*]] = arith.addi %[[VAL_12]], %[[VAL_5]] : index @@ -918,9 +916,7 @@ // CHECK-DAG: %[[VAL_4:.*]] = arith.constant 0 : index // CHECK-DAG: %[[VAL_5:.*]] = sparse_tensor.pointers %[[VAL_0]], %[[VAL_3]] : tensor<10x20xf32, #sparse_tensor.encoding<{ dimLevelType = [ "dense", "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_6:.*]] = sparse_tensor.values %[[VAL_0]] : tensor<10x20xf32, #sparse_tensor.encoding<{ dimLevelType = [ "dense", "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref -// CHECK-DAG: %[[VAL_7:.*]] = bufferization.to_memref %[[VAL_1]] : memref -// CHECK-DAG: %[[VAL_8:.*]] = memref.alloc() : memref -// CHECK: memref.copy %[[VAL_7]], %[[VAL_8]] : memref to memref +// CHECK-DAG: %[[VAL_8:.*]] = bufferization.to_memref %[[VAL_1]] : memref // CHECK: %[[VAL_9:.*]] = memref.load %[[VAL_8]][] : memref // CHECK: %[[VAL_10:.*]] = scf.for %[[VAL_11:.*]] = %[[VAL_4]] to %[[VAL_2]] step %[[VAL_3]] iter_args(%[[VAL_12:.*]] = %[[VAL_9]]) -> (f32) { // CHECK: %[[VAL_13:.*]] = memref.load %[[VAL_5]]{{\[}}%[[VAL_11]]] : memref @@ -967,8 +963,7 @@ // CHECK-DAG: %[[VAL_6:.*]] = sparse_tensor.indices %[[VAL_0]], %[[VAL_4]] : tensor> to memref // CHECK-DAG: %[[VAL_7:.*]] = sparse_tensor.values %[[VAL_0]] : tensor> to memref // CHECK-DAG: %[[VAL_8:.*]] = tensor.dim %[[VAL_1]], %[[VAL_3]] : tensor -// CHECK-DAG: %[[VAL_9:.*]] = tensor.dim %[[VAL_1]], %[[VAL_4]] : tensor -// CHECK-DAG: %[[VAL_11:.*]] = memref.alloc(%[[VAL_8]], %[[VAL_9]]) : memref +// CHECK-DAG: %[[VAL_11:.*]] = bufferization.to_memref %[[VAL_1]] : memref // CHECK: linalg.fill ins(%{{.*}} : f64) outs(%[[VAL_11]] : memref) // CHECK: scf.for %[[VAL_12:.*]] = %[[VAL_3]] to %[[VAL_8]] step %[[VAL_4]] { // CHECK: %[[VAL_13:.*]] = memref.load %[[VAL_5]]{{\[}}%[[VAL_12]]] : memref @@ -1022,11 +1017,7 @@ // CHECK-DAG: %[[VAL_11:.*]] = bufferization.to_memref %[[VAL_1]] : memref // CHECK-DAG: %[[VAL_12:.*]] = tensor.dim %[[VAL_2]], %[[VAL_4]] : tensor // CHECK-DAG: %[[VAL_13:.*]] = bufferization.to_memref %[[VAL_2]] : memref -// CHECK-DAG: %[[VAL_14:.*]] = tensor.dim %[[VAL_3]], %[[VAL_4]] : tensor -// CHECK-DAG: %[[VAL_15:.*]] = tensor.dim %[[VAL_3]], %[[VAL_5]] : tensor -// CHECK-DAG: %[[VAL_16:.*]] = bufferization.to_memref %[[VAL_3]] : memref -// CHECK-DAG: %[[VAL_17:.*]] = memref.alloc(%[[VAL_14]], %[[VAL_15]]) : memref -// CHECK: memref.copy %[[VAL_16]], %[[VAL_17]] : memref to memref +// CHECK-DAG: %[[VAL_17:.*]] = bufferization.to_memref %[[VAL_3]] : memref // CHECK: %[[VAL_18:.*]] = memref.load %[[VAL_6]]{{\[}}%[[VAL_4]]] : memref // CHECK: %[[VAL_19:.*]] = memref.load %[[VAL_6]]{{\[}}%[[VAL_5]]] : memref // CHECK: scf.for %[[VAL_20:.*]] = %[[VAL_18]] to %[[VAL_19]] step %[[VAL_5]] { @@ -1105,9 +1096,7 @@ // CHECK-DAG: %[[VAL_20:.*]] = bufferization.to_memref %[[VAL_3]] : memref // CHECK-DAG: %[[VAL_21:.*]] = bufferization.to_memref %[[VAL_4]] : memref // CHECK-DAG: %[[VAL_22:.*]] = tensor.dim %[[VAL_5]], %[[VAL_6]] : tensor -// CHECK-DAG: %[[VAL_23:.*]] = bufferization.to_memref %[[VAL_5]] : memref -// CHECK-DAG: %[[VAL_24:.*]] = memref.alloc(%[[VAL_22]]) : memref -// CHECK: memref.copy %[[VAL_23]], %[[VAL_24]] : memref to memref +// CHECK-DAG: %[[VAL_24:.*]] = bufferization.to_memref %[[VAL_5]] : memref // CHECK: %[[VAL_25:.*]] = memref.load %[[VAL_21]][] : memref // CHECK: %[[VAL_26:.*]] = memref.load %[[VAL_9]]{{\[}}%[[VAL_6]]] : memref // CHECK: %[[VAL_27:.*]] = memref.load %[[VAL_9]]{{\[}}%[[VAL_7]]] : memref diff --git a/mlir/test/Dialect/SparseTensor/sparse_3d.mlir b/mlir/test/Dialect/SparseTensor/sparse_3d.mlir --- a/mlir/test/Dialect/SparseTensor/sparse_3d.mlir +++ b/mlir/test/Dialect/SparseTensor/sparse_3d.mlir @@ -34,7 +34,7 @@ // CHECK-DAG: %[[VAL_7:.*]] = arith.constant 1 : index // CHECK-DAG: %[[VAL_8:.*]] = sparse_tensor.values %[[VAL_0]] : tensor<32x16x8xf32, #sparse_tensor.encoding<{ dimLevelType = [ "dense", "dense", "dense" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_9:.*]] = bufferization.to_memref %[[VAL_1]] : memref<32x16x8xf32> -// CHECK-DAG: %[[VAL_11:.*]] = memref.alloc() : memref<32x16x8xf32> +// CHECK-DAG: %[[VAL_11:.*]] = bufferization.to_memref %[[VAL_2]] : memref<32x16x8xf32> // CHECK: linalg.fill ins(%[[ZERO]] : f32) outs(%[[VAL_11]] : memref<32x16x8xf32>) // CHECK: scf.for %[[VAL_12:.*]] = %[[VAL_6]] to %[[VAL_3]] step %[[VAL_7]] { // CHECK: scf.for %[[VAL_13:.*]] = %[[VAL_6]] to %[[VAL_4]] step %[[VAL_7]] { @@ -76,7 +76,7 @@ // CHECK-DAG: %[[VAL_7:.*]] = arith.constant 1 : index // CHECK-DAG: %[[VAL_8:.*]] = sparse_tensor.values %[[VAL_0]] : tensor<32x16x8xf32, #sparse_tensor.encoding<{ dimLevelType = [ "dense", "dense", "dense" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_9:.*]] = bufferization.to_memref %[[VAL_1]] : memref<32x16x8xf32> -// CHECK-DAG: %[[VAL_11:.*]] = memref.alloc() : memref<32x16x8xf32> +// CHECK-DAG: %[[VAL_11:.*]] = bufferization.to_memref %[[VAL_2]] : memref<32x16x8xf32> // CHECK: linalg.fill ins(%[[ZERO]] : f32) outs(%[[VAL_11]] : memref<32x16x8xf32>) // CHECK: scf.for %[[VAL_12:.*]] = %[[VAL_6]] to %[[VAL_3]] step %[[VAL_7]] { // CHECK: scf.for %[[VAL_13:.*]] = %[[VAL_6]] to %[[VAL_4]] step %[[VAL_7]] { @@ -122,7 +122,7 @@ // CHECK-DAG: %[[VAL_11:.*]] = sparse_tensor.indices %[[VAL_0]], %[[VAL_3]] : tensor<32x16x8xf32, #sparse_tensor.encoding<{ dimLevelType = [ "dense", "dense", "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_12:.*]] = sparse_tensor.values %[[VAL_0]] : tensor<32x16x8xf32, #sparse_tensor.encoding<{ dimLevelType = [ "dense", "dense", "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_13:.*]] = bufferization.to_memref %[[VAL_1]] : memref<32x16x8xf32> -// CHECK-DAG: %[[VAL_15:.*]] = memref.alloc() : memref<32x16x8xf32> +// CHECK-DAG: %[[VAL_15:.*]] = bufferization.to_memref %[[VAL_2]] : memref<32x16x8xf32> // CHECK: linalg.fill ins(%[[ZERO]] : f32) outs(%[[VAL_15]] : memref<32x16x8xf32>) // CHECK: scf.for %[[VAL_16:.*]] = %[[VAL_7]] to %[[VAL_4]] step %[[VAL_9]] { // CHECK: scf.for %[[VAL_17:.*]] = %[[VAL_7]] to %[[VAL_5]] step %[[VAL_9]] { @@ -190,7 +190,7 @@ // CHECK-DAG: %[[VAL_9:.*]] = sparse_tensor.indices %[[VAL_0]], %[[VAL_3]] : tensor<32x16x8xf32, #sparse_tensor.encoding<{ dimLevelType = [ "dense", "dense", "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_10:.*]] = sparse_tensor.values %[[VAL_0]] : tensor<32x16x8xf32, #sparse_tensor.encoding<{ dimLevelType = [ "dense", "dense", "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_11:.*]] = bufferization.to_memref %[[VAL_1]] : memref<32x16x8xf32> -// CHECK-DAG: %[[VAL_13:.*]] = memref.alloc() : memref<32x16x8xf32> +// CHECK-DAG: %[[VAL_13:.*]] = bufferization.to_memref %[[VAL_2]] : memref<32x16x8xf32> // CHECK: linalg.fill ins(%[[ZERO]] : f32) outs(%[[VAL_13]] : memref<32x16x8xf32>) // CHECK: scf.for %[[VAL_14:.*]] = %[[VAL_6]] to %[[VAL_4]] step %[[VAL_7]] { // CHECK: scf.for %[[VAL_15:.*]] = %[[VAL_6]] to %[[VAL_5]] step %[[VAL_7]] { @@ -237,7 +237,7 @@ // CHECK-DAG: %[[VAL_10:.*]] = sparse_tensor.indices %[[VAL_0]], %[[VAL_8]] : tensor<32x16x8xf32, #sparse_tensor.encoding<{ dimLevelType = [ "dense", "compressed", "dense" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_11:.*]] = sparse_tensor.values %[[VAL_0]] : tensor<32x16x8xf32, #sparse_tensor.encoding<{ dimLevelType = [ "dense", "compressed", "dense" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_12:.*]] = bufferization.to_memref %[[VAL_1]] : memref<32x16x8xf32> -// CHECK-DAG: %[[VAL_14:.*]] = memref.alloc() : memref<32x16x8xf32> +// CHECK-DAG: %[[VAL_14:.*]] = bufferization.to_memref %[[VAL_2]] : memref<32x16x8xf32> // CHECK: linalg.fill ins(%[[ZERO]] : f32) outs(%[[VAL_14]] : memref<32x16x8xf32>) // CHECK: scf.for %[[VAL_15:.*]] = %[[VAL_7]] to %[[VAL_3]] step %[[VAL_8]] { // CHECK: %[[VAL_16:.*]] = memref.load %[[VAL_9]]{{\[}}%[[VAL_15]]] : memref @@ -308,7 +308,7 @@ // CHECK-DAG: %[[VAL_8:.*]] = sparse_tensor.indices %[[VAL_0]], %[[VAL_6]] : tensor<32x16x8xf32, #sparse_tensor.encoding<{ dimLevelType = [ "dense", "compressed", "dense" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_9:.*]] = sparse_tensor.values %[[VAL_0]] : tensor<32x16x8xf32, #sparse_tensor.encoding<{ dimLevelType = [ "dense", "compressed", "dense" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_10:.*]] = bufferization.to_memref %[[VAL_1]] : memref<32x16x8xf32> -// CHECK-DAG: %[[VAL_12:.*]] = memref.alloc() : memref<32x16x8xf32> +// CHECK-DAG: %[[VAL_12:.*]] = bufferization.to_memref %[[VAL_2]] : memref<32x16x8xf32> // CHECK: linalg.fill ins(%[[ZERO]] : f32) outs(%[[VAL_12]] : memref<32x16x8xf32>) // CHECK: scf.for %[[VAL_13:.*]] = %[[VAL_5]] to %[[VAL_3]] step %[[VAL_6]] { // CHECK: %[[VAL_14:.*]] = memref.load %[[VAL_7]]{{\[}}%[[VAL_13]]] : memref @@ -358,7 +358,7 @@ // CHECK-DAG: %[[VAL_13:.*]] = sparse_tensor.indices %[[VAL_0]], %[[VAL_3]] : tensor<32x16x8xf32, #sparse_tensor.encoding<{ dimLevelType = [ "dense", "compressed", "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_14:.*]] = sparse_tensor.values %[[VAL_0]] : tensor<32x16x8xf32, #sparse_tensor.encoding<{ dimLevelType = [ "dense", "compressed", "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_15:.*]] = bufferization.to_memref %[[VAL_1]] : memref<32x16x8xf32> -// CHECK-DAG: %[[VAL_17:.*]] = memref.alloc() : memref<32x16x8xf32> +// CHECK-DAG: %[[VAL_17:.*]] = bufferization.to_memref %[[VAL_2]] : memref<32x16x8xf32> // CHECK: linalg.fill ins(%[[ZERO]] : f32) outs(%[[VAL_17]] : memref<32x16x8xf32>) // CHECK: scf.for %[[VAL_18:.*]] = %[[VAL_8]] to %[[VAL_4]] step %[[VAL_9]] { // CHECK: %[[VAL_19:.*]] = memref.load %[[VAL_10]]{{\[}}%[[VAL_18]]] : memref @@ -455,7 +455,7 @@ // CHECK-DAG: %[[VAL_10:.*]] = sparse_tensor.indices %[[VAL_0]], %[[VAL_3]] : tensor<32x16x8xf32, #sparse_tensor.encoding<{ dimLevelType = [ "dense", "compressed", "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_11:.*]] = sparse_tensor.values %[[VAL_0]] : tensor<32x16x8xf32, #sparse_tensor.encoding<{ dimLevelType = [ "dense", "compressed", "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_12:.*]] = bufferization.to_memref %[[VAL_1]] : memref<32x16x8xf32> -// CHECK-DAG: %[[VAL_14:.*]] = memref.alloc() : memref<32x16x8xf32> +// CHECK-DAG: %[[VAL_14:.*]] = bufferization.to_memref %[[VAL_2]] : memref<32x16x8xf32> // CHECK: linalg.fill ins(%[[ZERO]] : f32) outs(%[[VAL_14]] : memref<32x16x8xf32>) // CHECK: scf.for %[[VAL_15:.*]] = %[[VAL_5]] to %[[VAL_4]] step %[[VAL_6]] { // CHECK: %[[VAL_16:.*]] = memref.load %[[VAL_7]]{{\[}}%[[VAL_15]]] : memref @@ -504,7 +504,7 @@ // CHECK-DAG: %[[VAL_10:.*]] = sparse_tensor.indices %[[VAL_0]], %[[VAL_7]] : tensor<32x16x8xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed", "dense", "dense" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_11:.*]] = sparse_tensor.values %[[VAL_0]] : tensor<32x16x8xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed", "dense", "dense" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_12:.*]] = bufferization.to_memref %[[VAL_1]] : memref<32x16x8xf32> -// CHECK-DAG: %[[VAL_14:.*]] = memref.alloc() : memref<32x16x8xf32> +// CHECK-DAG: %[[VAL_14:.*]] = bufferization.to_memref %[[VAL_2]] : memref<32x16x8xf32> // CHECK: linalg.fill ins(%[[ZERO]] : f32) outs(%[[VAL_14]] : memref<32x16x8xf32>) // CHECK: %[[VAL_15:.*]] = memref.load %[[VAL_9]]{{\[}}%[[VAL_7]]] : memref // CHECK: %[[VAL_16:.*]] = memref.load %[[VAL_9]]{{\[}}%[[VAL_8]]] : memref @@ -580,7 +580,7 @@ // CHECK-DAG: %[[VAL_8:.*]] = sparse_tensor.indices %[[VAL_0]], %[[VAL_5]] : tensor<32x16x8xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed", "dense", "dense" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_9:.*]] = sparse_tensor.values %[[VAL_0]] : tensor<32x16x8xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed", "dense", "dense" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_10:.*]] = bufferization.to_memref %[[VAL_1]] : memref<32x16x8xf32> -// CHECK-DAG: %[[VAL_12:.*]] = memref.alloc() : memref<32x16x8xf32> +// CHECK-DAG: %[[VAL_12:.*]] = bufferization.to_memref %[[VAL_2]] : memref<32x16x8xf32> // CHECK: linalg.fill ins(%[[ZERO]] : f32) outs(%[[VAL_12]] : memref<32x16x8xf32>) // CHECK: %[[VAL_13:.*]] = memref.load %[[VAL_7]]{{\[}}%[[VAL_5]]] : memref // CHECK: %[[VAL_14:.*]] = memref.load %[[VAL_7]]{{\[}}%[[VAL_6]]] : memref @@ -631,7 +631,7 @@ // CHECK-DAG: %[[VAL_13:.*]] = sparse_tensor.indices %[[VAL_0]], %[[VAL_3]] : tensor<32x16x8xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed", "dense", "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_14:.*]] = sparse_tensor.values %[[VAL_0]] : tensor<32x16x8xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed", "dense", "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_15:.*]] = bufferization.to_memref %[[VAL_1]] : memref<32x16x8xf32> -// CHECK-DAG: %[[VAL_17:.*]] = memref.alloc() : memref<32x16x8xf32> +// CHECK-DAG: %[[VAL_17:.*]] = bufferization.to_memref %[[VAL_2]] : memref<32x16x8xf32> // CHECK: linalg.fill ins(%[[ZERO]] : f32) outs(%[[VAL_17]] : memref<32x16x8xf32>) // CHECK: %[[VAL_18:.*]] = memref.load %[[VAL_10]]{{\[}}%[[VAL_8]]] : memref // CHECK: %[[VAL_19:.*]] = memref.load %[[VAL_10]]{{\[}}%[[VAL_9]]] : memref @@ -733,7 +733,7 @@ // CHECK-DAG: %[[VAL_10:.*]] = sparse_tensor.indices %[[VAL_0]], %[[VAL_3]] : tensor<32x16x8xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed", "dense", "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_11:.*]] = sparse_tensor.values %[[VAL_0]] : tensor<32x16x8xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed", "dense", "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_12:.*]] = bufferization.to_memref %[[VAL_1]] : memref<32x16x8xf32> -// CHECK-DAG: %[[VAL_14:.*]] = memref.alloc() : memref<32x16x8xf32> +// CHECK-DAG: %[[VAL_14:.*]] = bufferization.to_memref %[[VAL_2]] : memref<32x16x8xf32> // CHECK: linalg.fill ins(%[[ZERO]] : f32) outs(%[[VAL_14]] : memref<32x16x8xf32>) // CHECK: %[[VAL_15:.*]] = memref.load %[[VAL_7]]{{\[}}%[[VAL_5]]] : memref // CHECK: %[[VAL_16:.*]] = memref.load %[[VAL_7]]{{\[}}%[[VAL_6]]] : memref @@ -785,7 +785,7 @@ // CHECK-DAG: %[[VAL_12:.*]] = sparse_tensor.indices %[[VAL_0]], %[[VAL_8]] : tensor<32x16x8xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed", "compressed", "dense" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_13:.*]] = sparse_tensor.values %[[VAL_0]] : tensor<32x16x8xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed", "compressed", "dense" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_14:.*]] = bufferization.to_memref %[[VAL_1]] : memref<32x16x8xf32> -// CHECK-DAG: %[[VAL_16:.*]] = memref.alloc() : memref<32x16x8xf32> +// CHECK-DAG: %[[VAL_16:.*]] = bufferization.to_memref %[[VAL_2]] : memref<32x16x8xf32> // CHECK: linalg.fill ins(%[[ZERO]] : f32) outs(%[[VAL_16]] : memref<32x16x8xf32>) // CHECK: %[[VAL_17:.*]] = memref.load %[[VAL_9]]{{\[}}%[[VAL_7]]] : memref // CHECK: %[[VAL_18:.*]] = memref.load %[[VAL_9]]{{\[}}%[[VAL_8]]] : memref @@ -890,7 +890,7 @@ // CHECK-DAG: %[[VAL_9:.*]] = sparse_tensor.indices %[[VAL_0]], %[[VAL_5]] : tensor<32x16x8xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed", "compressed", "dense" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_10:.*]] = sparse_tensor.values %[[VAL_0]] : tensor<32x16x8xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed", "compressed", "dense" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_11:.*]] = bufferization.to_memref %[[VAL_1]] : memref<32x16x8xf32> -// CHECK-DAG: %[[VAL_13:.*]] = memref.alloc() : memref<32x16x8xf32> +// CHECK-DAG: %[[VAL_13:.*]] = bufferization.to_memref %[[VAL_2]] : memref<32x16x8xf32> // CHECK: linalg.fill ins(%[[ZERO]] : f32) outs(%[[VAL_13]] : memref<32x16x8xf32>) // CHECK: %[[VAL_14:.*]] = memref.load %[[VAL_6]]{{\[}}%[[VAL_4]]] : memref // CHECK: %[[VAL_15:.*]] = memref.load %[[VAL_6]]{{\[}}%[[VAL_5]]] : memref @@ -945,7 +945,7 @@ // CHECK-DAG: %[[VAL_15:.*]] = sparse_tensor.indices %[[VAL_0]], %[[VAL_3]] : tensor<32x16x8xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed", "compressed", "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_16:.*]] = sparse_tensor.values %[[VAL_0]] : tensor<32x16x8xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed", "compressed", "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_17:.*]] = bufferization.to_memref %[[VAL_1]] : memref<32x16x8xf32> -// CHECK-DAG: %[[VAL_19:.*]] = memref.alloc() : memref<32x16x8xf32> +// CHECK-DAG: %[[VAL_19:.*]] = bufferization.to_memref %[[VAL_2]] : memref<32x16x8xf32> // CHECK: linalg.fill ins(%[[ZERO]] : f32) outs(%[[VAL_19]] : memref<32x16x8xf32>) // CHECK: %[[VAL_20:.*]] = memref.load %[[VAL_10]]{{\[}}%[[VAL_8]]] : memref // CHECK: %[[VAL_21:.*]] = memref.load %[[VAL_10]]{{\[}}%[[VAL_9]]] : memref @@ -1076,7 +1076,7 @@ // CHECK-DAG: %[[VAL_11:.*]] = sparse_tensor.indices %[[VAL_0]], %[[VAL_3]] : tensor<32x16x8xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed", "compressed", "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_12:.*]] = sparse_tensor.values %[[VAL_0]] : tensor<32x16x8xf32, #sparse_tensor.encoding<{ dimLevelType = [ "compressed", "compressed", "compressed" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_13:.*]] = bufferization.to_memref %[[VAL_1]] : memref<32x16x8xf32> -// CHECK-DAG: %[[VAL_15:.*]] = memref.alloc() : memref<32x16x8xf32> +// CHECK-DAG: %[[VAL_15:.*]] = bufferization.to_memref %[[VAL_2]] : memref<32x16x8xf32> // CHECK: linalg.fill ins(%[[ZERO]] : f32) outs(%[[VAL_15]] : memref<32x16x8xf32>) // CHECK: %[[VAL_16:.*]] = memref.load %[[VAL_6]]{{\[}}%[[VAL_4]]] : memref // CHECK: %[[VAL_17:.*]] = memref.load %[[VAL_6]]{{\[}}%[[VAL_5]]] : memref @@ -1140,9 +1140,7 @@ // CHECK-DAG: %[[VAL_12:.*]] = bufferization.to_memref %[[VAL_3]] : memref // CHECK-DAG: %[[VAL_13:.*]] = tensor.dim %[[VAL_0]], %[[VAL_5]] : tensor // CHECK-DAG: %[[VAL_14:.*]] = tensor.dim %[[VAL_0]], %[[VAL_6]] : tensor -// CHECK-DAG: %[[VAL_15:.*]] = bufferization.to_memref %[[VAL_0]] : memref -// CHECK-DAG: %[[VAL_16:.*]] = memref.alloc(%[[VAL_13]], %[[VAL_14]]) : memref -// CHECK: memref.copy %[[VAL_15]], %[[VAL_16]] : memref to memref +// CHECK-DAG: %[[VAL_16:.*]] = bufferization.to_memref %[[VAL_0]] : memref // CHECK: scf.for %[[VAL_17:.*]] = %[[VAL_5]] to %[[VAL_13]] step %[[VAL_6]] { // CHECK: scf.for %[[VAL_18:.*]] = %[[VAL_5]] to %[[VAL_10]] step %[[VAL_6]] { // CHECK: %[[VAL_19:.*]] = arith.muli %[[VAL_10]], %[[VAL_17]] : index @@ -1203,9 +1201,7 @@ // CHECK-DAG: %[[VAL_6:.*]] = sparse_tensor.pointers %[[VAL_0]], %[[VAL_3]] : tensor<10x20x30xf32, #sparse_tensor.encoding<{{{.*}}>> // CHECK-DAG: %[[VAL_7:.*]] = sparse_tensor.pointers %[[VAL_0]], %[[VAL_4]] : tensor<10x20x30xf32, #sparse_tensor.encoding<{{{.*}}}>> // CHECK-DAG: %[[VAL_8:.*]] = sparse_tensor.values %[[VAL_0]] : tensor<10x20x30xf32, #sparse_tensor.encoding<{{{.*}}}>> -// CHECK-DAG: %[[VAL_9:.*]] = bufferization.to_memref %[[VAL_1]] : memref -// CHECK-DAG: %[[VAL_10:.*]] = memref.alloc() : memref -// CHECK: memref.copy %[[VAL_9]], %[[VAL_10]] : memref to memref +// CHECK-DAG: %[[VAL_10:.*]] = bufferization.to_memref %[[VAL_1]] : memref // CHECK: %[[VAL_11:.*]] = memref.load %[[VAL_10]][] : memref // CHECK: %[[VAL_12:.*]] = memref.load %[[VAL_5]]{{\[}}%[[VAL_2]]] : memref // CHECK: %[[VAL_13:.*]] = memref.load %[[VAL_5]]{{\[}}%[[VAL_3]]] : memref @@ -1263,9 +1259,7 @@ // CHECK-DAG: %[[VAL_8:.*]] = bufferization.to_memref %[[VAL_0]] : memref // CHECK-DAG: %[[VAL_9:.*]] = tensor.dim %[[VAL_1]], %[[VAL_5]] : tensor> // CHECK-DAG: %[[VAL_10:.*]] = sparse_tensor.values %[[VAL_1]] : tensor> -// CHECK-DAG: %[[VAL_11:.*]] = bufferization.to_memref %[[VAL_2]] : memref -// CHECK-DAG: %[[VAL_12:.*]] = memref.alloc() : memref -// CHECK: memref.copy %[[VAL_11]], %[[VAL_12]] : memref to memref +// CHECK-DAG: %[[VAL_12:.*]] = bufferization.to_memref %[[VAL_2]] : memref // CHECK: %[[VAL_13:.*]] = memref.load %[[VAL_12]][] : memref // CHECK: %[[VAL_14:.*]] = scf.for %[[VAL_15:.*]] = %[[VAL_5]] to %[[VAL_9]] step %[[VAL_3]] iter_args(%[[VAL_16:.*]] = %[[VAL_13]]) -> (f32) { // CHECK: %[[VAL_17:.*]] = memref.load %[[VAL_10]]{{\[}}%[[VAL_15]]] : memref @@ -1323,7 +1317,7 @@ // CHECK-DAG: %[[VAL_9:.*]] = sparse_tensor.values %[[VAL_0]] : tensor<10xf32, #sparse_tensor.encoding<{ dimLevelType = [ "dense" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_10:.*]] = bufferization.to_memref %[[VAL_1]] : memref<20xf32> // CHECK-DAG: %[[VAL_11:.*]] = bufferization.to_memref %[[VAL_2]] : memref<30xf32> -// CHECK-DAG: %[[VAL_13:.*]] = memref.alloc() : memref<10x20x30xf32> +// CHECK-DAG: %[[VAL_13:.*]] = bufferization.to_memref %[[VAL_3]] : memref<10x20x30xf32> // CHECK: linalg.fill ins(%[[ZERO]] : f32) outs(%[[VAL_13]] : memref<10x20x30xf32>) // CHECK: scf.for %[[VAL_14:.*]] = %[[VAL_7]] to %[[VAL_4]] step %[[VAL_8]] { // CHECK: %[[VAL_15:.*]] = memref.load %[[VAL_9]]{{\[}}%[[VAL_14]]] : memref diff --git a/mlir/test/Dialect/SparseTensor/sparse_affine.mlir b/mlir/test/Dialect/SparseTensor/sparse_affine.mlir --- a/mlir/test/Dialect/SparseTensor/sparse_affine.mlir +++ b/mlir/test/Dialect/SparseTensor/sparse_affine.mlir @@ -25,9 +25,7 @@ // CHECK-DAG: %[[VAL_7:.*]] = sparse_tensor.indices %[[VAL_0]], %[[VAL_3]] : tensor<32xf32, #sparse_tensor.encoding<{{{.*}}}>> // CHECK-DAG: %[[VAL_8:.*]] = sparse_tensor.values %[[VAL_0]] : tensor<32xf32, #sparse_tensor.encoding<{{{.*}}}>> // CHECK-DAG: %[[VAL_9:.*]] = bufferization.to_memref %[[VAL_1]] : memref<4xf32> -// CHECK-DAG: %[[VAL_10:.*]] = bufferization.to_memref %[[VAL_2]] : memref<32xf32> -// CHECK-DAG: %[[VAL_11:.*]] = memref.alloc() : memref<32xf32> -// CHECK: memref.copy %[[VAL_10]], %[[VAL_11]] : memref<32xf32> to memref<32xf32> +// CHECK-DAG: %[[VAL_11:.*]] = bufferization.to_memref %[[VAL_2]] : memref<32xf32> // CHECK: %[[VAL_12:.*]] = memref.load %[[VAL_9]]{{\[}}%[[VAL_4]]] : memref<4xf32> // CHECK: %[[VAL_13:.*]] = memref.load %[[VAL_6]]{{\[}}%[[VAL_3]]] : memref // CHECK: %[[VAL_14:.*]] = memref.load %[[VAL_6]]{{\[}}%[[VAL_5]]] : memref @@ -78,7 +76,7 @@ // CHECK-DAG: %[[VAL_7:.*]] = sparse_tensor.indices %[[VAL_0]], %[[VAL_3]] : tensor<32xi32, #sparse_tensor.encoding<{{{.*}}}>> // CHECK-DAG: %[[VAL_8:.*]] = sparse_tensor.values %[[VAL_0]] : tensor<32xi32, #sparse_tensor.encoding<{{{.*}}}>> // CHECK-DAG: %[[VAL_9:.*]] = bufferization.to_memref %[[VAL_1]] : memref<34xi32> -// CHECK-DAG: %[[VAL_11:.*]] = memref.alloc() : memref<32xi32> +// CHECK-DAG: %[[VAL_11:.*]] = bufferization.to_memref %[[VAL_2]] : memref<32xi32> // CHECK: linalg.fill ins(%[[ZERO]] : i32) outs(%[[VAL_11]] : memref<32xi32>) // CHECK: %[[VAL_12:.*]] = memref.load %[[VAL_6]]{{\[}}%[[VAL_3]]] : memref // CHECK: %[[VAL_13:.*]] = memref.load %[[VAL_6]]{{\[}}%[[VAL_4]]] : memref @@ -129,9 +127,7 @@ // CHECK-DAG: %[[VAL_9:.*]] = sparse_tensor.indices %[[VAL_0]], %[[VAL_3]] : tensor<32x16xf64, #sparse_tensor.encoding<{{{.*}}}>> // CHECK-DAG: %[[VAL_10:.*]] = sparse_tensor.values %[[VAL_0]] : tensor<32x16xf64, #sparse_tensor.encoding<{{{.*}}}>> // CHECK-DAG: %[[VAL_11:.*]] = bufferization.to_memref %[[VAL_1]] : memref<34x19xf64> -// CHECK-DAG: %[[VAL_12:.*]] = bufferization.to_memref %[[VAL_2]] : memref<32x16xf64> -// CHECK-DAG: %[[VAL_13:.*]] = memref.alloc() : memref<32x16xf64> -// CHECK: memref.copy %[[VAL_12]], %[[VAL_13]] : memref<32x16xf64> to memref<32x16xf64> +// CHECK-DAG: %[[VAL_13:.*]] = bufferization.to_memref %[[VAL_2]] : memref<32x16xf64> // CHECK: scf.for %[[VAL_14:.*]] = %[[VAL_5]] to %[[VAL_4]] step %[[VAL_3]] { // CHECK: %[[VAL_15:.*]] = memref.load %[[VAL_8]]{{\[}}%[[VAL_14]]] : memref // CHECK: %[[VAL_16:.*]] = arith.addi %[[VAL_14]], %[[VAL_3]] : index diff --git a/mlir/test/Dialect/SparseTensor/sparse_fp_ops.mlir b/mlir/test/Dialect/SparseTensor/sparse_fp_ops.mlir --- a/mlir/test/Dialect/SparseTensor/sparse_fp_ops.mlir +++ b/mlir/test/Dialect/SparseTensor/sparse_fp_ops.mlir @@ -33,7 +33,7 @@ // CHECK-LABEL: func @abs( // CHECK-SAME: %[[VAL_0:.*]]: tensor<32xf64, #sparse_tensor.encoding<{{{.*}}}>>, -// CHECK-SAME: %[[VAL_1:.*]]: tensor<32xf64> {linalg.inplaceable = true}) -> tensor<32xf64> { +// CHECK-SAME: %[[VAL_1:.*]]: tensor<32xf64>) -> tensor<32xf64> { // CHECK-DAG: %[[VAL_2:.*]] = arith.constant 0 : index // CHECK-DAG: %[[VAL_3:.*]] = arith.constant 1 : index // CHECK: %[[VAL_4:.*]] = sparse_tensor.pointers %[[VAL_0]], %[[VAL_2]] : tensor<32xf64, #sparse_tensor.encoding<{{{.*}}}>> to memref @@ -52,7 +52,7 @@ // CHECK: return %[[VAL_14]] : tensor<32xf64> // CHECK: } func.func @abs(%arga: tensor<32xf64, #SV>, - %argx: tensor<32xf64> {linalg.inplaceable = true}) -> tensor<32xf64> { + %argx: tensor<32xf64>) -> tensor<32xf64> { %0 = linalg.generic #trait1 ins(%arga: tensor<32xf64, #SV>) outs(%argx: tensor<32xf64>) { @@ -65,7 +65,7 @@ // CHECK-LABEL: func @ceil( // CHECK-SAME: %[[VAL_0:.*]]: tensor<32xf64, #sparse_tensor.encoding<{{{.*}}}>>, -// CHECK-SAME: %[[VAL_1:.*]]: tensor<32xf64> {linalg.inplaceable = true}) -> tensor<32xf64> { +// CHECK-SAME: %[[VAL_1:.*]]: tensor<32xf64>) -> tensor<32xf64> { // CHECK-DAG: %[[VAL_2:.*]] = arith.constant 0 : index // CHECK-DAG: %[[VAL_3:.*]] = arith.constant 1 : index // CHECK: %[[VAL_4:.*]] = sparse_tensor.pointers %[[VAL_0]], %[[VAL_2]] : tensor<32xf64, #sparse_tensor.encoding<{{{.*}}}>> to memref @@ -84,7 +84,7 @@ // CHECK: return %[[VAL_14]] : tensor<32xf64> // CHECK: } func.func @ceil(%arga: tensor<32xf64, #SV>, - %argx: tensor<32xf64> {linalg.inplaceable = true}) -> tensor<32xf64> { + %argx: tensor<32xf64>) -> tensor<32xf64> { %0 = linalg.generic #trait1 ins(%arga: tensor<32xf64, #SV>) outs(%argx: tensor<32xf64>) { @@ -97,7 +97,7 @@ // CHECK-LABEL: func @floor( // CHECK-SAME: %[[VAL_0:.*]]: tensor<32xf64, #sparse_tensor.encoding<{{{.*}}}>>, -// CHECK-SAME: %[[VAL_1:.*]]: tensor<32xf64> {linalg.inplaceable = true}) -> tensor<32xf64> { +// CHECK-SAME: %[[VAL_1:.*]]: tensor<32xf64>) -> tensor<32xf64> { // CHECK-DAG: %[[VAL_2:.*]] = arith.constant 0 : index // CHECK-DAG: %[[VAL_3:.*]] = arith.constant 1 : index // CHECK: %[[VAL_4:.*]] = sparse_tensor.pointers %[[VAL_0]], %[[VAL_2]] : tensor<32xf64, #sparse_tensor.encoding<{{{.*}}}>> to memref @@ -116,7 +116,7 @@ // CHECK: return %[[VAL_14]] : tensor<32xf64> // CHECK: } func.func @floor(%arga: tensor<32xf64, #SV>, - %argx: tensor<32xf64> {linalg.inplaceable = true}) -> tensor<32xf64> { + %argx: tensor<32xf64>) -> tensor<32xf64> { %0 = linalg.generic #trait1 ins(%arga: tensor<32xf64, #SV>) outs(%argx: tensor<32xf64>) { @@ -129,7 +129,7 @@ // CHECK-LABEL: func @neg( // CHECK-SAME: %[[VAL_0:.*]]: tensor<32xf64, #sparse_tensor.encoding<{{{.*}}}>>, -// CHECK-SAME: %[[VAL_1:.*]]: tensor<32xf64> {linalg.inplaceable = true}) -> tensor<32xf64> { +// CHECK-SAME: %[[VAL_1:.*]]: tensor<32xf64>) -> tensor<32xf64> { // CHECK-DAG: %[[VAL_2:.*]] = arith.constant 0 : index // CHECK-DAG: %[[VAL_3:.*]] = arith.constant 1 : index // CHECK: %[[VAL_4:.*]] = sparse_tensor.pointers %[[VAL_0]], %[[VAL_2]] : tensor<32xf64, #sparse_tensor.encoding<{{{.*}}}>> to memref @@ -148,7 +148,7 @@ // CHECK: return %[[VAL_14]] : tensor<32xf64> // CHECK: } func.func @neg(%arga: tensor<32xf64, #SV>, - %argx: tensor<32xf64> {linalg.inplaceable = true}) -> tensor<32xf64> { + %argx: tensor<32xf64>) -> tensor<32xf64> { %0 = linalg.generic #trait1 ins(%arga: tensor<32xf64, #SV>) outs(%argx: tensor<32xf64>) { @@ -162,7 +162,7 @@ // CHECK-LABEL: func @add( // CHECK-SAME: %[[VAL_0:.*]]: tensor<32xf64, #sparse_tensor.encoding<{{{.*}}}>>, // CHECK-SAME: %[[VAL_1:.*]]: tensor<32xf64>, -// CHECK-SAME: %[[VAL_2:.*]]: tensor<32xf64> {linalg.inplaceable = true}) -> tensor<32xf64> { +// CHECK-SAME: %[[VAL_2:.*]]: tensor<32xf64>) -> tensor<32xf64> { // CHECK-DAG: %[[VAL_3:.*]] = arith.constant 32 : index // CHECK-DAG: %[[VAL_4:.*]] = arith.constant 0 : index // CHECK-DAG: %[[VAL_5:.*]] = arith.constant true @@ -207,8 +207,8 @@ // CHECK: return %[[VAL_33]] : tensor<32xf64> // CHECK: } func.func @add(%arga: tensor<32xf64, #SV>, - %argb: tensor<32xf64>, - %argx: tensor<32xf64> {linalg.inplaceable = true}) -> tensor<32xf64> { + %argb: tensor<32xf64>, + %argx: tensor<32xf64>) -> tensor<32xf64> { %0 = linalg.generic #trait2 ins(%arga, %argb: tensor<32xf64, #SV>, tensor<32xf64>) outs(%argx: tensor<32xf64>) { @@ -222,7 +222,7 @@ // CHECK-LABEL: func @sub( // CHECK-SAME: %[[VAL_0:.*]]: tensor<32xf64, #sparse_tensor.encoding<{{{.*}}}>>, // CHECK-SAME: %[[VAL_1:.*]]: tensor<32xf64>, -// CHECK-SAME: %[[VAL_2:.*]]: tensor<32xf64> {linalg.inplaceable = true}) -> tensor<32xf64> { +// CHECK-SAME: %[[VAL_2:.*]]: tensor<32xf64>) -> tensor<32xf64> { // CHECK-DAG: %[[VAL_3:.*]] = arith.constant 32 : index // CHECK-DAG: %[[VAL_4:.*]] = arith.constant 0 : index // CHECK-DAG: %[[VAL_5:.*]] = arith.constant true @@ -269,8 +269,8 @@ // CHECK: return %[[VAL_35]] : tensor<32xf64> // CHECK: } func.func @sub(%arga: tensor<32xf64, #SV>, - %argb: tensor<32xf64>, - %argx: tensor<32xf64> {linalg.inplaceable = true}) -> tensor<32xf64> { + %argb: tensor<32xf64>, + %argx: tensor<32xf64>) -> tensor<32xf64> { %0 = linalg.generic #trait2 ins(%arga, %argb: tensor<32xf64, #SV>, tensor<32xf64>) outs(%argx: tensor<32xf64>) { @@ -284,7 +284,7 @@ // CHECK-LABEL: func @mul( // CHECK-SAME: %[[VAL_0:.*]]: tensor<32xf64, #sparse_tensor.encoding<{{{.*}}}>>, // CHECK-SAME: %[[VAL_1:.*]]: tensor<32xf64>, -// CHECK-SAME: %[[VAL_2:.*]]: tensor<32xf64> {linalg.inplaceable = true}) -> tensor<32xf64> { +// CHECK-SAME: %[[VAL_2:.*]]: tensor<32xf64>) -> tensor<32xf64> { // CHECK-DAG: %[[VAL_3:.*]] = arith.constant 0 : index // CHECK-DAG: %[[VAL_4:.*]] = arith.constant 1 : index // CHECK: %[[VAL_5:.*]] = sparse_tensor.pointers %[[VAL_0]], %[[VAL_3]] : tensor<32xf64, #sparse_tensor.encoding<{{{.*}}}>> @@ -305,8 +305,8 @@ // CHECK: return %[[VAL_17]] : tensor<32xf64> // CHECK: } func.func @mul(%arga: tensor<32xf64, #SV>, - %argb: tensor<32xf64>, - %argx: tensor<32xf64> {linalg.inplaceable = true}) -> tensor<32xf64> { + %argb: tensor<32xf64>, + %argx: tensor<32xf64>) -> tensor<32xf64> { %0 = linalg.generic #trait2 ins(%arga, %argb: tensor<32xf64, #SV>, tensor<32xf64>) outs(%argx: tensor<32xf64>) { @@ -319,7 +319,7 @@ // CHECK-LABEL: func @divbyc( // CHECK-SAME: %[[VAL_0:.*]]: tensor<32xf64, #sparse_tensor.encoding<{{{.*}}}>>, -// CHECK-SAME: %[[VAL_1:.*]]: tensor<32xf64> {linalg.inplaceable = true}) -> tensor<32xf64> { +// CHECK-SAME: %[[VAL_1:.*]]: tensor<32xf64>) -> tensor<32xf64> { // CHECK-DAG: %[[VAL_2:.*]] = arith.constant 2.000000e+00 : f64 // CHECK-DAG: %[[VAL_3:.*]] = arith.constant 0 : index // CHECK-DAG: %[[VAL_4:.*]] = arith.constant 1 : index @@ -339,7 +339,7 @@ // CHECK: return %[[VAL_15]] : tensor<32xf64> // CHECK: } func.func @divbyc(%arga: tensor<32xf64, #SV>, - %argx: tensor<32xf64> {linalg.inplaceable = true}) -> tensor<32xf64> { + %argx: tensor<32xf64>) -> tensor<32xf64> { %c = arith.constant 2.0 : f64 %0 = linalg.generic #traitc ins(%arga: tensor<32xf64, #SV>) diff --git a/mlir/test/Dialect/SparseTensor/sparse_int_ops.mlir b/mlir/test/Dialect/SparseTensor/sparse_int_ops.mlir --- a/mlir/test/Dialect/SparseTensor/sparse_int_ops.mlir +++ b/mlir/test/Dialect/SparseTensor/sparse_int_ops.mlir @@ -25,7 +25,7 @@ // CHECK-LABEL: func @add( // CHECK-SAME: %[[VAL_0:.*]]: tensor<32xi64, #sparse_tensor.encoding<{{{.*}}}>>, // CHECK-SAME: %[[VAL_1:.*]]: tensor<32xi64>, -// CHECK-SAME: %[[VAL_2:.*]]: tensor<32xi64> {linalg.inplaceable = true}) -> tensor<32xi64> { +// CHECK-SAME: %[[VAL_2:.*]]: tensor<32xi64>) -> tensor<32xi64> { // CHECK-DAG: %[[VAL_3:.*]] = arith.constant 32 : index // CHECK-DAG: %[[VAL_4:.*]] = arith.constant 0 : index // CHECK-DAG: %[[VAL_5:.*]] = arith.constant true @@ -70,8 +70,8 @@ // CHECK: return %[[VAL_33]] : tensor<32xi64> // CHECK: } func.func @add(%arga: tensor<32xi64, #SV>, - %argb: tensor<32xi64>, - %argx: tensor<32xi64> {linalg.inplaceable = true}) -> tensor<32xi64> { + %argb: tensor<32xi64>, + %argx: tensor<32xi64>) -> tensor<32xi64> { %0 = linalg.generic #trait2 ins(%arga, %argb: tensor<32xi64, #SV>, tensor<32xi64>) outs(%argx: tensor<32xi64>) { @@ -85,7 +85,7 @@ // CHECK-LABEL: func @sub( // CHECK-SAME: %[[VAL_0:.*]]: tensor<32xi64, #sparse_tensor.encoding<{{{.*}}}>>, // CHECK-SAME: %[[VAL_1:.*]]: tensor<32xi64>, -// CHECK-SAME: %[[VAL_2:.*]]: tensor<32xi64> {linalg.inplaceable = true}) -> tensor<32xi64> { +// CHECK-SAME: %[[VAL_2:.*]]: tensor<32xi64>) -> tensor<32xi64> { // CHECK-DAG: %[[VAL_3:.*]] = arith.constant 32 : index // CHECK-DAG: %[[VAL_4:.*]] = arith.constant 0 : index // CHECK-DAG: %[[VAL_5:.*]] = arith.constant true @@ -133,8 +133,8 @@ // CHECK: return %[[VAL_36]] : tensor<32xi64> // CHECK: } func.func @sub(%arga: tensor<32xi64, #SV>, - %argb: tensor<32xi64>, - %argx: tensor<32xi64> {linalg.inplaceable = true}) -> tensor<32xi64> { + %argb: tensor<32xi64>, + %argx: tensor<32xi64>) -> tensor<32xi64> { %0 = linalg.generic #trait2 ins(%arga, %argb: tensor<32xi64, #SV>, tensor<32xi64>) outs(%argx: tensor<32xi64>) { @@ -148,7 +148,7 @@ // CHECK-LABEL: func @mul( // CHECK-SAME: %[[VAL_0:.*]]: tensor<32xi64, #sparse_tensor.encoding<{{{.*}}}>>, // CHECK-SAME: %[[VAL_1:.*]]: tensor<32xi64>, -// CHECK-SAME: %[[VAL_2:.*]]: tensor<32xi64> {linalg.inplaceable = true}) -> tensor<32xi64> { +// CHECK-SAME: %[[VAL_2:.*]]: tensor<32xi64>) -> tensor<32xi64> { // CHECK-DAG: %[[VAL_3:.*]] = arith.constant 0 : index // CHECK-DAG: %[[VAL_4:.*]] = arith.constant 1 : index // CHECK: %[[VAL_5:.*]] = sparse_tensor.pointers %[[VAL_0]], %[[VAL_3]] : tensor<32xi64, #sparse_tensor.encoding<{{{.*}}}>> @@ -169,8 +169,8 @@ // CHECK: return %[[VAL_17]] : tensor<32xi64> // CHECK: } func.func @mul(%arga: tensor<32xi64, #SV>, - %argb: tensor<32xi64>, - %argx: tensor<32xi64> {linalg.inplaceable = true}) -> tensor<32xi64> { + %argb: tensor<32xi64>, + %argx: tensor<32xi64>) -> tensor<32xi64> { %0 = linalg.generic #trait2 ins(%arga, %argb: tensor<32xi64, #SV>, tensor<32xi64>) outs(%argx: tensor<32xi64>) { @@ -183,7 +183,7 @@ // CHECK-LABEL: func @divsbyc( // CHECK-SAME: %[[VAL_0:.*]]: tensor<32xi64, #sparse_tensor.encoding<{{{.*}}}>>, -// CHECK-SAME: %[[VAL_1:.*]]: tensor<32xi64> {linalg.inplaceable = true}) -> tensor<32xi64> { +// CHECK-SAME: %[[VAL_1:.*]]: tensor<32xi64>) -> tensor<32xi64> { // CHECK-DAG: %[[VAL_2:.*]] = arith.constant 2 : i64 // CHECK-DAG: %[[VAL_3:.*]] = arith.constant 0 : index // CHECK-DAG: %[[VAL_4:.*]] = arith.constant 1 : index @@ -203,7 +203,7 @@ // CHECK: return %[[VAL_15]] : tensor<32xi64> // CHECK: } func.func @divsbyc(%arga: tensor<32xi64, #SV>, - %argx: tensor<32xi64> {linalg.inplaceable = true}) -> tensor<32xi64> { + %argx: tensor<32xi64>) -> tensor<32xi64> { %c = arith.constant 2 : i64 %0 = linalg.generic #traitc ins(%arga: tensor<32xi64, #SV>) @@ -217,7 +217,7 @@ // CHECK-LABEL: func @divubyc( // CHECK-SAME: %[[VAL_0:.*]]: tensor<32xi64, #sparse_tensor.encoding<{{{.*}}}>>, -// CHECK-SAME: %[[VAL_1:.*]]: tensor<32xi64> {linalg.inplaceable = true}) -> tensor<32xi64> { +// CHECK-SAME: %[[VAL_1:.*]]: tensor<32xi64>) -> tensor<32xi64> { // CHECK-DAG: %[[VAL_2:.*]] = arith.constant 2 : i64 // CHECK-DAG: %[[VAL_3:.*]] = arith.constant 0 : index // CHECK-DAG: %[[VAL_4:.*]] = arith.constant 1 : index @@ -237,7 +237,7 @@ // CHECK: return %[[VAL_15]] : tensor<32xi64> // CHECK: } func.func @divubyc(%arga: tensor<32xi64, #SV>, - %argx: tensor<32xi64> {linalg.inplaceable = true}) -> tensor<32xi64> { + %argx: tensor<32xi64>) -> tensor<32xi64> { %c = arith.constant 2 : i64 %0 = linalg.generic #traitc ins(%arga: tensor<32xi64, #SV>) @@ -252,7 +252,7 @@ // CHECK-LABEL: func @and( // CHECK-SAME: %[[VAL_0:.*]]: tensor<32xi64, #sparse_tensor.encoding<{{{.*}}}>>, // CHECK-SAME: %[[VAL_1:.*]]: tensor<32xi64>, -// CHECK-SAME: %[[VAL_2:.*]]: tensor<32xi64> {linalg.inplaceable = true}) -> tensor<32xi64> { +// CHECK-SAME: %[[VAL_2:.*]]: tensor<32xi64>) -> tensor<32xi64> { // CHECK-DAG: %[[VAL_3:.*]] = arith.constant 0 : index // CHECK-DAG: %[[VAL_4:.*]] = arith.constant 1 : index // CHECK: %[[VAL_5:.*]] = sparse_tensor.pointers %[[VAL_0]], %[[VAL_3]] : tensor<32xi64, #sparse_tensor.encoding<{{{.*}}}>> to memref @@ -273,8 +273,8 @@ // CHECK: return %[[VAL_17]] : tensor<32xi64> // CHECK: } func.func @and(%arga: tensor<32xi64, #SV>, - %argb: tensor<32xi64>, - %argx: tensor<32xi64> {linalg.inplaceable = true}) -> tensor<32xi64> { + %argb: tensor<32xi64>, + %argx: tensor<32xi64>) -> tensor<32xi64> { %0 = linalg.generic #trait2 ins(%arga, %argb: tensor<32xi64, #SV>, tensor<32xi64>) outs(%argx: tensor<32xi64>) { @@ -288,7 +288,7 @@ // CHECK-LABEL: func @or( // CHECK-SAME: %[[VAL_0:.*]]: tensor<32xi64, #sparse_tensor.encoding<{{{.*}}}>>, // CHECK-SAME: %[[VAL_1:.*]]: tensor<32xi64>, -// CHECK-SAME: %[[VAL_2:.*]]: tensor<32xi64> {linalg.inplaceable = true}) -> tensor<32xi64> { +// CHECK-SAME: %[[VAL_2:.*]]: tensor<32xi64>) -> tensor<32xi64> { // CHECK-DAG: %[[VAL_3:.*]] = arith.constant 32 : index // CHECK-DAG: %[[VAL_4:.*]] = arith.constant 0 : index // CHECK-DAG: %[[VAL_5:.*]] = arith.constant true @@ -333,8 +333,8 @@ // CHECK: return %[[VAL_33]] : tensor<32xi64> // CHECK: } func.func @or(%arga: tensor<32xi64, #SV>, - %argb: tensor<32xi64>, - %argx: tensor<32xi64> {linalg.inplaceable = true}) -> tensor<32xi64> { + %argb: tensor<32xi64>, + %argx: tensor<32xi64>) -> tensor<32xi64> { %0 = linalg.generic #trait2 ins(%arga, %argb: tensor<32xi64, #SV>, tensor<32xi64>) outs(%argx: tensor<32xi64>) { @@ -348,7 +348,7 @@ // CHECK-LABEL: func @xor( // CHECK-SAME: %[[VAL_0:.*]]: tensor<32xi64, #sparse_tensor.encoding<{{{.*}}}>>, // CHECK-SAME: %[[VAL_1:.*]]: tensor<32xi64>, -// CHECK-SAME: %[[VAL_2:.*]]: tensor<32xi64> {linalg.inplaceable = true}) -> tensor<32xi64> { +// CHECK-SAME: %[[VAL_2:.*]]: tensor<32xi64>) -> tensor<32xi64> { // CHECK-DAG: %[[VAL_3:.*]] = arith.constant 32 : index // CHECK-DAG: %[[VAL_4:.*]] = arith.constant 0 : index // CHECK-DAG: %[[VAL_5:.*]] = arith.constant true @@ -393,8 +393,8 @@ // CHECK: return %[[VAL_33]] : tensor<32xi64> // CHECK: } func.func @xor(%arga: tensor<32xi64, #SV>, - %argb: tensor<32xi64>, - %argx: tensor<32xi64> {linalg.inplaceable = true}) -> tensor<32xi64> { + %argb: tensor<32xi64>, + %argx: tensor<32xi64>) -> tensor<32xi64> { %0 = linalg.generic #trait2 ins(%arga, %argb: tensor<32xi64, #SV>, tensor<32xi64>) outs(%argx: tensor<32xi64>) { @@ -407,7 +407,7 @@ // CHECK-LABEL: func @ashrbyc( // CHECK-SAME: %[[VAL_0:.*]]: tensor<32xi64, #sparse_tensor.encoding<{{{.*}}}>>, -// CHECK-SAME: %[[VAL_1:.*]]: tensor<32xi64> {linalg.inplaceable = true}) -> tensor<32xi64> { +// CHECK-SAME: %[[VAL_1:.*]]: tensor<32xi64>) -> tensor<32xi64> { // CHECK-DAG: %[[VAL_2:.*]] = arith.constant 2 : i64 // CHECK-DAG: %[[VAL_3:.*]] = arith.constant 0 : index // CHECK-DAG: %[[VAL_4:.*]] = arith.constant 1 : index @@ -427,7 +427,7 @@ // CHECK: return %[[VAL_15]] : tensor<32xi64> // CHECK: } func.func @ashrbyc(%arga: tensor<32xi64, #SV>, - %argx: tensor<32xi64> {linalg.inplaceable = true}) -> tensor<32xi64> { + %argx: tensor<32xi64>) -> tensor<32xi64> { %c = arith.constant 2 : i64 %0 = linalg.generic #traitc ins(%arga: tensor<32xi64, #SV>) @@ -441,7 +441,7 @@ // CHECK-LABEL: func @lsrbyc( // CHECK-SAME: %[[VAL_0:.*]]: tensor<32xi64, #sparse_tensor.encoding<{{{.*}}}>>, -// CHECK-SAME: %[[VAL_1:.*]]: tensor<32xi64> {linalg.inplaceable = true}) -> tensor<32xi64> { +// CHECK-SAME: %[[VAL_1:.*]]: tensor<32xi64>) -> tensor<32xi64> { // CHECK-DAG: %[[VAL_2:.*]] = arith.constant 2 : i64 // CHECK-DAG: %[[VAL_3:.*]] = arith.constant 0 : index // CHECK-DAG: %[[VAL_4:.*]] = arith.constant 1 : index @@ -461,7 +461,7 @@ // CHECK: return %[[VAL_15]] : tensor<32xi64> // CHECK: } func.func @lsrbyc(%arga: tensor<32xi64, #SV>, - %argx: tensor<32xi64> {linalg.inplaceable = true}) -> tensor<32xi64> { + %argx: tensor<32xi64>) -> tensor<32xi64> { %c = arith.constant 2 : i64 %0 = linalg.generic #traitc ins(%arga: tensor<32xi64, #SV>) @@ -475,7 +475,7 @@ // CHECK-LABEL: func @lslbyc( // CHECK-SAME: %[[VAL_0:.*]]: tensor<32xi64, #sparse_tensor.encoding<{{{.*}}}>>, -// CHECK-SAME: %[[VAL_1:.*]]: tensor<32xi64> {linalg.inplaceable = true}) -> tensor<32xi64> { +// CHECK-SAME: %[[VAL_1:.*]]: tensor<32xi64>) -> tensor<32xi64> { // CHECK-DAG: %[[VAL_2:.*]] = arith.constant 2 : i64 // CHECK-DAG: %[[VAL_3:.*]] = arith.constant 0 : index // CHECK-DAG: %[[VAL_4:.*]] = arith.constant 1 : index @@ -495,7 +495,7 @@ // CHECK: return %[[VAL_15]] : tensor<32xi64> // CHECK: } func.func @lslbyc(%arga: tensor<32xi64, #SV>, - %argx: tensor<32xi64> {linalg.inplaceable = true}) -> tensor<32xi64> { + %argx: tensor<32xi64>) -> tensor<32xi64> { %c = arith.constant 2 : i64 %0 = linalg.generic #traitc ins(%arga: tensor<32xi64, #SV>) diff --git a/mlir/test/Dialect/SparseTensor/sparse_kernels.mlir b/mlir/test/Dialect/SparseTensor/sparse_kernels.mlir --- a/mlir/test/Dialect/SparseTensor/sparse_kernels.mlir +++ b/mlir/test/Dialect/SparseTensor/sparse_kernels.mlir @@ -20,9 +20,7 @@ // CHECK-DAG: %[[VAL_9:.*]] = sparse_tensor.indices %[[VAL_0]], %[[VAL_4]] : tensor<10x20xf32, #sparse_tensor.encoding<{{{.*}}}>> // CHECK-DAG: %[[VAL_10:.*]] = sparse_tensor.values %[[VAL_0]] : tensor<10x20xf32, #sparse_tensor.encoding<{{{.*}}}>> // CHECK-DAG: %[[VAL_11:.*]] = bufferization.to_memref %[[VAL_1]] : memref<20x30xf32> -// CHECK-DAG: %[[VAL_12:.*]] = bufferization.to_memref %[[VAL_2]] : memref<10x30xf32> -// CHECK-DAG: %[[VAL_13:.*]] = memref.alloc() : memref<10x30xf32> -// CHECK: memref.copy %[[VAL_12]], %[[VAL_13]] : memref<10x30xf32> to memref<10x30xf32> +// CHECK-DAG: %[[VAL_13:.*]] = bufferization.to_memref %[[VAL_2]] : memref<10x30xf32> // CHECK: %[[VAL_14:.*]] = memref.load %[[VAL_6]]{{\[}}%[[VAL_3]]] : memref // CHECK: %[[VAL_15:.*]] = memref.load %[[VAL_6]]{{\[}}%[[VAL_4]]] : memref // CHECK: scf.for %[[VAL_16:.*]] = %[[VAL_14]] to %[[VAL_15]] step %[[VAL_4]] { @@ -166,9 +164,7 @@ // CHECK-DAG: %[[VAL_9:.*]] = sparse_tensor.pointers %[[VAL_1]], %[[VAL_4]] : tensor<3x3xi32, #sparse_tensor.encoding<{{{.*}}}>> // CHECK-DAG: %[[VAL_10:.*]] = sparse_tensor.indices %[[VAL_1]], %[[VAL_4]] : tensor<3x3xi32, #sparse_tensor.encoding<{{{.*}}}>> // CHECK-DAG: %[[VAL_11:.*]] = sparse_tensor.values %[[VAL_1]] : tensor<3x3xi32, #sparse_tensor.encoding<{{{.*}}}>> -// CHECK-DAG: %[[VAL_12:.*]] = bufferization.to_memref %[[VAL_2]] : memref<6x6xi32> -// CHECK-DAG: %[[VAL_13:.*]] = memref.alloc() : memref<6x6xi32> -// CHECK: memref.copy %[[VAL_12]], %[[VAL_13]] : memref<6x6xi32> to memref<6x6xi32> +// CHECK-DAG: %[[VAL_13:.*]] = bufferization.to_memref %[[VAL_2]] : memref<6x6xi32> // CHECK: %[[VAL_14:.*]] = memref.load %[[VAL_7]]{{\[}}%[[VAL_3]]] : memref // CHECK: %[[VAL_15:.*]] = memref.load %[[VAL_7]]{{\[}}%[[VAL_4]]] : memref // CHECK: scf.for %[[VAL_16:.*]] = %[[VAL_14]] to %[[VAL_15]] step %[[VAL_4]] { @@ -218,9 +214,7 @@ // CHECK-DAG: %[[VAL_10:.*]] = sparse_tensor.pointers %[[VAL_1]], %[[VAL_5]] : tensor<3x6xi8, #sparse_tensor.encoding<{{{.*}}}>> // CHECK-DAG: %[[VAL_11:.*]] = sparse_tensor.indices %[[VAL_1]], %[[VAL_5]] : tensor<3x6xi8, #sparse_tensor.encoding<{{{.*}}}>> // CHECK-DAG: %[[VAL_12:.*]] = sparse_tensor.values %[[VAL_1]] : tensor<3x6xi8, #sparse_tensor.encoding<{{{.*}}}>> -// CHECK-DAG: %[[VAL_13:.*]] = bufferization.to_memref %[[VAL_2]] : memref<5x6xi64> -// CHECK-DAG: %[[VAL_14:.*]] = memref.alloc() : memref<5x6xi64> -// CHECK: memref.copy %[[VAL_13]], %[[VAL_14]] : memref<5x6xi64> to memref<5x6xi64> +// CHECK-DAG: %[[VAL_14:.*]] = bufferization.to_memref %[[VAL_2]] : memref<5x6xi64> // CHECK: %[[VAL_15:.*]] = memref.load %[[VAL_8]]{{\[}}%[[VAL_4]]] : memref // CHECK: %[[VAL_16:.*]] = memref.load %[[VAL_8]]{{\[}}%[[VAL_5]]] : memref // CHECK: scf.for %[[VAL_17:.*]] = %[[VAL_15]] to %[[VAL_16]] step %[[VAL_5]] { @@ -266,9 +260,7 @@ // CHECK-DAG: %[[VAL_8:.*]] = sparse_tensor.pointers %[[VAL_1:.*]], %[[VAL_3]] : tensor<1024xf32, #sparse_tensor.encoding<{{{.*}}}>> to memref // CHECK-DAG: %[[VAL_9:.*]] = sparse_tensor.indices %[[VAL_1]], %[[VAL_3]] : tensor<1024xf32, #sparse_tensor.encoding<{{{.*}}}>> to memref // CHECK-DAG: %[[VAL_10:.*]] = sparse_tensor.values %[[VAL_1]] : tensor<1024xf32, #sparse_tensor.encoding<{{{.*}}}>> to memref -// CHECK-DAG: %[[VAL_11:.*]] = memref.alloc() : memref -// CHECK-DAG: %[[VAL_12:.*]] = bufferization.to_memref %[[VAL_2:.*]] : memref -// CHECK-DAG: memref.copy %[[VAL_12]], %[[VAL_11]] : memref to memref +// CHECK-DAG: %[[VAL_11:.*]] = bufferization.to_memref %[[VAL_2:.*]] : memref // CHECK-DAG: %[[VAL_13:.*]] = memref.load %[[VAL_11]][] : memref // CHECK-DAG: %[[VAL_14:.*]] = memref.load %[[VAL_5]]{{\[}}%[[VAL_3]]] : memref // CHECK-DAG: %[[VAL_15:.*]] = memref.load %[[VAL_5]]{{\[}}%[[VAL_4]]] : memref diff --git a/mlir/test/Dialect/SparseTensor/sparse_lower.mlir b/mlir/test/Dialect/SparseTensor/sparse_lower.mlir --- a/mlir/test/Dialect/SparseTensor/sparse_lower.mlir +++ b/mlir/test/Dialect/SparseTensor/sparse_lower.mlir @@ -31,9 +31,7 @@ // CHECK-HIR-DAG: %[[VAL_7:.*]] = sparse_tensor.indices %[[VAL_0]], %[[VAL_5]] : tensor<32x64xf64, #sparse_tensor.encoding<{{{.*}}}>> // CHECK-HIR-DAG: %[[VAL_8:.*]] = sparse_tensor.values %[[VAL_0]] : tensor<32x64xf64, #sparse_tensor.encoding<{{{.*}}}>> // CHECK-HIR-DAG: %[[VAL_9:.*]] = bufferization.to_memref %[[VAL_1]] : memref<64xf64> -// CHECK-HIR-DAG: %[[VAL_10:.*]] = bufferization.to_memref %[[VAL_2]] : memref<32xf64> -// CHECK-HIR-DAG: %[[VAL_11:.*]] = memref.alloc() : memref<32xf64> -// CHECK-HIR: memref.copy %[[VAL_10]], %[[VAL_11]] : memref<32xf64> to memref<32xf64> +// CHECK-HIR-DAG: %[[VAL_11:.*]] = bufferization.to_memref %[[VAL_2]] : memref<32xf64> // CHECK-HIR: scf.for %[[VAL_12:.*]] = %[[VAL_4]] to %[[VAL_3]] step %[[VAL_5]] { // CHECK-HIR-DAG: %[[VAL_13:.*]] = memref.load %[[VAL_6]]{{\[}}%[[VAL_12]]] : memref // CHECK-HIR-DAG: %[[VAL_14:.*]] = arith.addi %[[VAL_12]], %[[VAL_5]] : index @@ -64,9 +62,7 @@ // CHECK-MIR-DAG: %[[VAL_7:.*]] = call @sparseIndices0(%[[VAL_0]], %[[VAL_5]]) : (!llvm.ptr, index) -> memref // CHECK-MIR-DAG: %[[VAL_8:.*]] = call @sparseValuesF64(%[[VAL_0]]) : (!llvm.ptr) -> memref // CHECK-MIR-DAG: %[[VAL_9:.*]] = bufferization.to_memref %[[VAL_1]] : memref<64xf64> -// CHECK-MIR-DAG: %[[VAL_10:.*]] = bufferization.to_memref %[[VAL_2]] : memref<32xf64> -// CHECK-MIR-DAG: %[[VAL_11:.*]] = memref.alloc() : memref<32xf64> -// CHECK-MIR: memref.copy %[[VAL_10]], %[[VAL_11]] : memref<32xf64> to memref<32xf64> +// CHECK-MIR-DAG: %[[VAL_11:.*]] = bufferization.to_memref %[[VAL_2]] : memref<32xf64> // CHECK-MIR: scf.for %[[VAL_14:.*]] = %[[VAL_4]] to %[[VAL_3]] step %[[VAL_5]] { // CHECK-MIR-DAG: %[[VAL_15:.*]] = memref.load %[[VAL_6]]{{\[}}%[[VAL_14]]] : memref // CHECK-MIR-DAG: %[[VAL_16:.*]] = arith.addi %[[VAL_14]], %[[VAL_5]] : index @@ -96,13 +92,11 @@ // CHECK-LIR-DAG: %[[VAL_6:.*]] = call @sparsePointers0(%[[VAL_0]], %[[VAL_5]]) : (!llvm.ptr, index) -> memref // CHECK-LIR-DAG: %[[VAL_7:.*]] = call @sparseIndices0(%[[VAL_0]], %[[VAL_5]]) : (!llvm.ptr, index) -> memref // CHECK-LIR-DAG: %[[VAL_8:.*]] = call @sparseValuesF64(%[[VAL_0]]) : (!llvm.ptr) -> memref -// CHECK-LIR-DAG: %[[VAL_9:.*]] = memref.alloc() : memref<32xf64> -// CHECK-LIR: memref.copy %[[VAL_2]], %[[VAL_9]] : memref<32xf64> to memref<32xf64> // CHECK-LIR: scf.for %[[VAL_12:.*]] = %[[VAL_4]] to %[[VAL_3]] step %[[VAL_5]] { // CHECK-LIR-DAG: %[[VAL_13:.*]] = memref.load %[[VAL_6]]{{\[}}%[[VAL_12]]] : memref // CHECK-LIR-DAG: %[[VAL_14:.*]] = arith.addi %[[VAL_12]], %[[VAL_5]] : index // CHECK-LIR-DAG: %[[VAL_15:.*]] = memref.load %[[VAL_6]]{{\[}}%[[VAL_14]]] : memref -// CHECK-LIR-DAG: %[[VAL_16:.*]] = memref.load %[[VAL_9]]{{\[}}%[[VAL_12]]] : memref<32xf64> +// CHECK-LIR-DAG: %[[VAL_16:.*]] = memref.load %[[VAL_2]]{{\[}}%[[VAL_12]]] : memref<32xf64> // CHECK-LIR: %[[VAL_17:.*]] = scf.for %[[VAL_18:.*]] = %[[VAL_13]] to %[[VAL_15]] step %[[VAL_5]] iter_args(%[[VAL_19:.*]] = %[[VAL_16]]) -> (f64) { // CHECK-LIR: %[[VAL_20:.*]] = memref.load %[[VAL_7]]{{\[}}%[[VAL_18]]] : memref // CHECK-LIR: %[[VAL_21:.*]] = memref.load %[[VAL_8]]{{\[}}%[[VAL_18]]] : memref @@ -111,9 +105,9 @@ // CHECK-LIR: %[[VAL_24:.*]] = arith.addf %[[VAL_19]], %[[VAL_23]] : f64 // CHECK-LIR: scf.yield %[[VAL_24]] : f64 // CHECK-LIR: } -// CHECK-LIR: memref.store %[[VAL_17]], %[[VAL_9]]{{\[}}%[[VAL_12]]] : memref<32xf64> +// CHECK-LIR: memref.store %[[VAL_17]], %[[VAL_2]]{{\[}}%[[VAL_12]]] : memref<32xf64> // CHECK-LIR: } -// CHECK-LIR: return %[[VAL_9]] : memref<32xf64> +// CHECK-LIR: return %[[VAL_2]] : memref<32xf64> // CHECK-LIR: } func.func @matvec(%arga: tensor<32x64xf64, #CSR>, diff --git a/mlir/test/Dialect/SparseTensor/sparse_lower_col.mlir b/mlir/test/Dialect/SparseTensor/sparse_lower_col.mlir --- a/mlir/test/Dialect/SparseTensor/sparse_lower_col.mlir +++ b/mlir/test/Dialect/SparseTensor/sparse_lower_col.mlir @@ -34,9 +34,7 @@ // CHECK-HIR-DAG: %[[VAL_7:.*]] = sparse_tensor.indices %[[VAL_0]], %[[VAL_5]] : tensor<32x64xf64, #sparse_tensor.encoding<{ dimLevelType = [ "dense", "compressed" ], dimOrdering = affine_map<(d0, d1) -> (d1, d0)>, pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-HIR-DAG: %[[VAL_8:.*]] = sparse_tensor.values %[[VAL_0]] : tensor<32x64xf64, #sparse_tensor.encoding<{ dimLevelType = [ "dense", "compressed" ], dimOrdering = affine_map<(d0, d1) -> (d1, d0)>, pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-HIR-DAG: %[[VAL_9:.*]] = bufferization.to_memref %[[VAL_1]] : memref<64xf64> -// CHECK-HIR-DAG: %[[VAL_10:.*]] = bufferization.to_memref %[[VAL_2]] : memref<32xf64> -// CHECK-HIR-DAG: %[[VAL_11:.*]] = memref.alloc() : memref<32xf64> -// CHECK-HIR: memref.copy %[[VAL_10]], %[[VAL_11]] : memref<32xf64> to memref<32xf64> +// CHECK-HIR-DAG: %[[VAL_11:.*]] = bufferization.to_memref %[[VAL_2]] : memref<32xf64> // CHECK-HIR: scf.for %[[VAL_12:.*]] = %[[VAL_4]] to %[[VAL_3]] step %[[VAL_5]] { // CHECK-HIR: %[[VAL_13:.*]] = memref.load %[[VAL_9]]{{\[}}%[[VAL_12]]] : memref<64xf64> // CHECK-HIR: %[[VAL_14:.*]] = memref.load %[[VAL_6]]{{\[}}%[[VAL_12]]] : memref @@ -66,9 +64,7 @@ // CHECK-MIR-DAG: %[[VAL_8:.*]] = call @sparseIndices0(%[[VAL_0]], %[[VAL_6]]) : (!llvm.ptr, index) -> memref // CHECK-MIR-DAG: %[[VAL_9:.*]] = call @sparseValuesF64(%[[VAL_0]]) : (!llvm.ptr) -> memref // CHECK-MIR-DAG: %[[VAL_10:.*]] = bufferization.to_memref %[[VAL_1]] : memref<64xf64> -// CHECK-MIR-DAG: %[[VAL_11:.*]] = bufferization.to_memref %[[VAL_2]] : memref<32xf64> -// CHECK-MIR-DAG: %[[VAL_12:.*]] = memref.alloc() : memref<32xf64> -// CHECK-MIR: memref.copy %[[VAL_11]], %[[VAL_12]] : memref<32xf64> to memref<32xf64> +// CHECK-MIR-DAG: %[[VAL_12:.*]] = bufferization.to_memref %[[VAL_2]] : memref<32xf64> // CHECK-MIR: scf.for %[[VAL_15:.*]] = %[[VAL_5]] to %[[VAL_3]] step %[[VAL_6]] { // CHECK-MIR: %[[VAL_16:.*]] = memref.load %[[VAL_10]]{{\[}}%[[VAL_15]]] : memref<64xf64> // CHECK-MIR: %[[VAL_17:.*]] = memref.load %[[VAL_7]]{{\[}}%[[VAL_15]]] : memref @@ -97,8 +93,6 @@ // CHECK-LIR-DAG: %[[VAL_7:.*]] = call @sparsePointers0(%[[VAL_0]], %[[VAL_6]]) : (!llvm.ptr, index) -> memref // CHECK-LIR-DAG: %[[VAL_8:.*]] = call @sparseIndices0(%[[VAL_0]], %[[VAL_6]]) : (!llvm.ptr, index) -> memref // CHECK-LIR-DAG: %[[VAL_9:.*]] = call @sparseValuesF64(%[[VAL_0]]) : (!llvm.ptr) -> memref -// CHECK-LIR-DAG: %[[VAL_10:.*]] = memref.alloc() : memref<32xf64> -// CHECK-LIR: memref.copy %[[VAL_2]], %[[VAL_10]] : memref<32xf64> to memref<32xf64> // CHECK-LIR: scf.for %[[VAL_13:.*]] = %[[VAL_5]] to %[[VAL_3]] step %[[VAL_6]] { // CHECK-LIR: %[[VAL_14:.*]] = memref.load %[[VAL_1]]{{\[}}%[[VAL_13]]] : memref<64xf64> // CHECK-LIR: %[[VAL_15:.*]] = memref.load %[[VAL_7]]{{\[}}%[[VAL_13]]] : memref @@ -106,14 +100,14 @@ // CHECK-LIR: %[[VAL_17:.*]] = memref.load %[[VAL_7]]{{\[}}%[[VAL_16]]] : memref // CHECK-LIR: scf.for %[[VAL_18:.*]] = %[[VAL_15]] to %[[VAL_17]] step %[[VAL_6]] { // CHECK-LIR: %[[VAL_19:.*]] = memref.load %[[VAL_8]]{{\[}}%[[VAL_18]]] : memref -// CHECK-LIR: %[[VAL_20:.*]] = memref.load %[[VAL_10]]{{\[}}%[[VAL_19]]] : memref<32xf64> +// CHECK-LIR: %[[VAL_20:.*]] = memref.load %[[VAL_2]]{{\[}}%[[VAL_19]]] : memref<32xf64> // CHECK-LIR: %[[VAL_21:.*]] = memref.load %[[VAL_9]]{{\[}}%[[VAL_18]]] : memref // CHECK-LIR: %[[VAL_22:.*]] = arith.mulf %[[VAL_21]], %[[VAL_14]] : f64 // CHECK-LIR: %[[VAL_23:.*]] = arith.addf %[[VAL_20]], %[[VAL_22]] : f64 -// CHECK-LIR: memref.store %[[VAL_23]], %[[VAL_10]]{{\[}}%[[VAL_19]]] : memref<32xf64> +// CHECK-LIR: memref.store %[[VAL_23]], %[[VAL_2]]{{\[}}%[[VAL_19]]] : memref<32xf64> // CHECK-LIR: } // CHECK-LIR: } -// CHECK-LIR: return %[[VAL_10]] : memref<32xf64> +// CHECK-LIR: return %[[VAL_2]] : memref<32xf64> // CHECK-LIR: } func.func @matvec(%arga: tensor<32x64xf64, #CSC>, diff --git a/mlir/test/Dialect/SparseTensor/sparse_lower_inplace.mlir b/mlir/test/Dialect/SparseTensor/sparse_lower_inplace.mlir --- a/mlir/test/Dialect/SparseTensor/sparse_lower_inplace.mlir +++ b/mlir/test/Dialect/SparseTensor/sparse_lower_inplace.mlir @@ -23,7 +23,7 @@ // CHECK-HIR-LABEL: func @matvec( // CHECK-HIR-SAME: %[[VAL_0:.*]]: tensor<32x64xf64, #sparse_tensor.encoding<{{{.*}}}>>, // CHECK-HIR-SAME: %[[VAL_1:.*]]: tensor<64xf64>, -// CHECK-HIR-SAME: %[[VAL_2:.*]]: tensor<32xf64> {linalg.inplaceable = true}) -> tensor<32xf64> { +// CHECK-HIR-SAME: %[[VAL_2:.*]]: tensor<32xf64>) -> tensor<32xf64> { // CHECK-HIR-DAG: %[[VAL_3:.*]] = arith.constant 32 : index // CHECK-HIR-DAG: %[[VAL_4:.*]] = arith.constant 0 : index // CHECK-HIR-DAG: %[[VAL_5:.*]] = arith.constant 1 : index @@ -54,7 +54,7 @@ // CHECK-MIR-LABEL: func @matvec( // CHECK-MIR-SAME: %[[VAL_0:.*]]: !llvm.ptr, // CHECK-MIR-SAME: %[[VAL_1:.*]]: tensor<64xf64>, -// CHECK-MIR-SAME: %[[VAL_2:.*]]: tensor<32xf64> {linalg.inplaceable = true}) -> tensor<32xf64> { +// CHECK-MIR-SAME: %[[VAL_2:.*]]: tensor<32xf64>) -> tensor<32xf64> { // CHECK-MIR-DAG: %[[VAL_3:.*]] = arith.constant 32 : index // CHECK-MIR-DAG: %[[VAL_4:.*]] = arith.constant 0 : index // CHECK-MIR-DAG: %[[VAL_5:.*]] = arith.constant 1 : index @@ -85,7 +85,7 @@ // CHECK-LIR-LABEL: func @matvec( // CHECK-LIR-SAME: %[[VAL_0:.*]]: !llvm.ptr, // CHECK-LIR-SAME: %[[VAL_1:.*]]: memref<64xf64>, -// CHECK-LIR-SAME: %[[VAL_2:.*]]: memref<32xf64> {linalg.inplaceable = true}) -> memref<32xf64> { +// CHECK-LIR-SAME: %[[VAL_2:.*]]: memref<32xf64>) -> memref<32xf64> { // CHECK-LIR-DAG: %[[VAL_3:.*]] = arith.constant 32 : index // CHECK-LIR-DAG: %[[VAL_4:.*]] = arith.constant 0 : index // CHECK-LIR-DAG: %[[VAL_5:.*]] = arith.constant 1 : index @@ -112,7 +112,7 @@ func.func @matvec(%arga: tensor<32x64xf64, #CSR>, %argb: tensor<64xf64>, - %argx: tensor<32xf64> {linalg.inplaceable = true}) -> tensor<32xf64> { + %argx: tensor<32xf64>) -> tensor<32xf64> { %0 = linalg.generic #trait_matvec ins(%arga, %argb : tensor<32x64xf64, #CSR>, tensor<64xf64>) outs(%argx: tensor<32xf64>) { diff --git a/mlir/test/Dialect/SparseTensor/sparse_nd.mlir b/mlir/test/Dialect/SparseTensor/sparse_nd.mlir --- a/mlir/test/Dialect/SparseTensor/sparse_nd.mlir +++ b/mlir/test/Dialect/SparseTensor/sparse_nd.mlir @@ -41,7 +41,7 @@ // CHECK-DAG: %[[VAL_16:.*]] = sparse_tensor.pointers %[[VAL_1]], %[[VAL_4]] : tensor<80x70x60x50x40x30x20x10xf32, #sparse_tensor.encoding<{ dimLevelType = [ "dense", "dense", "dense", "compressed", "compressed", "dense", "dense", "dense" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_17:.*]] = sparse_tensor.indices %[[VAL_1]], %[[VAL_4]] : tensor<80x70x60x50x40x30x20x10xf32, #sparse_tensor.encoding<{ dimLevelType = [ "dense", "dense", "dense", "compressed", "compressed", "dense", "dense", "dense" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref // CHECK-DAG: %[[VAL_18:.*]] = sparse_tensor.values %[[VAL_1]] : tensor<80x70x60x50x40x30x20x10xf32, #sparse_tensor.encoding<{ dimLevelType = [ "dense", "dense", "dense", "compressed", "compressed", "dense", "dense", "dense" ], pointerBitWidth = 0, indexBitWidth = 0 }>> to memref -// CHECK-DAG: %[[VAL_20:.*]] = memref.alloc() : memref<10x20x30x40x50x60x70x80xf32> +// CHECK-DAG: %[[VAL_20:.*]] = bufferization.to_memref %[[VAL_2]] : memref<10x20x30x40x50x60x70x80xf32> // CHECK: linalg.fill ins(%[[ZERO]] : f32) outs(%[[VAL_20]] : memref<10x20x30x40x50x60x70x80xf32> // CHECK: scf.for %[[VAL_21:.*]] = %[[VAL_11]] to %[[VAL_10]] step %[[VAL_12]] { // CHECK: scf.for %[[VAL_22:.*]] = %[[VAL_11]] to %[[VAL_9]] step %[[VAL_12]] { diff --git a/mlir/test/Dialect/SparseTensor/sparse_out.mlir b/mlir/test/Dialect/SparseTensor/sparse_out.mlir --- a/mlir/test/Dialect/SparseTensor/sparse_out.mlir +++ b/mlir/test/Dialect/SparseTensor/sparse_out.mlir @@ -46,7 +46,7 @@ // CHECK: %[[VAL_18:.*]] = sparse_tensor.load %[[VAL_0]] : tensor<32x16xf32, #sparse_tensor.encoding<{{.*}}>> // CHECK: return %[[VAL_18]] : tensor<32x16xf32, #sparse_tensor.encoding<{{.*}}>> // CHECK: } -func.func @sparse_simply_dynamic1(%argx: tensor<32x16xf32, #DCSR> {linalg.inplaceable = true}) -> tensor<32x16xf32, #DCSR> { +func.func @sparse_simply_dynamic1(%argx: tensor<32x16xf32, #DCSR>) -> tensor<32x16xf32, #DCSR> { %c = arith.constant 2.0 : f32 %0 = linalg.generic #trait_scale_inpl outs(%argx: tensor<32x16xf32, #DCSR>) { @@ -80,7 +80,7 @@ // CHECK: %[[VAL_16:.*]] = sparse_tensor.load %[[VAL_0]] : tensor<32x16xf32, #sparse_tensor.encoding<{{.*}}>> // CHECK: return %[[VAL_16]] : tensor<32x16xf32, #sparse_tensor.encoding<{{.*}}>> // CHECK: } -func.func @sparse_simply_dynamic2(%argx: tensor<32x16xf32, #DCSR> {linalg.inplaceable = true}) -> tensor<32x16xf32, #DCSR> { +func.func @sparse_simply_dynamic2(%argx: tensor<32x16xf32, #DCSR>) -> tensor<32x16xf32, #DCSR> { %0 = linalg.generic #trait_scale_inpl outs(%argx: tensor<32x16xf32, #DCSR>) { ^bb(%x: f32): diff --git a/mlir/test/Dialect/SparseTensor/sparse_outbuf.mlir b/mlir/test/Dialect/SparseTensor/sparse_outbuf.mlir --- a/mlir/test/Dialect/SparseTensor/sparse_outbuf.mlir +++ b/mlir/test/Dialect/SparseTensor/sparse_outbuf.mlir @@ -12,7 +12,7 @@ // CHECK-LABEL: func.func @allout_inplace( // CHECK-SAME: %[[VAL_0:.*]]: tensor<10xi32, #{{.*}}>, -// CHECK-SAME: %[[VAL_1:.*]]: tensor<10xf32> {linalg.inplaceable = true}) -> tensor<10xf32> { +// CHECK-SAME: %[[VAL_1:.*]]: tensor<10xf32>) -> tensor<10xf32> { // CHECK-DAG: %[[VAL_2:.*]] = arith.constant 0 : index // CHECK-DAG: %[[VAL_3:.*]] = arith.constant 0.000000e+00 : f32 // CHECK-DAG: %[[VAL_4:.*]] = arith.constant 1 : index @@ -33,7 +33,7 @@ // CHECK: return %[[VAL_15]] : tensor<10xf32> // CHECK: } func.func @allout_inplace(%arga: tensor<10xi32, #SV>, - %argb: tensor<10xf32> {linalg.inplaceable = true}) -> tensor<10xf32> { + %argb: tensor<10xf32>) -> tensor<10xf32> { %0 = linalg.generic #trait ins(%arga: tensor<10xi32, #SV>) outs(%argb: tensor<10xf32>) { @@ -53,7 +53,7 @@ // CHECK: %[[VAL_5:.*]] = sparse_tensor.pointers %[[VAL_0]], %[[VAL_1]] : tensor<10xi32, #{{.*}}> to memref // CHECK: %[[VAL_6:.*]] = sparse_tensor.indices %[[VAL_0]], %[[VAL_1]] : tensor<10xi32, #{{.*}}> to memref // CHECK: %[[VAL_7:.*]] = sparse_tensor.values %[[VAL_0]] : tensor<10xi32, #{{.*}}> to memref -// CHECK: %[[VAL_8:.*]] = memref.alloc() : memref<10xf32> +// CHECK: %[[VAL_8:.*]] = bufferization.to_memref %[[VAL_4]] : memref<10xf32> // CHECK: linalg.fill ins(%[[VAL_2]] : f32) outs(%[[VAL_8]] : memref<10xf32>) // CHECK: %[[VAL_9:.*]] = memref.load %[[VAL_5]]{{\[}}%[[VAL_1]]] : memref // CHECK: %[[VAL_10:.*]] = memref.load %[[VAL_5]]{{\[}}%[[VAL_3]]] : memref @@ -78,44 +78,9 @@ return %0 : tensor<10xf32> } -// CHECK-LABEL: func.func @update_notinplace( -// CHECK-SAME: %[[VAL_0:.*]]: tensor<10xf32, #{{.*}}>, -// CHECK-SAME: %[[VAL_1:.*]]: tensor<10xf32> {linalg.inplaceable = false}) -> tensor<10xf32> { -// CHECK-DAG: %[[VAL_2:.*]] = arith.constant 0 : index -// CHECK-DAG: %[[VAL_3:.*]] = arith.constant 1 : index -// CHECK: %[[VAL_4:.*]] = sparse_tensor.pointers %[[VAL_0]], %[[VAL_2]] : tensor<10xf32, #{{.*}}> to memref -// CHECK: %[[VAL_5:.*]] = sparse_tensor.indices %[[VAL_0]], %[[VAL_2]] : tensor<10xf32, #{{.*}}> to memref -// CHECK: %[[VAL_6:.*]] = sparse_tensor.values %[[VAL_0]] : tensor<10xf32, #{{.*}}> to memref -// CHECK: %[[VAL_7:.*]] = memref.alloc() : memref<10xf32> -// CHECK: %[[VAL_8:.*]] = bufferization.to_memref %[[VAL_1]] : memref<10xf32> -// CHECK: memref.copy %[[VAL_8]], %[[VAL_7]] : memref<10xf32> to memref<10xf32> -// CHECK: %[[VAL_9:.*]] = memref.load %[[VAL_4]]{{\[}}%[[VAL_2]]] : memref -// CHECK: %[[VAL_10:.*]] = memref.load %[[VAL_4]]{{\[}}%[[VAL_3]]] : memref -// CHECK: scf.for %[[VAL_11:.*]] = %[[VAL_9]] to %[[VAL_10]] step %[[VAL_3]] { -// CHECK: %[[VAL_12:.*]] = memref.load %[[VAL_5]]{{\[}}%[[VAL_11]]] : memref -// CHECK: %[[VAL_13:.*]] = memref.load %[[VAL_6]]{{\[}}%[[VAL_11]]] : memref -// CHECK: %[[VAL_14:.*]] = memref.load %[[VAL_7]]{{\[}}%[[VAL_12]]] : memref<10xf32> -// CHECK: %[[VAL_15:.*]] = arith.addf %[[VAL_13]], %[[VAL_14]] : f32 -// CHECK: memref.store %[[VAL_15]], %[[VAL_7]]{{\[}}%[[VAL_12]]] : memref<10xf32> -// CHECK: } -// CHECK: %[[VAL_16:.*]] = bufferization.to_tensor %[[VAL_7]] : memref<10xf32> -// CHECK: return %[[VAL_16]] : tensor<10xf32> -// CHECK: } -func.func @update_notinplace(%arga: tensor<10xf32, #SV>, - %argb: tensor<10xf32> {linalg.inplaceable = false}) -> tensor<10xf32> { - %0 = linalg.generic #trait - ins(%arga: tensor<10xf32, #SV>) - outs(%argb: tensor<10xf32>) { - ^bb(%a: f32, %x : f32): - %up = arith.addf %a, %x : f32 - linalg.yield %up : f32 - } -> tensor<10xf32> - return %0 : tensor<10xf32> -} - // CHECK-LABEL: func.func @update_inplace( // CHECK-SAME: %[[VAL_0:.*]]: tensor<10xf32, #{{.*}}>, -// CHECK-SAME: %[[VAL_1:.*]]: tensor<10xf32> {linalg.inplaceable = true}) -> tensor<10xf32> { +// CHECK-SAME: %[[VAL_1:.*]]: tensor<10xf32>) -> tensor<10xf32> { // CHECK-DAG: %[[VAL_2:.*]] = arith.constant 0 : index // CHECK-DAG: %[[VAL_3:.*]] = arith.constant 1 : index // CHECK: %[[VAL_4:.*]] = sparse_tensor.pointers %[[VAL_0]], %[[VAL_2]] : tensor<10xf32, #{{.*}}> to memref @@ -135,7 +100,7 @@ // CHECK: return %[[VAL_15]] : tensor<10xf32> // CHECK: } func.func @update_inplace(%arga: tensor<10xf32, #SV>, - %argb: tensor<10xf32> {linalg.inplaceable = true}) -> tensor<10xf32> { + %argb: tensor<10xf32>) -> tensor<10xf32> { %0 = linalg.generic #trait ins(%arga: tensor<10xf32, #SV>) outs(%argb: tensor<10xf32>) { diff --git a/mlir/test/Dialect/SparseTensor/sparse_perm.mlir b/mlir/test/Dialect/SparseTensor/sparse_perm.mlir --- a/mlir/test/Dialect/SparseTensor/sparse_perm.mlir +++ b/mlir/test/Dialect/SparseTensor/sparse_perm.mlir @@ -24,7 +24,7 @@ // CHECK-DAG: %[[VAL_5:.*]] = arith.constant 0 : index // CHECK-DAG: %[[VAL_6:.*]] = arith.constant 1 : index // CHECK-DAG: %[[VAL_7:.*]] = sparse_tensor.values %[[VAL_0]] : tensor<10x20x30xf32, #sparse_tensor.encoding<{{{.*}}}>> -// CHECK-DAG: %[[VAL_9:.*]] = memref.alloc() : memref<20x30x10xf32> +// CHECK-DAG: %[[VAL_9:.*]] = bufferization.to_memref %[[VAL_1]] : memref<20x30x10xf32> // CHECK: linalg.fill ins(%[[ZERO]] : f32) outs(%[[VAL_9]] : memref<20x30x10xf32>) // CHECK: scf.for %[[VAL_10:.*]] = %[[VAL_5]] to %[[VAL_3]] step %[[VAL_6]] { // CHECK: scf.for %[[VAL_11:.*]] = %[[VAL_5]] to %[[VAL_4]] step %[[VAL_6]] { @@ -63,7 +63,7 @@ // CHECK-DAG: %[[VAL_6:.*]] = tensor.dim %[[VAL_1]], %[[VAL_3]] : tensor // CHECK-DAG: %[[VAL_7:.*]] = tensor.dim %[[VAL_1]], %[[VAL_4]] : tensor // CHECK-DAG: %[[VAL_8:.*]] = tensor.dim %[[VAL_1]], %[[VAL_2]] : tensor -// CHECK-DAG: %[[VAL_10:.*]] = memref.alloc(%[[VAL_6]], %[[VAL_7]], %[[VAL_8]]) : memref +// CHECK-DAG: %[[VAL_10:.*]] = bufferization.to_memref %[[VAL_1]] : memref // CHECK: linalg.fill ins(%[[ZERO]] : f32) outs(%[[VAL_10]] : memref) // CHECK: scf.for %[[VAL_11:.*]] = %[[VAL_3]] to %[[VAL_7]] step %[[VAL_4]] { // CHECK: scf.for %[[VAL_12:.*]] = %[[VAL_3]] to %[[VAL_8]] step %[[VAL_4]] { @@ -81,7 +81,7 @@ // CHECK: return %[[VAL_19]] : tensor // CHECK: } func.func @sparse_dynamic_dims(%arga: tensor, - %argx: tensor) -> tensor { + %argx: tensor) -> tensor { %0 = linalg.generic #trait ins(%arga: tensor) outs(%argx: tensor) { diff --git a/mlir/test/Dialect/SparseTensor/sparse_perm_lower.mlir b/mlir/test/Dialect/SparseTensor/sparse_perm_lower.mlir --- a/mlir/test/Dialect/SparseTensor/sparse_perm_lower.mlir +++ b/mlir/test/Dialect/SparseTensor/sparse_perm_lower.mlir @@ -26,10 +26,8 @@ // CHECK-HIR-DAG: %[[VAL_6:.*]] = tensor.dim %[[VAL_0]], %[[VAL_3]] : tensor> // CHECK-HIR-DAG: %[[VAL_7:.*]] = tensor.dim %[[VAL_0]], %[[VAL_2]] : tensor> // CHECK-HIR-DAG: %[[VAL_8:.*]] = sparse_tensor.values %[[VAL_0]] : tensor> -// CHECK-HIR-DAG: %[[VAL_9:.*]] = bufferization.to_memref %[[VAL_1]] : memref -// CHECK-HIR-DAG: %[[VAL_10:.*]] = memref.alloc() : memref -// CHECK-HIR: memref.copy %[[VAL_9]], %[[VAL_10]] : memref to memref -// CHECK-HIR: %[[VAL_11:.*]] = memref.load %[[VAL_10]][] : memref +// CHECK-HIR-DAG: %[[VAL_10:.*]] = bufferization.to_memref %[[VAL_1]] : memref +// CHECK-HIR: %[[VAL_11:.*]] = tensor.extract %[[VAL_1]][] : tensor // CHECK-HIR: %[[VAL_12:.*]] = scf.for %[[VAL_13:.*]] = %[[VAL_3]] to %[[VAL_5]] step %[[VAL_2]] iter_args(%[[VAL_14:.*]] = %[[VAL_11]]) -> (f32) { // CHECK-HIR: %[[VAL_15:.*]] = scf.for %[[VAL_16:.*]] = %[[VAL_3]] to %[[VAL_6]] step %[[VAL_2]] iter_args(%[[VAL_17:.*]] = %[[VAL_14]]) -> (f32) { // CHECK-HIR: %[[VAL_18:.*]] = arith.muli %[[VAL_6]], %[[VAL_13]] : index @@ -60,10 +58,8 @@ // CHECK-MIR-DAG: %[[VAL_6:.*]] = call @sparseDimSize(%[[VAL_0]], %[[VAL_3]]) : (!llvm.ptr, index) -> index // CHECK-MIR-DAG: %[[VAL_7:.*]] = call @sparseDimSize(%[[VAL_0]], %[[VAL_2]]) : (!llvm.ptr, index) -> index // CHECK-MIR-DAG: %[[VAL_8:.*]] = call @sparseValuesF32(%[[VAL_0]]) : (!llvm.ptr) -> memref -// CHECK-MIR-DAG: %[[VAL_9:.*]] = bufferization.to_memref %[[VAL_1]] : memref -// CHECK-MIR-DAG: %[[VAL_10:.*]] = memref.alloc() : memref -// CHECK-MIR: memref.copy %[[VAL_9]], %[[VAL_10]] : memref to memref -// CHECK-MIR: %[[VAL_11:.*]] = memref.load %[[VAL_10]][] : memref +// CHECK-MIR-DAG: %[[VAL_10:.*]] = bufferization.to_memref %[[VAL_1]] : memref +// CHECK-MIR: %[[VAL_11:.*]] = tensor.extract %[[VAL_1]][] : tensor // CHECK-MIR: %[[VAL_12:.*]] = scf.for %[[VAL_13:.*]] = %[[VAL_4]] to %[[VAL_5]] step %[[VAL_3]] iter_args(%[[VAL_14:.*]] = %[[VAL_11]]) -> (f32) { // CHECK-MIR: %[[VAL_15:.*]] = scf.for %[[VAL_16:.*]] = %[[VAL_4]] to %[[VAL_6]] step %[[VAL_3]] iter_args(%[[VAL_17:.*]] = %[[VAL_14]]) -> (f32) { // CHECK-MIR: %[[VAL_18:.*]] = arith.muli %[[VAL_6]], %[[VAL_13]] : index diff --git a/mlir/test/Dialect/SparseTensor/sparse_scalars.mlir b/mlir/test/Dialect/SparseTensor/sparse_scalars.mlir --- a/mlir/test/Dialect/SparseTensor/sparse_scalars.mlir +++ b/mlir/test/Dialect/SparseTensor/sparse_scalars.mlir @@ -23,7 +23,7 @@ // CHECK-SAME: %[[VAL_1:.*1]]: tensor, // CHECK-SAME: %[[VAL_2:.*2]]: f32, // CHECK-SAME: %[[VAL_3:.*3]]: f32, -// CHECK-SAME: %[[VAL_4:.*4]]: tensor<32x16xf32> {linalg.inplaceable = true}) -> tensor<32x16xf32> { +// CHECK-SAME: %[[VAL_4:.*4]]: tensor<32x16xf32>) -> tensor<32x16xf32> { // CHECK-DAG: %[[VAL_5:.*]] = arith.constant 2.200000e+00 : f32 // CHECK-DAG: %[[VAL_6:.*]] = arith.constant 0 : index // CHECK-DAG: %[[VAL_7:.*]] = arith.constant 1 : index @@ -60,10 +60,10 @@ // CHECK: return %[[VAL_34]] : tensor<32x16xf32> // CHECK: } func.func @mul(%arga: tensor<32x16xf32, #SparseMatrix>, - %argp: tensor, - %argq: f32, - %argr: f32, - %argx: tensor<32x16xf32> {linalg.inplaceable = true}) -> tensor<32x16xf32> { + %argp: tensor, + %argq: f32, + %argr: f32, + %argx: tensor<32x16xf32>) -> tensor<32x16xf32> { %s = arith.addf %argq, %argr : f32 %c = arith.constant 2.2 : f32 %0 = linalg.generic #trait diff --git a/mlir/test/Dialect/SparseTensor/sparse_vector.mlir b/mlir/test/Dialect/SparseTensor/sparse_vector.mlir --- a/mlir/test/Dialect/SparseTensor/sparse_vector.mlir +++ b/mlir/test/Dialect/SparseTensor/sparse_vector.mlir @@ -585,7 +585,7 @@ // CHECK-VEC4: return // func.func @add_dense(%arga: tensor<32x64xf64, #SparseMatrix>, - %argx: tensor<33x64xf64> {linalg.inplaceable = true}) -> tensor<33x64xf64> { + %argx: tensor<33x64xf64>) -> tensor<33x64xf64> { %0 = linalg.generic #trait_affine ins(%arga: tensor<32x64xf64, #SparseMatrix>) outs(%argx: tensor<33x64xf64>) { diff --git a/mlir/test/Dialect/SparseTensor/sparse_vector_chain.mlir b/mlir/test/Dialect/SparseTensor/sparse_vector_chain.mlir --- a/mlir/test/Dialect/SparseTensor/sparse_vector_chain.mlir +++ b/mlir/test/Dialect/SparseTensor/sparse_vector_chain.mlir @@ -18,7 +18,7 @@ // while-loop are chained before horizontally reducing these back to scalar. // // CHECK-LABEL: func @sparse_matrix_sum( -// CHECK-SAME: %[[VAL_0:.*]]: tensor {linalg.inplaceable = true}, +// CHECK-SAME: %[[VAL_0:.*]]: tensor, // CHECK-SAME: %[[VAL_1:.*]]: tensor<64x32xf64, #sparse_tensor.encoding<{{{.*}}}>>, // CHECK-SAME: %[[VAL_2:.*]]: tensor<64x32xf64, #sparse_tensor.encoding<{{{.*}}}>>) -> tensor { // CHECK-DAG: %[[VAL_3:.*]] = arith.constant dense<0.000000e+00> : vector<8xf64> @@ -112,9 +112,9 @@ // CHECK: %[[VAL_87:.*]] = bufferization.to_tensor %[[VAL_15]] : memref // CHECK: return %[[VAL_87]] : tensor // CHECK: } -func.func @sparse_matrix_sum(%argx: tensor {linalg.inplaceable = true}, - %arga: tensor<64x32xf64, #SparseMatrix>, - %argb: tensor<64x32xf64, #SparseMatrix>) -> tensor { +func.func @sparse_matrix_sum(%argx: tensor, + %arga: tensor<64x32xf64, #SparseMatrix>, + %argb: tensor<64x32xf64, #SparseMatrix>) -> tensor { %0 = linalg.generic #trait ins(%arga, %argb: tensor<64x32xf64, #SparseMatrix>, tensor<64x32xf64, #SparseMatrix>) diff --git a/mlir/test/Dialect/SparseTensor/sparse_vector_index.mlir b/mlir/test/Dialect/SparseTensor/sparse_vector_index.mlir --- a/mlir/test/Dialect/SparseTensor/sparse_vector_index.mlir +++ b/mlir/test/Dialect/SparseTensor/sparse_vector_index.mlir @@ -32,7 +32,8 @@ // CHECK-DAG: %[[VAL_7:.*]] = sparse_tensor.pointers %[[VAL_0]], %[[VAL_6]] : tensor<8xi64, #sparse_tensor.encoding<{{{.*}}}>> to memref // CHECK-DAG: %[[VAL_8:.*]] = sparse_tensor.indices %[[VAL_0]], %[[VAL_6]] : tensor<8xi64, #sparse_tensor.encoding<{{{.*}}}>> to memref // CHECK-DAG: %[[VAL_9:.*]] = sparse_tensor.values %[[VAL_0]] : tensor<8xi64, #sparse_tensor.encoding<{{{.*}}}>> to memref -// CHECK-DAG: %[[VAL_10:.*]] = memref.alloc() : memref<8xi64> +// CHECK-DAG: %[[VAL_10a:.*]] = linalg.init_tensor [8] : tensor<8xi64> +// CHECK-DAG: %[[VAL_10:.*]] = bufferization.to_memref %[[VAL_10a]] : memref<8xi64> // CHECK-DAG: linalg.fill ins(%[[VAL_5]] : i64) outs(%[[VAL_10]] : memref<8xi64>) // CHECK-DAG: %[[VAL_11:.*]] = memref.load %[[VAL_7]]{{\[}}%[[VAL_6]]] : memref // CHECK-DAG: %[[VAL_12:.*]] = memref.load %[[VAL_7]]{{\[}}%[[VAL_4]]] : memref @@ -72,7 +73,8 @@ // CHECK-DAG: %[[VAL_6:.*]] = sparse_tensor.pointers %[[VAL_0]], %[[VAL_5]] : tensor<8xi64, #sparse_tensor.encoding<{{{.*}}}>> to memref // CHECK-DAG: %[[VAL_7:.*]] = sparse_tensor.indices %[[VAL_0]], %[[VAL_5]] : tensor<8xi64, #sparse_tensor.encoding<{{{.*}}}>> to memref // CHECK-DAG: %[[VAL_8:.*]] = sparse_tensor.values %[[VAL_0]] : tensor<8xi64, #sparse_tensor.encoding<{{{.*}}}>> to memref -// CHECK-DAG: %[[VAL_9:.*]] = memref.alloc() : memref<8xi64> +// CHECK-DAG: %[[VAL_9a:.*]] = linalg.init_tensor [8] : tensor<8xi64> +// CHECK-DAG: %[[VAL_9:.*]] = bufferization.to_memref %[[VAL_9a]] : memref<8xi64> // CHECK-DAG: linalg.fill ins(%[[VAL_3]] : i64) outs(%[[VAL_9]] : memref<8xi64>) // CHECK-DAG: %[[VAL_10:.*]] = memref.load %[[VAL_6]]{{\[}}%[[VAL_5]]] : memref // CHECK-DAG: %[[VAL_11:.*]] = memref.load %[[VAL_6]]{{\[}}%[[VAL_2]]] : memref 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 @@ -353,10 +353,8 @@ vector.print %1 : vector<16xf64> // Dump the dense vector to verify structure is correct. %dv = sparse_tensor.convert %arg0 : tensor to tensor - %2 = bufferization.to_memref %dv : memref - %3 = vector.transfer_read %2[%c0], %d0: memref, vector<32xf64> + %3 = vector.transfer_read %dv[%c0], %d0: tensor, vector<32xf64> vector.print %3 : vector<32xf64> - memref.dealloc %2 : memref return } @@ -369,10 +367,8 @@ vector.print %1 : vector<24xi32> // Dump the dense vector to verify structure is correct. %dv = sparse_tensor.convert %arg0 : tensor to tensor - %2 = bufferization.to_memref %dv : memref - %3 = vector.transfer_read %2[%c0], %d0: memref, vector<32xi32> + %3 = vector.transfer_read %dv[%c0], %d0: tensor, vector<32xi32> vector.print %3 : vector<32xi32> - memref.dealloc %2 : memref return } @@ -380,10 +376,8 @@ %d0 = arith.constant 0.0 : f64 %c0 = arith.constant 0 : index %dm = sparse_tensor.convert %arg0 : tensor to tensor - %0 = bufferization.to_memref %dm : memref - %1 = vector.transfer_read %0[%c0, %c0], %d0: memref, vector<4x8xf64> + %1 = vector.transfer_read %dm[%c0, %c0], %d0: tensor, vector<4x8xf64> vector.print %1 : vector<4x8xf64> - memref.dealloc %0 : memref return } @@ -392,16 +386,13 @@ %du = arith.constant -1.0 : f64 %c = sparse_tensor.convert %A : tensor<4x4xf64, #DCSR> to tensor<4x4xf64> - %m = bufferization.to_memref %c : memref<4x4xf64> - %v = vector.transfer_read %m[%c0, %c0], %du: memref<4x4xf64>, vector<4x4xf64> + %v = vector.transfer_read %c[%c0, %c0], %du: tensor<4x4xf64>, vector<4x4xf64> vector.print %v : vector<4x4xf64> %1 = sparse_tensor.values %A : tensor<4x4xf64, #DCSR> to memref %2 = vector.transfer_read %1[%c0], %du: memref, vector<16xf64> vector.print %2 : vector<16xf64> - // Release the resources. - memref.dealloc %m : memref<4x4xf64> return } @@ -410,16 +401,13 @@ %du = arith.constant -1 : i8 %c = sparse_tensor.convert %A : tensor<4x4xi8, #DCSR> to tensor<4x4xi8> - %m = bufferization.to_memref %c : memref<4x4xi8> - %v = vector.transfer_read %m[%c0, %c0], %du: memref<4x4xi8>, vector<4x4xi8> + %v = vector.transfer_read %c[%c0, %c0], %du: tensor<4x4xi8>, vector<4x4xi8> vector.print %v : vector<4x4xi8> %1 = sparse_tensor.values %A : tensor<4x4xi8, #DCSR> to memref %2 = vector.transfer_read %1[%c0], %du: memref, vector<16xi8> vector.print %2 : vector<16xi8> - - // Release the resources. - memref.dealloc %m : memref<4x4xi8> + 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 @@ -45,110 +45,110 @@ // Since all casts are "zero preserving" unary operations, lattice computation // and conversion to sparse code is straightforward. // - func.func @sparse_cast_s32_to_f32(%arga: tensor<10xi32, #SV>) -> tensor<10xf32> { - %argx = arith.constant dense<0.0> : tensor<10xf32> + func.func @sparse_cast_s32_to_f32(%arga: tensor<10xi32, #SV>, + %argb: tensor<10xf32>) -> tensor<10xf32> { %0 = linalg.generic #trait_cast ins(%arga: tensor<10xi32, #SV>) - outs(%argx: tensor<10xf32>) { + outs(%argb: tensor<10xf32>) { ^bb(%a: i32, %x : f32): %cst = arith.sitofp %a : i32 to f32 linalg.yield %cst : f32 } -> tensor<10xf32> return %0 : tensor<10xf32> } - func.func @sparse_cast_u32_to_f32(%arga: tensor<10xi32, #SV>) -> tensor<10xf32> { - %argx = arith.constant dense<0.0> : tensor<10xf32> + func.func @sparse_cast_u32_to_f32(%arga: tensor<10xi32, #SV>, + %argb: tensor<10xf32>) -> tensor<10xf32> { %0 = linalg.generic #trait_cast ins(%arga: tensor<10xi32, #SV>) - outs(%argx: tensor<10xf32>) { + outs(%argb: tensor<10xf32>) { ^bb(%a: i32, %x : f32): %cst = arith.uitofp %a : i32 to f32 linalg.yield %cst : f32 } -> tensor<10xf32> return %0 : tensor<10xf32> } - func.func @sparse_cast_f32_to_s32(%arga: tensor<10xf32, #SV>) -> tensor<10xi32> { - %argx = arith.constant dense<0> : tensor<10xi32> + func.func @sparse_cast_f32_to_s32(%arga: tensor<10xf32, #SV>, + %argb: tensor<10xi32>) -> tensor<10xi32> { %0 = linalg.generic #trait_cast ins(%arga: tensor<10xf32, #SV>) - outs(%argx: tensor<10xi32>) { + outs(%argb: tensor<10xi32>) { ^bb(%a: f32, %x : i32): %cst = arith.fptosi %a : f32 to i32 linalg.yield %cst : i32 } -> tensor<10xi32> return %0 : tensor<10xi32> } - func.func @sparse_cast_f64_to_u32(%arga: tensor<10xf64, #SV>) -> tensor<10xi32> { - %argx = arith.constant dense<0> : tensor<10xi32> + func.func @sparse_cast_f64_to_u32(%arga: tensor<10xf64, #SV>, + %argb: tensor<10xi32>) -> tensor<10xi32> { %0 = linalg.generic #trait_cast ins(%arga: tensor<10xf64, #SV>) - outs(%argx: tensor<10xi32>) { + outs(%argb: tensor<10xi32>) { ^bb(%a: f64, %x : i32): %cst = arith.fptoui %a : f64 to i32 linalg.yield %cst : i32 } -> tensor<10xi32> return %0 : tensor<10xi32> } - func.func @sparse_cast_f32_to_f64(%arga: tensor<10xf32, #SV>) -> tensor<10xf64> { - %argx = arith.constant dense<0.0> : tensor<10xf64> + func.func @sparse_cast_f32_to_f64(%arga: tensor<10xf32, #SV>, + %argb: tensor<10xf64>) -> tensor<10xf64> { %0 = linalg.generic #trait_cast ins(%arga: tensor<10xf32, #SV>) - outs(%argx: tensor<10xf64>) { + outs(%argb: tensor<10xf64>) { ^bb(%a: f32, %x : f64): %cst = arith.extf %a : f32 to f64 linalg.yield %cst : f64 } -> tensor<10xf64> return %0 : tensor<10xf64> } - func.func @sparse_cast_f64_to_f32(%arga: tensor<10xf64, #SV>) -> tensor<10xf32> { - %argx = arith.constant dense<0.0> : tensor<10xf32> + func.func @sparse_cast_f64_to_f32(%arga: tensor<10xf64, #SV>, + %argb: tensor<10xf32>) -> tensor<10xf32> { %0 = linalg.generic #trait_cast ins(%arga: tensor<10xf64, #SV>) - outs(%argx: tensor<10xf32>) { + outs(%argb: tensor<10xf32>) { ^bb(%a: f64, %x : f32): %cst = arith.truncf %a : f64 to f32 linalg.yield %cst : f32 } -> tensor<10xf32> return %0 : tensor<10xf32> } - func.func @sparse_cast_s32_to_u64(%arga: tensor<10xi32, #SV>) -> tensor<10xi64> { - %argx = arith.constant dense<0> : tensor<10xi64> + func.func @sparse_cast_s32_to_u64(%arga: tensor<10xi32, #SV>, + %argb: tensor<10xi64>) -> tensor<10xi64> { %0 = linalg.generic #trait_cast ins(%arga: tensor<10xi32, #SV>) - outs(%argx: tensor<10xi64>) { + outs(%argb: tensor<10xi64>) { ^bb(%a: i32, %x : i64): %cst = arith.extsi %a : i32 to i64 linalg.yield %cst : i64 } -> tensor<10xi64> return %0 : tensor<10xi64> } - func.func @sparse_cast_u32_to_s64(%arga: tensor<10xi32, #SV>) -> tensor<10xi64> { - %argx = arith.constant dense<0> : tensor<10xi64> + func.func @sparse_cast_u32_to_s64(%arga: tensor<10xi32, #SV>, + %argb: tensor<10xi64>) -> tensor<10xi64> { %0 = linalg.generic #trait_cast ins(%arga: tensor<10xi32, #SV>) - outs(%argx: tensor<10xi64>) { + outs(%argb: tensor<10xi64>) { ^bb(%a: i32, %x : i64): %cst = arith.extui %a : i32 to i64 linalg.yield %cst : i64 } -> tensor<10xi64> return %0 : tensor<10xi64> } - func.func @sparse_cast_i32_to_i8(%arga: tensor<10xi32, #SV>) -> tensor<10xi8> { - %argx = arith.constant dense<0> : tensor<10xi8> + func.func @sparse_cast_i32_to_i8(%arga: tensor<10xi32, #SV>, + %argb: tensor<10xi8>) -> tensor<10xi8> { %0 = linalg.generic #trait_cast ins(%arga: tensor<10xi32, #SV>) - outs(%argx: tensor<10xi8>) { + outs(%argb: tensor<10xi8>) { ^bb(%a: i32, %x : i8): %cst = arith.trunci %a : i32 to i8 linalg.yield %cst : i8 } -> tensor<10xi8> return %0 : tensor<10xi8> } - func.func @sparse_cast_f32_as_s32(%arga: tensor<10xf32, #SV>) -> tensor<10xi32> { - %argx = arith.constant dense<0> : tensor<10xi32> + func.func @sparse_cast_f32_as_s32(%arga: tensor<10xf32, #SV>, + %argb: tensor<10xi32>) -> tensor<10xi32> { %0 = linalg.generic #trait_cast ins(%arga: tensor<10xf32, #SV>) - outs(%argx: tensor<10xi32>) { + outs(%argb: tensor<10xi32>) { ^bb(%a: f32, %x : i32): %cst = arith.bitcast %a : f32 to i32 linalg.yield %cst : i32 @@ -168,6 +168,12 @@ %f = arith.constant 0.0 : f32 %d = arith.constant 0.0 : f64 + %zero_b = arith.constant dense<0> : tensor<10xi8> + %zero_d = arith.constant dense<0.0> : tensor<10xf64> + %zero_f = arith.constant dense<0.0> : tensor<10xf32> + %zero_i = arith.constant dense<0> : tensor<10xi32> + %zero_l = arith.constant dense<0> : tensor<10xi64> + // Initialize dense tensors, convert to a sparse vectors. %0 = arith.constant dense<[ -4, -3, -2, -1, 0, 1, 2, 3, 4, 305 ]> : tensor<10xi32> %1 = sparse_tensor.convert %0 : tensor<10xi32> to tensor<10xi32, #SV> @@ -182,82 +188,72 @@ // // CHECK: ( -4, -3, -2, -1, 0, 1, 2, 3, 4, 305 ) // - %c0 = call @sparse_cast_s32_to_f32(%1) : (tensor<10xi32, #SV>) -> tensor<10xf32> - %m0 = bufferization.to_memref %c0 : memref<10xf32> - %v0 = vector.transfer_read %m0[%z], %f: memref<10xf32>, vector<10xf32> + %c0 = call @sparse_cast_s32_to_f32(%1, %zero_f) : (tensor<10xi32, #SV>, tensor<10xf32>) -> tensor<10xf32> + %v0 = vector.transfer_read %c0[%z], %f: tensor<10xf32>, vector<10xf32> vector.print %v0 : vector<10xf32> // // CHECK: ( 4.29497e+09, 4.29497e+09, 4.29497e+09, 4.29497e+09, 0, 1, 2, 3, 4, 305 ) // - %c1 = call @sparse_cast_u32_to_f32(%1) : (tensor<10xi32, #SV>) -> tensor<10xf32> - %m1 = bufferization.to_memref %c1 : memref<10xf32> - %v1 = vector.transfer_read %m1[%z], %f: memref<10xf32>, vector<10xf32> + %c1 = call @sparse_cast_u32_to_f32(%1, %zero_f) : (tensor<10xi32, #SV>, tensor<10xf32>) -> tensor<10xf32> + %v1 = vector.transfer_read %c1[%z], %f: tensor<10xf32>, vector<10xf32> vector.print %v1 : vector<10xf32> // // CHECK: ( -4, -3, -2, -1, 0, 1, 2, 3, 4, 305 ) // - %c2 = call @sparse_cast_f32_to_s32(%3) : (tensor<10xf32, #SV>) -> tensor<10xi32> - %m2 = bufferization.to_memref %c2 : memref<10xi32> - %v2 = vector.transfer_read %m2[%z], %i: memref<10xi32>, vector<10xi32> + %c2 = call @sparse_cast_f32_to_s32(%3, %zero_i) : (tensor<10xf32, #SV>, tensor<10xi32>) -> tensor<10xi32> + %v2 = vector.transfer_read %c2[%z], %i: tensor<10xi32>, vector<10xi32> vector.print %v2 : vector<10xi32> // // CHECK: ( 4294967295, 4294967294, 4294967293, 4294967292, 0, 1, 2, 3, 4, 305 ) // - %c3 = call @sparse_cast_f64_to_u32(%7) : (tensor<10xf64, #SV>) -> tensor<10xi32> - %m3 = bufferization.to_memref %c3 : memref<10xi32> - %v3 = vector.transfer_read %m3[%z], %i: memref<10xi32>, vector<10xi32> + %c3 = call @sparse_cast_f64_to_u32(%7, %zero_i) : (tensor<10xf64, #SV>, tensor<10xi32>) -> tensor<10xi32> + %v3 = vector.transfer_read %c3[%z], %i: tensor<10xi32>, vector<10xi32> %vu = vector.bitcast %v3 : vector<10xi32> to vector<10xui32> vector.print %vu : vector<10xui32> // // CHECK: ( -4.4, -3.3, -2.2, -1.1, 0, 1.1, 2.2, 3.3, 4.4, 305.5 ) // - %c4 = call @sparse_cast_f32_to_f64(%3) : (tensor<10xf32, #SV>) -> tensor<10xf64> - %m4 = bufferization.to_memref %c4 : memref<10xf64> - %v4 = vector.transfer_read %m4[%z], %d: memref<10xf64>, vector<10xf64> + %c4 = call @sparse_cast_f32_to_f64(%3, %zero_d) : (tensor<10xf32, #SV>, tensor<10xf64>) -> tensor<10xf64> + %v4 = vector.transfer_read %c4[%z], %d: tensor<10xf64>, vector<10xf64> vector.print %v4 : vector<10xf64> // // CHECK: ( -4.4, -3.3, -2.2, -1.1, 0, 1.1, 2.2, 3.3, 4.4, 305.5 ) // - %c5 = call @sparse_cast_f64_to_f32(%5) : (tensor<10xf64, #SV>) -> tensor<10xf32> - %m5 = bufferization.to_memref %c5 : memref<10xf32> - %v5 = vector.transfer_read %m5[%z], %f: memref<10xf32>, vector<10xf32> + %c5 = call @sparse_cast_f64_to_f32(%5, %zero_f) : (tensor<10xf64, #SV>, tensor<10xf32>) -> tensor<10xf32> + %v5 = vector.transfer_read %c5[%z], %f: tensor<10xf32>, vector<10xf32> vector.print %v5 : vector<10xf32> // // CHECK: ( -4, -3, -2, -1, 0, 1, 2, 3, 4, 305 ) // - %c6 = call @sparse_cast_s32_to_u64(%1) : (tensor<10xi32, #SV>) -> tensor<10xi64> - %m6 = bufferization.to_memref %c6 : memref<10xi64> - %v6 = vector.transfer_read %m6[%z], %l: memref<10xi64>, vector<10xi64> + %c6 = call @sparse_cast_s32_to_u64(%1, %zero_l) : (tensor<10xi32, #SV>, tensor<10xi64>) -> tensor<10xi64> + %v6 = vector.transfer_read %c6[%z], %l: tensor<10xi64>, vector<10xi64> vector.print %v6 : vector<10xi64> // // CHECK: ( 4294967292, 4294967293, 4294967294, 4294967295, 0, 1, 2, 3, 4, 305 ) // - %c7 = call @sparse_cast_u32_to_s64(%1) : (tensor<10xi32, #SV>) -> tensor<10xi64> - %m7 = bufferization.to_memref %c7 : memref<10xi64> - %v7 = vector.transfer_read %m7[%z], %l: memref<10xi64>, vector<10xi64> + %c7 = call @sparse_cast_u32_to_s64(%1, %zero_l) : (tensor<10xi32, #SV>, tensor<10xi64>) -> tensor<10xi64> + %v7 = vector.transfer_read %c7[%z], %l: tensor<10xi64>, vector<10xi64> vector.print %v7 : vector<10xi64> // // CHECK: ( -4, -3, -2, -1, 0, 1, 2, 3, 4, 49 ) // - %c8 = call @sparse_cast_i32_to_i8(%1) : (tensor<10xi32, #SV>) -> tensor<10xi8> - %m8 = bufferization.to_memref %c8 : memref<10xi8> - %v8 = vector.transfer_read %m8[%z], %b: memref<10xi8>, vector<10xi8> + %c8 = call @sparse_cast_i32_to_i8(%1, %zero_b) : (tensor<10xi32, #SV>, tensor<10xi8>) -> tensor<10xi8> + %v8 = vector.transfer_read %c8[%z], %b: tensor<10xi8>, vector<10xi8> vector.print %v8 : vector<10xi8> // // CHECK: ( -1064514355, -1068289229, -1072902963, -1081291571, 0, 1066192077, 1074580685, 1079194419, 1082969293, 1134084096 ) // - %c9 = call @sparse_cast_f32_as_s32(%3) : (tensor<10xf32, #SV>) -> tensor<10xi32> - %m9 = bufferization.to_memref %c9 : memref<10xi32> - %v9 = vector.transfer_read %m9[%z], %i: memref<10xi32>, vector<10xi32> + %c9 = call @sparse_cast_f32_as_s32(%3, %zero_i) : (tensor<10xf32, #SV>, tensor<10xi32>) -> tensor<10xi32> + %v9 = vector.transfer_read %c9[%z], %i: tensor<10xi32>, vector<10xi32> vector.print %v9 : vector<10xi32> // Release the resources. @@ -265,16 +261,6 @@ sparse_tensor.release %3 : tensor<10xf32, #SV> sparse_tensor.release %5 : tensor<10xf64, #SV> sparse_tensor.release %7 : tensor<10xf64, #SV> - memref.dealloc %m0 : memref<10xf32> - memref.dealloc %m1 : memref<10xf32> - memref.dealloc %m2 : memref<10xi32> - memref.dealloc %m3 : memref<10xi32> - memref.dealloc %m4 : memref<10xf64> - memref.dealloc %m5 : memref<10xf32> - memref.dealloc %m6 : memref<10xi64> - memref.dealloc %m7 : memref<10xi64> - memref.dealloc %m8 : memref<10xi8> - memref.dealloc %m9 : memref<10xi32> 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 @@ -51,57 +51,41 @@ } func.func @dumpAndRelease_234(%arg0: tensor<2x3x4xf64>) { call @dump(%arg0) : (tensor<2x3x4xf64>) -> () - %1 = bufferization.to_memref %arg0 : memref<2x3x4xf64> - memref.dealloc %1 : memref<2x3x4xf64> return } func.func @dumpAndRelease_p34(%arg0: tensor) { %0 = tensor.cast %arg0 : tensor to tensor<2x3x4xf64> call @dump(%0) : (tensor<2x3x4xf64>) -> () - %1 = bufferization.to_memref %arg0 : memref - memref.dealloc %1 : memref return } func.func @dumpAndRelease_2p4(%arg0: tensor<2x?x4xf64>) { %0 = tensor.cast %arg0 : tensor<2x?x4xf64> to tensor<2x3x4xf64> call @dump(%0) : (tensor<2x3x4xf64>) -> () - %1 = bufferization.to_memref %arg0 : memref<2x?x4xf64> - memref.dealloc %1 : memref<2x?x4xf64> return } func.func @dumpAndRelease_23p(%arg0: tensor<2x3x?xf64>) { %0 = tensor.cast %arg0 : tensor<2x3x?xf64> to tensor<2x3x4xf64> call @dump(%0) : (tensor<2x3x4xf64>) -> () - %1 = bufferization.to_memref %arg0 : memref<2x3x?xf64> - memref.dealloc %1 : memref<2x3x?xf64> return } func.func @dumpAndRelease_2pp(%arg0: tensor<2x?x?xf64>) { %0 = tensor.cast %arg0 : tensor<2x?x?xf64> to tensor<2x3x4xf64> call @dump(%0) : (tensor<2x3x4xf64>) -> () - %1 = bufferization.to_memref %arg0 : memref<2x?x?xf64> - memref.dealloc %1 : memref<2x?x?xf64> return } func.func @dumpAndRelease_p3p(%arg0: tensor) { %0 = tensor.cast %arg0 : tensor to tensor<2x3x4xf64> call @dump(%0) : (tensor<2x3x4xf64>) -> () - %1 = bufferization.to_memref %arg0 : memref - memref.dealloc %1 : memref return } func.func @dumpAndRelease_pp4(%arg0: tensor) { %0 = tensor.cast %arg0 : tensor to tensor<2x3x4xf64> call @dump(%0) : (tensor<2x3x4xf64>) -> () - %1 = bufferization.to_memref %arg0 : memref - memref.dealloc %1 : memref return } func.func @dumpAndRelease_ppp(%arg0: tensor) { %0 = tensor.cast %arg0 : tensor to tensor<2x3x4xf64> call @dump(%0) : (tensor<2x3x4xf64>) -> () - %1 = bufferization.to_memref %arg0 : memref - memref.dealloc %1 : memref 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 @@ -32,8 +32,6 @@ } func.func @dumpAndRelease_234(%arg0: tensor<2x3x4xf64>) { call @dump(%arg0) : (tensor<2x3x4xf64>) -> () - %1 = bufferization.to_memref %arg0 : memref<2x3x4xf64> - memref.dealloc %1 : memref<2x3x4xf64> 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 @@ -11,8 +11,8 @@ // Sparse kernel. // func.func @sparse_dot(%a: tensor<1024xf32, #SparseVector>, - %b: tensor<1024xf32, #SparseVector>) -> tensor { - %x = linalg.init_tensor [] : tensor + %b: tensor<1024xf32, #SparseVector>, + %x: tensor) -> tensor { %dot = linalg.dot ins(%a, %b: tensor<1024xf32, #SparseVector>, tensor<1024xf32, #SparseVector>) outs(%x: tensor) -> tensor @@ -37,16 +37,16 @@ // // CHECK: 53 // - %0 = call @sparse_dot(%s1, %s2) : (tensor<1024xf32, #SparseVector>, - tensor<1024xf32, #SparseVector>) -> tensor + %x = bufferization.alloc_tensor() : tensor + %0 = call @sparse_dot(%s1, %s2, %x) : (tensor<1024xf32, #SparseVector>, + tensor<1024xf32, #SparseVector>, + tensor) -> tensor %1 = tensor.extract %0[] : tensor vector.print %1 : f32 // Release the resources. sparse_tensor.release %s1 : tensor<1024xf32, #SparseVector> sparse_tensor.release %s2 : tensor<1024xf32, #SparseVector> - %m = bufferization.to_memref %0 : memref - memref.dealloc %m : memref 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 @@ -63,14 +63,12 @@ // CHECK-SAME: ( 0, 0, 3, 6, -3, -6 ), // CHECK-SAME: ( 2, -1, 3, 0, -3, 0 ) ) // - %m = bufferization.to_memref %0 : memref<6x6xi32> - %v = vector.transfer_read %m[%c0, %c0], %i0 - : memref<6x6xi32>, vector<6x6xi32> + %v = vector.transfer_read %0[%c0, %c0], %i0 + : tensor<6x6xi32>, vector<6x6xi32> vector.print %v : vector<6x6xi32> // Release the resources. sparse_tensor.release %sparse_filter : tensor<3x3xi32, #DCSR> - memref.dealloc %m : memref<6x6xi32> 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 @@ -45,7 +45,7 @@ // A kernel that flattens a rank 8 tensor into a dense matrix. // func.func @kernel_flatten(%arga: tensor<7x3x3x3x3x3x5x3xf64, #SparseTensor>, - %argx: tensor<7x3xf64> {linalg.inplaceable = true}) + %argx: tensor<7x3xf64>) -> tensor<7x3xf64> { %0 = linalg.generic #trait_flatten ins(%arga: tensor<7x3x3x3x3x3x5x3xf64, #SparseTensor>) 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 @@ -138,8 +138,7 @@ // CHECK-SAME: ( 405.48, 443.88, 482.28, 520.68 ), // CHECK-SAME: ( 413.84, 453.04, 492.24, 531.44 ) ) // - %m0 = bufferization.to_memref %0 : memref<4x4xf64> - %v0 = vector.transfer_read %m0[%c0, %c0], %d1 : memref<4x4xf64>, vector<4x4xf64> + %v0 = vector.transfer_read %0[%c0, %c0], %d1 : tensor<4x4xf64>, vector<4x4xf64> vector.print %v0 : vector<4x4xf64> // @@ -149,8 +148,7 @@ // CHECK-SAME: ( 413.84, 453.04, 492.24, 531.44 ) ) // %c1 = sparse_tensor.convert %1 : tensor<4x4xf64, #CSR> to tensor<4x4xf64> - %m1 = bufferization.to_memref %c1 : memref<4x4xf64> - %v1 = vector.transfer_read %m1[%c0, %c0], %d1 : memref<4x4xf64>, vector<4x4xf64> + %v1 = vector.transfer_read %c1[%c0, %c0], %d1 : tensor<4x4xf64>, vector<4x4xf64> vector.print %v1 : vector<4x4xf64> // @@ -160,8 +158,7 @@ // CHECK-SAME: ( 413.84, 453.04, 492.24, 531.44 ) ) // %c2 = sparse_tensor.convert %2 : tensor<4x4xf64, #DCSR> to tensor<4x4xf64> - %m2 = bufferization.to_memref %c2 : memref<4x4xf64> - %v2 = vector.transfer_read %m2[%c0, %c0], %d1 : memref<4x4xf64>, vector<4x4xf64> + %v2 = vector.transfer_read %c2[%c0, %c0], %d1 : tensor<4x4xf64>, vector<4x4xf64> vector.print %v2 : vector<4x4xf64> // @@ -170,8 +167,7 @@ // CHECK-SAME: ( 23.46, 25.76, 28.06, 30.36 ), // CHECK-SAME: ( 10.8, 11.8, 12.8, 13.8 ) ) // - %m3 = bufferization.to_memref %3 : memref<4x4xf64> - %v3 = vector.transfer_read %m3[%c0, %c0], %d1 : memref<4x4xf64>, vector<4x4xf64> + %v3 = vector.transfer_read %3[%c0, %c0], %d1 : tensor<4x4xf64>, vector<4x4xf64> vector.print %v3 : vector<4x4xf64> // @@ -181,8 +177,7 @@ // CHECK-SAME: ( 10.8, 11.8, 12.8, 13.8 ) ) // %c4 = sparse_tensor.convert %4 : tensor<4x4xf64, #CSR> to tensor<4x4xf64> - %m4 = bufferization.to_memref %c4 : memref<4x4xf64> - %v4 = vector.transfer_read %m4[%c0, %c0], %d1 : memref<4x4xf64>, vector<4x4xf64> + %v4 = vector.transfer_read %c4[%c0, %c0], %d1 : tensor<4x4xf64>, vector<4x4xf64> vector.print %v4 : vector<4x4xf64> // @@ -192,31 +187,27 @@ // CHECK-SAME: ( 10.8, 11.8, 12.8, 13.8 ) ) // %c5 = sparse_tensor.convert %5 : tensor<4x4xf64, #DCSR> to tensor<4x4xf64> - %m5 = bufferization.to_memref %c5 : memref<4x4xf64> - %v5 = vector.transfer_read %m5[%c0, %c0], %d1 : memref<4x4xf64>, vector<4x4xf64> + %v5 = vector.transfer_read %c5[%c0, %c0], %d1 : tensor<4x4xf64>, vector<4x4xf64> vector.print %v5 : vector<4x4xf64> // // CHECK: ( ( 0, 30.5, 4.2, 0 ), ( 0, 0, 0, 0 ), ( 0, 0, 4.6, 0 ), ( 0, 0, 7, 8 ) ) // - %m6 = bufferization.to_memref %6 : memref<4x4xf64> - %v6 = vector.transfer_read %m6[%c0, %c0], %d1 : memref<4x4xf64>, vector<4x4xf64> + %v6 = vector.transfer_read %6[%c0, %c0], %d1 : tensor<4x4xf64>, vector<4x4xf64> vector.print %v6 : vector<4x4xf64> // // CHECK: ( ( 0, 30.5, 4.2, 0 ), ( 0, 0, 0, 0 ), ( 0, 0, 4.6, 0 ), ( 0, 0, 7, 8 ) ) // %c7 = sparse_tensor.convert %7 : tensor<4x4xf64, #CSR> to tensor<4x4xf64> - %m7 = bufferization.to_memref %c7 : memref<4x4xf64> - %v7 = vector.transfer_read %m7[%c0, %c0], %d1 : memref<4x4xf64>, vector<4x4xf64> + %v7 = vector.transfer_read %c7[%c0, %c0], %d1 : tensor<4x4xf64>, vector<4x4xf64> vector.print %v7 : vector<4x4xf64> // // CHECK: ( ( 0, 30.5, 4.2, 0 ), ( 0, 0, 0, 0 ), ( 0, 0, 4.6, 0 ), ( 0, 0, 7, 8 ) ) // %c8 = sparse_tensor.convert %8 : tensor<4x4xf64, #DCSR> to tensor<4x4xf64> - %m8 = bufferization.to_memref %c8 : memref<4x4xf64> - %v8 = vector.transfer_read %m8[%c0, %c0], %d1 : memref<4x4xf64>, vector<4x4xf64> + %v8 = vector.transfer_read %c8[%c0, %c0], %d1 : tensor<4x4xf64>, vector<4x4xf64> vector.print %v8 : vector<4x4xf64> // @@ -247,15 +238,6 @@ sparse_tensor.release %5 : tensor<4x4xf64, #DCSR> sparse_tensor.release %7 : tensor<4x4xf64, #CSR> sparse_tensor.release %8 : tensor<4x4xf64, #DCSR> - memref.dealloc %m0 : memref<4x4xf64> - memref.dealloc %m1 : memref<4x4xf64> - memref.dealloc %m2 : memref<4x4xf64> - memref.dealloc %m3 : memref<4x4xf64> - memref.dealloc %m4 : memref<4x4xf64> - memref.dealloc %m5 : memref<4x4xf64> - memref.dealloc %m6 : memref<4x4xf64> - memref.dealloc %m7 : memref<4x4xf64> - memref.dealloc %m8 : memref<4x4xf64> 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 @@ -54,8 +54,7 @@ } // Scales a sparse matrix in place. - func.func @matrix_scale_inplace(%argx: tensor - {linalg.inplaceable = true}) -> tensor { + func.func @matrix_scale_inplace(%argx: tensor) -> tensor { %s = arith.constant 2.0 : f64 %0 = linalg.generic #trait_scale_inpl outs(%argx: tensor) { @@ -68,7 +67,7 @@ // Adds two sparse matrices element-wise into a new sparse matrix. func.func @matrix_add(%arga: tensor, - %argb: tensor) -> tensor { + %argb: tensor) -> tensor { %c0 = arith.constant 0 : index %c1 = arith.constant 1 : index %d0 = tensor.dim %arga, %c0 : tensor @@ -86,7 +85,7 @@ // Multiplies two sparse matrices element-wise into a new sparse matrix. func.func @matrix_mul(%arga: tensor, - %argb: tensor) -> tensor { + %argb: tensor) -> tensor { %c0 = arith.constant 0 : index %c1 = arith.constant 1 : index %d0 = tensor.dim %arga, %c0 : tensor @@ -107,10 +106,8 @@ %d0 = arith.constant 0.0 : f64 %c0 = arith.constant 0 : index %dm = sparse_tensor.convert %arg0 : tensor to tensor - %0 = bufferization.to_memref %dm : memref - %1 = vector.transfer_read %0[%c0, %c0], %d0: memref, vector<4x8xf64> + %1 = vector.transfer_read %dm[%c0, %c0], %d0: tensor, vector<4x8xf64> vector.print %1 : vector<4x8xf64> - memref.dealloc %0 : memref return } @@ -129,22 +126,24 @@ [6.0, 5.0, 4.0, 3.0, 2.0, 1.0 ] > : tensor<4x8xf64> %sm1 = sparse_tensor.convert %m1 : tensor<4x8xf64> to tensor + // TODO: Use %sm1 when we support sparse tensor copies. + %sm1_dup = sparse_tensor.convert %m1 : tensor<4x8xf64> to tensor %sm2 = sparse_tensor.convert %m2 : tensor<4x8xf64> to tensor // Call sparse matrix kernels. %0 = call @matrix_scale(%sm1) : (tensor) -> tensor - %1 = call @matrix_scale_inplace(%sm1) + %1 = call @matrix_scale_inplace(%sm1_dup) : (tensor) -> tensor - %2 = call @matrix_add(%sm1, %sm2) + %2 = call @matrix_add(%1, %sm2) : (tensor, tensor) -> tensor - %3 = call @matrix_mul(%sm1, %sm2) + %3 = call @matrix_mul(%1, %sm2) : (tensor, tensor) -> tensor // // Verify the results. // - // CHECK: ( ( 2, 4, 0, 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0, 0, 0, 6 ), ( 0, 0, 8, 0, 10, 0, 0, 12 ), ( 14, 0, 16, 18, 0, 0, 0, 0 ) ) + // CHECK: ( ( 1, 2, 0, 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0, 0, 0, 3 ), ( 0, 0, 4, 0, 5, 0, 0, 6 ), ( 7, 0, 8, 9, 0, 0, 0, 0 ) ) // CHECK-NEXT: ( ( 6, 0, 0, 0, 0, 0, 0, 5 ), ( 4, 0, 0, 0, 0, 0, 3, 0 ), ( 0, 2, 0, 0, 0, 0, 0, 1 ), ( 0, 0, 0, 0, 0, 0, 0, 0 ) ) // CHECK-NEXT: ( ( 2, 4, 0, 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0, 0, 0, 6 ), ( 0, 0, 8, 0, 10, 0, 0, 12 ), ( 14, 0, 16, 18, 0, 0, 0, 0 ) ) // CHECK-NEXT: ( ( 2, 4, 0, 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0, 0, 0, 6 ), ( 0, 0, 8, 0, 10, 0, 0, 12 ), ( 14, 0, 16, 18, 0, 0, 0, 0 ) ) @@ -160,6 +159,7 @@ // 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 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 @@ -44,8 +44,8 @@ // into a dense vector x. // func.func @kernel_matvec(%arga: tensor, - %argb: tensor, - %argx: tensor {linalg.inplaceable = true}) + %argb: tensor, + %argx: tensor) -> tensor { %0 = linalg.generic #matvec ins(%arga, %argb: tensor, tensor) 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 @@ -42,9 +42,9 @@ // http://tensor-compiler.org/docs/data_analytics/index.html. // func.func @kernel_mttkrp(%argb: tensor, - %argc: tensor, - %argd: tensor, - %arga: tensor {linalg.inplaceable = true}) + %argc: tensor, + %argd: tensor, + %arga: tensor) -> tensor { %0 = linalg.generic #mttkrp ins(%argb, %argc, %argd: 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 @@ -77,15 +77,13 @@ vector.print %vv : vector<4xi32> %dm = sparse_tensor.convert %0 : tensor to tensor - %db = bufferization.to_memref %dm : memref - %vm = vector.transfer_read %db[%c0, %c0], %i0: memref, vector<3x3xi32> + %vm = vector.transfer_read %dm[%c0, %c0], %i0: tensor, vector<3x3xi32> vector.print %vm : vector<3x3xi32> // Release the resources. sparse_tensor.release %st1 : tensor sparse_tensor.release %st2 : tensor sparse_tensor.release %0 : tensor - memref.dealloc %db : memref 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 @@ -41,7 +41,7 @@ // a sparse tensor as output, but although the values of the // sparse tensor change, its nonzero structure remains the same. // - func.func @kernel_eltwise_mult(%argx: tensor {linalg.inplaceable = true}) + func.func @kernel_eltwise_mult(%argx: tensor) -> tensor { %0 = linalg.generic #eltwise_mult outs(%argx: tensor) { 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 @@ -65,14 +65,12 @@ // CHECK-SAME: ( -254, 0, 256, -300, -30, -6 ), // CHECK-SAME: ( 1397, 0, -1408, 100, 10, 33 ) ) // - %m = bufferization.to_memref %0 : memref<5x6xi32> - %v = vector.transfer_read %m[%c0, %c0], %i0 - : memref<5x6xi32>, vector<5x6xi32> + %v = vector.transfer_read %0[%c0, %c0], %i0 + : tensor<5x6xi32>, vector<5x6xi32> vector.print %v : vector<5x6xi32> // Release the resources. sparse_tensor.release %sparse_input2 : tensor<3x6xi8, #DCSR> - memref.dealloc %m : memref<5x6xi32> 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 @@ -109,14 +109,14 @@ return %0 : tensor } - func.func @dump_i32(%arg0 : memref) { - %v = memref.load %arg0[] : memref + func.func @dump_i32(%arg0 : tensor) { + %v = tensor.extract %arg0[] : tensor vector.print %v : i32 return } - func.func @dump_f32(%arg0 : memref) { - %v = memref.load %arg0[] : memref + func.func @dump_f32(%arg0 : tensor) { + %v = tensor.extract %arg0[] : tensor vector.print %v : f32 return } @@ -185,33 +185,19 @@ // CHECK: 15 // CHECK: 10 // - %m0 = bufferization.to_memref %0 : memref - call @dump_i32(%m0) : (memref) -> () - %m1 = bufferization.to_memref %1 : memref - call @dump_f32(%m1) : (memref) -> () - %m2 = bufferization.to_memref %2 : memref - call @dump_i32(%m2) : (memref) -> () - %m3 = bufferization.to_memref %3 : memref - call @dump_f32(%m3) : (memref) -> () - %m4 = bufferization.to_memref %4 : memref - call @dump_i32(%m4) : (memref) -> () - %m5 = bufferization.to_memref %5 : memref - call @dump_i32(%m5) : (memref) -> () - %m6 = bufferization.to_memref %6 : memref - call @dump_i32(%m6) : (memref) -> () + call @dump_i32(%0) : (tensor) -> () + call @dump_f32(%1) : (tensor) -> () + call @dump_i32(%2) : (tensor) -> () + call @dump_f32(%3) : (tensor) -> () + call @dump_i32(%4) : (tensor) -> () + call @dump_i32(%5) : (tensor) -> () + 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> - memref.dealloc %m0 : memref - memref.dealloc %m1 : memref - memref.dealloc %m2 : memref - memref.dealloc %m3 : memref - memref.dealloc %m4 : memref - memref.dealloc %m5 : memref - memref.dealloc %m6 : memref return } 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 @@ -45,9 +45,9 @@ // A kernel that computes a sampled matrix matrix multiplication. // func.func @sampled_dense_dense(%args: tensor, - %arga: tensor, - %argb: tensor, - %argx: tensor {linalg.inplaceable = true}) -> tensor { + %arga: tensor, + %argb: tensor, + %argx: tensor) -> tensor { %0 = linalg.generic #trait_sampled_dense_dense ins(%args, %arga, %argb: tensor, tensor, tensor) outs(%argx: tensor) { 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 @@ -31,8 +31,7 @@ // // A kernel that scales a sparse matrix A by a factor of 2.0. // - func.func @sparse_scale(%argx: tensor<8x8xf32, #CSR> - {linalg.inplaceable = true}) -> tensor<8x8xf32, #CSR> { + func.func @sparse_scale(%argx: tensor<8x8xf32, #CSR>) -> tensor<8x8xf32, #CSR> { %c = arith.constant 2.0 : f32 %0 = linalg.generic #trait_scale outs(%argx: tensor<8x8xf32, #CSR>) { 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 @@ -41,8 +41,8 @@ // into a dense matrix X. // func.func @kernel_spmm(%arga: tensor, - %argb: tensor, - %argx: tensor {linalg.inplaceable = true}) -> tensor { + %argb: tensor, + %argx: tensor) -> tensor { %0 = linalg.generic #spmm ins(%arga, %argb: tensor, tensor) outs(%argx: tensor) { 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 @@ -39,7 +39,7 @@ // A kernel that sum-reduces a matrix to a single scalar. // func.func @kernel_sum_reduce(%arga: tensor, - %argx: tensor {linalg.inplaceable = true}) -> tensor { + %argx: tensor) -> tensor { %0 = linalg.generic #trait_sum_reduce ins(%arga: tensor) outs(%argx: tensor) { @@ -61,9 +61,7 @@ // Setup memory for a single reduction scalar, // initialized to zero. - %xdata = memref.alloc() : memref - memref.store %d0, %xdata[] : memref - %x = bufferization.to_tensor %xdata : memref + %x = tensor.from_elements %d0 : tensor // Read the sparse matrix from file, construct sparse storage. %fileName = call @getTensorFilename(%c0) : (index) -> (!Filename) @@ -77,12 +75,10 @@ // // CHECK: 30.2 // - %m = bufferization.to_memref %0 : memref - %v = memref.load %m[] : memref + %v = tensor.extract %0[] : tensor vector.print %v : f64 // Release the resources. - memref.dealloc %xdata : memref sparse_tensor.release %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 @@ -24,7 +24,7 @@ // A kernel that sum-reduces a matrix to a single scalar. // func.func @kernel_sum_reduce(%arga: tensor, - %argx: tensor {linalg.inplaceable = true}) -> tensor { + %argx: tensor) -> tensor { %0 = linalg.generic #trait_sum_reduce ins(%arga: tensor) outs(%argx: tensor) { 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 @@ -30,7 +30,7 @@ // A kernel that sum-reduces a matrix to a single scalar. // func.func @kernel_sum_reduce(%arga: tensor, #SparseMatrix>, - %argx: tensor> {linalg.inplaceable = true}) -> tensor> { + %argx: tensor>) -> tensor> { %0 = linalg.generic #trait_sum_reduce ins(%arga: tensor, #SparseMatrix>) outs(%argx: tensor>) { @@ -53,9 +53,9 @@ // Setup memory for a single reduction scalar, // initialized to zero. - %xdata = memref.alloc() : memref> - memref.store %d0, %xdata[] : memref> - %x = bufferization.to_tensor %xdata : memref> + // TODO: tensor.from_elements does not support complex. + %alloc = bufferization.alloc_tensor() : tensor> + %x = tensor.insert %d0 into %alloc[] : tensor> // Read the sparse matrix from file, construct sparse storage. %fileName = call @getTensorFilename(%c0) : (index) -> (!Filename) @@ -70,15 +70,13 @@ // CHECK: 30.2 // CHECK-NEXT: 22.2 // - %m = bufferization.to_memref %0 : memref> - %v = memref.load %m[] : memref> + %v = tensor.extract %0[] : tensor> %real = complex.re %v : complex %imag = complex.im %v : complex vector.print %real : f64 vector.print %imag : f64 // Release the resources. - memref.dealloc %xdata : memref> sparse_tensor.release %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 @@ -24,7 +24,7 @@ // A kernel that sum-reduces a matrix to a single scalar. // func.func @kernel_sum_reduce(%arga: tensor, - %argx: tensor {linalg.inplaceable = true}) -> tensor { + %argx: tensor) -> tensor { %0 = linalg.generic #trait_sum_reduce ins(%arga: tensor) outs(%argx: tensor) { 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 @@ -16,8 +16,7 @@ module { // Performs zero-preserving math to sparse vector. - func.func @sparse_tanh(%vec: tensor - {linalg.inplaceable = true}) + func.func @sparse_tanh(%vec: tensor) -> tensor { %0 = linalg.generic #trait_op outs(%vec: tensor) { @@ -40,10 +39,8 @@ // Dump the dense vector to verify structure is correct. %dv = sparse_tensor.convert %arg0 : tensor to tensor - %2 = bufferization.to_memref %dv : memref - %3 = vector.transfer_read %2[%c0], %d0: memref, vector<32xf64> + %3 = vector.transfer_read %dv[%c0], %d0: tensor, vector<32xf64> vector.print %3 : vector<32xf64> - memref.dealloc %2 : memref return } @@ -67,7 +64,7 @@ // CHECK: {{( -0.761[0-9]*, 0.761[0-9]*, 0.96[0-9]*, 0.99[0-9]*, 0.99[0-9]*, 0.99[0-9]*, 0.99[0-9]*, 0.99[0-9]*, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 )}} // CHECK-NEXT {{( -0.761[0-9]*, 0, 0, 0.761[0-9]*, 0, 0, 0, 0, 0, 0, 0, 0.96[0-9]*, 0, 0, 0, 0, 0, 0.99[0-9]*, 0, 0, 0.99[0-9]*, 0.99[0-9]*, 0, 0, 0, 0, 0, 0, 0.99[0-9]*, 0.99[0-9]*, 0, 1 )}} // - call @dump_vec_f64(%sv1) : (tensor) -> () + call @dump_vec_f64(%0) : (tensor) -> () // Release the resources. sparse_tensor.release %sv1 : tensor 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 @@ -100,24 +100,19 @@ // CHECK-NEXT: ( 1.4, 0, 3.4 ) // %x = sparse_tensor.convert %0 : tensor<4x3xf64, #DCSR> to tensor<4x3xf64> - %m = bufferization.to_memref %x : memref<4x3xf64> scf.for %i = %c0 to %c4 step %c1 { - %v1 = vector.transfer_read %m[%i, %c0], %du: memref<4x3xf64>, vector<3xf64> + %v1 = vector.transfer_read %x[%i, %c0], %du: tensor<4x3xf64>, vector<3xf64> vector.print %v1 : vector<3xf64> } %y = sparse_tensor.convert %1 : tensor<4x3xf64, #DCSR> to tensor<4x3xf64> - %n = bufferization.to_memref %y : memref<4x3xf64> scf.for %i = %c0 to %c4 step %c1 { - %v2 = vector.transfer_read %n[%i, %c0], %du: memref<4x3xf64>, vector<3xf64> + %v2 = vector.transfer_read %y[%i, %c0], %du: tensor<4x3xf64>, vector<3xf64> vector.print %v2 : vector<3xf64> } // Release resources. sparse_tensor.release %a : tensor<3x4xf64, #DCSR> sparse_tensor.release %0 : tensor<4x3xf64, #DCSR> - sparse_tensor.release %1 : tensor<4x3xf64, #DCSR> - memref.dealloc %m : memref<4x3xf64> - memref.dealloc %n : memref<4x3xf64> 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 @@ -166,10 +166,8 @@ vector.print %1 : vector<32xf64> // Dump the dense vector to verify structure is correct. %dv = sparse_tensor.convert %arg0 : tensor to tensor - %2 = bufferization.to_memref %dv : memref - %3 = vector.transfer_read %2[%c0], %d0: memref, vector<32xf64> + %3 = vector.transfer_read %dv[%c0], %d0: tensor, vector<32xf64> vector.print %3 : vector<32xf64> - memref.dealloc %2 : memref return } @@ -183,10 +181,8 @@ vector.print %1 : vector<24xi32> // Dump the dense vector to verify structure is correct. %dv = sparse_tensor.convert %arg0 : tensor to tensor - %2 = bufferization.to_memref %dv : memref - %3 = vector.transfer_read %2[%c0], %d0: memref, vector<32xi32> + %3 = vector.transfer_read %dv[%c0], %d0: tensor, vector<32xi32> vector.print %3 : vector<32xi32> - memref.dealloc %2 : memref return } @@ -198,10 +194,8 @@ %1 = vector.transfer_read %0[%c0], %d0: memref, vector<16xf64> vector.print %1 : vector<16xf64> %dm = sparse_tensor.convert %arg0 : tensor to tensor - %2 = bufferization.to_memref %dm : memref - %3 = vector.transfer_read %2[%c0, %c0], %d0: memref, vector<4x8xf64> + %3 = vector.transfer_read %dm[%c0, %c0], %d0: tensor, vector<4x8xf64> vector.print %3 : vector<4x8xf64> - memref.dealloc %2 : memref 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 @@ -62,8 +62,7 @@ } // Scales a sparse vector in place. - func.func @vector_scale_inplace(%argx: tensor - {linalg.inplaceable = true}) -> tensor { + func.func @vector_scale_inplace(%argx: tensor) -> tensor { %s = arith.constant 2.0 : f64 %0 = linalg.generic #trait_scale_inpl outs(%argx: tensor) { @@ -125,7 +124,7 @@ // Sum reduces dot product of two sparse vectors. func.func @vector_dotprod(%arga: tensor, %argb: tensor, - %argx: tensor {linalg.inplaceable = true}) -> tensor { + %argx: tensor) -> tensor { %0 = linalg.generic #trait_dot ins(%arga, %argb: tensor, tensor) outs(%argx: tensor) { @@ -147,10 +146,8 @@ vector.print %1 : vector<16xf64> // Dump the dense vector to verify structure is correct. %dv = sparse_tensor.convert %arg0 : tensor to tensor - %2 = bufferization.to_memref %dv : memref - %3 = vector.transfer_read %2[%c0], %d0: memref, vector<32xf64> - vector.print %3 : vector<32xf64> - memref.dealloc %2 : memref + %2 = vector.transfer_read %dv[%c0], %d0: tensor, vector<32xf64> + vector.print %2 : vector<32xf64> return } @@ -169,36 +166,36 @@ [11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0 ] > : tensor<32xf64> %sv1 = sparse_tensor.convert %v1 : tensor<32xf64> to tensor + // TODO: Use %sv1 when copying sparse tensors is supported. + %sv1_dup = sparse_tensor.convert %v1 : tensor<32xf64> to tensor %sv2 = sparse_tensor.convert %v2 : tensor<32xf64> to tensor // Setup memory for a single reduction scalar. - %xdata = memref.alloc() : memref - memref.store %d1, %xdata[] : memref - %x = bufferization.to_tensor %xdata : memref + %x = tensor.from_elements %d1 : tensor // Call sparse vector kernels. %0 = call @vector_scale(%sv1) : (tensor) -> tensor - %1 = call @vector_scale_inplace(%sv1) + %1 = call @vector_scale_inplace(%sv1_dup) : (tensor) -> tensor - %2 = call @vector_add(%sv1, %sv2) + %2 = call @vector_add(%1, %sv2) : (tensor, tensor) -> tensor - %3 = call @vector_mul(%sv1, %sv2) + %3 = call @vector_mul(%1, %sv2) : (tensor, tensor) -> tensor - %4 = call @vector_mul_d(%sv1, %sv2) + %4 = call @vector_mul_d(%1, %sv2) : (tensor, tensor) -> tensor - %5 = call @vector_dotprod(%sv1, %sv2, %x) + %5 = call @vector_dotprod(%1, %sv2, %x) : (tensor, tensor, tensor) -> tensor // // Verify the results. // - // CHECK: ( 2, 4, 6, 8, 10, 12, 14, 16, 18, -1, -1, -1, -1, -1, -1, -1 ) - // CHECK-NEXT: ( 2, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 8, 0, 0, 10, 12, 0, 0, 0, 0, 0, 0, 14, 16, 0, 18 ) + // CHECK: ( 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, -1 ) + // CHECK-NEXT: ( 1, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 4, 0, 0, 5, 6, 0, 0, 0, 0, 0, 0, 7, 8, 0, 9 ) // CHECK-NEXT: ( 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, -1, -1, -1, -1, -1, -1 ) // CHECK-NEXT: ( 0, 11, 0, 12, 13, 0, 0, 0, 0, 0, 14, 0, 0, 0, 0, 0, 15, 0, 16, 0, 0, 17, 0, 0, 0, 0, 0, 0, 18, 19, 0, 20 ) // CHECK-NEXT: ( 2, 4, 6, 8, 10, 12, 14, 16, 18, -1, -1, -1, -1, -1, -1, -1 ) @@ -212,6 +209,7 @@ // CHECK-NEXT: ( 0, 0, 0, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 204, 0, 0, 0, 0, 0, 0, 252, 304, 0, 360 ) // CHECK-NEXT: 1169.1 // + call @dump(%sv1) : (tensor) -> () call @dump(%sv2) : (tensor) -> () call @dump(%0) : (tensor) -> () @@ -227,12 +225,12 @@ // 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 - memref.dealloc %xdata : memref return } }