brintos

brintos / llvm-project-archived public Read only

0
0
Text · 7.5 KiB · a14483f Raw
163 lines · plain
1// RUN: mlir-opt -split-input-file -verify-diagnostics -tosa-narrow-i64-to-i32="convert-function-boundaries=0" %s | FileCheck %s --allow-unused-prefixes --check-prefixes=COMMON,DEFAULT2// RUN: mlir-opt -split-input-file -verify-diagnostics -tosa-narrow-i64-to-i32="convert-function-boundaries=1" %s | FileCheck %s --allow-unused-prefixes --check-prefixes=COMMON,FUNCBOUND3 4// -----5 6// CHECK-LABEL: test_i64_argmax7func.func @test_i64_argmax(%arg0: tensor<1x513x513x19xi8>) -> tensor<1x513x513xi64> {8  // COMMON: %[[ARGMAX:.*]] = tosa.argmax %arg0 {axis = 3 : i32} : (tensor<1x513x513x19xi8>) -> tensor<1x513x513xi32>9  %0 = tosa.argmax %arg0 {axis = 3 : i32} : (tensor<1x513x513x19xi8>) -> tensor<1x513x513xi64>10 11  // DEFAULT: %[[CAST:.*]] = tosa.cast %[[ARGMAX]] : (tensor<1x513x513xi32>) -> tensor<1x513x513xi64>12  // FUNCBOUND: return %[[ARGMAX]] : tensor<1x513x513xi32>13  return %0 : tensor<1x513x513xi64>14}15 16// -----17 18// CHECK-LABEL: test_i64_argmax_cast19func.func @test_i64_argmax_cast(%arg0: tensor<1x513x513x19xi8>) -> tensor<1x513x513xf32> {20  // COMMON: %[[ARGMAX:.*]] = tosa.argmax %arg0 {axis = 3 : i32} : (tensor<1x513x513x19xi8>) -> tensor<1x513x513xi32>21  %0 = tosa.argmax %arg0 {axis = 3 : i32} : (tensor<1x513x513x19xi8>) -> tensor<1x513x513xi64>22  // COMMON: tosa.cast %[[ARGMAX]] : (tensor<1x513x513xi32>) -> tensor<1x513x513xf32>23  %1 = tosa.cast %0 : (tensor<1x513x513xi64>) -> tensor<1x513x513xf32>24  return %1 : tensor<1x513x513xf32>25}26 27// -----28 29// CHECK-LABEL: test_i64_argmax_large_axis_dim30func.func @test_i64_argmax_large_axis_dim(%arg0: tensor<1x513x513x2147483650xi8>) -> tensor<1x513x513xi64> {31  // expected-error @+1 {{failed to legalize operation 'tosa.argmax'}}32  %0 = tosa.argmax %arg0 {axis = 3 : i32} : (tensor<1x513x513x2147483650xi8>) -> tensor<1x513x513xi64>33  return %0 : tensor<1x513x513xi64>34}35 36// -----37 38// CHECK-LABEL: test_add39func.func @test_add(%arg0: tensor<13x21x1xi64>, %arg1: tensor<13x21x3xi64>) -> tensor<13x21x3xi64> {40  // expected-error @+1 {{failed to legalize operation 'tosa.add'}}41  %0 = tosa.add %arg0, %arg1 : (tensor<13x21x1xi64>, tensor<13x21x3xi64>) -> tensor<13x21x3xi64>42  return %0 : tensor<13x21x3xi64>43}44 45// -----46 47// CHECK-LABEL: test_regions48func.func @test_regions(%arg0: tensor<1x2xi32>, %arg1: tensor<1xi32>, %arg2: tensor<i1>) -> tensor<1xi32> {49  // COMMON: %[[IF_RESULT:.*]] = tosa.cond_if %arg2 : tensor<i1> -> tensor<1xi32>50  %0 = tosa.cond_if %arg2 : tensor<i1> -> tensor<1xi32> {51    // COMMON: %[[ARGMAX:.*]] = tosa.argmax %arg0 {axis = 1 : i32} : (tensor<1x2xi32>) -> tensor<1xi32>52    %1 = tosa.argmax %arg0 {axis = 1 : i32} : (tensor<1x2xi32>) -> tensor<1xi64>53    // COMMON: %[[CAST:.*]] = tosa.cast %[[ARGMAX]] : (tensor<1xi32>) -> tensor<1xi32>54    %2 = tosa.cast %1 : (tensor<1xi64>) -> tensor<1xi32>55    // COMMON: tosa.yield %[[CAST]] : tensor<1xi32>56    tosa.yield %2 : tensor<1xi32>57  } else {58    tosa.yield %arg1 : tensor<1xi32>59  }60  // COMMON: return %[[IF_RESULT]] : tensor<1xi32>61  return %0 : tensor<1xi32>62}63 64// -----65 66// CHECK-LABEL: test_concat67func.func @test_concat(%arg0: tensor<13x21x3xi64>, %arg1: tensor<13x21x3xi64>) -> tensor<26x21x3xi64> {68  // COMMON: tosa.concat %{{.*}}, %{{.*}} {axis = 0 : i32} : (tensor<13x21x3xi32>, tensor<13x21x3xi32>) -> tensor<26x21x3xi32>69  %0 = tosa.concat %arg0, %arg1 {axis = 0 : i32} : (tensor<13x21x3xi64>, tensor<13x21x3xi64>) -> tensor<26x21x3xi64>70  return %0 : tensor<26x21x3xi64>71}72 73// -----74 75// CHECK-LABEL: test_pad76func.func @test_pad(%arg0: tensor<13x21x3xi64>, %arg1: tensor<1xi64>) -> tensor<15x23x5xi64> {77  %padding = tosa.const_shape {values = dense<1> : tensor<6xindex>} : () -> !tosa.shape<6>78  // COMMON: tosa.pad %{{.*}}, %{{.*}}, %{{.*}} : (tensor<13x21x3xi32>, !tosa.shape<6>, tensor<1xi32>) -> tensor<15x23x5xi32>79  %1 = tosa.pad %arg0, %padding, %arg1 : (tensor<13x21x3xi64>, !tosa.shape<6>, tensor<1xi64>) -> tensor<15x23x5xi64>80  return %1 : tensor<15x23x5xi64>81}82 83// -----84 85// CHECK-LABEL: test_reshape86func.func @test_reshape(%arg0: tensor<13x21x3xi64>) -> tensor<1x819xi64> {87  %1 = tosa.const_shape {values = dense<[1, 819]> : tensor<2xindex>} : () -> !tosa.shape<2>88  // COMMON: tosa.reshape %{{.*}}, %{{.*}} : (tensor<13x21x3xi32>, !tosa.shape<2>) -> tensor<1x819xi32>89  %0 = tosa.reshape %arg0, %1 : (tensor<13x21x3xi64>, !tosa.shape<2>) -> tensor<1x819xi64>90  return %0 : tensor<1x819xi64>91}92 93// -----94 95// CHECK-LABEL: test_reverse96func.func @test_reverse(%arg0: tensor<13x21x3xi64>) -> tensor<13x21x3xi64> {97  // COMMON: tosa.reverse %{{.*}} {axis = 0 : i32} : (tensor<13x21x3xi32>) -> tensor<13x21x3xi32>98  %0 = tosa.reverse %arg0 {axis = 0 : i32} : (tensor<13x21x3xi64>) -> tensor<13x21x3xi64>99  return %0 : tensor<13x21x3xi64>100}101 102// -----103 104// CHECK-LABEL: test_slice105func.func @test_slice(%arg0: tensor<13x21x3xi64>) -> tensor<4x11x1xi64> {106  %0 = tosa.const_shape {values = dense<[4, 11, 1]> : tensor<3xindex>} : () -> !tosa.shape<3>107  %1 = tosa.const_shape {values = dense<[6, 8, 0]> : tensor<3xindex>} : () -> !tosa.shape<3>108  // COMMON: tosa.slice %{{.*}}, %{{.*}}, %{{.*}} : (tensor<13x21x3xi32>, !tosa.shape<3>, !tosa.shape<3>) -> tensor<4x11x1xi32>109  %2 = tosa.slice %arg0, %0, %1 : (tensor<13x21x3xi64>, !tosa.shape<3>, !tosa.shape<3>) -> tensor<4x11x1xi64>110  return %2 : tensor<4x11x1xi64>111}112 113// -----114 115// CHECK-LABEL: test_tile116func.func @test_tile(%arg0: tensor<13x21x3xi64>) -> tensor<39x21x6xi64> {117  %cst = tosa.const_shape { values = dense<[3, 1, 2]> : tensor<3xindex> } : () -> !tosa.shape<3>118  // COMMON: tosa.tile %{{.*}}, %{{.*}} : (tensor<13x21x3xi32>, !tosa.shape<3>) -> tensor<39x21x6xi32>119  %0 = tosa.tile %arg0, %cst: (tensor<13x21x3xi64>, !tosa.shape<3>) -> tensor<39x21x6xi64>120  return %0 : tensor<39x21x6xi64>121}122 123// -----124 125// CHECK-LABEL: transpose126func.func @test_transpose(%arg0: tensor<13x21x3xi64>) -> tensor<3x13x21xi64> {127  // COMMON: tosa.transpose %{{.*}} {perms = array<i32: 2, 0, 1>} : (tensor<13x21x3xi32>) -> tensor<3x13x21xi32>128  %1 = tosa.transpose %arg0 {perms = array<i32: 2, 0, 1>} : (tensor<13x21x3xi64>) -> tensor<3x13x21xi64>129  return %1 : tensor<3x13x21xi64>130}131 132// -----133 134// CHECK-LABEL: test_transition_to_i64135func.func @test_transition_to_i64(%arg0: tensor<1xi32>) -> tensor<1xi64> {136  // COMMON: %[[CAST:.*]] = tosa.cast %arg0 : (tensor<1xi32>) -> tensor<1xi32>137  %0 = tosa.cast %arg0 : (tensor<1xi32>) -> tensor<1xi64>138  // COMMON: %[[IDENTITY1:.*]] = tosa.identity %[[CAST]] : (tensor<1xi32>) -> tensor<1xi32>139  %1 = tosa.identity %0 : (tensor<1xi64>) -> tensor<1xi64>140  // COMMON: %[[IDENTITY2:.*]] = tosa.identity %[[IDENTITY1]] : (tensor<1xi32>) -> tensor<1xi32>141  %2 = tosa.identity %1 : (tensor<1xi64>) -> tensor<1xi64>142  // DEFAULT: %[[OUT_CAST:.*]] = tosa.cast %[[IDENTITY2]] : (tensor<1xi32>) -> tensor<1xi64>143  // DEFAULT: return %[[OUT_CAST]] : tensor<1xi64>144  // FUNCBOUND: return %[[IDENTITY2]] : tensor<1xi32>145  return %2 : tensor<1xi64>146}147 148// -----149 150// CHECK-LABEL: test_transition_from_i64151func.func @test_transition_from_i64(%arg0: tensor<1xi64>) -> tensor<1xi32> {152  // DEFAULT: %[[CAST:.*]] = tosa.cast %arg0 : (tensor<1xi64>) -> tensor<1xi32>153  // DEFAULT: %[[IDENTITY1:.*]] = tosa.identity %[[CAST]] : (tensor<1xi32>) -> tensor<1xi32>154  // FUNCBOUND: %[[IDENTITY1:.*]] = tosa.identity %arg0 : (tensor<1xi32>) -> tensor<1xi32>155  %0 = tosa.identity %arg0 : (tensor<1xi64>) -> tensor<1xi64>156  // COMMON: %[[IDENTITY2:.*]] = tosa.identity %[[IDENTITY1]] : (tensor<1xi32>) -> tensor<1xi32>157  %1 = tosa.identity %0 : (tensor<1xi64>) -> tensor<1xi64>158  // COMMON: %[[OUT_CAST:.*]] = tosa.cast %[[IDENTITY2]] : (tensor<1xi32>) -> tensor<1xi32>159  %2 = tosa.cast %1 : (tensor<1xi64>) -> tensor<1xi32>160  // COMMON: return %[[OUT_CAST]] : tensor<1xi32>161  return %2 : tensor<1xi32>162}163