|
1 |
| -// RUN: mlir-opt %s -split-input-file -test-vector-linearize | FileCheck %s --check-prefixes=ALL,DEFAULT |
2 |
| -// RUN: mlir-opt %s -split-input-file -test-vector-linearize=target-vector-bitwidth=128 | FileCheck %s --check-prefixes=ALL,BW-128 |
| 1 | +// RUN: mlir-opt %s -split-input-file -test-vector-linearize -verify-diagnostics | FileCheck %s --check-prefixes=ALL,DEFAULT |
| 2 | +// RUN: mlir-opt %s -split-input-file -test-vector-linearize=target-vector-bitwidth=128 -verify-diagnostics | FileCheck %s --check-prefixes=ALL,BW-128 |
3 | 3 | // RUN: mlir-opt %s -split-input-file -test-vector-linearize=target-vector-bitwidth=0 | FileCheck %s --check-prefixes=ALL,BW-0
|
4 | 4 |
|
5 | 5 | // ALL-LABEL: test_linearize
|
@@ -97,3 +97,60 @@ func.func @test_tensor_no_linearize(%arg0: tensor<2x2xf32>, %arg1: tensor<2x2xf3
|
97 | 97 |
|
98 | 98 | return %0, %arg0 : tensor<2x2xf32>, tensor<2x2xf32>
|
99 | 99 | }
|
| 100 | + |
| 101 | +// ----- |
| 102 | + |
| 103 | +// ALL-LABEL: func.func @test_scalable_linearize( |
| 104 | +// ALL-SAME: %[[ARG_0:.*]]: vector<2x[2]xf32>) -> vector<2x[2]xf32> { |
| 105 | +func.func @test_scalable_linearize(%arg0: vector<2x[2]xf32>) -> vector<2x[2]xf32> { |
| 106 | + // DEFAULT: %[[SC:.*]] = vector.shape_cast %[[ARG_0]] : vector<2x[2]xf32> to vector<[4]xf32> |
| 107 | + // DEFAULT: %[[CST:.*]] = arith.constant dense<3.000000e+00> : vector<[4]xf32> |
| 108 | + // BW-128: %[[SC:.*]] = vector.shape_cast %[[ARG_0]] : vector<2x[2]xf32> to vector<[4]xf32> |
| 109 | + // BW-128: %[[CST:.*]] = arith.constant dense<3.000000e+00> : vector<[4]xf32> |
| 110 | + // BW-0: %[[CST:.*]] = arith.constant dense<3.000000e+00> : vector<2x[2]xf32> |
| 111 | + %0 = arith.constant dense<[[3., 3.], [3., 3.]]> : vector<2x[2]xf32> |
| 112 | + |
| 113 | + // DEFAULT: %[[SIN:.*]] = math.sin %[[SC]] : vector<[4]xf32> |
| 114 | + // BW-128: %[[SIN:.*]] = math.sin %[[SC]] : vector<[4]xf32> |
| 115 | + // BW-0: %[[SIN:.*]] = math.sin %[[ARG_0]] : vector<2x[2]xf32> |
| 116 | + %1 = math.sin %arg0 : vector<2x[2]xf32> |
| 117 | + |
| 118 | + // DEFAULT: %[[ADDF:.*]] = arith.addf %[[SIN]], %[[CST]] : vector<[4]xf32> |
| 119 | + // BW-128: %[[ADDF:.*]] = arith.addf %[[SIN]], %[[CST]] : vector<[4]xf32> |
| 120 | + // BW-0: %[[RES:.*]] = arith.addf %[[CST]], %[[SIN]] : vector<2x[2]xf32> |
| 121 | + %2 = arith.addf %0, %1 : vector<2x[2]xf32> |
| 122 | + |
| 123 | + // DEFAULT: %[[RES:.*]] = vector.shape_cast %[[ADDF]] : vector<[4]xf32> to vector<2x[2]xf32> |
| 124 | + // BW-128: %[[RES:.*]] = vector.shape_cast %[[ADDF]] : vector<[4]xf32> to vector<2x[2]xf32> |
| 125 | + // ALL: return %[[RES]] : vector<2x[2]xf32> |
| 126 | + return %2 : vector<2x[2]xf32> |
| 127 | +} |
| 128 | + |
| 129 | +// ----- |
| 130 | + |
| 131 | +// ALL-LABEL: func.func @test_scalable_no_linearize( |
| 132 | +// ALL-SAME: %[[VAL_0:.*]]: vector<[2]x[2]xf32>) -> vector<[2]x[2]xf32> { |
| 133 | +func.func @test_scalable_no_linearize(%arg0: vector<[2]x[2]xf32>) -> vector<[2]x[2]xf32> { |
| 134 | + // ALL: %[[CST:.*]] = arith.constant dense<2.000000e+00> : vector<[2]x[2]xf32> |
| 135 | + %0 = arith.constant dense<[[2., 2.], [2., 2.]]> : vector<[2]x[2]xf32> |
| 136 | + |
| 137 | + // ALL: %[[SIN:.*]] = math.sin %[[VAL_0]] : vector<[2]x[2]xf32> |
| 138 | + %1 = math.sin %arg0 : vector<[2]x[2]xf32> |
| 139 | + |
| 140 | + // ALL: %[[RES:.*]] = arith.addf %[[CST]], %[[SIN]] : vector<[2]x[2]xf32> |
| 141 | + %2 = arith.addf %0, %1 : vector<[2]x[2]xf32> |
| 142 | + |
| 143 | + // ALL: return %[[RES]] : vector<[2]x[2]xf32> |
| 144 | + return %2 : vector<[2]x[2]xf32> |
| 145 | +} |
| 146 | + |
| 147 | +// ----- |
| 148 | + |
| 149 | +func.func @test_scalable_no_linearize(%arg0: vector<2x[2]xf32>) -> vector<2x[2]xf32> { |
| 150 | + // expected-error@+1 {{failed to legalize operation 'arith.constant' that was explicitly marked illegal}} |
| 151 | + %0 = arith.constant dense<[[1., 1.], [3., 3.]]> : vector<2x[2]xf32> |
| 152 | + %1 = math.sin %arg0 : vector<2x[2]xf32> |
| 153 | + %2 = arith.addf %0, %1 : vector<2x[2]xf32> |
| 154 | + |
| 155 | + return %2 : vector<2x[2]xf32> |
| 156 | +} |
0 commit comments