brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.4 KiB · 9d2a125 Raw
35 lines · plain
1// RUN: mlir-opt %s --sparse-reinterpret-map -sparsification -cse | FileCheck %s2 3#Dense = #sparse_tensor.encoding<{4  map = (d0, d1) -> (d0 : dense, d1 : dense)5}>6 7#trait_scale = {8  indexing_maps = [9    affine_map<(i,j) -> (i,j)>  // X (out)10  ],11  iterator_types = ["parallel", "parallel"],12  doc = "X(i,j) = X(i,j) * 2.0"13}14 15// CHECK-LABEL: func.func @sparse_scale(16// CHECK-SAME:    %[[VAL_0:.*]]: tensor<1x1xf32, #sparse{{[0-9]*}}>)17// CHECK-DAG:     %[[VAL_1:.*]] = arith.constant 0 : index18// CHECK-DAG:     %[[VAL_2:.*]] = arith.constant 2.000000e+00 : f3219// CHECK:         %[[VAL_3:.*]] = sparse_tensor.values %[[VAL_0]] : tensor<1x1xf32, #sparse{{[0-9]*}}> to memref<?xf32>20// CHECK:         %[[VAL_4:.*]] = memref.load %[[VAL_3]]{{\[}}%[[VAL_1]]] : memref<?xf32>21// CHECK:         %[[VAL_5:.*]] = arith.mulf %[[VAL_4]], %[[VAL_2]] : f3222// CHECK:         memref.store %[[VAL_5]], %[[VAL_3]]{{\[}}%[[VAL_1]]] : memref<?xf32>23// CHECK:         %[[VAL_6:.*]] = sparse_tensor.load %[[VAL_0]] : tensor<1x1xf32, #sparse{{[0-9]*}}>24// CHECK:         return %[[VAL_6]] : tensor<1x1xf32, #sparse{{[0-9]*}}>25func.func @sparse_scale(%argx: tensor<1x1xf32, #Dense>) -> tensor<1x1xf32, #Dense> {26  %c = arith.constant 2.0 : f3227  %0 = linalg.generic #trait_scale28    outs(%argx: tensor<1x1xf32, #Dense>) {29      ^bb(%x: f32):30        %1 = arith.mulf %x, %c : f3231        linalg.yield %1 : f3232  } -> tensor<1x1xf32, #Dense>33  return %0 : tensor<1x1xf32, #Dense>34}35