File: codegen_sparse_alloc.mlir

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (44 lines) | stat: -rw-r--r-- 3,092 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// RUN: mlir-opt %s --sparse-tensor-codegen --canonicalize --cse | FileCheck %s

#CSR = #sparse_tensor.encoding<{ lvlTypes = ["dense", "compressed"]}>
#COO = #sparse_tensor.encoding<{ lvlTypes = ["compressed-nu", "singleton"]}>

// CHECK-LABEL:   func.func @sparse_alloc_copy_CSR(
// CHECK-SAME:      %[[VAL_0:.*0]]: memref<?xindex>,
// CHECK-SAME:      %[[VAL_1:.*1]]: memref<?xindex>,
// CHECK-SAME:      %[[VAL_2:.*2]]: memref<?xf32>,
// CHECK-SAME:      %[[VAL_3:.*]]: !sparse_tensor.storage_specifier<#{{.*}}>) -> (memref<?xindex>, memref<?xindex>, memref<?xf32>, !sparse_tensor.storage_specifier<#{{.*}}>) {
// CHECK:           %[[VAL_4:.*]] = arith.constant 0 : index
// CHECK:           %[[VAL_5:.*]] = memref.dim %[[VAL_0]], %[[VAL_4]] : memref<?xindex>
// CHECK:           %[[VAL_6:.*]] = memref.alloc(%[[VAL_5]]) : memref<?xindex>
// CHECK:           memref.copy %[[VAL_0]], %[[VAL_6]] : memref<?xindex> to memref<?xindex>
// CHECK:           %[[VAL_7:.*]] = memref.dim %[[VAL_1]], %[[VAL_4]] : memref<?xindex>
// CHECK:           %[[VAL_8:.*]] = memref.alloc(%[[VAL_7]]) : memref<?xindex>
// CHECK:           memref.copy %[[VAL_1]], %[[VAL_8]] : memref<?xindex> to memref<?xindex>
// CHECK:           %[[VAL_9:.*]] = memref.dim %[[VAL_2]], %[[VAL_4]] : memref<?xf32>
// CHECK:           %[[VAL_10:.*]] = memref.alloc(%[[VAL_9]]) : memref<?xf32>
// CHECK:           memref.copy %[[VAL_2]], %[[VAL_10]] : memref<?xf32> to memref<?xf32>
func.func @sparse_alloc_copy_CSR(%arg0: tensor<2x2xf32, #CSR>) -> tensor<2x2xf32, #CSR> {
  %0 = bufferization.alloc_tensor() copy(%arg0) : tensor<2x2xf32, #CSR>
  "test.sink"(%0) : (tensor<2x2xf32, #CSR>) -> ()
}

// CHECK-LABEL:   func.func @sparse_alloc_copy_COO(
// CHECK-SAME:      %[[VAL_0:.*0]]: memref<?xindex>,
// CHECK-SAME:      %[[VAL_1:.*1]]: memref<?xindex>,
// CHECK-SAME:      %[[VAL_2:.*2]]: memref<?xf32>,
// CHECK-SAME:      %[[VAL_3:.*]]: !sparse_tensor.storage_specifier<#{{.*}}>) -> (memref<?xindex>, memref<?xindex>, memref<?xf32>, !sparse_tensor.storage_specifier<#{{.*}}>) {
// CHECK:           %[[VAL_4:.*]] = arith.constant 0 : index
// CHECK:           %[[VAL_5:.*]] = memref.dim %[[VAL_0]], %[[VAL_4]] : memref<?xindex>
// CHECK:           %[[VAL_6:.*]] = memref.alloc(%[[VAL_5]]) : memref<?xindex>
// CHECK:           memref.copy %[[VAL_0]], %[[VAL_6]] : memref<?xindex> to memref<?xindex>
// CHECK:           %[[VAL_7:.*]] = memref.dim %[[VAL_1]], %[[VAL_4]] : memref<?xindex>
// CHECK:           %[[VAL_8:.*]] = memref.alloc(%[[VAL_7]]) : memref<?xindex>
// CHECK:           memref.copy %[[VAL_1]], %[[VAL_8]] : memref<?xindex> to memref<?xindex>
// CHECK:           %[[VAL_9:.*]] = memref.dim %[[VAL_2]], %[[VAL_4]] : memref<?xf32>
// CHECK:           %[[VAL_10:.*]] = memref.alloc(%[[VAL_9]]) : memref<?xf32>
// CHECK:           memref.copy %[[VAL_2]], %[[VAL_10]] : memref<?xf32> to memref<?xf32>
func.func @sparse_alloc_copy_COO(%arg0: tensor<2x2xf32, #COO>) -> tensor<2x2xf32, #COO> {
  %0 = bufferization.alloc_tensor() copy(%arg0) : tensor<2x2xf32, #COO>
  "test.sink"(%0) : (tensor<2x2xf32, #COO>) -> ()
}