// RUN: mlir-opt %s -sparsification | \ // RUN: FileCheck %s --check-prefix=CHECK-SPARSE // RUN: mlir-opt %s -sparsification -sparse-tensor-conversion | \ // RUN: FileCheck %s --check-prefix=CHECK-CONVERT #DCSC = #sparse_tensor.encoding<{ dimLevelType = [ "compressed", "compressed" ], dimOrdering = affine_map<(i,j) -> (j,i)> }> #SV = #sparse_tensor.encoding<{ dimLevelType = [ "compressed" ] }> #rowsum = { indexing_maps = [ affine_map<(i,j) -> (i,j)>, // A affine_map<(i,j) -> (i)> // x (out) ], iterator_types = ["parallel", "reduction"], doc = "X(i) = SUM A(i,j)" } // // CHECK-SPARSE-LABEL: func @kernel( // CHECK-SPARSE: %[[A:.*]], %[[B:.*]], %[[C:.*]], %{{.*}} = sparse_tensor.expand // CHECK-SPARSE: scf.for // CHECK-SPARSE: scf.for // CHECK-SPARSE: sparse_tensor.compress %{{.*}}, %{{.*}}, %[[A]], %[[B]], %[[C]] // CHECK-SPARSE: %[[RET:.*]] = sparse_tensor.load %{{.*}} hasInserts // CHECK-SPARSE: return %[[RET]] // // CHECK-CONVERT-LABEL: func @kernel( // CHECK-CONVERT: %{{.*}} = call @sparseDimSize // CHECK-CONVERT: %[[S:.*]] = call @sparseDimSize // CHECK-CONVERT: %[[A:.*]] = memref.alloc(%[[S]]) : memref // CHECK-CONVERT: %[[B:.*]] = memref.alloc(%[[S]]) : memref // CHECK-CONVERT: %[[C:.*]] = memref.alloc(%[[S]]) : memref // CHECK-CONVERT: linalg.fill ins(%{{.*}} : f64) outs(%[[A]] : memref) // CHECK-CONVERT: linalg.fill ins(%{{.*}} : i1) outs(%[[B]] : memref) // CHECK-CONVERT: scf.for // CHECK-CONVERT: scf.for // CHECK-CONVERT: call @expInsertF64 // CHECK-CONVERT: memref.dealloc %[[A]] : memref // CHECK-CONVERT: memref.dealloc %[[B]] : memref // CHECK-CONVERT: memref.dealloc %[[C]] : memref // CHECK-CONVERT: call @endInsert // func.func @kernel(%arga: tensor) -> tensor { %c0 = arith.constant 0 : index %n = tensor.dim %arga, %c0 : tensor %v = sparse_tensor.init [%n] : tensor %0 = linalg.generic #rowsum ins(%arga: tensor) outs(%v: tensor) { ^bb(%a: f64, %x: f64): %1 = arith.addf %x, %a : f64 linalg.yield %1 : f64 } -> tensor return %0 : tensor }