File: value-bounds-op-interface-impl.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 (64 lines) | stat: -rw-r--r-- 2,243 bytes parent folder | download | duplicates (6)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// RUN: mlir-opt %s -test-affine-reify-value-bounds -verify-diagnostics \
// RUN:     -split-input-file | FileCheck %s

// CHECK-LABEL: func @linalg_fill(
//  CHECK-SAME:     %[[t:.*]]: tensor<?xf32>
//       CHECK:   %[[c0:.*]] = arith.constant 0 : index
//       CHECK:   %[[dim:.*]] = tensor.dim %[[t]], %[[c0]]
//       CHECK:   return %[[dim]]
func.func @linalg_fill(%t: tensor<?xf32>, %f: f32) -> index {
  %0 = linalg.fill ins(%f : f32) outs(%t : tensor<?xf32>) -> tensor<?xf32>
  %1 = "test.reify_bound"(%0) {dim = 0} : (tensor<?xf32>) -> (index)
  return %1 : index
}

// -----

#accesses = [
  affine_map<(i, j, k) -> (j, i)>,
  affine_map<(i, j, k) -> (i, k, i + j)>
]

#trait = {
  indexing_maps = #accesses,
  iterator_types = ["parallel", "parallel", "parallel"]
}

// CHECK-LABEL: func @linalg_index(
//  CHECK-SAME:     %[[arg0:.*]]: memref<?x?xf32>
func.func @linalg_index(%arg0: memref<?x?xf32>,
                        %arg1: memref<?x5x?xf32>) {
  linalg.generic #trait
                 ins(%arg0 : memref<?x?xf32>)
                 outs(%arg1 : memref<?x5x?xf32>)
  {
    ^bb(%a: f32, %b: f32):
      // CHECK: %[[c1:.*]] = arith.constant 1 : index
      // CHECK: %[[ub_0:.*]] = memref.dim %[[arg0]], %[[c1]]
      // CHECK: "test.some_use"(%[[ub_0]])
      %0 = linalg.index 0 : index
      %ub_0 = "test.reify_bound"(%0) {type = "UB"} : (index) -> (index)
      "test.some_use"(%ub_0) : (index) -> ()

      // CHECK: %[[c0:.*]] = arith.constant 0 : index
      // CHECK: "test.some_use"(%[[c0]])
      %lb_0 = "test.reify_bound"(%0) {type = "LB"} : (index) -> (index)
      "test.some_use"(%lb_0) : (index) -> ()

      // CHECK: %[[c0:.*]] = arith.constant 0 : index
      // CHECK: %[[ub_1:.*]] = memref.dim %[[arg0]], %[[c0]]
      // CHECK: "test.some_use"(%[[ub_1]])
      %1 = linalg.index 1 : index
      %ub_1 = "test.reify_bound"(%1) {type = "UB"} : (index) -> (index)
      "test.some_use"(%ub_1) : (index) -> ()

      // CHECK: %[[ub_2:.*]] = arith.constant 5 : index
      // CHECK: "test.some_use"(%[[ub_2]])
      %2 = linalg.index 2 : index
      %ub_2 = "test.reify_bound"(%2) {type = "UB"} : (index) -> (index)
      "test.some_use"(%ub_2) : (index) -> ()

      linalg.yield %b : f32
  }
  return
}