65 lines · plain
1// RUN: mlir-opt %s -pass-pipeline='builtin.module(func.func(test-affine-reify-value-bounds))' -verify-diagnostics \2// RUN: -split-input-file | FileCheck %s3 4// CHECK-LABEL: func @linalg_fill(5// CHECK-SAME: %[[t:.*]]: tensor<?xf32>6// CHECK: %[[c0:.*]] = arith.constant 0 : index7// CHECK: %[[dim:.*]] = tensor.dim %[[t]], %[[c0]]8// CHECK: return %[[dim]]9func.func @linalg_fill(%t: tensor<?xf32>, %f: f32) -> index {10 %0 = linalg.fill ins(%f : f32) outs(%t : tensor<?xf32>) -> tensor<?xf32>11 %1 = "test.reify_bound"(%0) {dim = 0} : (tensor<?xf32>) -> (index)12 return %1 : index13}14 15// -----16 17#accesses = [18 affine_map<(i, j, k) -> (j, i)>,19 affine_map<(i, j, k) -> (i, k, i + j)>20]21 22#trait = {23 indexing_maps = #accesses,24 iterator_types = ["parallel", "parallel", "parallel"]25}26 27// CHECK-LABEL: func @linalg_index(28// CHECK-SAME: %[[arg0:.*]]: memref<?x?xf32>29func.func @linalg_index(%arg0: memref<?x?xf32>,30 %arg1: memref<?x5x?xf32>) {31 linalg.generic #trait32 ins(%arg0 : memref<?x?xf32>)33 outs(%arg1 : memref<?x5x?xf32>)34 {35 ^bb(%a: f32, %b: f32):36 // CHECK: %[[c1:.*]] = arith.constant 1 : index37 // CHECK: %[[ub_0:.*]] = memref.dim %[[arg0]], %[[c1]]38 // CHECK: "test.some_use"(%[[ub_0]])39 %0 = linalg.index 0 : index40 %ub_0 = "test.reify_bound"(%0) {type = "UB"} : (index) -> (index)41 "test.some_use"(%ub_0) : (index) -> ()42 43 // CHECK: %[[c0:.*]] = arith.constant 0 : index44 // CHECK: "test.some_use"(%[[c0]])45 %lb_0 = "test.reify_bound"(%0) {type = "LB"} : (index) -> (index)46 "test.some_use"(%lb_0) : (index) -> ()47 48 // CHECK: %[[c0:.*]] = arith.constant 0 : index49 // CHECK: %[[ub_1:.*]] = memref.dim %[[arg0]], %[[c0]]50 // CHECK: "test.some_use"(%[[ub_1]])51 %1 = linalg.index 1 : index52 %ub_1 = "test.reify_bound"(%1) {type = "UB"} : (index) -> (index)53 "test.some_use"(%ub_1) : (index) -> ()54 55 // CHECK: %[[ub_2:.*]] = arith.constant 5 : index56 // CHECK: "test.some_use"(%[[ub_2]])57 %2 = linalg.index 2 : index58 %ub_2 = "test.reify_bound"(%2) {type = "UB"} : (index) -> (index)59 "test.some_use"(%ub_2) : (index) -> ()60 61 linalg.yield %b : f3262 }63 return64}65