1// RUN: mlir-opt %s --sparse-assembler="direct-out=True" -split-input-file | FileCheck %s 2 3// ----- 4 5// CHECK-LABEL: func.func @sparse_in( 6// CHECK-SAME: %[[B:.*0]]: tensor<?xindex>, 7// CHECK-SAME: %[[C:.*1]]: tensor<?xindex>, 8// CHECK-SAME: %[[A:.*]]: tensor<?xf32>) -> tensor<64x64xf32> { 9// CHECK: %[[I:.*]] = sparse_tensor.assemble (%[[B]], %[[C]]), %[[A]] 10// CHECK: %[[F:.*]] = call @_internal_sparse_in(%[[I]]) 11// CHECK: return %[[F]] : tensor<64x64xf32> 12// CHECK: } 13// CHECK: func.func private @_internal_sparse_in 14#sparse = #sparse_tensor.encoding<{ map = (d0, d1) -> (d0 : dense, d1 : compressed) }> 15func.func @sparse_in(%arg0: tensor<64x64xf32, #sparse>) -> tensor<64x64xf32> { 16 %0 = sparse_tensor.convert %arg0 : tensor<64x64xf32, #sparse> to tensor<64x64xf32> 17 return %0 : tensor<64x64xf32> 18} 19 20// ----- 21 22// CHECK-LABEL: func.func @sparse_out( 23// CHECK-SAME: %[[X:.*0]]: tensor<64x64xf32>) 24// CHECK: %[[F:.*]] = call @_internal_sparse_out(%[[X]]) 25// CHECK: %[[P:.*]] = sparse_tensor.positions %[[F]] 26// CHECK: %[[C:.*]] = sparse_tensor.coordinates %[[F]] 27// CHECK: %[[V:.*]] = sparse_tensor.values %[[F]] 28// CHECK: return %[[P]], %[[C]], %[[V]] 29// CHECK: } 30// CHECK: func.func private @_internal_sparse_out 31#sparse = #sparse_tensor.encoding<{ map = (d0, d1) -> (d0 : dense, d1 : compressed) }> 32func.func @sparse_out(%arg0: tensor<64x64xf32>) -> tensor<64x64xf32, #sparse> { 33 %0 = sparse_tensor.convert %arg0 : tensor<64x64xf32> to tensor<64x64xf32, #sparse> 34 return %0 : tensor<64x64xf32, #sparse> 35} 36 37// ----- 38 39// CHECK-LABEL: func.func @sparse_out2( 40// CHECK-SAME: %[[X:.*0]]: tensor<64x64xf32>) 41// CHECK: %[[F:.*]]:2 = call @_internal_sparse_out2(%[[X]]) 42// CHECK: %[[P:.*]] = sparse_tensor.positions %[[F]]#1 43// CHECK: %[[C:.*]] = sparse_tensor.coordinates %[[F]]#1 44// CHECK: %[[V:.*]] = sparse_tensor.values %[[F]]#1 45// CHECK: return %[[F]]#0, %[[P]], %[[C]], %[[V]] 46// CHECK: } 47// CHECK: func.func private @_internal_sparse_out2 48#sparse = #sparse_tensor.encoding<{ map = (d0, d1) -> (d0 : dense, d1 : compressed) }> 49func.func @sparse_out2(%arg0: tensor<64x64xf32>) -> (tensor<64x64xf32>, tensor<64x64xf32, #sparse>) { 50 %0 = sparse_tensor.convert %arg0 : tensor<64x64xf32> to tensor<64x64xf32, #sparse> 51 return %arg0, %0 : tensor<64x64xf32>, tensor<64x64xf32, #sparse> 52} 53