brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.5 KiB · e90ebf5 Raw
75 lines · plain
1// RUN: mlir-opt -int-range-optimizations --split-input-file %s | FileCheck %s2 3// CHECK-LABEL: @dim_const4// CHECK: %[[ret:.+]] = arith.constant 3 : index5// CHECK: return %[[ret]]6func.func @dim_const(%t: tensor<3x5xi32>) -> index {7  %c0 = arith.constant 0 : index8  %0 = tensor.dim %t, %c0 : tensor<3x5xi32>9  return %0 : index10}11 12// -----13 14// CHECK-LABEL: @dim_any_static15// CHECK: %[[op:.+]] = tensor.dim16// CHECK: %[[ret:.+]] = test.reflect_bounds {smax = 5 : index, smin = 3 : index, umax = 5 : index, umin = 3 : index} %[[op]]17// CHECK: return %[[ret]]18func.func @dim_any_static(%t: tensor<3x5xi32>, %x: index) -> index {19  %0 = tensor.dim %t, %x : tensor<3x5xi32>20  %1 = test.reflect_bounds %0 : index21  return %1 : index22}23 24// -----25 26// CHECK-LABEL: @dim_dynamic27// CHECK: %[[op:.+]] = tensor.dim28// CHECK: %[[ret:.+]] = test.reflect_bounds {smax = 9223372036854775807 : index, smin = 0 : index, umax = 9223372036854775807 : index, umin = 0 : index} %[[op]]29// CHECK: return %[[ret]]30func.func @dim_dynamic(%t: tensor<?x5xi32>) -> index {31  %c0 = arith.constant 0 : index32  %0 = tensor.dim %t, %c0 : tensor<?x5xi32>33  %1 = test.reflect_bounds %0 : index34  return %1 : index35}36 37// -----38 39// CHECK-LABEL: @dim_any_dynamic40// CHECK: %[[op:.+]] = tensor.dim41// CHECK: %[[ret:.+]] = test.reflect_bounds {smax = 9223372036854775807 : index, smin = 0 : index, umax = 9223372036854775807 : index, umin = 0 : index} %[[op]]42// CHECK: return %[[ret]]43func.func @dim_any_dynamic(%t: tensor<?x5xi32>, %x: index) -> index {44  %0 = tensor.dim %t, %x : tensor<?x5xi32>45  %1 = test.reflect_bounds %0 : index46  return %1 : index47}48 49// -----50 51// CHECK-LABEL: @dim_some_omitting_dynamic52// CHECK: %[[op:.+]] = tensor.dim53// CHECK: %[[ret:.+]] = test.reflect_bounds {smax = 5 : index, smin = 3 : index, umax = 5 : index, umin = 3 : index} %[[op]]54// CHECK: return %[[ret]]55func.func @dim_some_omitting_dynamic(%t: tensor<?x3x5xi32>, %x: index) -> index {56  %c1 = arith.constant 1 : index57  %0 = arith.maxsi %x, %c1 : index58  %1 = tensor.dim %t, %0 : tensor<?x3x5xi32>59  %2 = test.reflect_bounds %1 : index60  return %2 : index61}62 63// -----64 65// CHECK-LABEL: @dim_unranked66// CHECK: %[[op:.+]] = tensor.dim67// CHECK: %[[ret:.+]] = test.reflect_bounds {smax = 9223372036854775807 : index, smin = 0 : index, umax = 9223372036854775807 : index, umin = 0 : index} %[[op]]68// CHECK: return %[[ret]]69func.func @dim_unranked(%t: tensor<*xi32>) -> index {70  %c0 = arith.constant 0 : index71  %0 = tensor.dim %t, %c0 : tensor<*xi32>72  %1 = test.reflect_bounds %0 : index73  return %1 : index74}75