brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · 25f0c79 Raw
35 lines · plain
1// RUN: mlir-opt %s --sparsification-and-bufferization | FileCheck %s2 3#map = affine_map<(d0, d1, d2) -> (d0, d1, d2)>4 5#sparse = #sparse_tensor.encoding<{6    map = (d0, d1, d2) -> (d0 : dense, d1 : dense, d2 : compressed)7}>8 9//10// Make sure a simple ReLU passes the sparsifier11//12// CHECK-LABEL: func.func @relu13// CHECK:       scf.for14// CHECK:         scf.for15// CHECK:           scf.for16// CHECK:             arith.cmpf ugt17// CHECK:             arith.select18//19func.func @relu(%arg0: tensor<10x20x30xf64, #sparse>) -> tensor<10x20x30xf64, #sparse> {20  %cst = arith.constant 0.000000e+00 : f6421  %0 = tensor.empty() : tensor<10x20x30xf64>22  %1 = linalg.generic {23      indexing_maps = [#map, #map],24      iterator_types = ["parallel", "parallel", "parallel"]}25      ins(%arg0 : tensor<10x20x30xf64, #sparse>)26      outs(%0 : tensor<10x20x30xf64>) {27  ^bb0(%in: f64, %out: f64):28      %2 = arith.cmpf ugt, %in, %cst : f6429      %3 = arith.select %2, %in, %cst : f6430      linalg.yield %3 : f6431  } -> tensor<10x20x30xf64>32  %cast = tensor.cast %1 : tensor<10x20x30xf64> to tensor<10x20x30xf64, #sparse>33  return %cast : tensor<10x20x30xf64, #sparse>34}35