// NOTE: Assertions have been autogenerated by utils/generate-test-checks.py // RUN: mlir-opt %s -sparsification | FileCheck %s #DenseMatrix = #sparse_tensor.encoding<{ dimLevelType = ["dense", "dense"] }> #SparseMatrix = #sparse_tensor.encoding<{ dimLevelType = ["compressed", "compressed"] }> #trait = { indexing_maps = [ affine_map<(i,j) -> (i,j)>, // A affine_map<(i,j) -> (i,j)> // X (out) ], iterator_types = ["parallel", "parallel"], doc = "X(i,j) = A(i,j) * i * j" } // CHECK-LABEL: func @dense_index( // CHECK-SAME: %[[VAL_0:.*]]: tensor // CHECK: %[[VAL_19:.*]] = arith.muli %[[VAL_17]], %[[VAL_18]] : i64 // CHECK: %[[VAL_20:.*]] = arith.muli %[[VAL_16]], %[[VAL_19]] : i64 // CHECK: memref.store %[[VAL_20]], %[[VAL_9]]{{\[}}%[[VAL_15]]] : memref // CHECK: } // CHECK: } // CHECK: %[[VAL_21:.*]] = sparse_tensor.load %[[VAL_5]] : tensor) -> tensor { %c0 = arith.constant 0 : index %c1 = arith.constant 0 : index %0 = tensor.dim %arga, %c0 : tensor %1 = tensor.dim %arga, %c1 : tensor %init = bufferization.alloc_tensor(%0, %1) : tensor %r = linalg.generic #trait ins(%arga: tensor) outs(%init: tensor) { ^bb(%a: i64, %x: i64): %i = linalg.index 0 : index %j = linalg.index 1 : index %ii = arith.index_cast %i : index to i64 %jj = arith.index_cast %j : index to i64 %m1 = arith.muli %ii, %a : i64 %m2 = arith.muli %jj, %m1 : i64 linalg.yield %m2 : i64 } -> tensor return %r : tensor } // CHECK-LABEL: func @sparse_index( // CHECK-SAME: %[[VAL_0:.*]]: tensor // CHECK: %[[BUF:.*]] = memref.alloca() : memref // CHECK: %[[VAL_13:.*]] = memref.load %[[VAL_7]]{{\[}}%[[VAL_1]]] : memref // CHECK: %[[VAL_14:.*]] = memref.load %[[VAL_7]]{{\[}}%[[VAL_2]]] : memref // CHECK: scf.for %[[VAL_15:.*]] = %[[VAL_13]] to %[[VAL_14]] step %[[VAL_2]] { // CHECK: %[[VAL_16:.*]] = memref.load %[[VAL_8]]{{\[}}%[[VAL_15]]] : memref // CHECK: memref.store %[[VAL_16]], %[[VAL_12]]{{\[}}%[[VAL_1]]] : memref // CHECK: %[[VAL_17:.*]] = memref.load %[[VAL_9]]{{\[}}%[[VAL_15]]] : memref // CHECK: %[[VAL_18:.*]] = arith.addi %[[VAL_15]], %[[VAL_2]] : index // CHECK: %[[VAL_19:.*]] = memref.load %[[VAL_9]]{{\[}}%[[VAL_18]]] : memref // CHECK: scf.for %[[VAL_20:.*]] = %[[VAL_17]] to %[[VAL_19]] step %[[VAL_2]] { // CHECK: %[[VAL_21:.*]] = memref.load %[[VAL_10]]{{\[}}%[[VAL_20]]] : memref // CHECK: memref.store %[[VAL_21]], %[[VAL_12]]{{\[}}%[[VAL_2]]] : memref // CHECK: %[[VAL_22:.*]] = arith.index_cast %[[VAL_21]] : index to i64 // CHECK: %[[VAL_23:.*]] = arith.index_cast %[[VAL_16]] : index to i64 // CHECK: %[[VAL_24:.*]] = memref.load %[[VAL_11]]{{\[}}%[[VAL_20]]] : memref // CHECK: %[[VAL_25:.*]] = arith.muli %[[VAL_23]], %[[VAL_24]] : i64 // CHECK: %[[VAL_26:.*]] = arith.muli %[[VAL_22]], %[[VAL_25]] : i64 // CHECK: memref.store %[[VAL_26]], %[[BUF]][] : memref // CHECK: sparse_tensor.lex_insert %[[VAL_6]], %[[VAL_12]], %[[BUF]] : tensor) -> tensor { %c0 = arith.constant 0 : index %c1 = arith.constant 0 : index %0 = tensor.dim %arga, %c0 : tensor %1 = tensor.dim %arga, %c1 : tensor %init = bufferization.alloc_tensor(%0, %1) : tensor %r = linalg.generic #trait ins(%arga: tensor) outs(%init: tensor) { ^bb(%a: i64, %x: i64): %i = linalg.index 0 : index %j = linalg.index 1 : index %ii = arith.index_cast %i : index to i64 %jj = arith.index_cast %j : index to i64 %m1 = arith.muli %ii, %a : i64 %m2 = arith.muli %jj, %m1 : i64 linalg.yield %m2 : i64 } -> tensor return %r : tensor }